var DomainUrl = top.location.hostname;
var AuthUrl = top.location.hostname;

function Trim(){
	return this.replace(/\s+$|^\s+/g,"");
}
String.prototype.Trim=Trim;

function getObjValues(id){
	if(getObjects(id).value!=undefined)
		return getObjects(id).value.Trim();
	else
		return "";
}
function getObjects(id) { 	
	if (document.getElementById) { 
		return document.getElementById(id);
	} else if (document.all) { 
		return document.all[id]; 
	} else if (document.layers) { 
		return document.layers[id]; 
	} 
}


function createXMLHttpRequest(){
       	if (window.XMLHttpRequest) {//
		XMLHttpReq=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {//IE 浏览器
	     try {
			    XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
	     } catch (e) {
		        try{
					XMLHttpReq=new ActiveXObject("Micrsost.XMLHTTP");
				} catch(e){}
	     }
        }
}
var cache = new Array();
function getHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

function getsupply(id){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", ""+web_url+"skins/skin_01/ajax_supply.php?id="+id, true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
           document.getElementById("getsupply").innerHTML = unescape(theHttpRequest.responseText);
           } else {
					document.getElementById("getsupply").innerHTML = "您请求的页面出现异常错误";
                  }
           }
     }
}

function getUserFav(_id){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", ""+web_url+"skins/skin_01/ajax.php?action=doUserFav&id="+ _id, true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
				var userfav = unescape(theHttpRequest.responseText);
				if(userfav == null || userfav ===""){
					document.getElementById("doUserFav").innerHTML = "<li>暂时没人收藏此舞曲！</li>";
				}else{
					document.getElementById("doUserFav").innerHTML = userfav;
				}
           } else {
           document.getElementById("doUserFav").innerHTML = "您请求的页面出现异常错误";
                  }
           }
     }
}

function getUserDown(_id){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", ""+web_url+"skins/skin_01/ajax.php?action=doUserDown&id="+ _id, true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
				var userdown = unescape(theHttpRequest.responseText);
				if(userdown == null || userdown ===""){
					document.getElementById("doUserDown").innerHTML = "<li>暂时没人下载此舞曲！</li>";
				}else{
					document.getElementById("doUserDown").innerHTML = userdown;
				}				
           } else {
				 document.getElementById("doUserDown").innerHTML = "您请求的页面出现异常错误";
                 }
           }
     }
}

function getdo5x(){
           document.getElementById("gqtour").innerHTML = '<iframe name="exobud_mp" src="'+web_url+'skins/skin_01/dj.php?ac=5x" width="650" height="330" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe>';
}

function getdonews(){
           document.getElementById("djourx").innerHTML = '<iframe name="exobud_mp" src="'+web_url+'skins/skin_01/dj.php?ac=news" width="650" height="603" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe>';
}

function getdoHits(_id){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", ""+web_url+"skins/skin_01/ajax.php?action=goodbad&id="+ _id, true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
           document.getElementById("doHits").innerHTML = unescape(theHttpRequest.responseText);
           } else {
           document.getElementById("doHits").innerHTML = "您请求的页面出现异常错误";
                  }
           }
     }
}

function up_down(_id, _do){
	 createXMLHttpRequest();
	 XMLHttpReq.open("GET", ""+web_url+"skins/skin_01/ajax.php?action=doHits&id="+ _id +"&dowhat="+ _do,true);
	 XMLHttpReq.onreadystatechange= function(){
		if(XMLHttpReq.readyState == 4){
			if(XMLHttpReq.status == 200){
	           		if(XMLHttpReq.responseText == "Err_145"){
	           	        	alert('您24小时内已顶（踩）过此舞曲！'); 
		        	}
                                	getdoHits(_id);
			}else alert("网络链接失败");
		}
	}
	 XMLHttpReq.send(null);
	}

function getlogin(){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", ""+web_url+"user/login.php", true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
           document.getElementById("userinfo").innerHTML = unescape(theHttpRequest.responseText);
           } else {
           document.getElementById("userinfo").innerHTML = "您请求的页面出现异常错误";
                  }
           }
     }
}

function sendRequest(){
	 createXMLHttpRequest();
	 XMLHttpReq.open("GET", ""+web_url+"user/login.php?action=login&name=" + escape(getObjValues("S_Name")) + "&pwd=" +escape(getObjValues("S_PassWord")),true);
	 XMLHttpReq.onreadystatechange= processResponse;
	 XMLHttpReq.send(null);
	 }

function goutRequest(){
	var ret;
	{ret=confirm("您是否要退出登录？");}
	if(ret!=false)
	createXMLHttpRequest();
	XMLHttpReq.open("GET", ""+web_url+"user/login.php?action=logout",true);
	XMLHttpReq.onreadystatechange= processResponse;
	window.setTimeout("document.location.reload()", 200);
	XMLHttpReq.send(null);  
	 }

function processResponse() {
	 if (XMLHttpReq.readyState==4){
	 if(XMLHttpReq.status==200){
	           var msg=XMLHttpReq.responseText;
	           if(msg == "Err_100"){
	                     alert('用户名不允许为空！'); 
	           } else if(msg == "Err_101"){
	                     alert('用户名非法！'); 
	           } else if(msg == "Err_102"){
	                     alert('密码不允许为空！'); 
	           } else if(msg == "Err_103"){
	                     alert('用户名或密码错误，请重试！'); 
	           } else if(msg == "Err_104"){
	                     alert('对不起，此账号已被锁定！'); return false;
	           } else if(msg == "Err_105"){
	                     //do_alert('登陆成功'); setTimeout('close_alert()', 1000);
	                     window.setTimeout("document.location.reload()", 200);
	           } else if(msg == "Err_106"){
	                     alert('对不起，此账号需要在本站激活！');
	                     window.setTimeout("window.location='/user/u.php?ac=activation'", 200);
	           } else {
	                     document.getElementById("userinfo").innerHTML =unescape(msg);
	           }
	 } else {
                   do_alert('您请求的页面出现异常错误！'); setTimeout('close_alert()', 5000);
	        }
         }
   }

function copyUrl(){
	window.clipboardData.setData("text",location.href);
	alert("复制成功，通过QQ/MSN/论坛发贴等发送给你的朋友即可！");
}
