	function isnull(str)	
	{
		str = rtrim(ltrim(str))
		if ( (str.length = 0) || ( str == ""))
			return true;
		else			
			return false;
	}

	function ltrim(field_name)
	{
		pos = field_name.indexOf(" ")
		while (pos == 0) 
		{ 
			field_name = field_name.substring(1)
			pos = field_name.indexOf(" ")
		}
		return field_name
	}

	function  rtrim(field_name)
	{
	    len = field_name.length
	    blank = field_name.charAt(len-1)
	    while (blank == " " )
	    {
	      field_name = field_name.substring(0,len-1)
	      len=field_name.length
	      blank = field_name.charAt(len-1)
	    }
	    return field_name    
	}

	function IsValidEmailSyntax ( sEmail )
	{	 
		return ( sEmail.search( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/ ) != -1); 
	}
	
	function validation(theForm)
	{
		if ( isnull(theForm.company.value))	
		{
			alert ('Enter Company Name');
			theForm.company.focus();
			return false;
		}
		if ( isnull(theForm.firstname.value))	
		{
			alert ('Enter First Name');
			theForm.firstname.focus();
			return false;
		}
		if ( isnull(theForm.email.value))	
		{
			alert ('Enter a vaild Email address');
			theForm.email.focus();
			return false;
		}		
		if ( isnull(theForm.email.value))	
		{
			alert ('Enter a vaild Email address');
			theForm.email.focus();
			return false;
		}
		if (IsValidEmailSyntax(theForm.email.value)== false)
		{
			alert ('Enter a vaild Email address');
			theForm.email.focus();
			return false;
		}				
		if ( isnull(theForm.proposal.value))	
		{
			alert ('Please enter when do you need a proposal by?');
			theForm.proposal.focus();
			return false;
		}
		if ( theForm.services.value == "Select below")
		{
			alert ('Select atleast one service');
			theForm.services.focus();
			return false;
		}
		if ( isnull(theForm.project.value))	
		{
			alert ('Enter project details');
			theForm.project.focus();
			return false;
		}
		theForm.hidMail.value = "Y";
		return true;
	}