<!--
function Trim(strInput, strFind)
	{
	/* Trim:
	// This function uses RTrim and LTrim to 
	// remove strFind from both sides of a strInput.
	// Spaces are removed by default if strFind is omitted.
	*/
	if (strFind == null)
		{
		strFind = ""
		}
		
	if (strInput != null && strInput != "")
		{
		strInput = LTrim(strInput, strFind);
		strInput = RTrim(strInput, strFind);
		}
	return strInput
	}

function RTrim(strInput, strFind)
	{
	/* RTrim:
	// This function uses Replace to remove strFind from the 
	// right side of strInput.  Spaces are removed by default
	// if strFind is omitted.
	*/
	if (strInput != null && strInput != "")
		{
		if (strFind == null || strFind == "")
			{
			strFind = " "
			}
		strInput = Replace(strInput, strFind + "+$", "")
		}
	return strInput
	}

function LTrim(strInput, strFind)
	{
	/* LTrim:
	// This function uses Replace to remove strFind from the 
	// Left side of strInput.  Spaces are removed by default
	// if strFind is omitted.
	*/
	if (strInput != null && strInput != "")
		{
		if (strFind == null || strFind == "")
			{
			strFind = " "
			}
		strInput = Replace(strInput, "^" + strFind + "+", "")
		}
	return strInput
	}


function Replace(strInput, reFind, strRepl, strMod){
	/* Replace:
	// This function will replace reFind with strRepl in the strInput string.  Use
	// the strMod to add regular expression modifiers.
	// strInput:	String to be searched.
	// reFind:		Regular Expression string to find and be replaced. Regular Expression
	//				values are valid here but must contain double back-slashes.
	//				(i.e. "the" or "\\bthe\\b" or "\\bthe\\Scat\\b"
	// strRepl:		String to be used in place of reFind string.
	// strMod:		Regular Expression modifier. 
	//				(i.e. "g" global, "i" ignore case or "gi" both)
	*/
	var newString
	// Must have a find string
	if (reFind == "" || reFind == null)
		{
		return null;}
		
	if (strMod == null)
		{strMod = ""}

	// use empty string for default replacement string
	if ( strRepl == null)
		{strRepl = ""}

	// Instanciate RegExp object and compile expression
	var objRegExp = new RegExp();

	objRegExp.compile(reFind, strMod)
	
	if(strInput != "" && strInput != null)
		{strInput = strInput.replace(objRegExp, strRepl)}
	return strInput
	}


function ValidateForm(objForm){
    var bEmail;

    
	if(Trim(objForm.first_name.value) == ""){
		alert("Please enter first name.");
		objForm.first_name.focus();
		return false;
	}	
	objForm.first_name.value=stripHTML(objForm.first_name.value) 
  
	if(Trim(objForm.last_name.value) == ""){
		alert("Please enter last name.");
		objForm.last_name.focus();
		return false;
	}
	objForm.last_name.value=stripHTML(objForm.last_name.value)
	objForm.job_title.value=stripHTML(objForm.job_title.value)
	
	if(Trim(objForm.company.value) == ""){
		alert("Please enter company name.");
		objForm.company.focus();
		return false;
	}
	objForm.company.value=stripHTML(objForm.company.value)
	
	if(Trim(objForm.email.value) == ""){
	    alert("Please enter email.");
		objForm.email.focus();
		return false;
	}	
	
	
	var str = objForm.email.value
	
	
	if((str.indexOf(".") == -1) || (str.indexOf("@") == -1)){
	    alert("Please enter a valid email address");
	    objForm.email.focus();
	    return false;
	}
	
//	if(str.indexOf("@") == -1){
//	
//        alert("Please enter a valid email address");
//        objForm.email.focus();
//	    return false;	   
//	}	
	

	
//	var filter = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//    if(filter.test(objForm.email.value) == false) {   
//    alert('Please provide a valid email address');    
//    //return false;    
//    }
		
	
//	var bTest 
//	
//	bTest = checkemail1(objForm.email.value);
//	
//		
//	if(bTest == false){
//	    objForm.email.focus();
//	    return true;
//	    } 
//	    
//	}
	
//	if(checkemail2(objForm.email.value) == false){
//	    objForm.email.focus();
//	    return false; 
//	}	   
//	
	objForm.email.value=stripHTML(objForm.email.value)
	
	if(Trim(objForm.phone.value) == ""){
		alert("Please enter phone number.");
		objForm.phone.focus();
		return false;
	}
	objForm.phone.value=stripHTML(objForm.phone.value)
	objForm.comments.value=stripHTML(objForm.comments.value)
	
   
	
}

function stripHTML(oldString){
  
        var s=oldString ;
        while(s.indexOf('<')!=-1)s=s.replace('<','');
        while(s.indexOf('>')!=-1)s=s.replace('>','');
        return s;        
}

function checkEmail(email) {     
    var filter = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(filter.test(email) == false) {   
    alert('Please provide a valid email address');    
    return false;
    }else{
    return true;
    }
}

var testresults

function checkemail1(email){
    
    var filter=/^.+@.+\..{2,3}$/;

    if (filter.test(email))
        testresults=true;
    else {
    alert("Please input a valid email address!");
    testresults=false;
    }    
    return (testresults)
}


function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}

function checkemail2(src) {
     var emailReg = "^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.checkemail2(src);
  }


document.frmContact.first_name.focus();
//-->

