function ltrim (s) {
	return s.replace(/^\s*/, "")
}

function rtrim (s) {
	return s.replace(/\s*$/, "");
}

/* trim spaces */
function trim (s) {
	return rtrim(ltrim(s));
}
	function validate()
	{
		if (trim(document.forms[0].company.value) == "")
		{
			alert('Company name cannot be empty');
			document.forms[0].company.focus();
			return false;
		}
		if (trim(document.forms[0].company.value) == "#")
		{
			alert('Please enter a valid name');
			document.forms[0].company.focus();
			return false;
		}
		if (trim(document.forms[0].contact_person.value) == "")
		{
			alert('Contact Person cannot be empty');
			document.forms[0].contact_person.focus();
			return false;
		}
		if (trim(document.forms[0].contact_person.value) == "#")
		{
			alert('Please enter a valid name');
			document.forms[0].contact_person.focus();
			return false;
		}
		/*if ((trim(document.forms[0].reqPhone.value).length==0) || ((document.forms[0].reqPhone.value.length) > 15))
		{
			alert('Pin Code cannot be empty and cannot be greater than 15 digits');
			document.forms[0].reqPhone.focus();
			return false;
		}
		if(isNaN((document.forms[0].reqPhone.value)))
		{
		  alert('Phone No. must be digits');
		  document.forms[0].reqPhone.focus();
		  return false;
		 }*/
		if ((trim(document.forms[0].mobile.value).length==0) || ((document.forms[0].mobile.value.length) > 10))
		{
			alert('Mobile No. cannot be empty and cannot be greater than 10 digits');
			document.forms[0].mobile.focus();
			return false;
		}
		if(isNaN((document.forms[0].mobile.value)))
		{
		  alert('Mobile No. must be digits');
		  document.forms[0].mobile.focus();
		  return false;
		 }
		if (trim(document.forms[0].email.value)=="")
		{
			alert('E-Mail cannot be empty');
			document.forms[0].email.focus();
			return false;
		}
		if (trim(document.forms[0].req.value) == "")
		{
			alert('Message cannot be empty');
			document.forms[0].req.focus();
			return false;
		}
		return true;
	}
	
function sendEnq(){
		if(validate()==true){
			
			document.forms[0].method = 'post';
			document.forms[0].action = 'enquiry_ack.jsp';
			document.forms[0].submit();
		}
}