function ValidateForm(){

	var title=document.addcustomer.txttitle
	var firstname=document.addcustomer.txtfirstname
	var lastname=document.addcustomer.txtlastname

	var emailID=document.addcustomer.txtemailaddress
	var confirmemailID=document.addcustomer.txtconfirmemailaddress
	var password=document.addcustomer.txtpassword
	var confirmpassword=document.addcustomer.txtconfirmpassword


	if (title.value=="0"){
		alert("Please select your Title")
		title.focus()
		return false
	}
	if ((firstname.value==null)||(firstname.value=="")){
		alert("Please enter your First Name")
		firstname.focus()
		return false
	}
	if ((lastname.value==null)||(lastname.value=="")){
		alert("Please enter your Last Name")
		lastname.focus()
		return false
	}

	
//if ( (!(emailID.value==null) && !(emailID.value=="")) || (!(confirmemailID.value==null) && !(confirmemailID.value=="")) ) {

		if ( (emailID.value==null) || (emailID.value=="")){
			alert("Please Enter your Email Address")
			emailID.focus()
			return false
		}

		if (echeck(emailID.value)==false){
			emailID.select()
			return false
		}

		if ((confirmemailID.value==null)||(confirmemailID.value=="")){
			alert("Please Confirm your Email Address")
			confirmemailID.focus()
			return false
		}
		if (echeck(confirmemailID.value)==false){
			confirmemailID.select()
			return false
		}
		if (!(emailID.value == confirmemailID.value)){
			alert("Email Addresses did not match.  Please enter them again")
			confirmemailID.focus()
			return false
		}

//	}

	if ((password.value==null)||(password.value=="")||(password.value.length<6)||(password.value.length>15)){
		alert("Please Enter a Password. Passwords must be between 6 - 15 characters")
		password.focus()
		return false
	}
	if ((confirmpassword.value==null)||(confirmpassword.value=="")||(confirmpassword.value.length<6)||(confirmpassword.value.length>15)){
		alert("Please Confirm your Password. Passwords must be between 6 - 15 characters")
		confirmpassword.focus()
		return false
	}
	if (!(password.value == confirmpassword.value)){
		alert("Passwords did not match.  Please enter them again")
		password.value=""
		confirmpassword.value=""
		password.focus()
		return false
	}

//	var secretquestion=document.addcustomer.txtquestion
//	var secretanswer=document.addcustomer.txtanswer

//	if ((secretquestion.value==null)||(secretquestion.value=="")){
//		alert("Please Enter your Secret Question")
//		secretquestion.focus()
//		return false
//	}
//	if ((secretanswer.value==null)||(secretanswer.value=="")){
//		alert("Please Enter your Secret Answer")
//		secretanswer.focus()
//		return false
//	}

////////////////
	return true
 }


function isNumeric(val) {
	var dp = false;
	for (var i=0; i < val.length; i++) {
		if (!isDigit(val.charAt(i))) { 
			if (val.charAt(i) == '.') {
				if (dp == true) { return false; }
				else { dp = true; }
			}
			else {
				return false; 
			}
		}
	}
	return true;
}

function isDigit(num) {
	var string="1234567890";
	if (string.indexOf(num) != -1) {
		return true;
	}
	return false;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}
