﻿// JScript 文件
var xmlHttp;

if (window.ActiveXObject)
{
   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest)
{
   xmlHttp=new XMLHttpRequest();
}



function killErrors() 
{
return true;
}
window.onerror = killErrors;




function Voted(temp)
{
   if(temp==1)
   {
      document.getElementById("addvoted").style.display = "block";
      document.getElementById("showvoted").style.display = "none";
   }
   else
   {
      document.getElementById("addvoted").style.display = "none";
      document.getElementById("showvoted").style.display = "block";
   }
}


function checkVote()
{

         var chkother= document.all("myVote").getElementsByTagName("input");
	     var j=0;
	     for (var i=0;i<chkother.length;i++)
	     {
	        
		    if( chkother[i].type=='radio')
		    {
			    if(chkother[i].checked == true)
			    {
				    j++;
			    }
		    }
	     }
	    
	     if(j==0) 
	     {
	        alert("Sorry,请至少选择一项！","",true);
	        return false;
	     }
	     else
	     {
	        for (var i=0;i<chkother.length;i++)
	        {
	        
		        if( chkother[i].type=='radio')
		        {
			        if(chkother[i].checked == true)
			        {   
				        sendVote(chkother[i].value); 
			        }
		        }
	       }
	     }
}

function sendVote(temp)
{

   var url="../WriteVote.aspx?id="+temp;
   xmlHttp.open("GET",url,true);
   xmlHttp.onreadystatechange=returnVote;
   xmlHttp.send(null);
}

function returnVote()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
           {
                var mes= xmlHttp.responseText;

                if(mes==true)
                {
                    document.getElementById("addvoted").style.display = "block";
                    document.getElementById("showvoted").style.display = "none";
                }
                else
                {
                    document.getElementById("addvoted").style.display = "none";
                    document.getElementById("showvoted").style.display = "block";
                }
    
           }
    }
}
