// JavaScript Document
/*
Lnnam 19/02/2008
*/
function validatePassword(IDPassword, IDRePassword) 
{	
	strPassword = document.getElementById(IDPassword).value;
	strRePassword = document.getElementById(IDRePassword).value;
	if(strPassword.length != strRePassword.length || !strPassword) return false;
	var sLength = strPassword.length;
	if(sLength < 6)   return false;
	for(i = 0; i < sLength; i++)
	{
		if(strPassword.charAt(i) != strRePassword.charAt(i))  return false;
	}
	return true;
}
function validateEmail(strEmail) {
	var emailPat=/^(.+)@(.+)$/	
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'	
	var word="(" + atom + "|" + quotedUser + ")"	
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")	
	var matchArray = strEmail.match(emailPat)	
	if (matchArray == null) return false;
	return true;
}

function validateForm() {
	if(!document.Form.txtFirstName.value) {
		alert('Please complete your first name.');
		document.Form.txtFirstName.focus();
		return;
	}
	if(!document.Form.txtLastName.value) {
		alert('Please complete your last name.');
		document.Form.txtLastName.focus();
		return;
	}
	if(!document.Form.txtEducationLevel.value) {
		alert('Please complete your education level.');
		document.Form.txtEducationLevel.focus();
		return;
	}
	var stripped = document.Form.txtAge.value.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
	   alert('The phone number contains illegal characters.');
	   document.Form.txtAge.focus();
		return;
	}

	if(!document.Form.txtSalon.value) {
		alert('Please complete your salon name.');
		document.Form.txtSalon.focus();
		return;
	}
	if(!document.Form.txtPhoneNumber.value) {
		alert('Please complete your cell number.');
		document.Form.txtPhoneNumber.focus();
		return;
	}
	if(document.Form.cboReferral.value=="none") {
		alert('Please select a referral source.');
		document.Form.cboReferral.focus();
		return;
	}
	if(document.Form.cboProfession.value=="none") {
		alert('Please select a profession.');
		document.Form.cboProfession.focus();
		return;
	}
	if ( ( document.Form.skin_care_line[0].checked == false )
    && ( document.Form.skin_care_line[1].checked == false ) )

	{
		alert('Do you currently carry a skin care line?');
		document.Form.skin_care_line[0].focus();
		return;
	}
	if ( ( document.Form.skin_therapist[0].checked == false )
    && ( document.Form.skin_therapist[1].checked == false ) )

	{
		alert('Is there a licensed skin therapist currently on your staff?');
		document.Form.skin_therapist[0].focus();
		return;
	}
	if ( ( document.Form.AttendIDI[0].checked == false )
    && ( document.Form.AttendIDI[1].checked == false ) )

	{
		alert('Have you attended an IDI School?');
		document.Form.AttendIDI[0].focus();
		return;
	}
	if ( ( document.Form.replace_line[0].checked == false )
    && ( document.Form.replace_line[1].checked == false ) )

	{
		alert('Are you looking to replace your current skin line or add a new skin line?');
		document.Form.replace_line[0].focus();
		return;
	}
	if(document.Form.cboChangeSkinLine.value=="none") {
		alert('How quickly are you looking to change skin lines or add skin to your business?');
		document.Form.cboChangeSkinLine.focus();
		return;
	}
	
	document.Form.submit();
}


