// JavaScript Document

function fnSubmit()
{
	var r = document.frmContact;
	var txtName = r.txtName;
	var sMethod = r.sMethod;
	var txtContact = r.txtContact;
	var txtEmail = r.txtEmail;
	var sType = r.sType;
	var txtMessage = r.txtMessage;
	var illegalChars = /[\~\`\|{\}\|\@\#\$\%\^\*\+\=\(\)\<\>\;\\\/\"\[\]]/ // allow letters, numbers, and underscores
	var emailFilter=/^.+@.+\..{2,3,4,6}$/;
	
	if (txtName.value == "")	{ 
		alert("Please enter your name.");
		txtName.select();
		txtName.focus();
		return false;
	} else if (illegalChars.test(txtName.value)) { 
		alert("Please enter letters or numbers only for your name.\n Special characters are not accepted."); 
		txtName.select(); 
		txtName.focus();
		return false;
	}
	
	if (r.sMethod.value == "")	{ 
		alert("Please select method of contact.");
		r.sMethod.focus(); 
		return false;
	}
	
	
	if (r.sMethod.value == "phone" && txtContact.value == "")	{ 
		alert("Please enter your phone number.");
		txtContact.select();
		txtContact.focus(); 
		return false;
	}
	
	/*if (txtContact.value == "" && txtEmail.value == "")
	{
		alert("Please enter either your cotact number or your E-mail address so we can contact you");
		txtContact.select();
		txtContact.focus();
		return false;
	}
	
	if (txtContact.value == "")	{ 
		alert("Please eneter your contact number."); 
		txtContact.select();
		txtContact.focus();
		return false;
	} else	*/
	
	if (isNaN(txtContact.value))	{ 
		alert("Please enter numbers only for your phone number.");
		txtContact.select();
		txtContact.focus();
		return false;
	}
	
	/*if (txtEmail.value == "")	{ 
		alert("Please eneter your e-mail address."); 
		txtEmail.select();
		txtEmail.focus(); 
		return false;
	}*/
	
	if (r.sMethod.value == "email" && txtEmail.value == "")	{ 
		alert("Please enter your E-mail address.");
		txtEmail.select();
		txtEmail.focus();  
		return false;
	}
	
	if (r.txtEmail.value.length >0) {
		 i=r.txtEmail.value.indexOf("@")
		 j=r.txtEmail.value.indexOf(".",i)
		 k=r.txtEmail.value.indexOf(",")
		 kk=r.txtEmail.value.indexOf(" ")
		 jj=r.txtEmail.value.lastIndexOf(".")+1
		 len=r.txtEmail.value.length
		if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
		} else {
			alert("Please enter a valid E-mail address.\n" + r.txtEmail.value + " is invalid.");
			txtEmail.select();
			txtEmail.focus(); 
			return false;
 		}
	}
	
	if (r.sType.value == "")	{ 
		alert("Please select an enquiry type.");
		r.sType.focus(); 
		return false;
	}
		
	if (txtMessage.value == "")	{ 
		alert("Please enter your message.");
		txtMessage.select();
		txtMessage.focus();
		return false;
	}
}