// JavaScript Document
function email_check(urlreleated)
{
	 var emailvalue=document.registration_form.cust_email.value;
	
	 var html = $.ajax({
	     type: "POST",
 		 url: urlreleated+"server-scripts/emailtest.php",
  		 async: false,
		 data:'emailvalue='+emailvalue
	 }).responseText;

    
	
		 if(html=="Yes"){
			  alert('Email-Id Already Exists');
		      $("#cust_email").focus();
			  return false;
		}
		else
		return true;
		
  
}
function validate_registration(furl){

var why = "";

var show = false;

var feildfocus = false;

boxone=false;boxtwo=false;boxthree=false; boxfour=false;boxfive=false; boxsix=false;boxseven=false;boxeight=false;boxnine=false;boxten=false;boxeleven=false;

boxtwelve=false;boxthirteen=false;boxsixteen=false;



if(document.registration_form.cust_name.value == ""){

 why+="Please enter Your First Name\n";

 show = true;

 boxone=true;

 }



if(document.registration_form.cust_surname.value == ""){

 why+="Please enter your Surname\n";

 show = true;

 boxtwo=true;

}

if(document.registration_form.cust_password.value== ""){

 why+="Please enter your password \n";

 show = true;

 boxfour=true;

}

if(document.registration_form.cust_password.value!= ""){

if(document.registration_form.cust_password.value!=document.registration_form.cust_passconfirm.value){

 why+="Password does not match \n";

 show = true;

 boxtwelve=true;

}

}

if(document.registration_form.cust_address.value== ""){

 why+="Please enter your address \n";

 show = true;

 boxfive=true;

}



if(document.registration_form.cust_suburb.value== ""){

 why+="Please enter your suburb \n";

 show = true;

 boxsix=true;

}



if(document.registration_form.cust_state.value== ""){

 why+="Please enter your state \n";

 show = true;

 boxseven=true;

}

if(document.registration_form.cust_postcode.value.length<1 || (CheckPostcodeee(document.registration_form.cust_postcode.value)==false)){

 why+="Please enter a valid postcode\n";

 show = true;

 boxeight=true;

}



if(document.registration_form.cust_country.value== ""){

 why+="Please enter your Country \n";

 show = true;

 boxnine=true;

}



if(isEmail($.trim(document.registration_form.cust_email.value))==false){

 why+="Please enter valid Email address\n";

 show = true;

 boxten=true;

}



if(document.registration_form.cust_email.value!= ""){

if(document.registration_form.cust_email.value!=document.registration_form.cust_confirmemail.value){

 why+="Email id does not match \n";

 show = true;

 boxthirteen=true;

}

}
if(document.registration_form.cust_telephone.value==""){

 why+="Please enter a valid Telephone number\n";

 show = true;

 boxeleven=true;

}

if(show){
	alert(why);	
              if(boxeleven){

   document.registration_form.cust_telephone.focus();}

   

    if(boxthirteen){

   document.registration_form.cust_confirmemail.focus();}



             if(boxten){

   document.registration_form.cust_email.focus();}

           if(boxnine){

   document.registration_form.cust_country.focus();}

   

    if(boxeight){

   document.registration_form.cust_postcode.focus();}

  

   if(boxseven){

   document.registration_form.cust_state.focus();}



  if(boxsix){

   document.registration_form.cust_suburb.focus();}



      if(boxfive){

   document.registration_form.cust_address.focus();}

   

    if(boxtwelve){

   document.registration_form.cust_passconfirm.focus();}



    if(boxfour){

   document.registration_form.cust_password.focus();}

  

  

   

    if(boxtwo){

   document.registration_form.cust_surname.focus();}

  

  if(boxone){

   document.registration_form.cust_name.focus();}   

  return false;

 }



 //document.registration_form.submit();
return email_check(furl);
}





function isEmail(strValue) {

 var objRegExp = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,3}$/i;

 return objRegExp.test(strValue);

}







function CheckPostcode(TheNumber) {

 var valid = 1

 var GoodChars = "0123456789()-+ "

 var i = 0

 if (TheNumber=="") {

 // Return false if number is empty

 valid = 0

 }

 for (i =0; i <= TheNumber.length -1; i++) {

 if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {

// Note: Remove the comments from the following line to see this

// for loop in action.

// alert(TheNumber.charAt(i) + " is no good.")

 valid = 0

 } // End if statement

 } // End for loop

 return valid

}

function CheckPostcodeee(TheNumber) {

 var valid = 1

 var GoodChars = "asdfghjklqwertyuiopzxcvbnmASDFGHJKLZXCVBNMQWERTYUIOP0123456789-"

 var i = 0

 if (TheNumber=="") {

 // Return false if number is empty

 valid = 0

 }

 for (i =0; i <= TheNumber.length -1; i++) {

 if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {

// Note: Remove the comments from the following line to see this

// for loop in action.

// alert(TheNumber.charAt(i) + " is no good.")

 valid = 0

 } // End if statement

 } // End for loop

 return valid

}
















function checkpassword()

{

if (document.registration_form.cust_passconfirm.value != document.registration_form.cust_password.value)

{

alert("Passwords do not match!");

document.registration_form.cust_passconfirm.focus();

//document.getElementById("para1");



//document.getElementById('cust_passconfirm').focus();

return false;

}

return true;



}







function validate_regist()

{

var why1 = "";

var show1 = false;

var feildfocus = false;

boxxone=false;boxxtwo=false;

if(isEmail(document.login.login_email.value)==false){

 why1+="Please enter valid Email address\n";

 show1=true;

 boxxone=true;

}

if(document.login.login_password.value == ""){

 why1+="Please enter Your Password\n";

 show1= true;

 boxxtwo=true;

 }







if(show1){

   alert(why1);

   

        if(boxxtwo){

   document.login.login_password.focus();}

   if(boxxone){

   document.login.login_email.focus();}

   

  return false;

 }



}

/*

function validate_regist()

{

var whyy = "";

var showw = false;

var feildfocus = false;

boxxone=false;boxxtwo=false;

if(isEmail(document.login.login_email.value)==false){

 whyy+="Please enter valid Email address\n";

 showw = true;

 boxxone=true;

}

 if(document.login.login_password.value == ""){

 whyy+="Please enter Your Password\n";

 showw = true;

 boxxtwo=true;

 }

}



if(showw){

   alert(whyy);

   

       if(boxxtwo){

   document.login.login_password.focus();}

  

  if(boxxone){

   document.login.login_email.focus();}

  return false;

 }



 //document.registration_form.submit();

} */