// JavaScript Document
function checkRequired() {


document.form1.firstname.style.border 	 = '1px solid #C7C7C7 ';
document.form1.surname.style.border 	 = '1px solid #C7C7C7 ';
document.form1.emailAddress.style.border  = '1px solid #C7C7C7 ';
document.form1.passwd.style.border = '1px solid #C7C7C7 ';
document.form1.passwdc.style.border  = '1px solid #C7C7C7 ';

if (document.form1.firstname.value==" " || IsBlank("form1","firstname")==false)
	{
		document.form1.firstname.style.border = '2px solid #FF0000 '; 
		document.form1.firstname.focus();
		document.getElementById('firstnameerror').style.visibility='visible';

		return (false);
	}
if (document.form1.surname.value==" " || IsBlank("form1","surname")==false)
	{
		document.form1.surname.style.border = '2px solid #FF0000 '; 
		document.getElementById('firstnameerror').style.visibility='hidden';
		document.form1.surname.focus();
		document.getElementById('surnameerror').style.visibility='visible';
		return (false);
	}

		
if (document.form1.emailAddress.value==" " || IsBlank("form1","emailAddress")==false)
	{
		document.getElementById('surnameerror').style.visibility='hidden';
		document.form1.emailAddress.style.border = '2px solid #FF0000 '; 
		document.form1.emailAddress.focus();
		document.getElementById('emailAddresserror').style.visibility='visible';
		document.getElementById('emailAddresserror').innerHTML='^ Enter your email address';

		return (false);
	}	
if (ValidEmail("form1","emailAddress")==false)
	{
		
		document.form1.emailAddress.style.border = '2px solid #FF0000 '; 
		document.form1.emailAddress.focus();

		document.getElementById('emailAddresserror').style.visibility='visible';
		document.getElementById('emailAddresserror').innerHTML='^ The format of your email address is invalid.';
		return (false);
	}
	
if (document.form1.passwd.value==" " || IsBlank("form1","passwd")==false)
	{
		document.form1.passwd.style.border = '2px solid #FF0000 '; 
		document.form1.passwd.focus();
		document.getElementById('passwderror').style.visibility='visible';
		document.getElementById('emailAddresserror').style.visibility='hidden';

		
		return (false);
	}
	
count = document.form1.passwd.value.length;
            if (count < 6)
            {
					document.form1.passwd.style.border = '2px solid #FF0000 '; 
		document.form1.passwd.focus();
		document.getElementById('passwderror').style.visibility='visible';
		document.getElementById('emailAddresserror').style.visibility='hidden';
	document.getElementById('passwderror').innerHTML='^ Minimum password characters must be 6 or more.';

return (false);
				
			
			}
	
	
if (document.form1.passwdc.value==" " || IsBlank("form1","passwdc")==false)
	{
		document.form1.passwdc.style.border = '2px solid #FF0000 '; 
		document.form1.passwdc.focus();
		document.getElementById('passwderror').style.visibility='hidden';
		document.getElementById('passwdcerror').style.visibility='visible';
		return (false);
	}
	
	
if (document.form1.passwd.value!=document.form1.passwdc.value)
	{
		
		document.form1.passwd.style.border = '2px solid #FF0000 '; 
		document.form1.passwdc.style.border = '2px solid #FF0000 '; 
		document.getElementById('passwdcerror').style.visibility='visible';
		document.getElementById('passwdcerror').innerHTML='^ Your confirmation password does not match.';

		return (false);
	}	

	return (true);
}


function checkmyemail(code, con){
table = 'customers';
col = 'emailAddress';
params='';
cond = con;
mes = 'Email already exist.';
  url = 'check_exist.php?val='+code+'&table='+table+'&col='+col+'&mes='+mes+'&cond='+con;
  new Ajax.Updater('emailAddresserror', url, {
   parameters: params,
   onComplete:  function () {
    if (document.getElementById('span_error_check')) {
    } else {
     if($('emailAddresserror').innerHTML==mes)
	 {
	 	$('emailAddress').value='';
		document.getElementById('emailAddresserror').style.visibility='visible';
		document.getElementById('emailAddresserror').innerHTML='^ There is already an account associated to this email address.';
		


	 }
    }
   }
  });
	
	
}
