window.onerror=function(){ return true; };

$$ = function(em) {
    if (document.getElementById){ return document.getElementById(em); }
    else if (document.all){ return document.all[em]; }
    else if (document.layers){ return document.layers[em]; }
    else{ return null; }
};

$$F = function(em){	return document.getElementById(em).value;	};

function show_select(_title, _options, _input){
    option_obj = $$(_options);
    option_obj.style.display = (option_obj.style.display == '') ? 'none' : '';
    option_obj.onblur = function() { option_obj.style.display = 'none'; };
    option_obj.focus();
    for (var i = 0; i < option_obj.childNodes.length; i++){
        option_obj.childNodes[i].onmouseover = function(){ this.className = 'options_over pointer'; };
        option_obj.childNodes[i].onmouseout = function(){ this.className = 'options_out pointer'; };
        option_obj.childNodes[i].onclick = function(){
            $$(_title).innerHTML = this.innerHTML;
            $$(_input).value = this.id;
            option_obj.blur();
            option_obj.style.display = 'none';
        }
    }
 };


function get_tags(parentobj, tag){
    if (typeof parentobj.getElementsByTagName != 'undefined'){ return parentobj.getElementsByTagName(tag);
    }else if (parentobj.all && parentobj.all.tags){ return parentobj.all.tags(tag);
    }else{ return new Array(); }
};

function clk(_act, _id) {
    var v = [];
    var a = get_tags($$(_id), 'input');

    for (var i = 0; i < a.length; i++) {
        if (_act == 'all' ) {a[i].checked = true;}
        else if (_act == 'un' ) { a[i].checked = (a[i].checked) ? false : true; }
		else if (_act == 'rundom' ) {
			var checkobj=document.getElementById(_id);
			var cboxs=checkobj.getElementsByTagName("input");
			var num=cboxs.length;			
			for(i=0;i<cboxs.length;i++){
				if(cboxs[i].type=="checkbox") cboxs[i].checked=false;
			}
			for(j=0;j<31;j++){
				var roundNum=Math.random()*num;
				if(cboxs[roundNum].type=="checkbox") {
						cboxs[roundNum].checked=true;
				}
			}			
		}else { if (0 < a[i].value && a[i].checked){ v.push(a[i].value); } }
    }
    if ( 'play' == _act ) {
        if (3 > v.length){ 
			alert('至少选择三首歌曲以上才能进行连播！'); 
			return; 
		}else if(v.length > 30){
			alert('一次最多连续播放30首歌曲！'); 
			return; 
		}else{
			window.open(''+web_url+'playsong.php?id=' + v.join(','), 'play');
		}
    }
};

function get_cookie(_name){
	var Res=eval('/'+_name+'=([^;]+)/').exec(document.cookie);
	return Res==null?'':unescape(Res[1]);
};

function set_cookie(_name, _value, _hours){
    var expdate = new Date();
    if( null != _hours ) expdate.setTime(expdate.getTime() + _hours * 3600000);
   document.cookie = _name + '=' + escape (_value) + '; path=/;domain=top.location.hostname;' +((_hours == null) ? '' : ('; expires='+ expdate.toGMTString()));
};

function SetCookie(name, value){
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
};

function create_div( _str, _msgw, _msgh ){
    //document.documentElement.style.overflow='hidden';
    //document.getElementsByTagName('body')[0].style.overflow='hidden';
    var bgObj=document.createElement('div');
    bgObj.setAttribute('id','bgDiv');
    bgObj.style.position='absolute';
    bgObj.style.top='0px';
    bgObj.style.left='0px';
    bgObj.style.background='#FFFFFF';
    bgObj.style.opacity='0.60';
    bgObj.style.filter = 'alpha(opacity=60)';
    bgObj.style.width='100%';
    bgObj.style.height=document.body.scrollHeight + 'PX';
    bgObj.style.zIndex = '10000';
    document.body.appendChild(bgObj);

    var msgObj = document.createElement('div');
    var _width = document.body.clientWidth;
    var _height = document.documentElement.clientHeight||document.body.clientHeight;
    var LeftPosition = (_width) ? (_width - _msgw)/2 : 0  ;
    var TopPosition = (_height) ? (_height - _msgh)/2 + document.documentElement.scrollTop : 0 ;
    msgObj.setAttribute('id','msgDiv');
    msgObj.setAttribute('align','center');
    msgObj.style.position = 'absolute';
    msgObj.style.border='0';
    msgObj.style.left = LeftPosition + 'px';
    msgObj.style.top  = TopPosition + 'px';
    msgObj.style.width = _msgw + 'px';
    msgObj.style.height = _msgh + 'px';
    msgObj.style.textAlign = 'center';
    msgObj.style.zIndex = '10001';
    msgObj.innerHTML= _str;
    document.body.appendChild(msgObj);
};
function close_div(){
    //document.documentElement.style.overflow='auto';
    document.body.removeChild($$('bgDiv'));
    document.body.removeChild($$('msgDiv'));
};


function do_alert( msg ){
    var _height = document.documentElement.clientHeight||document.body.clientHeight;
    var _top = (_height) ? (_height - 39)/2 + document.documentElement.scrollTop : 0;
    var msgObj=document.createElement('div');
    msgObj.setAttribute('id', 'msgInfo');
    msgObj.setAttribute('align', 'center');
    msgObj.style.position = 'absolute';
    msgObj.style.top = _top + 'px';
    msgObj.style.left = '0';
    msgObj.style.width = '100%';
    msgObj.style.height = '33px';
    msgObj.style.zIndex = '999';
    msgObj.innerHTML = '<span id="alert">'+ msg +'</span>';
    document.body.appendChild(msgObj);
};

function close_alert(){
    document.body.removeChild($$('msgInfo'));
};

function ShowDiv(_current, n){
    for(i=1;i<=n;i++){
        $$('DivNum_' + i).className = (i == _current) ? 'now' : 'now2';
        $$('newmusic_' + i).style.display  = (i == _current) ? '' : 'none';
    }
};

function ShowHot(_current, n){
    for(i=1;i<=n;i++){
        $$('DivHot_' + i).className = (i == _current) ? 'now' : 'now2';
        $$('musichot_' + i).style.display  = (i == _current) ? '' : 'none';
    }
};

function strLen(str) {
	var charset = document.charset; 
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == "utf-8" ? 3 : 2) : 1;
	}
	return len;
}

//控制在同一窗口中打开
function Listen(ListenURL) {
	var Listen = window.open(ListenURL,"Listens","resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes,top=0,left=0");
	return false;
}

s_title=encodeURIComponent(document.title);
s_url=encodeURIComponent(document.location.href.replace('#none', ''));
function fx_qq(){window.open('http://shuqian.qq.com/post?from=3&title='+s_title+'&uri='+s_url+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');}
function fx_baidu(){window.open('http://tieba.baidu.com/i/sys/share?title='+s_title+'&link='+s_url+'&type=text&content=%AC!','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');}
function fx_renren(){window.open('http://share.renren.com/share/buttonshare.do?link='+s_url+'&title='+s_title+'','xnshare','toolbar=0,status=0,resizable=1,width=626,height=436');}
function fx_kaixin(){window.open('http://www.kaixin001.com/repaste/share.php?rurl='+s_url+'&rtitle='+s_title+'&rcontent=%E7%9C%9F%E5%A5%BD%E5%90%AC%E5%95%8A%2C%E5%BF%AB%E5%8E%BB%E5%90%AC%E4%B8%80%E5%90%AC');}
function fx_douban(){window.open('http://www.douban.com/recommend/?url='+s_url+'&title='+s_title+'&sel='+s_title+'&v=1','douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330');};
function fx_sina(){window.open('http://v.t.sina.com.cn/share/share.php?appkey=1435846576'+'&url='+s_url+'&title='+encodeURIComponent('推荐歌曲:#')+''+s_title+'%23&source=&sourceUrl=&content=utf-8&pic=http://www.dj527.com/iimages/logo.gif','sina','toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=540');}
function fx_delicious(){window.open('http://del.icio.us/post?url='+s_url+'&title='+s_title+'');};
function fx_myspace(){window.open('http://www.myspace.cn/Modules/PostTo/Pages/DefaultMblog.aspx?t='+s_title+'&u='+s_url+'');};
function openWin(tag) {window.open(tag,"ylmv","resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes,top=0,left=0");};

function ChangIterm(s,ss,sss,n) {
        for(var i=1;i<=3;i++){
            var curC=document.getElementById(s+i);
            var curB=document.getElementById(ss+i);
            if(n==i){
                curC.style.display="block";
                curB.className=sss;
            }else{
                curC.style.display="none";
                curB.className=""
            }
       } 
}

function ChangClass(s,ss,sss,n) {
        for(var i=1;i<=2;i++){
            var curC=document.getElementById(s+i);
            var curB=document.getElementById(ss+i);
            if(n==i){
                curC.style.display="block";
                curB.className=sss;
            }else{
                curC.style.display="none";
                curB.className="";
        }
     }
}

function Changplay(n) {
        for(var i=1;i<=4;i++){
            var curC=document.getElementById("p_"+i);
            var curB=document.getElementById("p_p"+i);
            if(n==i){
                curC.style.display="block";
                curB.className="play-history-select"
            }else{
                curC.style.display="none";
                curB.className=""
        }
    }
}
function show(s){
	document.getElementById(s).style.display='block'; //显示导航层
}
function hide(s){
	document.getElementById(s).style.display='none'; //隐藏导航层
}
