﻿// JScript 文件
function GetXmlHttp()
{
    var A=null; 
    try
     { 
	    A=new ActiveXObject("Msxml2.XMLHTTP"); 
     }
    catch(e)    
    { 
	    try
	    { 
		    A=new ActiveXObject("Microsoft.XMLHTTP"); 
	    }
	    catch(oc)
	    { 
			A=null;
    	}
    } 
	if ( !A && typeof XMLHttpRequest != "undefined" )
	{ 
	 	A=new XMLHttpRequest() ;
    } 
    return A ;
}
//获取用户的IP
function getIPinfo()
{
    var xmlhttp = GetXmlHttp();
    if(xmlhttp==null) return;
    xmlhttp.open("GET","/ajax.aspx?type=getip",true,null);
    xmlhttp.onreadystatechange=function()
    {
	    if(xmlhttp.readyState==4&&xmlhttp.status==200)
	    {
	        var strIP=xmlhttp.responseXML.getElementsByTagName("num")[0].firstChild.nodeValue;
	        if(parseInt(strIP,2)!=0)
	        {
	            $("hidIP").value= strIP;       
	        }	       
	    }
	}
	xmlhttp.send (null);
} 

//检查当天投票的次数
function checkVoteStatus()
{
    var xmlhttp = GetXmlHttp();
    if(xmlhttp==null) return;
    xmlhttp.open("GET","/ajax.aspx?type=votenum",true,null);
    xmlhttp.onreadystatechange=function()
    {
	    if(xmlhttp.readyState==4&&xmlhttp.status==200)
	    {
	        var strnum=xmlhttp.responseXML.getElementsByTagName("status")[0].firstChild.nodeValue;
	        if(parseInt(strnum,2)!=0)
	        {
	            $("hidisinfo").value= strnum;       
	        }	       
	    }
	}
	xmlhttp.send (null);
} 

function checkInfo()
{  
    if($("hidisinfo").value!="0")     
    {        
        alert("Sorry, your answers can be only sent once per day !");
        return false;
    }
    if(!IsCheckbox("region"))
    {
        alert("Please let us know your favourite place for the next summit. Thanks!");
        return false;
    }
    else if(!IsCheckbox("sdata"))
    {
        alert("Please let us know your favourite time for the next summit. Thanks!");
        return false;
    }
    else
    {      
        $("hidisinfo").value="1";
        alert("Your message has been sent successfully!");       
        document.form1.action = "/2008/getvalue.aspx"; 
        document.form1.target = "_blank";
        document.form1.submit(); 
       
    }
}

function IsCheckbox(obj)
{
     var status=0;
     var list=document.getElementsByName(obj);
     for(var i=0;i<list.length;i++)
     {
        if(list[i].checked==true)
        {
            status=1;
        }
     }
     if(status==0)
     {
        return false;
     }
     return true;
}

//加入邮件组
function checkEmail()
{
    var str=$("txt_mail");
    if(str.value=="Please enter your E-mail" || str.value=="")
    {
        alert("Please let us know your personal email address if you want!");
        str.value="";
        //str.focus();
    }
    else if(!validateEmail(str.value))
    {
        alert("Sorry! The email address you entered is incorrect, please check and reenter!");
        str.value="";
       // str.focus();        
    }
    else
    {
        AddPuMailgroup(str.value);   
    }
}
    
function $(obj)
{
    return document.getElementById(obj);
}