/*********封装的公用选项卡***********/

function clickTabs(tabTit,on,tabCon){

     $(tabTit).children().click(function(){

       $(this).addClass(on).siblings().removeClass(on);

       var index = $(tabTit).children().index(this);

     $(tabCon).children().eq(index).show().siblings().hide();

     });

     }

$(function(){ clickTabs(".clickTab-hd", "current", ".clickTab-bd");});

/*********返回顶部***********/

function backTop(){

	h = $(window).height();

	t = $(document).scrollTop();

	if(t > h){

		$('#gotop').show();

	}else{

		$('#gotop').hide();

	}

}

$(function(){

	$("body").append('<div id="huodong"></div><a id="fankui" href="/index.php/gbook" title="在线反馈">在线反馈</a><a id="weixin" href="tencent://message/?uin=321218882&amp;Site=追梦站长&amp;Menu=yes"></a><a id="gotop" href="javascript:void(0)"></a><div id="#" href="#javascript:void(0);"></div>');

	backTop();

	$('#gotop').live("click",function(){

		$(document).scrollTop(0);	

	})

   $("#weixin").live({

     mouseenter:function(){

     $('#weixin_img').show();

   },

     mouseleave:function(){

     $('#weixin_img').hide();

   }

});

	

});

$(window).scroll(function(e){

	backTop();		

})



/*********导航悬浮***********/

dropTop=72;

$(function(){

if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) { 

return false;

}else{

	if($("#pageHeader").length>0){

       $(window).bind('scroll resize',function(){

			if($(window).scrollTop()>140){

				dropTop=50;

				$("#pageHeader").addClass("heiaderFix");

				$(".dropMenu").css({"top":dropTop});

			}else{

                dropTop=72;

				$("#pageHeader").removeClass("heiaderFix");

				$(".dropMenu").css({"top":dropTop});

			} 

      });

  } 

  }

})



/*********顶部下拉菜单***********/

$(function(){

	dropTop=72;

	show=false;

	//用户个人中心

	 

	  

	  $("#dropMenuUser").live({mouseenter:function () {

                show=true;

            },mouseleave: function () {

                show=false;

	            dropMenuHide();

            }

      });

	  	  

	//软件下载

	  $(".headeSoftware").hover(function(){

		var softLeft=$(".headeSoftware").offset().left-120

		dropRemove();

		$("body").append('<div id="dropSoftware" class="dropMenu"></div>');
		
		$("#dropSoftware").css({"left":softLeft,"top":dropTop});

		show=true;

	  },function(){

        show=false;

        setTimeout("dropSoftHide()",300);

      });

	

	  $("#dropSoftware").live({mouseenter:function () {

                show=true;

            },mouseleave: function () {

                show=false;

	            dropSoftHide();

            }

      });

	  

	  

	  //mini导航悬浮

	  $("#miniNav").hover(function(){

		var softLeft=$(".miniNav").offset().left-156

		dropRemove();

		$("body").append('<div id="dropMiniNav" class="dropMenu"><div class="dropHd"></div><div class="dropBd"><ul class="miniNavList1"><li><a href="/"><span>首页</span></a><a href="/index.php/dance" target="_blank" style="color:#259b24;"><span>音乐大全</span></a><a href="/index.php/singer" target="_blank"><span>歌手大全</span></a><a href="/index.php/opt/mold/hits" target="_blank"><span>音乐排行榜</span></a><a href="/index.php/zj/lists/id/1/1" target="_blank"><span>音乐专辑</span></a><a href="/index.php/m/fm/" target="_blank"><span>电台</span></a></li><li><a href="/index.php/news" target="_blank"><span>新闻资讯</span></a><a href="/index.php/vod" target="_blank"><span>音乐MV</span></a><a href="/index.php/song" target="_blank" style="color:#0b4de3;"><span>音乐盒</span></a><a href="/index.php/user" target="_blank"><span>会员中心</span></a><a href="/index.php/gbook" target="_blank" style="color:#0b4de3;"><span>留言求歌</span></a><a href="/index.php/m/bbs" target="_blank" style="color:#259b24;"><span>论坛</span></a></li></ul><ul class="miniNavList2"><li><a href="/index.php/dance/lists/id/1/1" target="_blank"><span>原创歌曲</span></a><a href="/index.php/dance/lists/id/3/1" target="_blank"><span>翻唱歌曲</span></a><a href="/index.php/dance/lists/id/4/1" target="_blank"><span>网络歌曲</span></a><a href="/index.php/dance/lists/id/5/1" target="_blank"><span>喊麦歌曲</span></a><a href="/index.php/dance/lists/id/6/1" target="_blank"><span>DJ舞曲</span></a><a href="/index.php/dance/lists/id/2/1" target="_blank"><span>现场串烧</span></a></li><li><a href="/index.php/dance/lists/id/11/1" target="_blank"><span>英文舞曲</span></a><a href="/index.php/dance/lists/id/12/1" target="_blank"><span>慢摇舞曲</span></a><a href="/index.php/dance/lists/id/13/1" target="_blank"><span>交谊舞曲</span></a><a href="/index.php/page/index/geng/" target="_blank"><span>更多分类栏目</span></a><a href="/index.php/opt/mold/hits" target="_blank"><span>歌曲人气榜</span></a></li><li><a href="/index.php/opt/mold/zhits" target="_blank"><span>歌曲本周榜</span></a><a href="/index.php/opt/mold/yhits" target="_blank"><span>歌曲本月榜</span></a><a href="/index.php/opt/mold/rhits" target="_blank"><span>歌曲今日榜</span></a><a href="/index.php/opt/mold/xhits" target="_blank"><span>歌曲下载榜</span></a><a href="/index.php/opt/mold/shits" target="_blank"><span>歌曲收藏榜</span></a></li></ul></div></div>');

		$("#dropMiniNav").css({"left":softLeft,"top":dropTop});

		show=true;

	  },function(){

        show=false;

        setTimeout("dropMiniNav()",1000);

      });

	

	  $("#dropMiniNav").live({mouseenter:function () {

                show=true;

            },mouseleave: function () {

                show=false;

	            dropMiniNav();     

            }

      });

	  

	  //试听历史

	  $(".headeHistory").hover(function(){

		var softLeft=$(".headeHistory").offset().left-220

		dropRemove();

		$("body").append('<div id="dropHistory" class="dropMenu"></div>');
				
		$("#dropHistory").css({"left":softLeft,"top":dropTop});

		show=true;

		showHisList(hisCurPage);//加载试听历史		

	  },function(){

        show=false;

        setTimeout("dropHistory()",300);

      });

	

	  $("#dropHistory").live({mouseenter:function () {

                show=true;

            },mouseleave: function () {

                show=false;

	            dropHistory();     

            }

      });

	  

	  $(".dropHistoryList li").live({mouseenter:function () {

              $(this).addClass("hisHover");

            },mouseleave: function () {

              $(this).removeClass("hisHover");  

            }

      });

	  

	  

	});



function dropRemove(){

	show=false;

	$(".dropMenu").remove();

}

function dropMenuHide(){

	if(show==false){

	$(".dropMenu").hide();

	}	

}

function dropSoftHide(){

	if(show==false){

	$("#dropSoftware").hide();

	}	

}

function dropHistory(){

	if(show==false){

	$("#dropHistory").hide();

	}	

}

function dropMiniNav(){

	if(show==false){

	$("#dropMiniNav").hide();

	}	

}

/*以上是公共部分*/



/*以下是自定义部分*/

/*我试听过的歌开始*/

//获取试听id

var hisCurPage=1,hisIsLoaded=0;

function getHisId(){

	var returnid="";

	var str=document.cookie;

	var num_start=str.indexOf("l_music");

	if(num_start!=-1){

		var num_end=str.indexOf("l_end");

		if(num_end>num_start){

			var str_list=str.substring(num_start,num_end).replace(/l_music=/ig,"");

			var arr_list=str_list.split(",");

			if(arr_list.length>0){

				for(i=0;i<arr_list.length;i++){

					var str_ti=arr_list[i];

					if(str_ti!=undefined||str_ti!="undefined"||str_ti!=null||str_ti!=""){

						returnid=returnid+str_ti+","

					}

				}

			}

		}

	}

	return returnid;

}

//*试听列表开始

var $song_data = new Array();

$song_data[1]="";

function showHisList(page){

	isTmpList=1;

	var _gqid="";

	var _s1url="";

	var str_ti_path="";

	var hidstr=getHisId();

	if(hidstr==",,")hidstr="";

	if(hidstr.length>1){

		//开始加载

		var hidstrs=hidstr.split(",");

		for(i=0;i<hidstrs.length;i++){

			var str_ti=hidstrs[i];

			if(str_ti!=undefined&&str_ti!=null&&str_ti!=""){

				str_ti_path=parseInt(str_ti/10000+1);

				_s1url="http://www.9ku.com/html/s1/"+str_ti_path+"/"+str_ti+".js";

				createScript(_s1url);

			}

		}

	}else{

		$("#hislist").html('<li><span style="display:block;text-align:center; color:#999;">没有试听记录！</li>');

		return;

	}

}

function formatFloat(src, pos){ var gyc= Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);if(src>gyc){return gyc+1;}else{return gyc;}}

//显示试听列表(x=1,fi=1)

function song_list(x,fi){

	hisCurPage=fi;

	//$("#hislist").html("");

	//$(".his-page").html("");

	x=parseInt(x);

	fi=parseInt(fi);

	var listHtml='';

	var pageHtml='';

	var ni=100;//每页数量

	var ki=0;

	var ei=ni;

	if($song_data[x]){

		var song_data = $song_data[x].split('||');

		var n=song_data.length-1;//试听歌曲数量

		var gy=formatFloat(n/ni, 0);

		if(fi>gy){fi=gy;}

		if(fi>1){ki=ei*(fi-1);}//序号

		if(n>ei){ei=ei*fi;}

		if(ei>n){ei=n;}

		for(var i = ki;i < ei;i++){

			var song_n = song_data[i].split('|');			

			listHtml += '<li><input style="display:none;" class="check" type="checkbox" value="'+song_n[0]+'@" ><span class="num">'+(i+1)+'</span><div class="songInfo"><a href="http://www.9ku.com/play/'+song_n[0]+'.htm" class="songName" target="_1">'+song_n[1]+'</a><span class="shortLine">-</span><a href="http://www.9ku.com/geshou/'+song_n[2]+'.htm" target="_blank" class="singerName">'+song_n[3]+'</a></div><span class="hideCao"><a href="http://www.9ku.com/play/'+song_n[0]+'.htm" class="hidePlay" target="_1"></a><a href="javascript:{};" onclick="HisAddplay(\''+song_n[0]+'\');" class="hideAdd" target="_blank"></a></span></li>';			

		}

		//分页

		if(fi-1>0){

			pageHtml += '<a href="javascript:song_list('+x+','+(fi-1)+');">上一页</a>';	

		}

		var d1=parseInt(n%ni);

		var pcount = 1;

		if(n/ni > parseInt(n/ni)){

			pcount=parseInt(n/ni)+1;

		}else{

			pcount=parseInt(n/ni); 

		}

		pageHtml += '<span class="page_total">'+fi+'/'+pcount+'</span>';



		if(fi+1<=pcount){

			pageHtml += '<a href="javascript:song_list('+x+','+(fi+1)+');">下一页</a>';	

		}

		$("#hislist").html(listHtml);

		//$(".his-page").html(pageHtml);

	}else{

		$("#hislist").html("<li>试听记录已全部删除！</li>");

	}

}



function createScript(URL){if(URL==""||URL==undefined)return;var Tag = document.createElement("script");Tag.charset="gb2312";Tag.type="text/javascript";Tag.src=URL;document.getElementsByTagName("head")[0].appendChild(Tag);}


