﻿
function search()
{
    var key=document.getElementById("key").value;
    if(key=="")
    {
         alert("请输入搜索关键词！");
            document.getElementById("key").value="";
            document.getElementById("key").focus();
            return;
    }
    else
    {
        //location.href=;
        window.open("/search/search.aspx?key=" +escape(key));
    }
}
function searchh()
{
    var key=document.getElementById("key").value;
    if(key=="")
    {
         alert("请输入搜索关键词！");
            document.getElementById("key").value="";
            document.getElementById("key").focus();
            return;
    }
    else
    {
        location.href="/search/search.aspx?key=" +escape(key);
    }
}


function searchop()
{
    var key=document.getElementById("key").value;
    if(key=="")
    {
         alert("请输入搜索关键词！");
            document.getElementById("key").value="";
            document.getElementById("key").focus();
            return;
    }
    else
    {
        window.open("/search/search.aspx?key=" +escape(key));
    }

}

function TagChange3(tagNum,tabName,tagId)
{
	for(i=1;i<=tagNum;i++)
	{
		if(i==tagId)
		{
			document.getElementById(tabName+i).style.display="block";	
			 
		}	
		else
		{
		    document.getElementById(tabName+i).style.display="none";
        }
	}
}
function TagChangeP(tagNum,tabName,tagId)
{
    var arrTop= new Array(4);
    arrTop[1]="/module/piao/piao_HotTop5.htm";
    arrTop[2]="/module/piao/piao_ychTop5.htm";
    arrTop[3]="/module/piao/piao_yyhTop5.htm";
    for(i=1;i<=tagNum;i++)
    {
	    if(i==tagId)
	    {
	         $.get(arrTop[tagId], { name: "1"},
            function(data){
                $("#"+tabName+"iao").html(data);
               document.getElementById(tabName+"_"+tagId).className=tabName+"c_"+tagId+"_1";
            }); 
	    }	
	    else
	    {
	        document.getElementById(tabName+"_"+i).className=tabName+"c_"+i+"_2";
        }
    }
}
function TagChangeSf(tagNum,tabName,tagId)
{
    var arrTop= new Array(3);
    arrTop[1]="/module/music/discsf_top10.htm";
    arrTop[2]="/module/music/discup_top10.htm";
    arrTop[3]="/module/music/discsm_top10.htm";
    for(i=1;i<=tagNum;i++)
    {
	    if(i==tagId)
	    {
	         $.get(arrTop[tagId], { name: "1"},
            function(data){
                $("#"+tabName+"Song").html(data);
               document.getElementById(tabName+"_"+tagId).className=tabName+"c_"+tagId+"_1";
            }); 
	    }	
	    else
	    {
	        document.getElementById(tabName+"_"+i).className=tabName+"c_"+i+"_2";
        }
    }
}
function TagChangeLX(tagNum,tabName,tagId)
{
    var arrSong= new Array(8);
    arrSong[1]="/module/music/songjd_top10.htm";
    arrSong[2]="/module/music/songmg_top10.htm";
    arrSong[3]="/module/music/songyg_top10.htm";
    arrSong[4]="/module/music/songwx_top10.htm";
    arrSong[5]="/module/music/songwh_top10.htm";
    arrSong[6]="/module/music/songys_top10.htm";
    arrSong[7]="/module/music/songqt_top10.htm";
    
    var arrDisc= new Array(8);
    arrDisc[1]="/module/music/discjd_top8.htm";
    arrDisc[2]="/module/music/discmg_top8.htm";
    arrDisc[3]="/module/music/discyg_top8.htm";
    arrDisc[4]="/module/music/discwx_top8.htm";
    arrDisc[5]="/module/music/discwh_top8.htm";
    arrDisc[6]="/module/music/discys_top8.htm";
    arrDisc[7]="/module/music/discqt_top8.htm";
    
    for(i=1;i<=tagNum;i++)
    {
	    if(i==tagId)
	    {
	   
	         $.get(arrSong[tagId], { name: "1"},
            function(data){
                $("#"+tabName+"Song").html(data);
               document.getElementById(tabName+"_"+tagId).className=tabName+"c_"+tagId+"_1";
            }); 
             $.get(arrDisc[tagId], { name: "1"},
            function(data){
                $("#"+tabName+"Disc").html(data);
            }); 
	    }	
	    else
	    {
	      document.getElementById(tabName+"_"+i).className=tabName+"c_"+i+"_2";
        }
    }
}

function TagChangeCP(tagNum,tabName,tagId)
{
    var arrSong= new Array(3);
    arrSong[1]="/module/music/songrm_yh_top10.htm";
    arrSong[2]="/module/music/songrm_fh_top10.htm";
    arrSong[3]="/module/music/songrm_sm_top10.htm";

    var arrDisc= new Array(3);
    arrDisc[1]="/module/music/discrm_yh_top8.htm";
    arrDisc[2]="/module/music/discrm_fh_top8.htm";
    arrDisc[3]="/module/music/discrm_sm_top8.htm";

    for(i=1;i<=tagNum;i++)
    {
	    if(i==tagId)
	    {
	         $.get(arrSong[tagId], { name: "1"},
            function(data){
                $("#"+tabName+"Song").html(data);
               document.getElementById(tabName+"_"+tagId).className=tabName+"c_"+tagId+"_1";
            }); 
             $.get(arrDisc[tagId], { name: "1"},
            function(data){
                $("#"+tabName+"Disc").html(data);
            }); 
	    }	
	    else
	    {
	      document.getElementById(tabName+"_"+i).className=tabName+"c_"+i+"_2";
        }
    }
}


/*打开一个新窗口*/
function popwinbar(url,width,height)
{
    window.open(url,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,top=230%,left=230%,width="+width+",height="+height);
}

var newWindow;
function makeNewWindow(url,width,height) {
    var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    newWindow = window.open(url, "subWind", windowFeatures);
    newWindow.focus();
}


function mplay(id) {
var play;
  // if (!play || play.closed) {
        var width=851
        var height=660
        var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中
        var top = parseInt((screen.availHeight/2) - (height/2));
        var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,scrollbars=auto;left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
        play = window.open("/play/play.htm?id="+id, "wmusicplay", windowFeatures);
//    } else {
        play.focus();
   // }
}

function ring12530(songname,singername,mobile){
window.open("http://210.51.163.138:8081/ring.aspx?channelId=54411024&songname="+escape(songname)+"&singername="+escape(singername)+"&mobile="+mobile,"12530Ring");   
}

function ring12530go(songname,singername,mobile){
location.href="http://210.51.163.138:8081/ring.aspx?channelId=54411024&songname="+escape(songname)+"&singername="+escape(singername)+"&mobile="+mobile;
//alert("http://12530.emuse.net.cn/ring.aspx?channelId=54411024&songname="+escape(songname)+"&singername="+escape(singername)+"&mobile="+mobile); 
}

function checkAll(tag,chkName){
if(tag=="1"){
$("input[@name='"+chkName+"']").each(function(){
   $(this).attr("checked","checked");   
});
}else{
$("input[@name='"+chkName+"']").each(function(){
    if($(this).attr("checked")==true)
        $(this).removeAttr("checked"); 
    else
       $(this).attr("checked","checked");   
});
}
}

function checkValue(chkName){
var str = '';
$("input[@name='"+chkName+"']").each(function(){
   if($(this).attr("checked")==true){
    str += $(this).attr("value")+",";
   }
})
return str;
}

function playall(chkName)
{
    var chkValue=checkValue(chkName);
    if(chkValue=="")
        alert("请选择歌曲!");
    else
    {
        mplay(chkValue);
    }
}


function SetCookie(name, value) {
var Days = 1;
var exp  = new Date();
exp.setTime(exp.getTime() +60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/;";
}  
function GetCookie(name) {
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}
function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=GetCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

function chkCookie()
{
    SetCookie('chkcoo','1');
    return GetCookie('chkcoo')==null?false:true;
}

function addplaylist(id)
{
    delCookie('wmplay');
    var idstr=checkValue(id);
    if(idstr!=''){
        if(chkCookie()){
            SetCookie('wmplay',idstr);
            if(GetCookie('wmstatus')!=1){mplay(idstr);}
        }else{mplay(idstr);}
    }else{
        alert("请选择歌曲!");
    }
}



