// New form validation library.  RL - Feb 2008
		
		function validateTextField(formObj, fieldName, messageVar) {

			if (formObj[fieldName].value == "" || formObj[fieldName].value == " " ) {
				alert("Please complete the \"" + messageVar + "\" section.")
				formObj[fieldName].focus()
				return false
			}
			return true
		}
		
		function validateTextFieldWithInit(formObj, fieldName, messageVar, initialVal) {
			if ((formObj[fieldName].value == "") || (formObj[fieldName].value == initialVal)) {
				alert("Please complete the \"" + messageVar + "\" section.")
				formObj[fieldName].focus()
				return false
			}
			return true
		}
		
		function validateDropDown(formObj, fieldName, messageVar) {
			if (formObj[fieldName].options[formObj[fieldName].selectedIndex].value == 0) {
				alert("Please select an option from the \"" + messageVar + "\" section.")
				formObj[fieldName].focus()
				return false
			}
			return true		
		}
		
		function validateEmail(formObj, fieldName, messageVar) {
			containsAt = formObj[fieldName].value.indexOf("@")
			containsDot = formObj[fieldName].value.lastIndexOf(".")
			if ((containsAt == -1) || (containsDot == -1) || (containsAt > containsDot)) {
				alert("The \"" + messageVar + "\" section does not contain a valid email address\r of the form yourname@company.com or similar.  Please enter a valid address.")
				formObj[fieldName].focus()
				return false
			}
			return true
		}
		
		function compareEmails(formObj, field1, field2, fieldName1, fieldName2) {
			if (formObj[field1].value != formObj[field2].value) {
				alert("The email addresses in the \"" + fieldName1 + "\" and \"" + fieldName2 + "\" sections do not match.\rPlease go back and correct this.")
				formObj[field2].focus()
				return false
			}
			return true
		}
		
		function validateOneOfTwo(formObj, field1, field2, fieldName1, fieldName2) {
			if ((formObj[field1].value == "") && (formObj[field2].value == "")) {
				alert("Please complete either the \"" + fieldName1 + "\" section or the \"" + fieldName2 + "\" section.")
				formObj[field1].focus()
				return false
			}
			return true
		}
		
		function validateOneOfTwoWithInit(formObj, field1, field2, fieldName1, fieldName2, initialVal1, initialVal2 ) {
			if (((formObj[field1].value == "") && (formObj[field2].value == "")) || ((formObj[field1].value == initialVal1) && (formObj[field2].value == initialVal2))) {
				alert("Please complete either the \"" + fieldName1 + "\" section or the \"" + fieldName2 + "\" section.")
				formObj[field1].focus()
				return false
			}
			return true
		}
		
		function validatePostCode(formObj, field, messageVar) {
			if (!checkPostCode(formObj[field].value)) {
				alert("The postcode in the \"" + messageVar + "\" section is in an invalid format.  Please correct this.")
				formObj[field].focus()
				return false
			}
			return true
		}
		
		function validateDate(formObj, ddField, mmField, yyyyField, messageVar, onlyFuture) {
			// if onlyFuture is true, we only return true for dates that are, well, in the future
			
			if (isNaN(parseInt(formObj[ddField].value))) {
				alert("The \"day\" part of the \"" + messageVar + "\" section is not a number.  Please correct this.")
				formObj[ddField].focus()
				return false
			}
			if (isNaN(parseInt(formObj[mmField].value))) {
				alert("The \"month\" part of the \"" + messageVar + "\" section is not a number.  Please correct this.")
				formObj[mmField].focus()
				return false
			}
			if (isNaN(parseInt(formObj[yyyyField].value))) {
				alert("The \"year\" part of the \"" + messageVar + "\" section is not a number.  Please correct this.")
				formObj[yyyyField].focus()
				return false
			}
			daysInMonth = new Array(999,31,28,31,30,31,30,31,31,30,31,30,31)
			theDay = parseInt(formObj[ddField].value)
			theMonth = parseInt(formObj[mmField].value)
			theYear = parseInt(formObj[yyyyField].value)
			if (theMonth > 12) {
				alert("The \"month\" part of the \"" + messageVar + "\" section is greater than 12.  Please correct this.")
				formObj[mmField].focus()
				return false
			}
			if (((theYear % 4 == 0) && (theYear % 100 !=0)) || (theYear % 400 == 0)) { daysInMonth[2] = 29 }
			if (theDay > daysInMonth[theMonth]) {
				alert("The date in the \"" + messageVar + "\" section is not valid.  Please correct.")
				formObj[ddField].focus()
				return false
			}
			
			
			supposedDepDate = new Date(theYear, theMonth, theDay)
			today = new Date()
			if (onlyFuture) {
				if (supposedDepDate < today) {
					alert("The date in the \"" + messageVar + "\" section has already passed.  Please correct.")
					formObj[ddField].focus()
					return false
				}
			}
			
			
			return true
		}
		
		function checkPostCode (toCheck) {
			// Adapted slightly from free code from Braemoor Software
			// www.braemoor.co.uk
			
		  // Permitted letters depend upon their position in the postcode.
		  var alpha1 = "[abcdefghijklmnoprstuwyz]";                       // Character 1
		  var alpha2 = "[abcdefghklmnopqrstuvwxy]";                       // Character 2
		  var alpha3 = "[abcdefghjkstuw]";                                // Character 3
		  var alpha4 = "[abehmnprvwxy]";                                  // Character 4
		  var alpha5 = "[abdefghjlnpqrstuwxyz]";                          // Character 5
		  // Array holds the regular expressions for the valid postcodes
		  var pcexp = new Array ();
		  // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
		  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
		  // Expression for postcodes: ANA NAA
		  pcexp.push (new RegExp ("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
		  // Expression for postcodes: AANA  NAA
		  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 +"{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
		  // Exception for the special postcode GIR 0AA
		  pcexp.push (/^(GIR)(\s*)(0AA)$/i);
		  // Standard BFPO numbers
		  pcexp.push (/^(bfpo)(\s*)([0-9]{1,4})$/i);
		  // c/o BFPO numbers
		  pcexp.push (/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);
		  var postCode = toCheck;
		  var valid = false;
		  
		  for ( var i=0; i<pcexp.length; i++) {
		    if (pcexp[i].test(postCode) && !valid) {
		      pcexp[i].exec(postCode);
		      postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
		      postCode = postCode.replace (/C\/O\s*/,"c/o ");
		      valid = true;
		    }
		  }
		  if (valid) {return true;} else  {	// return postCode here, rather than "true" to correct case and space errors.
		  	return false;
		  }
		}

// end new form validation library	

   // Declaring required variables

var digits = "0123456789";

// non-digit characters which are allowed in phone numbers

var phoneNumberDelimiters = "()- ";

// characters which are allowed in international phone numbers

// (a leading + is OK)

var validWorldPhoneChars = phoneNumberDelimiters + "+";

// Minimum no of digits in an international phone no.

var minDigitsInIPhoneNumber = 10;



function isInteger(s)

{   var i;

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character is number.

        var c = s.charAt(i);

        if (((c < "0") || (c > "9"))) return false;

    }

    // All characters are numbers.

    return true;

}



function stripCharsInBag(s, bag)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (bag.indexOf(c) == -1) returnString += c;

    }

    return returnString;

}

function trim(s)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not a whitespace, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (c != " ") returnString += c;

    }

    return returnString;

}

function checkInternationalPhone(strPhone){

var bracket=3

strPhone=trim(strPhone)

if(strPhone.indexOf("+")>1) return false

if(strPhone.indexOf("(")!=-1 && strPhone.indexOf(")")==-1)return false

if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false

s=stripCharsInBag(strPhone,validWorldPhoneChars);

return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

}



function validatePhone(){

	var Phone=document.info.phone

	if ((Phone.value==null)||(Phone.value=="")){

		alert("Please Enter your Phone Number")

		Phone.focus()

		return false

	}

	if (checkInternationalPhone(Phone.value)==false){

		alert("Please Enter a Valid Phone Number")

//		Phone.value=""

		Phone.focus()

		return false

	}

	return true

 }

