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

function CheckAll(myform){	
	var strCBValue = "";
	for (var i=0;i<myform.elements.length;i++){  //用来历遍form中所有控件,
		var e = myform.elements[i];
		if(e.type=="checkbox"){					//当是checkbox时才执行下面
			e.checked = !e.checked;
			if(e.checked){						//当是checkbox被选取时才执行下面
				strCBValue = strCBValue+"id=" + e.value+"&amp;";
			}
			select_element(e,!e.checked);
		}
	}
}

function CheckNO(myform){	
	var strCBValue = "";
	for (var i=0;i<myform.elements.length;i++){  //用来历遍form中所有控件,
		var e = myform.elements[i];
		if(e.type=="checkbox"){					//当是checkbox时才执行下面
			e.checked = false;
			select_element(e,1);
		}
	}
}

function RndNum(n){
	var rnd="";
	rnd = Math.floor(Math.random()*10);
	return rnd;
}

function CheckRND(myform){	
	var strCBValue = "";
	var rnds = myform.elements.length;
	for (var i=0;i<myform.elements.length;i++){  //用来历遍form中所有控件,
		var e = myform.elements[i];
		var rnd = RndNum(rnds);
		e.checked = false;
		select_element(e,1);
		if(rnd > 5){					//当是checkbox时才执行下面
			e.checked = true;
			select_element(e,!e.checked);
		}
	}
}
function CheckPlayUser(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("/index.php/dance/playsong?id=" + v.join(",") + "","djwin","");
	}else{
		alert("请选择歌曲再播放?");
		return false;
	}
}

function CheckPlay(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("/index.php/dance/playsong?id=" + v.join(",") + "","djwin","");
	}else{
		alert("请选择歌曲再播放?");
		return false;
	}
}

function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"hover":"";
		con.style.display=i==cursel?"block":"none";
	}
}

function Check(n) {
	var obj = document.getElementById("menu"+n)
	if (obj.style.display=="none") {
	obj.style.display=""
	}else {
	obj.style.display="none"
	}
} 
function showAstroValue(n,nValue,nTxt) {
	if (n == 1){
		var thisInput0 = document.getElementById("type");
		var thisInput1 = document.getElementById("typename");
		thisInput0.value = nValue;
		thisInput1.value = nTxt;
	}
}

function CopyTxt(obj){  
	obj.select();     
	js=obj.createTextRange();          
	js.execCommand("Copy");    
	alert("复制成功，您可以粘贴到你的QQ/MSN上推荐给你的好友");    
}  
//input_js
function getid(id) {
    return document.getElementById(id);
}
function gettag(tag, obj) {
    if (obj) {
        return obj.getElementsByTagName(tag)
    } else {
        return document.getElementsByTagName(tag)
    }
}
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != "function") {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    };
}
function select_element(obj, type) {
	
	/*if (obj.type == "checkbox") {
		obj.parentNode.style.background = "url(/img/input_style.gif) no-repeat -15px -15px";
		
	}
	if (type) {
		if (obj.type == "checkbox") {
			obj.parentNode.style.background = "url(/img/input_style.gif) no-repeat 0px -15px";
		}
	}*/
}

//用于取得播放状态
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);
			//setcookie("PLAYLIST", id, 24);
			show_sure("加入成功");
		} else {
			window.open("/_play.php?id=" + v.join("_") + "","musiclist1","");
		}
	}
}

function Addplay(url){
	//var ifplay= GetCookiePlay("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=dj.cc;path=/;expires="+ now.toGMTString();
	//}else{
		//if(url.indexOf("_")!=-1){
		//	window.open("/playlist.html?"+url,"jk_play");
		//}else{
		//	window.open("/play/"+url+".htm","jk_play");
		//}
	//}
}

//--------------利用javascript创建层显示对?----------------------------
//									-
//	如果?iframe包含的，就要在document前面加上 parent.		-	
//	或者直接获取已存在的层						            -
//	var obj=parent.document.getElementById("float");		-
//	var obj2=parent.document.getElementById("bg_div");		-								-
//									-
//-----------------------------------------------------------------------
function show_sure(msg){
	var show_str="<div style='height:20px;padding-top:5px;background-color:#4465a2;color:#FFFFFF;font-weight:bold;text-align:left;padding-left:10px'>今生缘提示</div><div style='height:40px;color:#FFFFFF;padding-top:30px;font-size:16px;text-align:center;'>"+msg+"</div>";

	if (document.getElementById("float")==null){
		var obj = document.createElement("div");
		obj.id = "float";
		obj.style.position="absolute";
		obj.style.zIndex = "9999";
		obj.style.width = "300px";
		obj.style.height = "105px";
		obj.style.top = document.documentElement.scrollTop + 200 + "px";
		obj.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
		obj.style.filter = "alpha(opacity=100)";
		obj.style.background = "#6685bc";
		obj.style.border = "#000000";

		obj.innerHTML = show_str;
		document.body.appendChild(obj);
	}else{
		var obj=document.getElementById("float");
		obj.style.top = document.documentElement.scrollTop + 200 + "px";
		obj.style.display ='';
	}


	setTimeout("tmp();",1000);
}
function tmp(){
	var obj=document.getElementById("float");
	//var obj2=document.getElementById("bg_div");
	obj.style.display ='none';
	//obj2.style.display ='none';
}


function radio_style() {
    if (gettag("input")) {
        var r = gettag("input");

        for (var i = 0; i < r.length; i++) {
            if (r[i].type == "radio" || r[i].type == "checkbox") {
                r[i].style.opacity = 0;
                r[i].style.filter = "alpha(opacity=0)";
                r[i].onclick = function() {
                    select_element(this);
                    unfocus();
                }
                if (r[i].checked == true) {
                    select_element(r[i]);
                } else {
                    select_element(r[i], 1);
                }
            }
        }
        function unfocus() {
            for (var i = 0; i < r.length; i++) {
                if (r[i].type == "radio" || r[i].type == "checkbox") {
                    if (r[i].checked == false) {
                        select_element(r[i], 1)
                    }
                }
            }
        }
    }
}