/*#############################################################
Name: function Js CSS
Version: 1.1
QQ: 262403819
URL: http://dede.playyy8.com/
#############################################################*/
function killErrors(){return true;}window.onerror=killErrors;
var hostname = "dede.playyy8.com"
document.domain = hostname;

function getObject(idname) {
	if (document.getElementById) { 
		return document.getElementById(idname);
	} else if (document.all) {
		return document.all[idname];
	} else if (document.layers) {
		return document.layers[idname];
	} else {
		return null;
	}
}
function getTags(parentobj, tag){
	if (parentobj == null) {
		return new Array();
	} else 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 lbsong(form){
	var j=0;
	var k=form.elements.length;
	if (k>100){k=100}
	var v = [];
	 for (var i=0;i < k;i++){
		var e = form.elements[i];
		if (e.type=="checkbox"){
			if (e.checked == true){
				v.push(form.elements[i].value);
			}
		}
	 }
	//alert(v.length);
	if (v.length != 0){
		window.open("/p.html?" + v.join(","),"musiclist","");
	}else{
		alert("请选择歌曲再播?");
		return false;
	}
}


function lbsong2(form){
	var j=0;
	var k=form.elements.length;
	if (k>100){k=100}
	var v = [];
	 for (var i=0;i < k;i++){
		var e = form.elements[i];
		if (e.type=="checkbox"){
			if (e.checked == true){
				v.push(form.elements[i].value);
			}
		}
	 }
	//alert(v.length);
	if (v.length != 0){
		window.open("/p.html?" + v.join(","),"musiclist","");
	}else{
		alert("请选择歌曲再播?");
		return false;
	}
}

function checkrandom(form){
	var num=form.elements.length;
	for (var i=0;i < num;i++){
		var e = form.elements[i];
		e.checked = false;
	}
	for(j=0;j<num/2;j++){
		var roundNum=Math.floor(Math.random()*num);
		var e=form.elements[roundNum];
		if(e.type=="checkbox") {
			e.checked=true;
		}
	}
	//这个随机是算法是首先刷新所有checkbox值为false;然后生成一个随机数,循环checkbox数组长度?/2?
	//这样可能会造成重复?因此得到的结果一般要少于数组长度长度?/2.
}


function CheckOthers(form){
	 for (var i=0;i < form.elements.length;i++){
		var e = form.elements[i];
		if (e.checked == false){
			e.checked = true;
		}else{
			e.checked = false;
		}
	 }
}

function CheckAll(form){
	 for (var i=0;i < form.elements.length;i++){
		var e = form.elements[i];
		e.checked = true;
	 }
}

function getObject(id){
	return document.getElementById(id);
}

//用于获取搜索的cookies?
function GetCookie(Name) {
	var search = Name + "=";
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) { 
			offset += search.length;
			end = document.cookie.indexOf(";", offset); 
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset,end));
		}
	}
	return returnvalue;
}

//用于播放的cookies值获取，注意：js中函数名是区分大小写?
function getcookie(name) {
	var cookie_start = document.cookie.indexOf(name);
	var cookie_end = document.cookie.indexOf(";", cookie_start);
	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
function setcookie(name, value, hours) {
	var expire = "";
	if (hours != null) {
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + encodeURIComponent(value) + "; domain=" + hostname + ";path=/" + expire;
}

//用于取得播放状态
function GetCookiePlay(name){
	var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr!=null){
		return unescape(arr[2]);
	}
	return null;
}
function addplaylist(form) {
	var j=0,id;
	var k=form.elements.length;
	var v = [];
	 for (var i=0;i < k;i++){
		var e = form.elements[i];
		if (e.type=="checkbox"){
			if (e.checked == true){
				v.push(form.elements[i].value);
			}
		}
	 }
	if (v.length != 0){
		id=v.join(",");
	}

	if (v.length == 0) {
		return alert("请选择歌曲后才能添加到播放列表");
	} else {
		if (GetCookiePlay("jk_ifplay") == "1") {
			Addplay(id);
			alert("恭喜，已经添加到连续播放列表！");
		} else {
			window.open("/p.html?" + id, "musiclist");
		}
	}
}


function Addplay(url){
var ifplay= GetCookie("jk_ifplay");
if(ifplay=="1"){
var now = new Date();
var ss = now.getTime();
now.setTime(ss + 12*60*60*1000);//12 hours
document.cookie = "jk_addplay="+(url)+";domain=127.0.1.1;path=/;expires="+ now.toGMTString();
alert("恭喜，已经添加到连续播放列表！");
}else{if(url.indexOf("/")!=-1){window.open("/djerr.php?aid="+url+"","jk_play");}else{window.open("/djerr.php?aid="+url+"","jk_play");}}}


function DecodeCookie(str) 
{ 
　var strArr; 
　var strRtn=""; 
　strArr=str.split("a"); 
　for (var i=0;i<strArr.length;i++) 
　strRtn+=String.fromCharCode(eval(strArr[i])); 
　return strRtn; 
}


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);
};


/*#############################################################
Name: play Js CSS
Version: 1.1
QQ: 262403819
URL: http://www.dj775.com/
#############################################################*/

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 (0 < a[i].value && a[i].checked){ v.push(a[i].value); } }
    }
    if ( 'play' == _act ) {
        if (3 > v.length){ alert('至少选择三首歌曲以上才能进行连播！'); return; }
        window.open(''+web_url+'Lplayer.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;
}

function open_comment(_id){
    try{
        if( '' == $('f_comment').getAttribute('src') ) { $('f_comment').setAttribute('src', ''+web_url+'plus/pl.php?aid=' + _id); }
        parent.document.documentElement.scrollTop = 530;
        parent.document.body.scrollTop = 530;
    }catch(e){
       return;
    }
};

function openWin(tag) {
	window.open(tag,"ylmv","resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes,top=0,left=0");
};