
function trimAll( strValue ) {

	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;
}

function validateEmail(strValue)
{
	var tmpValue;
	tmpValue = trimAll(strValue);
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(tmpValue))
	{
		return true;
	}
	return false;
}
		
function validateNotEmpty( strValue ) {

	var strTemp = strValue;
	strTemp = trimAll(strTemp);
	if(strTemp.length > 0){
	 return true;
	}  
	return false;
}
		
		function validateForm()
		{
			var msg='';
			if (!validateNotEmpty(document.contactFrm.name.value))
			{
				msg = msg + "\n Enter Name";
			}
			
			if (!validateEmail(document.contactFrm.email.value))
			{
				msg = msg + "\n Enter valid Email";
			}
			
			if (!validateNotEmpty(document.contactFrm.phone.value))
			{
				msg = msg + "\n Enter Phone Number";
			}
			
			if (!validateNotEmpty(document.contactFrm.subject.value))
			{
				msg = msg + "\n Enter Subject";
			}
			
			if (!validateNotEmpty(document.contactFrm.qc.value))
			{
				msg = msg + "\n Enter Question/Comment";
			}
			
			
			if (msg != "")
			{
				alert(msg);
				return false;
			}
			return true;
		}
