/* Registration Form Validation */

function checkFormat(theName, theValue) {
  var chara;
  var email="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.@-_" ;

  if(theName=="email") {
      chara=email;
  }
  else{return false;}

  for(var i=0; i<theValue.length; i++) {
      if(chara.indexOf(theValue.substring(i,i+1))==-1) {
        return true;
    }
  }
  
  return false;
}


function checkEmail()
         {
    if ((document.Regform.emailaddress.value.indexOf("@") != -1) && 
      (document.Regform.emailaddress.value.indexOf("@") < document.Regform.emailaddress.value.lastIndexOf("."))
                     && (checkFormat('email', document.Regform.emailaddress.value) != -1)){ } else
    {
                Alerttag += "- Email \n";
    }
  }

function newcheck() {

    if(document.Regform.salutation.options[0].selected == true){
			            Alerttag += "- Title \n";
	  } 

    if(document.Regform.firstname.value =="") {
                Alerttag += "- First Name \n";
    }

    if(document.Regform.lastname.value =="") {
                Alerttag += "- Last Name \n";
    }
    
    if ((document.Regform.gender[0].checked == false) && 
           (document.Regform.gender[1].checked == false)) {
                Alerttag += "- Gender \n";
	  }    

    checkEmail()
    


    if(document.Regform.username.value =="") {
                Alerttag += "- Username \n";
    }    
    
    if(document.Regform.password.value =="") {
                Alerttag += "- Password \n";
    }
    
    if((document.Regform.passwordc.value =="") || (document.Regform.password.value != document.Regform.passwordc.value)) {
                Alerttag += "- Confirm Password \n";
    }   
 
    if(document.Regform.terms.checked == false) {
                  Alerttag += "- Terms of Use \n";
    }

}

function lastCheck() {
  Alerttag = "";
  newcheck();
    if(Alerttag == "") {
    document.Regform.submit();
  }
    else {
    Alerttag2 = "Please make sure that the required fields are filled.\n\n";
    Alerttag2 += Alerttag;
    alert (Alerttag2); 
    return false ;
    }
}
