
    //check form
function checkform ( form )
{
  // see http://www.thesitewizard.com/archive/validation.shtml
  // for an explanation of this script and how to use it on your
  // own website

  // ** START **
  var strErrors = new Array();
		strErrors[0] = 'FullName must be 4 to 20 letters or numbers.';
		strErrors[1] = 'You must agree our user agreement to complete registration.';
		strErrors[3] = 'Please choose your city';
		strErrors[4] = 'password must be between 6-12 characters, and cannot contain spaces or special characters.';
		strErrors[5] = 'Please enter your zip code';
		strErrors[6] = 'Your password verifier does not match the password you entered. ';
		strErrors[7] = 'Please enter email';
		strErrors[8] = 'Please retype your email. Your email verifier does not match the email you typed in.';
		strErrors[9] = 'This email is already in use. Please enter a different one.';
		var validationErrors = 0;
  var username= form.fullname.value;
   var mail=form.email.value;
   var  pass=form.password.value;
   var confirmpass=form.confirmpassword.value;
   
   
   //fullname validation
   if(form.fullname)
   {
     if (username.length == 0 ||  username.length < 4 ) {
      document.getElementById('fullname').innerHTML=strErrors[0];
         validationErrors ++ ;
      }else {
				 document.getElementById('fullname').innerHTML='';
			}
     }
	
	
   // password validation
		if ( form.password ) {
		
			if ( pass.length == 0 ||  pass.length < 6 ) {
				document.getElementById('password').innerHTML=strErrors[4];
				validationErrors++;
			}else {
				document.getElementById('password').innerHTML='';
			}
			 }
	// confirmpassword validation
			if ( form.confirmpassword ) {
				 
				 	if ( confirmpass.length == 0 ||  confirmpass.length < 6) {
					document.getElementById('confirmpassword').innerHTML = strErrors[6];
					validationErrors++;
				}	else if (confirmpass != pass ) {
					document.getElementById('confirmpassword').innerHTML = strErrors[6]; 
						validationErrors++;
				}	else {
					document.getElementById('confirmpassword').innerHTML = '';
				}
			}
		
      //emial validation
         if( form.email)
         {
               if(mail.length == 0){
                 document.getElementById('emailjs').innerHTML=strErrors[7];
                 validationErrors ++ ;
                    }else{
                      document.getElementById('emailjs').innerHTML='';
                 }
          }   

  
 if ( validationErrors == 0 ) {
			return true;
			
		}
		else {
			return false;
		}

}
// ajax function
function ajaxFunction()
 {      var xmlHttp;
   try
      { 
       
       xmlHttp = new XMLHttpRequest();  }
     catch (e)
      { 
      try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
      
     catch (e)
    {   
     try
      {      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
          }
    catch (e)
      {     window.alert( "Your browser does not support AJAX!");  
          return false;   
             }  
            } 
             }
 
    
 
    var email= document.registation.email.value;
 
    var url="checkemail.action?email=" + email;
        xmlHttp.open("POST", url ,true);
        xmlHttp.send(null);  
        xmlHttp.onreadystatechange= function()
    {
    if(xmlHttp.readyState==4 && xmlHttp.status == 200)
      {
  
	var spanArray = document.getElementsByTagName('span');
	
	spanArray[5].innerHTML=xmlHttp.responseText;
      }
    }
    }
    
    // ajax function
    function ajaxFunction()
 {      var xmlHttp;
   try
      { 
       
       xmlHttp = new XMLHttpRequest();  }
     catch (e)
      { 
      try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
      
     catch (e)
    {   
     try
      {      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
          }
    catch (e)
      {     window.alert( "Your browser does not support AJAX!");  
          return false;   
             }  
            } 
             }
 
    
 
 var email= document.registation.email.value;
 
    var url="checkemail.action?email=" + email;
   xmlHttp.open("GET", url ,true);
   xmlHttp.send(null);  
   xmlHttp.onreadystatechange= function()
    {
    if(xmlHttp.readyState==4 && xmlHttp.status == 200)
      {
  
	var spanArray = document.getElementsByTagName('span');
	
	spanArray[6].innerHTML=xmlHttp.responseText;
      }
    }
    }
    
