
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function progValidateForm(){
			var oForm = document.cForm;
			var sErrorString = "";
			var oErrorField = document.getElementById("errorField");
			oErrorField.style.display="none";
			//check that name has been entered
			var oNameField = oForm.posName;
			if (oNameField.value == "") sErrorString += "Please Enter a Contact Name.<br/>";
			//check that email has been entered and is valid
			var oEmailField = oForm.posEmail;
			if (oEmailField.value == "" || !(echeck(oEmailField.value))) sErrorString += "Please Enter a Valid Email.<br/>";
			//check that telephone no. has been entered
			var oTelField = oForm.posRegard;
			if (oTelField.value == "") sErrorString += "Please Enter a Contact Number.<br/>";//if (oTelField.value == "" || IsNotNum(oTelField.value)) sErrorString += "Please Enter a Contact Number.<br/>";
			//check that at least a contact mode has been ticked
			var arrStrCC = document.cForm.selfCC;
			var validCC = false;
   for(i=0;i<arrStrCC.length;i++) {
     if (arrStrCC[i].checked == true) validCC = true;
   }
			if (!validCC) sErrorString += "Please Select on Contact Method by Ticking the Appropriate Box";
			if (sErrorString != "") {
	    oErrorField.style.display = "block";
					oErrorField.innerHTML = sErrorString;
					return false;
			}
			sendPosEmail();
			return true;
	}
/*HELPERS*/

function IsNotAlpha(strToCheck)
{
   //var validReg="[^a-zA-Z\s]";
			var validReg="^[a-zA-Z-\s]{2,128}$"
   var regex= new RegExp(validReg);
   return regex.test(strToCheck);
 }
	function IsNotNum(strToCheck)

{
				var validReg="[^0-9\s]";
				var regex= new RegExp(validReg);
				return regex.test(strToCheck);
 }


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
