	//JS Trim Function - Pass it Text and Minimum String length

	function Ck4Spaces(txt,minlength) {
	    chkKeyword = txt.replace(/\s+$/gi, "");
	    chkKeyword = chkKeyword.replace(/^\s*/gi, "");
		if(chkKeyword.length<minlength){
			return false;		
		}
	}
	
	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 Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
	   		alert("Invalid E-mail Address")
	   		return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert("Invalid E-mail Address")
	    	return false
		}

		if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid E-mail Address")
	    	return false
	 	}

	 	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    	alert("Invalid E-mail Address")
	    	return false
	 	}

	 	if (str.indexOf(dot,(lat+2))==-1){
	    	alert("Invalid E-mail Address")
	    	return false
	 	}
	
	 	if (str.indexOf(" ")!=-1){
	    	alert("Invalid E-mail Address")
	    	return false
	 	}

		 	return true					
	}
	
	function validate() {
		// 	VALIDATION FOR SELECTION (DROP DOWN)
		//var sal=document.frm_contactform.Salutation
		
		//if(sal.selectedIndex==0){
		//	alert("Please select a Salutation.");
		//	sal.focus();
		//	return false;
		//}
		
		
		var rfn=document.frm_contactform.FirstName
		
		if ((Ck4Spaces(rfn.value,1)==false)){
				alert("Please provide your First Name.")
				rfn.focus()
				return false
		}
			
		var rln=document.frm_contactform.LastName
		
		if ((Ck4Spaces(rln.value,1)==false)){
				alert("Please provide your Last Name.")
				rln.focus()
				return false
		}		
				
		var rfeml=document.frm_contactform.Email
	
		if ((Ck4Spaces(rfeml.value,1)==false)){
				alert("Please provide your Email Address.")
				rfeml.focus()
				return false
		}
	
		if (echeck(rfeml.value)==false){
				rfeml.focus()
				return false
		}
		
		var rph=document.frm_contactform.Phone
		
		if ((Ck4Spaces(rph.value,1)==false)){
				alert("Please provide your Phone Number.")
				rph.focus()
				return false
		}
				
		// everything OK
		document.frm_contactform.submit();
	}

