<!--
	function checkMailForm(theForm){

		var formOK=true;

		if(theForm.em.value==''){
			alert('Please enter your email address');
			theForm.em.focus();
			formOK=false;
		}
		if(!isEmail(theForm.em.value)){
			if(formOK==true){
				alert('Invalid email address');
				theForm.em.focus();
				formOK=false;
			}
		}
		return formOK;
	}


	function checkForm(theForm,flag)
	{
		var formOK;
		
		formOK = false;
		
		if(checkReq(theForm,flag))
		{
			if(checkValid(theForm,flag))			

				formOK = true;
		}


		return formOK;

	}

	function checkReq(theForm,flag)
	{
		var formReqOK, textAlert;
		
		formReqOK = true;
		textAlert = '\n';

		if(theForm.Name.value == "")
		{
			textAlert = textAlert + '- Name:\n';
				if(formReqOK == true)
					theForm.Name.focus();
			formReqOK = false;
		}

		if(flag == 'b')
		{
			if(theForm.Company_Name.value == "")
			{
				textAlert = textAlert + '- Company Name:\n';
					if(formReqOK == true)
						theForm.Company_Name.focus();
				formReqOK = false;
			}
		}

		if(theForm.Address.value == "")
		{
			textAlert = textAlert + '- Address:\n';
				if(formReqOK == true)
					theForm.Address.focus();
			formReqOK = false;
		}

		if(theForm.Tel.value == "")
		{
			textAlert = textAlert + '- Telephone:\n';
				if(formReqOK == true)
					theForm.Tel.focus();
			formReqOK = false;
		}

		if(theForm.Email.value == "")
		{
			textAlert = textAlert + '- Email Address:\n';
				if(formReqOK == true)
					theForm.Email.focus();
			formReqOK = false;
		}

		if(flag == 'a')
		{
			if(theForm.Enquiry.value == "")
			{
				textAlert = textAlert + '- Enquiry:\n';
					if(formReqOK == true)
						theForm.Enquiry.focus();
				formReqOK = false;
			}
		}

		if(flag == 'b')
		{
			if(theForm.Nature_of_Business.value == "")
			{
				textAlert = textAlert + '- Nature of Business:\n';
					if(formReqOK == true)
						theForm.Nature_of_Business.focus();
				formReqOK = false;
			}

			if(theForm.Product_Interest.value == "")
			{
				textAlert = textAlert + '- Products that interest you:\n';
					if(formReqOK == true)
						theForm.Product_Interest.focus();
				formReqOK = false;
			}
		}

		if(!formReqOK)
		{
			alert('Please fill in the following field(s):\n' + textAlert);
		}

	return formReqOK;	
	}
	
	function checkValid(theForm,flag)
	{
		var formValOK, textAlert;
		
		formValOK = true;
		textAlert = '\n';

		if(theForm.Tel.value.length < 6)
		{
			textAlert = textAlert + '- Invalid phone number\n';
				if(formValOK == true)
				{
					theForm.Tel.select();
					theForm.Tel.focus();
				}
			formValOK = false;
		}

		if(flag = 'b')
		{
			if(theForm.Fax.value.length > 0 && theForm.Fax.value.length < 6)
			{
				textAlert = textAlert + '- Invalid fax number\n';
					if(formValOK == true)
					{
						theForm.Fax.select();
						theForm.Fax.focus();
					}
				formValOK = false;
			}
		}

		if(!isEmail(theForm.Email.value))
		{
			textAlert = textAlert + '- Invalid e-mail address\n';
				if(formValOK == true)
				{
					theForm.Email.select();
					theForm.Email.focus();
				}
			formValOK = false;
		}	

		if(!formValOK)
		{
			alert ('The following error(s) occurred:\n' + textAlert);
		}

		return formValOK;

	}
	
	function isEmail(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) {
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]

		if (user.match(userPat)==null) {
			return false
		}

		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
				return false
				}
			}
			return true
		}

		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			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>5) {
		   return false
		}

		if (len<2) {
		   return false
		}

		return true;
	}
	
//-->