<!-- DO NOT EDIT THIS PAGE -->
//Validate if the Field is Blank

function isBlank(elm) {
	if (elm.value == '') {
		 return false;
	}
	else {
		 return true;
	}
}


//Validate if the Field ContainsNumbers

function isNum(elm) {
	var pattern=/[0-9]/;
	 if (pattern.test(elm.value))
	 {
		 return false;
	 }
	else {
		 return true;
	}
}

//Validate if the Field is < 2

function isLength(elm) {
	if (elm.value.length < 2)
	{
		 return false;
	}
	else {
		 return true;
	}
}

//Validate Email. Check for invalid Email
function isEmail(elm){ 
  var pattern1 = /^[a-zA-Z0-9\-\.\_]+\@[a-zA-Z0-9 \-\.]+\.([a-zA-Z]{2,3})$/
	// Uses the test() method and pattern matching that is described 
	// below.
	if (pattern1.test(elm.value)) {	
		  return true;
	}
	else {
	   return false;
	}	 
}

// Validate  Phone Number. Check for invalid Phone number.
function isPhone(elm){ 
	// Checks to see if the value matches the pattern this 
	// i.e looks at the first 3 digits if it is a number from 0-9 it is
	// okay

	var pattern1 = /[0-9]{3}-[0-9]{3}-[0-9]{4}/;

	// Use the test method to check against the form element value
	// test() returns ture if the string arguement passed to it in this 
	// case elm.value

	if (pattern1.test(elm.value)) {	
		  return true;
	}
	else {
	   return false;
	}	 
}

//Validate form

function validate(form){
	  if (isBlank(form.name)== false) 
	 		{
			 		alert("Please enter your name!");
					form.name.focus();
					return false;
			}

    if (isNum(form.name)== false) 
     {
		 	 	alert("Please enter your name correctly - without numbers");
				form.name.focus();
				return false;
		 }

    if (isLength(form.name)== false) 
	 	  {
		 		alert("Please completely fill your name");
		        form.name.focus();
				return false;
      }

	if (isBlank(form.school)== false) 
	 		{
			 		alert("Please enter your School, Agency, Business or Organization!");
					form.school.focus();
					return false;
			}

	 if (isNum(form.school)== false) 
     {
		 	 	alert("Please enter this correctly - without numbers");
				form.school.focus();
				return false;
		 }

	if (isLength(form.school)== false) 
	 	  {
	 		alert("Please completely fill the field correctly");
		    form.school.focus();
				return false;
      }
	if (isBlank(form.address)== false) 
	 		{
			 		alert("Please enter your address!");
					form.address.focus();
					return false;
			}

    if (isLength(form.address)== false) 
	 	  {
		 		alert("Please completely fill your address");
		        form.address.focus();
				return false;

      }

	if (isBlank(form.city)== false) 
	 		{
			 		alert("Please enter your City!");
					form.city.focus();
					return false;
			}

	 if (isNum(form.city)== false) 
      {
		 	 	alert("Please enter your city correctly - without numbers");
				form.city.focus();
				return false;
		  }

    if (isLength(form.city)== false) 
 	  {
	 		alert("Please completely fill your address");
        form.city.focus();
				return false;
      }

  if (isBlank(form.province)== false) 

	 		{

			 		alert("Please enter your Province!");

					form.province.focus();

					return false;

			}



			 if (isNum(form.province)== false) 

      {

		 	 	alert("Please enter your province correctly - without numbers");

				form.province.focus();

				return false;

		  }



			 if (form.province.value.length < 2) {

			  alert("Please completely fill your Province or State");

        form.province.focus();

				return false;

      }

			 

			 if (isBlank(form.zip)== false) 

	 		{

			 		alert("Please enter your Postal or Zip Code!");

					form.zip.focus();

					return false;

			}

	   

	   if ((form.phone.value != "" )&& (isPhone(form.phone) == false))  {



		  var errmsg = "Please enter a valid phone number format xxx-xxx-xxxx."; 



		  alert(errmsg);



	    form.phone.focus();



	    return false;



	   }



	 



	  if (isEmail(form.username) == false) {



	     alert("Please enter a valid email address.");



			 form.username.focus();



			 return false;



	  }



	 



	  return true;



}


