// JavaScript Document
function checkform ()
{    var why = "";
	why += checkBusinessNameEnglish(RequestForm.BusinessNameEnglish.value);
	why += checkTelephone(RequestForm.Telephone.value);
	why += checkStreet(RequestForm.Street.value);
    why += checkCity(RequestForm.City.value);
    why += checkProvince(RequestForm.Province.value);
    why += checkPostalCode(RequestForm.PostalCode.value);
    why += checkCategoryList(RequestForm.CategoryList.selectedIndex);
    why += checkContactName(RequestForm.ContactName.value);
    why += checkContactEmail(RequestForm.ContactEmail.value);
    why += checkContactTel(RequestForm.ContactTel.value);
 
	why += checkFax(RequestForm.Fax.value);
	
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

	function checkBusinessNameEnglish(strng)
	{
		var error = "";
		  if (strng.length == 0) {
			 error = "The 'Business Name (English)' has not been filled in.\n"
		  }
		return error;	  

	}

    function checkTelephone(strng)
	{
		var error = "";
		if (strng == "") {
		   error = "You didn't enter a Telephone number.\n";
		}
		
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
			if (isNaN(parseInt(stripped))) {
			   error = "The Telephone number contains illegal characters.";
		  
			}
			if (!(stripped.length == 10)) {
			error = "The Telephone number is the wrong length. Make sure you included an area code.\n";
			} 
		return error;

	}
	
    function checkStreet(strng)
	{
			var error = "";
		  if (strng.length == 0) {
			 error = "The 'Street' has not been filled in.\n"
		  }
		return error;	  

	}
	
    function checkCity(strng)
	{
			var error = "";
		  if (strng.length == 0) {
			 error = "The 'City' has not been filled in.\n"
		  }
		return error;	  

	}

    function checkProvince(strng)
	{
			var error = "";
		  if (strng.length == 0) {
			 error = "The 'Province' has not been filled in.\n"
		  }
		return error;	  

	}

    function checkPostalCode(strng)
	{
			var error = "";
		  if (strng.length == 0) {
			 error = "The 'Postal Code' has not been filled in.\n"
		  }
		return error;	  

	}

    function checkCategoryList(choice)
	{
		var error = "";
			if (choice == 0) {
			error = "You didn't choose an option from the Category list.\n";
			}    
		return error;
	}

    function checkContactName(strng)
	{
		var error = "";
		  if (strng.length == 0) {
			 error = "The 'Contact Name' has not been filled in.\n"
		  }
		return error;	  

	}

    function checkContactEmail(strng)
	{	if(strng!='')
		{var error = "";
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { 
		   error = "Please enter a valid Contact Email address.\n";
		}
		else {
	//test email for illegal characters
		   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) {
			  error = "The Contact Email address contains illegal characters.\n";
		   }
		}
	return error; }
	else 
			{error="";
		return error;}

	}
	
    function checkContactTel(strng)
	{
		var error = "";
		if (strng == "") {
		   error = "You didn't enter a Contact Telephone number.\n";
		}
		
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
			if (isNaN(parseInt(stripped))) {
			   error = "The Contact Telephone number contains illegal characters.";
		  
			}
			if (!(stripped.length == 10)) {
			error = "The Contact Telephone number is the wrong length. Make sure you included an area code.\n";
			} 
		return error;

	}

	
    function checkFax(strng)
	{	if(strng!='')
		{var error = "";
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
			if (isNaN(parseInt(stripped))) {
			   error = "The Contact Telephone number contains illegal characters.";
		  
			}
			if (!(stripped.length == 10)) {
			error = "The Contact Telephone number is the wrong length. Make sure you included an area code.\n";
			} 
		return error;
		}
		else
		{error='';
		return error;
		}
	}
	
//-->

