<script type="text/JavaScript">
function trimLeft(s)
		{
		i=0;
		n= s.length;
		  while((i<n)&&(s.charAt(i)==' ')) i++;
			s = s.substring(i);
		  return(s);
		} 

		function trimRight(s)
		{
		 n= s.length;
		 i= s.length-1;
		 while((i>=0)&&(s.charAt(i)==' ')) i--;
			s = s.substring(0,i+1);
		 return(s);
		}
function trimAll(s)
		{
		 s = trimLeft(s);
		 s = trimRight(s);
		 return(s);
		} 

	
function validateemail(emailid)
     {

	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(emailid.value.match(emailExp))
	{
	return true;
	}
	else
	{
	emailid.focus();
		return false;
	}

}
function phone(number)
{	var phExp = /^[+]\d{1,3}-\d{2,5}-\d{5,8}$/;
	if(number.value.match(phExp))
	{
	return true;
	}
	else
	{
number.focus();
		return false;
	}

}
function namevalidation(nameexp)
{

	var letters = /^[a-z.A-Z]+$/;
	if(nameexp.value.match(letters))
	{
	return true;
	}
	else
	{
nameexp.focus();
		return false;
	}

}
function validate_data()
{

       if(trimAll(document.contact_form.name.value)=='')
         {
            alert("Name field can not be empty");
            document.contact_form.name.focus();
            return false;
         }

else if(namevalidation(document.contact_form.name)==false)
         {
             alert("Enter Only alphabets for Name");
             document.contact_form.name.focus();
             return false;
         }
		  else if((document.contact_form.name.value.length)>25)
		{
		alert("Name should not Exceed more than 25 Characters");
        document.contact_form.name.focus();
            return false;
         }
		  else if(trimAll(document.contact_form.email.value)=='')
         {
            alert("Email field can not be empty");
            document.contact_form.email.focus();
            return false;
         }
        else if(validateemail(document.contact_form.email)==false)
         {
             alert("Enter valid Email Address");
             document.contact_form.email.focus();
             return false;
         }
		  else if(trimAll(document.contact_form.telephone.value)=='')
         {
            alert("Telephone field can not be empty");
            document.contact_form.telephone.focus();
            return false;
         }
		   else if(phone(document.contact_form.telephone)==false)
         {
		 alert("Enter +Countrycode-Areacode-Localnumber for landline \n +Countrycode-Mobilenumber(+countrycode-00000-00000) for mobilenumber");
            document.contact_form.telephone.focus();
            return false;
         }
         else if(trimAll(document.contact_form.company.value)=='')
         {
            alert("Enter the company name");
            document.contact_form.company.focus();
            return false;
         }
		 else if((document.contact_form.company.value.length)>50)
		{
		alert("Company Name should not Exceed more than 50 Characters");
        document.contact_form.company.focus();
            return false;
         }
         else if(trimAll(document.contact_form.message.value)=='')
         {
            alert("Please enter the Message");
			
            document.contact_form.message.focus();
            return false;
         }
		 else if(namevalidation(document.contact_form.message)==false)
         {
            alert("Enter Only alphabets for Message");
            document.contact_form.message.focus();
            return false;
         }
		else if((document.contact_form.message.value.length)>150)
		{
		alert("Message text should not Exceed more than 150 Characters");
document.contact_form.message.focus();
            return false;
}
		  else if(trimAll(document.contact_form.six_letters_code.value)=='')
         {
            alert("Enter the Code");
            document.contact_form.six_letters_code.focus();
            return false;
         }
		 return true;
}		 
</script>