// JavaScript Document
(function($) {
	window.searchHouse = function(){
		var vrl = '/'+$("#searchClass").val()+'/';
		vrl += $("#searchRegion").val() + '_';
		vrl += $("#searchType").val() + '_';
		vrl += $("#searchRoom").val() + '_0_0_';
		var price;
		if($("#searchClass").val()=="esf"){
			price = $("#searchPriceEsf").val().split(':');
		}else{
			price = $("#searchPriceRent").val().split(':');
		}
		vrl += price[0]+'_'+price[1]+'_';
		var area = $("#searchArea").val().split(':');
		vrl += area[0]+'_'+area[1]+'_';
		vrl += '0/list_1.html';
		var key = $("#searchKey").val();
		if(key == '请输入地址，小区名称')key = '';
		if(key!='')vrl += '?key='+escape(key);
		location.assign(vrl);
	}
    $(document).ready(function() {
		if($("#searchClass").val()=="esf"){
			$("#searchPriceEsf").show();
		}else{
			$("#searchPriceRent").show();
		}
		
        $("ul.tab").each(function(i) {
            $(this).css("margin-top", $(this).parent().height() - $(this).height());
            $(this).find("li").eq(0).addClass("now");
            $("#" + $(this).attr("relid")).children("div").eq(0).addClass("now");
			
            $(this).find("li").bind("mouseover", function() {
                $(this).parent().children("li").removeClass("now");
                $(this).addClass("now");
                $("#" + $(this).parent().attr("relid")).children("div").hide().eq($(this).index()).fadeTo('fast', 1);
            });
        });
		
		$("#searchButton").bind("click",function(){
			searchHouse();
			return false;
		});
		
		$("#searchKey").bind("focus", function(){
			if($(this).val()=="请输入地址，小区名称"){
				$(this).val('');
			}
		});
		
		$("#searchKey").bind("blur", function(){
			if($(this).val()==""){
				$(this).val('请输入地址，小区名称');
			}
		});
		
		$("#searchClass").bind("change",function(){
			if($(this).val()=="esf"){
				$("#searchPriceEsf").show();
				$("#searchPriceRent").hide();
			}else{
				$("#searchPriceEsf").hide();
				$("#searchPriceRent").show();
			}
		});
    });
})(jQuery);
