						
$(function(){
			   $(".formbtn").click(function(){
								$("#contactform").submit();	
								return false;
													  });
						$("#contactform").submit(function(){

															if (validateForm()){
																				$("#contactform").hide();
																				$("#thanks").show();
								
																				return true;
   
															}else{
															return false;
															}
														 });
});
function IsEmail(email) {
		var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (regex.test(email)) return true;
		else return false;
	} 
function validateForm(){
	 if(lng==1){
		msg='Please fill the following fields:\n';		
		mailError=' -  Mail address is invalid';
		//msg2='יש למלות לפחות מספר טלפון אחד';
	 }else{
		 
		msg='Please fill the following fields:\n';		
		mailError=' -  Mail address is invalid';
		 
	 }
		 rt=true; 
		 ro=false;
		 $(".reqOr").each(function() {
		 
		  if ($(this).val()) {
			  ro=true;
			  msg2='';
			  $("#validfieldc").hide();
			  $("#validfieldf").hide();
		  }
		 
								   });
		 if(!ro){
			 
			  $("#validfieldc").show();
			  $("#validfieldf").show();
		 }
		$(".req").each(function() {
								
				  if (!$(this).val()||($(this).attr("name")=="email"&&!IsEmail($(this).val()) ) ){
					 rt=false; 
					fName=$(this).attr("title");
				 
					msg+=fName;
					 
					if ($(this).attr("name")=="email"&&!IsEmail($(this).val()) &&$(this).val() )  msg+=mailError;
					 
					msg+="\n";
				  }
		 })
	 
		if(!rt) alert(msg);
		return rt;
}

function clearForm(){
	
	
	$("input").attr("value","");
	
	}	
                            
