/**
 *  搜索
 */
function zf_search() {	
    if (document.form2.oldxxh && document.form2.oldxxh.value == "房源信息号搜索") {
        document.form2.oldxxh.value = "";
    }
    if (document.form2.oldxxh.value.length == 12) {
       var zftype = document.form2.oldxxh.value.substr(3, 1);
       if (zftype == "6") {
           document.form2.different.value = 1;
       } else if (zftype == "7") {
           document.form2.different.value = 2;
       } else if (zftype == "8") {
           document.form2.different.value = 0;
       }
       showMenuInformation_zf();
    }
    document.form2.target="_blank";
	if (document.form2.different.value == 0){  //求租
	    document.form2.opt.value = "searchQZ";
	    document.form2.action = "/zf/qz_list.jsp?service=ls";
    } else if (document.form2.different.value == 2){  //合租
        document.form2.opt.value = "searchHZ";
        document.form2.action = "/zf/hz_list.jsp?service=ls";
    }else {                                   //出售  
    	document.form2.opt.value = "searchCZ";
    	document.form2.action = "/zf/cz_list.jsp?service=ls";
    }
    if (document.form2.xqinfo && document.form2.xqinfo.value == "小区地址或名称") {
        document.form2.xqinfo.value = "";
    }    
	document.form2.submit();
}

/**
 *  城区快捷搜索
 */
function czf_search(id){
    clearForm();
	searchCityzone(id);
}

/**
 *  价格快捷搜索
 */
function pzf_search(minprice, maxprice) {
    clearForm();
    searchPrice(minprice, maxprice);
}

function cly_search(diff, source, id) {
    clearForm();	
    document.form2.different.value = diff;
    document.form2.sourceid.value = source;
    searchCityzone(id);
}

function cp_search(minprice, maxprice) {
    clearForm();
    document.form2.different.value = 1;
    //document.form2.sourceid.value = 2;
    searchPrice(minprice, maxprice);
}

function bl_search(room, hall) {
    clearForm();
    document.form2.different.value = 1;
    document.form2.room.value = room;
    document.form2.hall.value = hall;
    document.form2.target = "_blank";
    document.form2.opt.value = "searchCZ";
    document.form2.action = "/zf/cz_list.jsp?service=ls";
    document.form2.submit();
}

function shortzf_search(lease) {
    clearForm();
    document.form2.different.value = 1;
    document.form2.lease.value = lease;
    document.form2.target = "_blank";
    document.form2.opt.value = "searchCZ";
    document.form2.action = "/zf/cz_list.jsp?service=ls";
    document.form2.submit();
}

function shortqz_search(lease) {
    clearForm();
    document.form2.different.value = 0;
    document.form2.lease.value = lease;
    document.form2.target = "_blank";
    document.form2.opt.value = "searchQZ";
    document.form2.action = "/zf/qz_list.jsp?service=ls";
    document.form2.submit();
}

function searchCityzone(id) {
    if (id == -1){
		document.form2.cityzone.value = id;
	}else{
		document.form2.cityzoneid.value = id;
	}
	document.form2.target="_blank";
	if (document.form2.different.value == 0){  //求租
	    document.form2.opt.value = "searchQZ";
	    document.form2.action = "/zf/qz_list.jsp?service=ls";
    } else if (document.form2.different.value == 2){//合租
        document.form2.opt.value = "searchHZ";
        document.form2.action = "/zf/hz_list.jsp?service=ls";
    } else {                                     //出租 
    	document.form2.opt.value = "searchCZ";
    	document.form2.action = "/zf/cz_list.jsp?service=ls";
    }
    if (document.form2.xqinfo && document.form2.xqinfo.value == "小区地址或名称") {
        document.form2.xqinfo.value = "";
    }
    document.form2.submit();
}

function searchPrice(minprice, maxprice) {
    document.form2.minprice.value = minprice;
    document.form2.maxprice.value = maxprice;
    document.form2.target = "_blank";
	if (document.form2.different.value == 0){  //求租
	    document.form2.opt.value = "searchQZ";
	    document.form2.action = "/zf/qz_list.jsp?service=ls";
    }else if (document.form2.different.value == 2){  //合租
	    document.form2.opt.value = "searchHZ";
	    document.form2.action = "/zf/hz_list.jsp?service=ls";
    }else{                                     //出租  
    	document.form2.opt.value = "searchCZ";
    	document.form2.action = "/zf/cz_list.jsp?service=ls";
    }
    if (document.form2.xqinfo && document.form2.xqinfo.value == "小区地址或名称") {
        document.form2.xqinfo.value = "";
    }
	document.form2.submit();
}

/**
*  户型快捷搜索
**/
function room_search(id) {
    clearForm();
    document.form2.room.value = id;
    document.form2.target="_blank";
	if (document.form2.different.value == 0){  //求租
	    document.form2.opt.value = "searchQZ";
	    document.form2.action = "/zf/qz_list.jsp?service=ls";
    }else if (document.form2.different.value == 2){  //合租
	    document.form2.opt.value = "searchHZ";
	    document.form2.action = "/zf/hz_list.jsp?service=ls";
    }else{                                     //出租  
    	document.form2.opt.value = "searchCZ";
    	document.form2.action = "/zf/cz_list.jsp?service=ls";
    }
    if (document.form2.xqinfo && document.form2.xqinfo.value == "小区地址或名称") {
        document.form2.xqinfo.value = "";
    }
	document.form2.submit();
}

function CheckIsNumeric(obj,msg) {
	var reg=/^\d+(\.\d+)?$/
	if(obj.value!=""){
	 if(!reg.exec(obj.value)) {
		alert(msg);
		obj.focus();
		return false;
	 }
   }
   return true;
}

/**
 *
 */
function defaultKey(obj) {
    if (obj.value == "小区地址或名称" || obj.value == "房源信息号搜索") {
        obj.value = "";
    }
    obj.select(); 
}

function showMenuInformation_zf() {  
	var oBox1 = document.getElementById("showcityzone1");
	var oBox2 = document.getElementById("showcityzone2");
	var oBox3 = document.getElementById("showcityzone3");
	var oBox4 = document.getElementById("showhztype");
	var oBox5 = document.getElementById("showtype");
	var oBox6 = document.getElementById("showsource");
	if (document.form2.different.value == 0) {
		oBox1.style.display = 'none';
		oBox2.style.display = 'none';
		oBox3.style.display = 'none';
		oBox4.style.display = 'none';
		oBox5.style.display = '';
		oBox6.style.display = '';
	}else if (document.form2.different.value == 2){
		oBox1.style.display = '';
		oBox2.style.display = '';
		oBox3.style.display = '';
		oBox4.style.display = '';
		oBox5.style.display = 'none';
		oBox6.style.display = 'none';
	}  else {
		oBox1.style.display = '';
		oBox2.style.display = '';
		oBox3.style.display = '';
		oBox4.style.display = 'none';
		oBox5.style.display = '';
		oBox6.style.display = '';
	} 
}

/**
* 搜索类别选择
**/
function showSearch_zf() {
	var oBox3 = document.getElementById("showcityzone3");
	var oBox4 = document.getElementById("showhztype");
	var oBox5 = document.getElementById("showtype");
	var oBox6 = document.getElementById("showsource");
	if (document.form2.different.value == 0) {
		oBox3.style.display = 'none';
		oBox4.style.display = 'none';
		oBox5.style.display = '';
		oBox6.style.display = '';
		document.getElementById("showCZAdvancedLabel").style.display='none';
		document.getElementById("showHZAdvancedLabel").style.display='none';
	}else if (document.form2.different.value == 2){
		oBox3.style.display = '';
		oBox4.style.display = '';
		oBox5.style.display = 'none';
		oBox6.style.display = 'none';
		document.getElementById("showCZAdvancedLabel").style.display='none';
		document.getElementById("showHZAdvancedLabel").style.display='';
	}  else {
		oBox3.style.display = '';
		oBox4.style.display = 'none';
		oBox5.style.display = '';
		oBox6.style.display = '';
		document.getElementById("showCZAdvancedLabel").style.display='';
		document.getElementById("showHZAdvancedLabel").style.display='none';
	} 
}

/**
 * 清空表单数据
 */
function clearForm() {
    document.getElementById("cityzoneid").value = "0";
    document.getElementById("minprice").value = "";
    document.getElementById("maxprice").value = "";
    document.getElementById("minarea").value = "";
    document.getElementById("maxarea").value = "";
    document.getElementById("xqinfo").value = "";

    if (document.getElementById("room")) {
        document.getElementById("room").value = "";
    }
    if (document.getElementById("hall")) {
        document.getElementById("hall").value = "";
    }
    if (document.getElementById("toilet")) {
        document.getElementById("toilet").value = "";
    }
    if (document.getElementById("typeid")) {
        document.getElementById("typeid").value = "-1";
    }
    if (document.getElementById("sourceid")) {
        document.getElementById("sourceid").value = "-1";
    }
    if (document.getElementById("availday")) {
        document.getElementById("availday").value = "-1";
    }    
}