

function validate() {

mNv=document.form1.FirstName.value;

if (mNv=="") {

	alert('Your First Name is a required field. Please try again.');

	event.returnValue=false;

}else if (document.form1.LastName.value ==""){

	alert('Your Last Name is a required field. Please try again.');

	event.returnValue=false;

}else if (document.form1.Phone.value ==""){

	alert('Your Phone Number is a required field. Please try again');

	event.returnValue=false;

	//event.returnValue=value;

}else if (document.form1.Phone.value !=""){

		value = CheckPhoneNumber(document.form1.Phone.value);

		if (value){

		}else{

			event.returnValue=false;

		}

}

if ((value) && (document.form1.Email1.value =="")){

	alert('Your Email Address is a required field. Please try again');

	event.returnValue=false;

}else if((value)&&(document.form1.Email1.value !="")){

		value1 = emailCheck(document.form1.Email1.value);

		if (value1){

		}else{

			event.returnValue=false;

		}

}

if ((value1) && (document.form1.Email2.value =="")){

	alert('Confirm your Email Address. Please try again');

	event.returnValue=false;

}else if((value1)&&(document.form1.Email2.value !="")){

		value2 = emailCheck(document.form1.Email2.value);

		if (value2){

		}else{

			event.returnValue=false;

		}

}

if ((value1) && (value2)){

	if(document.form1.Email1.value != document.form1.Email2.value){

		alert('Your email address did not match. Please try again');

		event.returnValue=false;

		value3 = false;

		

	}

	value3=true;

}

	var newmonthnbday = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
	with(document.form1) { 
	var j = fromday[fromday.selectedIndex].value; 
	var m = frommonth[frommonth.selectedIndex].value; 
	var a = fromyear[fromyear.selectedIndex].value; 
	}
	
	maxday = (m == 2 && a % 4 == 0 && (a % 100 != 0 || a % 400 == 0)) ? 29 : newmonthnbday[m];
	if (j > maxday) 
	{
	alert('Invalid date'); 
	event.returnValue=false; 
	}
	value4 = true;

value5= document.form1.Program.value;

if ((value4) && ((value5) == "Acommodation")){

		document.form1.action   = "Acommodation.php";

}else{

		document.form1.action   = "RegistDetailsConfirmation.php";

	

} 

}







function CheckPhoneNumber(TheNumber) {

var GoodChars = "0123456789()-+ "

var i = 0



if (TheNumber=="") {

	alert('Your Phone Number is a required field. Please try again');

return false

	}

for (i =0; i <= TheNumber.length -1; i++) {

if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {

 alert(TheNumber.charAt(i) + " is not a valid character for the Phone entry. Please try again")

return false

} // End if statement

	} // End for loop

return true

}



function emailCheck (emailStr) {

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=emailStr.match(emailPat)

if (matchArray==null) {

	alert("Email address seems incorrect (check @ and .'s)")

	return false

}

var user=matchArray[1]

var domain=matchArray[2]



if (user.match(userPat)==null) {

    alert("The username doesn't seem to be valid.")

    return false

}



/* if the e-mail address is at an IP address (as opposed to a symbolic

   host name). */

var IPArray=domain.match(ipDomainPat)

if (IPArray!=null) {

    // this is an IP address

	  for (var i=1;i<=4;i++) {

	    if (IPArray[i]>255) {

	        alert("Destination IP address is invalid!")

		return false

	    }

    }

    return true

}



// Domain is symbolic name

var domainArray=domain.match(domainPat)

if (domainArray==null) {

	alert("The domain name doesn't seem to be valid.")

    return false

}



var atomPat=new RegExp(atom,"g")

var domArr=domain.match(atomPat)

var len=domArr.length

if (domArr[domArr.length-1].length<2 || 

    domArr[domArr.length-1].length>3) {

   // the address must end in a two letter or three letter word.

   alert("The email address must end in a three-letter domain, or two letter country.")

   return false

}



// there's a host name preceding the domain.

if (len<2) {

   var errStr="This email address is missing a hostname!"

   alert(errStr)

   return false

}



// If we've gotten this far, everything's valid!

return true;

}





