
/* CHECKS Email for correct formatting */

function validateEmail(strValue) {
/************************************************
DESCRIPTION: Validates that a string contains a 
  valid email pattern. 
  
 PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
   
REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) or valid country suffix.
*************************************************/
var objRegExp  = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
//old - /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i; 
  //check for valid email
  return objRegExp.test(strValue);
}


function formCheck() 
 {

		if (validateNotEmpty(document.quoterequest.Project.value) == validateNotEmpty(""))
        	{
        		alert("Please enter the Project Name/Identification.");
        		document.quoterequest.Project.focus();
        		document.quoterequest.Project.select();
        		return false;		
        	}
	
		if (validateNotEmpty(document.quoterequest.Name.value) == validateNotEmpty(""))
        	{
        		alert("Please enter your name.");
        		document.quoterequest.Name.focus();
        		document.quoterequest.Name.select();
        		return false;		
        	}	
        
		if (validateNotEmpty(document.quoterequest.Company.value) == validateNotEmpty(""))
        	{
        		alert("Please enter your company name.");
        		document.quoterequest.Company.focus();
        		document.quoterequest.Company.select();
        		return false;		
        	}		
			
		if (validateNotEmpty(document.quoterequest.DaytimePhone.value) == validateNotEmpty(""))
        	{
        		alert("Please enter your daytime phone number.");
        		document.quoterequest.DaytimePhone.focus();
        		document.quoterequest.DaytimePhone.select();
        		return false;		
        	}	
			
		
			
		if (validateEmail(document.quoterequest.EmailAddress.value) == false)
			{
        		alert("The format of your email address does not apear to be valid.  Please correct this and try again.");
        		document.quoterequest.EmailAddress.focus();
        		document.quoterequest.EmailAddress.select();
        		return false;					
			}								
			
			
		if (validateEmail(document.quoterequest.Rep_Email_Address.value) == false)
			{
        		alert("The format of the email address you would like to copy does not apear to be valid.  Please correct this and try again.");
        		document.quoterequest.Rep_Email_Address.focus();
        		document.quoterequest.Rep_Email_Address.select();
        		return false;					
			}		
 }
		


	
function validateNotEmpty( strValue ) {
/************************************************
DESCRIPTION: Validates that a string is not all
  blank (whitespace) characters.
    
PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
*************************************************/
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return true;
   }  
   return false;
}
function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/ 
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
    
   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}	



