// JavaScript Document
function make_autocom(autoObj,showObj,fullPathWeb){
	var mkAutoObj=autoObj; // ชื่อของ input ที่ต้องการให้เป็น autocomplete
	var mkSerValObj=showObj; // id ของ input ที่รับค่าจาก การเลือก autocomplete
	new Autocomplete(mkAutoObj, function() {
		this.setValue = function(id) {		
			document.getElementById(mkSerValObj).value = id;
		}
		if ( this.isModified )
			this.setValue("");
		if ( this.value.length < 1 && this.isNotClick ) 
			return ;
		return fullPathWeb+"www.atthailandhotel.com/th/ajax/ajax-get-hotelID.php?q=" + this.value;
    });	
}	
make_autocom("q","h_KeywordHotelID",fullPathWeb);
 function goSearchNow(){
	$("form#hotel_search_form").submit(); 
 }
$(function(){
	var objKey="#q";
	if($(objKey).val()==""){
			$(objKey).css("background","#FFFFFF url("+fullPathWeb+"www.google.com/cse/intl/en/images/google_site_search_watermark.gif) 4px 2px  no-repeat");
	}	
	$(objKey).focus(function(){	 
		$(objKey).css("background-image","none");					 
	}).blur(function(){
		if($(objKey).val()==""){
			$(objKey).css("background","#FFFFFF url("+fullPathWeb+"www.google.com/cse/intl/en/images/google_site_search_watermark.gif) 4px 2px  no-repeat");
		}	
	});		  
	
 $("input#q").keyup(function(event){
// 	console.log(event.keyCode);
	if(event.keyCode==13){
		$("form#hotel_search_form").submit();
	}
 });
  
$("a#menuHotelz").hover(function(){
	var ix=$(this).offset().left;							 
	$("ul#hotel_dropdown").css("margin-left",ix).show();							 
},function(){
	var inowShow=$("ul#hotel_dropdown").css("display");
	if(inowShow=='block'){
		$("ul#hotel_dropdown").hide();
	}
	$("ul#hotel_dropdown").hover(function(){
		$(this).show();								  
	},function(){
		$(this).hide();
	});
});
	
});

 