
var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
    var xmlHttp;
    
    try
    {
        xmlHttp = new XMLHttpRequest();
    }
    catch (e)
        
        {
            var XmlHttpVersions = new Array("MSXML2.XMlHTTP.6.0",
                                            "MSXML2.XMlHTTP.5.0",
                                            "MSXML2.XMlHTTP.4.0",
                                            "MSXML2.XMlHTTP.3.0",
                                            "MSXML2.XMlHTTP",
                                            "Microsoft.XMlHTTP");
    for(var i=0;i<XmlHttpVersions.length && !xmlHttp;i++)
    {
        try
        {
            xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
        }
        catch (e) {}
    }
        }
        
        
        if(!xmlHttp)
            alert("Error crearing XMLHttpRequest");
        else
            return xmlHttp;
}


function CallServer_name()
{
var js_name=document.getElementById("tbUid").value;
	//alert(js_name.length);
	if (js_name==""){
		}else{
					var url ="../member/CheckUserName.aspx?username="+encodeURI(js_name); //UTF-8下要用encodeURI
					xmlHttp.open("GET",url,true);
					xmlHttp.onreadystatechange=handleRequestStateChange_name;
					xmlHttp.send(null);					
			}
			
}
function handleRequestStateChange_name()
{
    if(xmlHttp.readyState < 4)
    {
    }
     else  if(xmlHttp.readyState == 4)
        {
            if(xmlHttp.status == 200)
            {
                
                try
                {	
					if(xmlHttp.responseText=="1"){	
					alert("用户名已经被注册");	
					}
									
                }
                catch (e)
                {
                    alert("error" + e.toString());
                }
            }
            else
            {
                //alert("problrm" + e.toString());
            }
        }
}

function CallServer_Pwd1()
{
var js_name=document.getElementById("tbPwd1").value;
	//alert(js_name.length);
	if (js_name.length>=6&&js_name.length<=12)
	{
		}else{
				alert("请输入6-12位密码");			
			}
			
}
function CallServer_Pwd2()
{
var js_name1=document.getElementById("tbPwd1").value;
var js_name2=document.getElementById("tbPwd2").value;
	//alert(js_name.length);
	if (js_name1==js_name2)
	{
		}else{
				alert("请正确输入重复密码");			
			}
			
}

function CallServer_Code()
{
var js_name=document.getElementById("tbCode").value;
	//alert(js_name.length);
	if (js_name==""){
	alert("验请输入验证码");	
		}else{
					var url ="../member/CheckCode.aspx?code="+encodeURI(js_name); //UTF-8下要用encodeURI
					xmlHttp.open("GET",url,true);
					xmlHttp.onreadystatechange=handleRequestStateChange_Code;
					xmlHttp.send(null);					
			}
			
}
function handleRequestStateChange_Code()
{
    if(xmlHttp.readyState < 4)
    {
    }
     else  if(xmlHttp.readyState == 4)
        {
            if(xmlHttp.status == 200)
            {
                
                try
                {	
					if(xmlHttp.responseText=="0"){	
					alert("验证码输入错误");	
					}
									
                }
                catch (e)
                {
                    alert("error" + e.toString());
                }
            }
            else
            {
                //alert("problrm" + e.toString());
            }
        }
}

function save(tid,uid){
	alert("投票已经结束");
/*var topicid= tid;
var userid = uid;
if(topicid!=null&&userid!=null)
{
var myflayer=new flayer(); 
        myflayer.create();
        $.ajax({
            url:"http://www.dreamkitchen.com.cn/js/vote.ashx",
            data:{date:new Date(),topicid:topicid,userid:userid},
            dataType:"xml",
            type:"POST",
            success:function(xml){
                $(xml).find("result").each(function(){
                    alert($(this).attr("msg"));
                    if ($(this).attr("flag")=="1"){
                        location.reload();
                    }else{
                        myflayer.closesend();
                    }
                })                
            },
            error:function(){                
                alert("载入文件错误，请联系管理员");
            }
        });  
   } */
}