﻿ 
function Set()
{
    document.getElementById("imgflag").src="image/eload.GIF";
    
    document.getElementById("btnReg").disabled=false;
    
    document.getElementById("Password1").disabled=false;
    
    document.getElementById("btnlogin").disabled=false;
}
function loginResult()
{
          if(xmlHttp.readyState==4)//服务器响应状态
    {
        if(xmlHttp.status==200)//代码执行状态
        {
            if(xmlHttp.responseText=="true")
            {   
                location="http://www.6188.net/login.ahtml?mode=login?";
            }
            else
            {
               window.alert("对不起,你登录失败");
                
                document.getElementById("UserName").value="";
                
                document.getElementById("Password").value="";
                
                document.getElementById("Password1").value="";
            }
        }
    }

}
function login()
{

    if(document.getElementById("UserName").value=="")
    {
        window.alert("用户名不能为空");
        
        document.getElementById("UserName").focus();
        
        return false;
    }
        if(document.getElementById("Password").value=="")
    {
        window.alert("密码不能为空");
        
        document.getElementById("Password").focus();
        
        return false;
    }    
        createXmlHttpRequest();
        
        var url="login.ahtml?Name="+document.getElementById("UserName").value+"&Pass="+document.getElementById("Password").value+"&Event=login";
    
        xmlHttp.open("GET",url,true);
    
        xmlHttp.onreadystatechange=loginResult;
    
        xmlHttp.send(null);
    
}

function csvote(id){
	var tp = arguments[1]?arguments[1]:'u';
	var dp = arguments[2]?arguments[2]:'view';
	var d  = new Date();
	var   d=new   Date(); 
    nyear=d.getYear(); 
    nmonth=d.getMonth()+1; 
    nday=d.getDate(); 
    nhrs=d.getHours(); 
    nmin=d.getMinutes(); 
    nsec=d.getSeconds(); 
     
    ftime=nyear+ "-"+nmonth+ "-"+nday+ " "+nhrs+ ":"+nmin+ ":"+nsec; 

	var url = '/vote.aspx?id='+id+'&tp='+tp+'&dp='+dp+'&time='+ftime;
	var req;
	var msg;
	
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		try {
			req.open("GET", url, false);
		} catch (e) {
			alert(e);
		}
		req.send(null);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.open("GET", url, false);
			req.send();
		}
	}
	if (req.readyState == 4) { 
		if (req.status == 200) { 
			if (req.responseText == 0) {
				msg = "您已经投过票了，感谢您的参与!";
			} else {
				var diggs = req.responseText.split(':');
				
				var sUp = parseInt(diggs[0]);
				var sDown = parseInt(diggs[1]);
				var sTotal = sUp+sDown;
				var spUp=(sUp/sTotal)*100;
				spUp=Math.round(spUp*10)/10;
				var spDown=100-spUp;
				spDown=Math.round(spDown*10)/10;
				 if(sTotal!=0){
				 	document.getElementById("s1").innerHTML=sUp;
				 	document.getElementById("s2").innerHTML=sDown;
				 	document.getElementById("sp1").innerHTML=spUp+'%';
				 	document.getElementById("sp2").innerHTML=spDown+'%';
				 	document.getElementById("bground1").style.width = parseInt((sUp/sTotal)*55);
				 	document.getElementById("bground2").style.width = parseInt((sDown/sTotal)*55);
				 }
				msg = "投票成功！";
			}
		}
	} else {
		msg = "暂时不能进行投票";
	}
	if(dp == 'vote'){
		alert(msg);
	}
	
}
   
