function $(str){
	return document.getElementById(str);
}

	//Email validation function
	
	function IsEmail(sText) {
		var at="@"
		var dot="."
		var lat=sText.indexOf(at)
		var lstr=sText.length
		var ldot=sText.indexOf(dot)
		if (sText=="" || sText==null){ return false }
		if (sText.indexOf(at)==-1 || sText.indexOf(at)==0 || sText.indexOf(at)==lstr){ return false }
		if (sText.indexOf(dot)==-1 || sText.indexOf(dot)==0 || sText.indexOf(dot)==lstr){ return false }
		if (sText.indexOf(at,(lat+1))!=-1){ return false }
		if (sText.substring(lat-1,lat)==dot || sText.substring(lat+1,lat+2)==dot){ return false }
		if (sText.indexOf(dot,(lat+2))==-1){ return false }
		if (sText.indexOf(" ")!=-1){ return false }
	 	return true
	}
	
response_sent = function(ajax_strresponse){
	if(ajax_strresponse=="ok"){
		alert("תודה שיצרת קשר איתנו. אנו עושים מאמצים להיענות לפנייתך בהקדם.");
		$('div_contact').style.display = 'none';
		$('frm_contact').style.display = 'none';
	}else{
		alert(ajax_strresponse);
	}
}
send_contact = function(){
	if($("txt_name").value==""){
		alert("נא הכנס שם");
		$("txt_name").focus();
		return false;
	}
	if($("txt_phone").value==""){
		alert("נא הכנס מספר טלפון");
		$("txt_phone").focus();
		return false;
	}
	if($("txt_email").value=="" || !IsEmail($("txt_email").value)){
		alert("נא הכנס כתובל אימייל חוקית");
		$("txt_email").focus();
		return false;
	}
	if($("txt_content").value==""){
		alert("נא הכנס את תוכן הפנייה");
		$("txt_content").focus();
		return false;
	}
	
	
	var poststr = "txt_name=" + encodeURI( $("txt_name").value );
	poststr += "&txt_phone=" + encodeURI( $("txt_phone").value );
	poststr += "&txt_email=" + encodeURI( $("txt_email").value );
	poststr += "&txt_ref=" + encodeURI( $("ref").value );
	poststr += "&txt_content=" + encodeURI( $("txt_content").value );
	
	doAjax("/_ajax/send_contact.post.ajax.php", response_sent, poststr, false);		
}