﻿function clearName()
{
 document.getElementById("nameLabel").innerHTML="";
 document.getElementById("username").style.borderColor ="";
 
}
function chkName()
{
   var obj=document.getElementById("username");
   if(obj.value=="")
  {
    document.getElementById("nameLabel").innerHTML="Please input your name to complete register.";
    obj.style.borderColor = '#FF0000';
    
  }
}
function clearEmail()
{
 document.getElementById("emailLabel").innerHTML="";
 document.getElementById("email").style.borderColor ="";
 
}
function chkEmail()
{
   var obj=document.getElementById("email");
   if(obj.value=="")
  {
    document.getElementById("emailLabel").innerHTML="Please input your email.";
    obj.style.borderColor = '#FF0000';
    return false;
    
  }
  else
  {
     var t = /^[A-Za-z0-9._%-]+@([\-_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;	 		
	 if(t.test(obj.value)!=true)
	 {
	    document.getElementById("emailLabel").innerHTML="Please input a validate email.";
        obj.style.borderColor = '#FF0000';
        return false;
	 }
  }
  return true;
}
function clearPhone()
{
 document.getElementById("phoneLabel").innerHTML="";
 document.getElementById("phone").style.borderColor ="";
 
}
function chkPhone()
{
   var obj=document.getElementById("phone");
   if(obj.value=="")
  {
    document.getElementById("phoneLabel").innerHTML="Please input phone number to complete register.";
    obj.style.borderColor = '#FF0000';
    
  }
  else
  {
     var t = /^[0-9]*$/;     ///^1(3|5|8)\d{9}$/;	 		
	 if(t.test(obj.value)!=true)
	 {
	    document.getElementById("phoneLabel").innerHTML="Wrong input, please try again.";
        obj.style.borderColor = '#FF0000';
	 }
  }
}
function chkcode()
{
 //alert(0);
  var codeObj=document.getElementById("checkcode");
  if(codeObj.value=="")
  {
    document.getElementById("codeLabel").innerHTML="Please input validate code to complete register.";
    codeObj.style.borderColor = '#FF0000';
    return false;
  
  }
  else
  {
      if(!ajaxGetCheckCode("checkcode="+codeObj.value))
      {
         document.getElementById("codeLabel").innerHTML="Wrong validate code, please try again.";
         document.getElementById("checkcode").style.borderColor = '#FF0000';
         return false;
      }
  }
  return true;
}
function clearcode()
{
 document.getElementById("codeLabel").innerHTML="";
 document.getElementById("checkcode").style.borderColor ="";
 //document.getElementById("checkcode")
 
}
function changeCheckCodeImg()
{
   document.getElementById("checkcodeimg").src="/_layouts/TheVillage/eng/app/forms/GetCheckCodeImg.aspx?r="+Math.random();

}

function getXMLHttpRequest() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        request = new ActiveXObject("Microsoft.XMLHTTP");
        if (!request) {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        return request;
    }

}

var xmlHttpRequestCheckCode;
function ajaxGetCheckCode(strInfo) {
  
    xmlHttpRequestCheckCode = getXMLHttpRequest();
    xmlHttpRequestCheckCode.open("POST", "/_layouts/TheVillage/eng/app/forms/CheckCodeValidate.aspx", false);
    xmlHttpRequestCheckCode.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   // xmlHttpRequestCheckCode.onreadystatechange = onReadyGetUserNewlyActions;
    xmlHttpRequestCheckCode.send(strInfo);
    return onReadyGetCheckCode();
}
function onReadyGetCheckCode() {
    if (xmlHttpRequestCheckCode.readyState == 4) {
      
        if (xmlHttpRequestCheckCode.status == 200) 
        {
          return xmlHttpRequestCheckCode.responseText=="1";
        //    if (xmlHttpRequestCheckCode.responseText=="0")
      //      {
      //         document.getElementById("codeLabel").innerHTML="Wrong validate code, please try again.";
   // document.getElementById("codeLabel").style.color='#FF0000';
   // document.getElementById("checkcode").style.borderColor = '#FF0000';
   // document.getElementById("checkcode").focus();
         //   }
        } 
        else
        	  
            alert("处理忙，请稍候再试！");
    }
}

function contactUs_form_success()
{
  $("div#div_contactUs_form").hide();
  $("div#div_contactUs_form_success_info").show();
}
