function check_if_to_start(word) {
	word=unescape(word);
	if (word==document.getElementById('topsearch').searchsubject.value && word.length>2) {
		if (word!='') {
			show_tip_results('<div align="center" style="padding:3px">טוען תוצאות...</div>');
			if (document.getElementById('topsearch').searchwhat.value=='yeshuv') {
				$.post('get_yishuvim.php',{'word':word},function(results) {
					show_tip_results(results);
				});
			} else {
				$.post('get_asakim.php',{'word':word},function(results) {
					show_tip_results(results);
				});
			}
		} else {
			$("#tip_container").css('display','none');
		}
	}
}
function show_tip_results(results) {
	if (results!='') {
		$("#tip_container").css('display','block');
		$("#tip_box").html('<div align="center" style="background:#BBBBBB; padding:3px;"><input type="button" value="סגור חלון זה X" onclick="show_tip_results(\'\')" /></div>'+results);
	} else {
		$("#tip_container").css('display','none');
	}
}
function search_click(word) {
	setTimeout("check_if_to_start('"+escape(word)+"')",700);
}
function changestate(changewhat) {
	$("#tip_container").css('display','none');
	if (changewhat=='esek') {
		document.getElementById('esek').src="images/checkedradio.jpg";
		document.getElementById('yeshuv').src="images/tip4trip_06.jpg";
		document.getElementById('topsearch').searchwhat.value='esek';
	}
	if (changewhat=='yeshuv') {
		document.getElementById('yeshuv').src="images/checkedradio.jpg";
		document.getElementById('esek').src="images/tip4trip_06.jpg";
		document.getElementById('topsearch').searchwhat.value='yeshuv';
	}
}
// bind searchbox to enter key
$(document).ready(function()
{
	$('#searchbox').bind('keypress', function(e) {
			if(e.keyCode==13){
				document.getElementById('topsearch').submit();
			}
	});
});
