$(document).ready(function() {
	$('#hotels').click(function() {
 	  $("#city_spec").attr("class","");
      if ($("#hotels_content").html()=="") {
   	   	   $("#hotel_spec").attr("class","c1");
		   var id = $(this).attr("name");
           $("#hotels_content").html("<img src='/i/ajax-loader.gif'>");
           $.post("/scripts/function/gmap_cat.php", {id: id}, function(returned_data) {
        	   $("#hotels_content").html(returned_data);
        	   $("#city_content").html("");
           });
     } else {
    	   $("#hotel_spec").attr("class","");
           $("#hotels_content").html("");
     }
     map.setCenter(map.getCenter(), map.getZoom());
    });
	
	$('#in_city').click(function() {
		$("#hotel_spec").attr("class","");
        if ($("#city_content").html()=="") {
     	   $("#city_spec").attr("class","c1");        	
		   var id = $(this).attr("name");
           $("#city_content").html("<img src='/i/ajax-loader.gif'>");
           $.post("/scripts/function/gmap_cat.php", {id: id}, function(returned_data) {
        	   $("#city_content").html(returned_data);
        	   $("#hotel_content").html("");
           });           
        } else {
           $("#city_spec").attr("class","");    	 
           $("#city_content").html("");
        }
        map.setCenter(map.getCenter(), map.getZoom());
    });	
	
    $("#help_voice_close").click(function() {
  		$("#help_tul").fadeOut(600);
  	});
  	
  	$("#help_voice").click(function() {
  		if ($("#help_tul").css("display")=="block") {
  			$("#help_tul").fadeOut(600);
  		} else {
  			$("#help_tul").slideDown(200);
  		}
  	});
	
  	$(".close_gmp").click(function() {
  		$("#gmp").hide(300);
  	});
  	
	$("#showsign").click(function() {
		if ($("#formsign").css("display")=="block") {
  			$("#formsign").hide();
  		} else {
			$("#formsign").html('<br><br><br><img src="/i/loader_3.gif">');
			$("#formsign").load("/scripts/function/signform_html.php");
  			$("#formsign").slideDown(100);
  		}
	});
	
	$("#sel_city").click(function() {
		if($("#display_sel").css("display")=="block") {
			$("#display_sel").hide();
			$("#fill_city_sell").html("");
			$("#fill_city_sell").hide();			
		} else {
			$("#new_city_sel").val("");
			$("#selected_custom_city").val("");
			$("#fill_city_sell").html("");
			$("#fill_city_sell").hide();			
			$("#display_sel").show();
			$("#new_city_sel").focus();
		}
	});
	
	$("#btn_city_sel").click(function() {
		var id=$("#selected_custom_city").val();
		$("#display_sel").hide();
		if(id!="") {
			$.post("/scripts/function/gmap_custom_sel.php", {id: id}, function(returned_data) {
				st=returned_data.split("|");
				$("#sel_city").html(st[0]);
				langitude=st[1];
				latitude = st[2];
				gpspoint = new GLatLng(langitude,latitude);
				map.setCenter(gpspoint, 12);
				map.setUIToDefault();
				$("#city_content").html("");
				$("#city_spec").attr("class","");
			});
		}
	});
	
	$("#new_city_sel").keyup(function() {
		var stri = $(this).val();		
		if(stri.length>2) {
			$.post("/scripts/function/gmap_city.php", {stri: stri}, function(returned_data) {
				if(returned_data!="") {
					$("#fill_city_sell").html(returned_data);
					$("#fill_city_sell").show();
				} else {
					$("#fill_city_sell").html("");
				}
			});
		} else {
			$("#fill_city_sell").hide();
		}
	});
	
	$("#btn_city_close").click(function() {
			$("#display_sel").hide();
	});
});