function removeValid(oBj){
$(oBj).css("border","1px solid #c3c3c3").css("width","164px") ; 
//if($(oBj).attr("id")== "strCAPTCHA"){$(oBj).css("width","164px") ; $("#codeError").fadeOut("fast");}
}
function rnd(){return (Math.random()*parseInt(666)).toFixed(9);}
var url="/scripts/aspcaptcha.asp?";
function getNewCode(){
$("#capImage").attr("src",url+rnd());	
$("#strCAPTCHA").val();
}
function checkForm(){
	
	
	var name=$("#name").val();
	var email=$("#email").val();
	var tphone=$("#tphone").val();
	var message=$("#message").val();
	var cname=$("#cname").val();
	var address=$("#address").val();
	var zip=$("#zip").val();
	var city=$("#city").val();
	var coutry=$("#coutry").val();
	var strCAPTCHA=$("#strCAPTCHA").val();
	var sf=true;
	if (!name){
	 $("#name").css("border-right","10px solid #b22125").css("border-bottom","1px solid #b22125").css("width","154px") ; 
	 sf=false;
	}
	/*if (!strCAPTCHA){
	 $("#strCAPTCHA").css("border-right","10px solid #b22125").css("border-bottom","1px solid #b22125").css("width","154px") ; 
	 sf=false;
	}*/
	if (!tphone){
	 $("#tphone").css("border-right","10px solid #b22125").css("border-bottom","1px solid #b22125").css("width","154px") ; 
	 sf=false; 	
	}
	if (!email||!echeck(email)){
	 $("#email").css("border-right","10px solid #b22125").css("border-bottom","1px solid #b22125").css("width","154px") ; 
	 sf=false;	
	}
    if(sf){
		//$.post( '/scripts/checkCap.asp', {CAPTCHA:strCAPTCHA},function(data, textStatus){
      //  if(data=="true"){
			 $('#contactForm').ajaxForm();
			$('#contactForm').submit();
		    clearForm();
			tb_show('', '/thanksYouMessage.asp?TB_iframe=true&height=150&width=320&modal=true', '') 
		// }else{
		//	 $("#strCAPTCHA").val();
		//	$("#codeError").fadeIn("fast");
		//	 $("#strCAPTCHA").css("border-right","10px solid #b22125").css("border-bottom","1px solid #b22125").css("width","128px") ;
		//	$("#capImage").attr("src",url+rnd());	 
		// }
		//} 
		//) 
	 }
}
function checkMail(){
if($("#email").val()){
if (!echeck($("#email").val())){
	  $("#email").css("border-right","10px solid #b22125").css("border-bottom","1px solid #b22125").css("width","154px") ; 
	  $("#mailError").html(' <b>email is not valid</b>');
}	else{
	   $("#mailError").html('');
}
}
}
function clearForm(){
	$("input,textarea").val('')  ; 
	$('input[@type=checkbox]').attr('checked', ''); 
	 $("#codeError").fadeOut("fast");
	$("#capImage").attr("src",url+rnd());
	$("#mailError").html('');
}
  
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   	   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		      return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   	    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		   	    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		        return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		  	    return false
		 }
		 if (str.indexOf(" ")!=-1){
		       return false
		 }
 		 return true					
	}