function  validateForm() 
{
	var frm = document.Form1;
	var errText = "";
				
	if (!validateNotEmpty(frm.txtFirst.value))
		errText += "	First Name is missing.\n";					
	if (!validateNotEmpty(frm.txtLast.value))
		errText += "	Last Name is missing.\n";
	if (!validateNotEmpty(frm.txtComments.value))
		errText += "	Comments are missing.\n";	
	if (validateNotEmpty(frm.txtEmail.value) & !validateEmail(frm.txtEmail.value))
		errText += "	Email Address is invalid.\n";	
								
	if (errText.length > 0) 
	{
       	alert("Your information could not be submitted because of the following:\n\n" 
        + errText + "\nPlease correct and resubmit.");
       	return false;
    }
    return true;
}

function validateEmail( strValue) 
{
	var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,4}(\.[a-z]{2}){0,2})$/i;
  	return objRegExp.test(strValue);
}
  		   				
function validateNotEmpty( strValue ) 
{
   	var strTemp = strValue;
   	strTemp = trimAll(strTemp);
   	if(strTemp.length > 0){
     	return true;
   	}  
   	return false;
}

function trimAll( strValue ) 
{

 var objRegExp = /^(\s*)$/;

    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
    
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function  validateNumeric( strValue ) {
  	var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 
 
  	return objRegExp.test(strValue);
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
