function isFloat(value){

   if(isNaN(value) || value.indexOf(".")<0){
     return false;
   } else {
      if(parseFloat(value)) {
              return true;
          } else {
              return false;
          }
   }
}

/****************************************Trim function *************************************/
function Trim(str) {
  return rTrim( lTrim( str ) );
}
function lTrim( str ) {
  while (str.charAt(0) == " ") {
      str = str.substring(1);
  }
 return str;
}
function rTrim( str ) {
   while (str.charAt(str.length - 1) == " ") {
      str = str.substring(0, str.length - 1);
  }
 return str;
}


function submittingValues(obj){

	if(Trim(obj.problem.value)==''){
		obj.problem.focus();
		alert('Please enter your problem');
		return false;
	}else if(Trim(obj.contact.value)==''){
		obj.contact.focus();
		alert('Please enter your contact details');
		return false;
	}else if(Trim(obj.timelocal.value)==''){
		obj.timelocal.focus();
		alert('Please enter your time to call');
		return false;
	}else{		
		return true;	
	}
	return false;
}


/****************************************Email Validation function *************************************/
function validateEmail( emailString ){  
		str = emailString;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if ((str.search(/\$/)!=-1)||(str.search(/\*/)!=-1)||(str.search(/\^/)!=-1)||(str.search(/\#/)!=-1)||(str.search(/\!/)!=-1)||(str.search(/\%/)!=-1)||(str.search(/\&/)!=-1)||(str.search(/\?/)!=-1)||(str.search(/\+/)!=-1)||(str.search(/\=/)!=-1)||(str.search(/\|/)!=-1)||(str.search(/\-/)!=-1)||(str.search(/\}/)!=-1)||(str.search(/\]/)!=-1)||(str.search(/\[/)!=-1)||(str.search(/\}/)!=-1)||(str.search(/\~/)!=-1)||(str.search(/\\/)!=-1)||(str.search(/\//)!=-1)||(str.search(/\)/)!=-1)||(str.search(/\(/)!=-1))

		{
			$("span#email").hide("slow");
			$("span#email1").show("slow");
			setTimeout("close_msg('span#email1')",3000);
			//alert("Only @, _ and . special characters allowed");        

			return false

		}

		

		if (str[lstr-1]=="."){

		   //alert("Invalid E-mail ID")
		   $("span#email").hide("slow");
		   $("span#email1").hide("slow");
		   $("span#email2").show("slow");
		   setTimeout("close_msg('span#email2')",3000);

		   return false

		}



		if (str.indexOf(at)==-1){

		  // alert("Invalid E-mail ID")
		    $("span#email").hide("slow");
		    $("span#email1").hide("slow");
			$("span#email2").show("slow");
			setTimeout("close_msg('span#email2')",3000);
			
		   return false

		}



		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		  // alert("Invalid E-mail ID")
		    $("span#email").hide("slow");
		    $("span#email1").hide("slow");
			$("span#email2").show("slow");
			setTimeout("close_msg('span#email2')",3000);
		   return false

		}



		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		   // alert("Invalid E-mail ID")
		     $("span#email").hide("slow");
		   $("span#email1").hide("slow");
	
  $("span#email2").show("slow");
  setTimeout("close_msg('span#email2')",3000);
		    return false

		}



		 if (str.indexOf(at,(lat+1))!=-1){

		   // alert("Invalid E-mail ID")
		     $("span#email").hide("slow");
		   $("span#email1").hide("slow");
		
  $("span#email2").show("slow");
  setTimeout("close_msg('span#email2')",3000);
		    return false

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		   // alert("Invalid E-mail ID")
		     $("span#email").hide("slow");
		   $("span#email1").hide("slow");
		
		  $("span#email2").show("slow");
		  setTimeout("close_msg('span#email2')",3000);
		    return false

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

		 //   alert("Invalid E-mail ID")
		   $("span#email").hide("slow");
		   $("span#email1").hide("slow");
		
	  $("span#email2").show("slow");
	  setTimeout("close_msg('span#email2')",3000);
		    return false

		 }

		

		 if (str.indexOf(" ")!=-1){

		  //  alert("Invalid E-mail ID")
		   $("span#email").hide("slow");
		   $("span#email1").hide("slow");
		  
		   $("span#email2").show("slow");
		   setTimeout("close_msg('span#email2')",3000);

		    return false

		 }



 		 return true;

}




function user_validation(obj){
   
	if(Trim(obj.name.value)==''){
	  alert("Please enter your name");
	  obj.name.focus();
	  return false;
	}else if(Trim(obj.company.value)==''){
	  alert("Please enter your company name");
	  obj.company.focus();
	  return false;
	}else if(Trim(obj.address.value)==''){
	  alert("Please enter your address");
	  obj.address.focus();
	  return false;
	}else if(Trim(obj.city.value)==''){
	  alert("Please enter your city");
	  obj.city.focus();
	  return false;
	}else if(obj.state.selectedIndex==0){
	  alert("Please select your state");
	  obj.state.focus();
	  return false;
	}else if(Trim(obj.zip.value)==''){
	  alert("Please enter your zip");
	  obj.zip.focus();
	  return false;
	}else if(Trim(obj.phone.value)==''){
	  alert("Please enter your phone");
	  obj.phone.focus();
	  return false;
	}else if(Trim(obj.email.value)==''){
	  alert("Please enter your email");
	  obj.email.focus();
	  return false;
	}else if(!validateEmail(obj.email.value)){
	  alert("Invalid Email");
	  obj.email.focus();
	  return false;
	}else{
		return true;
	}
	return false;
}


