window.CheckAverpice = false;
window.LoginOut = 'http://nj.zsb.house365.com/sell/jump/login/';
//单击发布小区
function addlishi(id)
{
  if(id>0)
  {
    $.ajax({
         type: 'get',
         url : '/ajax/find_block_detail/',
         data: {'id' : id},
         dataType:'json',
         success: function(data){
			if(data.errorCode == '401')
			{
				jump_win(LoginOut , '请重新登录');
				return false;
			}
            $("#district").val(data.district);
            $("#street").val(data.streetname);
            $("#blockaddress").val(data.address);
            $("#block_id").val(data.id);
            $("#blockshowname").val(data.blockname);
            getBlockImg(1);
            if ($('#tbl').val() == 'sell') {
                showblockinfo (data.averprice , data.address ,data.esta_block, data.url_block);
            }
         }
     });
   }else{
	
   }
}

//添加临时模板
function tempblock_add () {	
	var query = $("#block_add").serialize();
	$.ajax({
		type: 'get',
		url : '/ajax/add_temp_block/',
		data: query,
		dataType:'json',
		success: function(data){
			if(data.errorCode == '401')
			{
				jump_win(LoginOut , '请重新登录');
				return false;
			}
			var msg = data.code;
			switch(msg){
				case '100':
					$("#xqerror").html("小区名称在2-8个汉字之间");
					$("#xqerror").show();
					break;
				case '300':
					$("#xqerror").html("已存在同名小区！");
					$("#xqerror").show();
					break;
				case '400':
					$("#xqerror").html("区属必须选择！");
					$("#xqerror").show();
					break;
				case '500':
					$("#xqerror").html("版块必须选择！");
					$("#xqerror").show();
					break;
				case '600':
					$("#xqerror").html("小区地址在2-30汉字之间！");
					$("#xqerror").show();
					break;
				case '700':
					$("#xqerror").html("小区地址已存在！");
					$("#xqerror").show();
					break;
				case '200':
					openWin('JS_noteHouse1'); 
					$("#jsLabelBlockshowname").hide();
					$("#blockshowname").val($("#jsNameInputOp").attr("value"));
					$("#block_id").val(data.id);
					$("#district").val($("#tcdistrict").attr("value"));
					$("#street").val($("#bankuai").attr("value"));
					$("#streetid").val($("#tcstreetid").attr("value"));
					$("#blockaddress").val($("#jsNameInputDz").attr("value"));
					break;
				default:
					alert("提交失败，请致电客服热线");
					break;
			}
		}
	});
}
	
function returnStrLen(sStr) {
	aMatch = sStr.match(/[\u4E00-\u9FA5|，]+/g);
	return (!aMatch ? 1 : 2);
}
	
//发布出租 租赁方式选择
$(".jsInput_rRadio").click(function(){							
    if($(this).val() == '合租')
    {
        $("#jsLeaseWaySelect").show()
    }
    else
    {
        $("#jsLeaseWaySelect").hide()
    }
});	

//autocomplete后单击小区填充信息
function getblock( district,street,address,id,streetid) {
	$("#district").val(district);
	$("#street").val(street);
	$("#streetid").val(streetid);
	$("#blockaddress").val(address);
	$("#block_id").val(id);
}

//添加小区
function block_add(){
	$('#jsNameInputOp').val($('#blockshowname').val());
	openWin('newblockadd');
}

//区属找板块
function getstreet(obj) {	
	text1=encodeURI(encodeURI($(obj).text()));
	$.ajax({ 
		async:false,  
		type: 'get',  
		url : '/ajax/find_street_list/', 
		data: 'district='+text1,
		dataType:'html',
		success: function(msg){		
			if(msg == 'errorCode401')
			{
				jump_win(LoginOut , '请重新登录');
				return false;
			}
			$("#street_add").html(msg);
			$("#qs").html("请选择版块");
			$("#bankuai").html("请选择版块");
		}  
	}); 

}
//设置编译器的值
function setEditorRemark(html) {
	$('#remark').val(html);
	$("#remark_iframe").contents().find(".ke-edit-iframe").contents().find('.ke-content').html(html);
}
function reload_remark() {
	/***
	var randnum = Math.random();
	var iframeurl = "/editor/house/?" + randnum;
	$("#remark_iframe").attr("src",iframeurl);***/

	/*var oIframe = document.getElementById("remark_iframe");
	oIframe.contentWindow.document.getElementsByTagName('iframe')[0].innerHTML = ''; 
	alert(0)*/
	setEditorRemark('');
}	

function savetemplate()
{
	$("#t_blockname").val($("input[name='blockshowname']").val());
	
	$("#t_remark").val($("#remark").attr("value"));
	$("#t_district").val($("#district").attr("value"));
	$("#t_street").val($("#street").attr("value"));
	$("#t_blockaddress").val($("#blockaddress").attr("value"));
	$("#t_block_id").val($("#block_id").attr("value"));
	$("#t_streetid").val($("#streetid").attr("value"));
	document.t_add.submit();
}
 
 function showblockinfo (averprice , address ,blockesta, urlblock){
    var str = '';
	$("#blockPrice").html(''); 
	if (averprice > 0) {
		str = str + '<span class="tB">均价：<strong class="p" id="averprice">' + averprice + '</strong>元/㎡</span>';
	} else {
		str = str + '<span class="tB">均价：<strong class="p" id="averprice">暂无均价</strong></span>';
	}
	str = str + '<span class="tB">状态：<strong class="zN">' + blockesta + '</strong></span>';
	if (blockesta == '正式小区') {
		str += '<a class="tB" href="' + urlblock + '" target="_blank">查看详情&gt;&gt;</a>';
	}
	$(".blockPBox").css('display', 'block'); 
	$("#blockPrice").html(str); 
	window.CheckAverpice = false;
}

function clearblockinfo()
{
	$(".blockPBox").css('display', 'none'); 
	$("#blockPrice").html(''); 
	$("#district").val('');
	$("#street").val('');
	$("#streetid").val('');
	$("#blockaddress").val('');
	$("#block_id").val('');
	$("#remark").val('');
	$("#tuku1").hide();
	$("#t1").html('');
	$("#tuku0").hide();
	$("#t0").html('');
	reload_remark();
	window.CheckAverpice = false;
}
//设置价格的label和priceunit
function setPriceLabelAndUnit(label, unit) {
	$('#priceunitname').val('');
	$('#priceunitname').val(label);
	$('#priceunit').val(unit);
}
//用于租赁方式切换价格
function changePriceUnit(rentType, infotype) {
	if (infotype == 1 || infotype == 2) {
		$('#priceunitshow').css('display', 'none');
		$('#priceshow3').css('display', 'none');
		$('#priceshow4').css('display', 'none');
		if (rentType == '日租') {
			$('#priceshow1').css('display', 'none');
			$('#priceshow2').css('display', 'block');
			setPriceLabelAndUnit('元/天', 4);
		} else {
			$('#priceshow1').css('display', 'block');
			$('#priceshow2').css('display', 'none');
			setPriceLabelAndUnit('元/月', 1);
		}
	} else {	
		$('#priceshow1').css('display', 'none');
		$('#priceshow2').css('display', 'none');
		$('#priceunitshow').css('display', 'block');
		if (rentType == '日租') {
			$('#priceshow3').css('display', 'none');
			$('#priceshow4').css('display', 'block');
			setPriceLabelAndUnit('元/天*平方米', 2);
		} else {
			$('#priceshow3').css('display', 'block');
			$('#priceshow4').css('display', 'none');
			setPriceLabelAndUnit('元/月', 1);
		}
	}
}

//去除左右空格
function ltrimSpace(str) {
	return str.replace(/\s+/g,"");
}

function getfeature(infotype) {	
   if (infotype == 1 || infotype == 2 || infotype == 3 || infotype == 4) {
		$('#feature_id').css('display', 'block');
		$('#jsAddTagBox').html('');
   } else {
		$('#feature_id').css('display', 'none');
   }
   $.ajax({ 
	async:false,  
	type: 'get',  
	url : '/ajax/find_housefeature/', 
	data: 'infotype='+infotype+'&tbl=sell',
	dataType:'html',
	success: function(msg){	
			if(msg == 'errorCode401')
			{
				jump_win(LoginOut , '请重新登录');
				return false;
			}	
			$("#jsAddTagInnerBox").html(msg);
			html = '';
			for(i=0; i<3; i++) {
				html += '<p class="addTag radius4">+</p>';
			}
			$('#jsAddTagBoxN').html(html);
		}  
	}); 

}
	
$(function() {
	//日租切换
	$("input[name='renttype']").click(function() {
		changePriceUnit($(this).val(), $("input[name='infotype']").val());
	});
    //房源类型切换
    $(".titleTabBox .item").click(function() {
        infotype = $(this).attr('id');
        var tbl = $("input[name='tbl']").val();
        $("input[name='infotype']").val(infotype);
        $(".titleTabBox .itemOn").attr('class', 'item');
        $(this).attr('class', 'item itemOn');
        $.ajax({
            type: 'get',
            url: '/ajax/find_house_add_ext/',
            data: 'tbl='+tbl+'&infotype=' + infotype,
            dataType: 'html',
            success: function(msg) {
				if(msg == 'errorCode401')
				{
					jump_win(LoginOut , '请重新登录');
					return false;
				}
                //写字楼、商铺隐藏房型文本框
                if (infotype != 1)
                {
                    if (infotype == 3 || infotype == 4 || infotype == 5 || infotype == 6) {
                        $("#roomshow").hide();
                    } else {
                        $("#roomshow").show();
                    }
                } else {
                    $("#roomshow").show();
                }
				
                if (infotype == 6)
                {
                    $('#buildyearShow').hide();
                    $('#buildyearShow1').show();
                    $("#fitmentshow").hide();
                    $("#floorshow").hide();	
                    $("#housekindShow").css('display', 'block');	
                } else {
                    $('#buildyearShow').show();
                    $('#buildyearShow1').hide();
                    $("#fitmentshow").show();
                    $("#floorshow").show();	
                    $("#housekindShow").css('display', 'none');	
                }
                $("#infotypeblock").html(msg);
                if ($("input[name='renttype']:checked").val() != '') {
                    changePriceUnit($("input[name='renttype']:checked").val(), $("input[name='infotype']").val());
                }
				//多图数值的控制 住宅为5 非住宅为3
				if (infotype == 1) {
					$('#star_room').html('5');
				} else {
					$('#star_room').html('3');
				}
				getfeature(infotype);
            }
        });
        return true;
    });
	

    //单层 跃层 切换
    $(".jsInputRadio").each(function(index, element) {
        if ($(this).attr("checked") == true || $(this).attr("checked") == "checked")
        {
            $(this).parents(".fgInput")
                    .next(".jsInputBox").show().siblings(".jsInputBox").hide()
        }
    });
    $("#jsInputRadio1").click(function() {
        $("#jsInputBox1").show();
        $("#jsInputBox2").hide();
    })
    $("#jsInputRadio2").click(function() {
        $("#jsInputBox2").show();
        $("#jsInputBox1").hide()
    })

    
	//详细信息 添加房源特色
	$("#jsAddTagInnerBox .addTagInner").hover(function(){
		$(this).addClass("addTagInnerHover");
	},function(){
		$(this).removeClass("addTagInnerHover");
	}).live('click', function(){
		if($(this).hasClass("addTagInnerSelect"))
		{
			$(this).removeClass("addTagInnerSelect");
			$("#jsAddTagBoxN").prepend('<p class="addTag radius4">+</p>')
			
			var oNum =$(this).attr("num")
			
			$("#jsAddTagBox").find(".addTagInner").each(function(index, element) {
				if($(this).attr("num") == oNum )	
				{ 
					$(this).remove()
				}
			});	
		}
		else
		{
			if($("#jsAddTagBox").find(".addTagInner").length >= 3)
			{
				openWin("jsDialog");
				$("#jsDialog .text").empty().html("对不起！您最多只可添加三个标签");
				return false
			}
			$(this).addClass("addTagInnerSelect");
			$('<p class="addTagInner radius4" num='+$(this).attr("num")+'>'+$(this).html()+'<span class="delBtn" title="删除"></span><input type="hidden" name="feature[]" value="'+$(this).attr("num")+'" /></p>').appendTo("#jsAddTagBox")
			$("#jsAddTagBoxN").find(".addTag:first").remove();
		}
	})
	$("#jsAddTagBox").find(".addTagInner").live("mouseover",function(){
		$(this).find(".delBtn").show();
	}).live("mouseout",function(){
		$(this).find(".delBtn").hide();
	})
	$("#jsAddTagBox").find(".delBtn").live("click",function(){

		$(this).parents(".addTagInner").remove();
		$("#jsAddTagBoxN").prepend('<p class="addTag radius4" >+</p>');
		var oNum =$(this).parents(".addTagInner").attr("num")
			
		$("#jsAddTagInnerBox").find(".addTagInner").each(function(index, element) {
			if($(this).attr("num") == oNum )	
			{ 
				$(this).removeClass("addTagInnerSelect")
			}
		});	
	})
    
	$.validator.addMethod("textInteger",function(value,element,params){
		var reg1 = "^-?//d+$";
		if(value.match(reg1)!=0)
		{
			return true
		}
		else
		{
			return false
		}
	},"请正确输入楼层");
	
	$.validator.addMethod("price",function(value,element,params){
		return value > 0
	},"请输入大于0的数");

	$("#jsInputRadio1,#jsInputRadio2").click(function(){
		$(this).parents(".fgInput").siblings(".textFgErroy").find("label.error").hide();
	})
	

	//出售提交
	$("#jsBtnSubmit_sell").click(function(){
	
		$("#jsForm_sell").validate({
                    errorPlacement:function(error,element) { 
                        error.appendTo(element.parents(".jsFgInput").siblings(".textFgErroy"))
                    },
					submitHandler:function(form)
					{
						//验证关键字
						$.ajax({
							type: 'get',
							url : '/ajax/banwords/',
							data: {address:encodeURI(encodeURI($('#address').val())),
								remark:encodeURI(encodeURI($('#remark').val()))},
							dataType:'json',
							success: function(data){
								if(data.errorCode == '401')
								{
									jump_win(LoginOut , '请重新登录');
									return false;
								}
								if (data.status == 2) {
									$('#banwords').html('您输入的房源标题中含有敏感词，请重新输入！');
									$('#address').focus();
									openWin('JS_noteHouse4');
									return false;
								} else if (data.status == 3) {
									$('#banwords').html('您输入的房源描述中含有敏感词，请重新输入！');
									$('#remark').focus();
									openWin('JS_noteHouse4');
									return false;
								} else {
									//均价不能小于小区价格的65%
									if ($('#price').val() != '' && $('#buildarea').val() != ''
										&& $("input[name='infotype']").val() == 1
											&& $("input[name='mright']").val() == '产权房') {
										var rate = 0;
										rate = $("input[name='lctype']:checked").val() == 1 ? 0.65 : 0.5;
										var blockaverprice = parseInt($('#averprice').html()) * rate;
										var buildarea = $('#buildarea').val() ? $('#buildarea').val() : 1;
										var houseaverprice = ($('#price').val() * 10000 / buildarea).toFixed() ;
										if (houseaverprice <= blockaverprice && isNaN(blockaverprice) == false) {
											openWin('JS_noteHouse3');
											return false;
										}
									}
									//均价不能超过小区价格的30%，只提示一次
									if (window.CheckAverpice == false && $('#price').val() != ''
										&& $('#buildarea').val() != '' && $("input[name='infotype']").val() == 1
											&& $("input[name='mright']").val() == '产权房') {
										var blockaverprice = parseInt($('#averprice').html()) * 1.35;
										var buildarea = $('#buildarea').val() ? $('#buildarea').val() : 1;
										var houseaverprice = ($('#price').val() * 10000 / buildarea).toFixed() ;
										if (houseaverprice >= blockaverprice && isNaN(blockaverprice) == false) {
											openWin('JS_noteHouse2');
											window.CheckAverpice = true;
											return false;
										} else {
											$('#new_login_btn_none').show();
											form.submit();
										}
									}
									else
									{
										$('#new_login_btn_none').show();
										form.submit();
									}
								}
							}
						});
						return false;
					},
                    rules: 
                    {
                        blockshowname:
                        {
                            required: true
                        },
                        price:
                        {
                            required: true,
                            number:true,
                            price : true
                        },
                        priceterm_name:
                        {
                            required: true
                        },
                        pricetypename:
                        {
                            required: true
                        },
                        buildarea:
                        {
                            required: true,
                            number:true
                        },
                        room:
                        {	
                            required: true,
                            digits:true,
                            min : 1
                        },
                        hall:
                        {
                            required: true,
                            digits:true	
                        },
                        toilet:
                        {
                            required: true,
                            digits:true	
                        },
                        mright:
                        {//权属
                            required: true	
                        },
                        forward:
                        {//朝向
                            required: true
                        },
                        fitment:
                        {//装修
                            required: true
                        },
                        /*housekind:
                        {//别墅类型属性
                            required: true
                        },*/
                        address:
                        {//房源标题
                            required: true
                        },
                        buildyear:
                        {//建筑年代
                            required: true,
                            digits:true,
                            maxlength:4,
                            minlength:4
                        },
                        ownid:
                        {//建筑年代
                            maxlength:15
                        },
						floor:
						{//单层 1
                            required: function(){
                                if($("#jsInputRadio1").attr("checked"))
                                {
                                    return true
                                }
                                else
                                {
                                    return false
                                }	
                            },
                            number:true,
                            textInteger:true	
                        },
                        totalfloor:
                        {//单层 2
                            required: function(){
                                if($("#jsInputRadio1").attr("checked"))
                                {
                                    return true
                                }
                                else
                                {
                                    return false
                                }	
                            },
                            digits:true,
                            min:function(){
                                return parseInt($("#floor").val())
                            }	
                        },
                        subfloor:
                        {//跃层1
                            required:function(){
                                if($("#jsInputRadio2").attr("checked"))
                                {
                                    return true
                                }
                                else
                                {
                                    return false
                                }	
                            },
                            number:true,
                            textInteger:true	
                        },
                        floor2:
                        {//跃层1
                            required:function(){
                                if($("#jsInputRadio2").attr("checked"))
                                {
                                    return true
                                }
                                else
                                {
                                    return false
                                }	
                            },
                            number:true,
                            min:function(){
                                    return parseInt($("#subfloor").val())
                            },
                            textInteger:true	
                        },
                        totalfloor2:
                        {//跃层1
                            required:function(){
                                if($("#jsInputRadio2").attr("checked"))
                                {
                                    return true
                                }
                                else
                                {
                                    return false
                                }	
                            },
                            digits:true,
                            min:function(){
                                return parseInt($("#floor2").val())
                            }		
                        },
						fee:
                        {
                            number:true	
                        }
			},
			messages: 
			{
                            blockshowname:
                            {
                                required: "请选择小区"
                            },
                            price:
                            {
                                required: "请填写售价",
                                number:"请正确填写售价"
                            },
                            priceterm_name:
                            {
                                required: "请选择价格条件"
                            },
                            pricetypename:
                            {
                                required: "请选择税费情况"
                            },
                            buildarea:
                            {
                                required: "请填写产证面积",
                                number:"请正确填写产证面积"
                            },
                            room:
                            {	
                                required: "请填写户型",
                                digits:"请正确填写户型"	,
                                min : "室必须大于0"
                            },
                            hall:
                            {
                                required: "请填写户型",
                                digits:"请正确填写户型"	
                            },
                            toilet:
                            {
                                required: "请填写户型",
                                digits:"请正确填写户型"	
                            } ,
                            houseType5:
                            {
                                required: "请填写户型",
                                digits:"请正确填写户型"	
                            },
                            mright:
                            {//权属
                                required: "请选择权属"	
                            } ,
                            payment:
                            {//支付方式
                                required: "请选择支付方式"	
                            } ,
                            forward:
                            {//朝向
                                required: "请选择朝向"
                            },
                            fitment:
                            {//装修
                                required: "请选择装修情况"
                            },
                            /*housekind:
                            {   //别墅类型
                                required: "请选择别墅类型"
                            },*/
                            housekindname:
                            {//车位属性
                                required: "请选择车位属性"
                            },
                            address:
                            {//房源标题
                                required: "请填写房源标题"
                            },
                            buildyear:
                            {//建筑年代
                                digits:"请正确填写 - 格式:2010",
                                maxlength:"请正确填写 - 格式:2010",
                                minlength:"请正确填写 - 格式:2010",
                                required: "请填写建筑年代"
                            },
                            ownid:
                            {//建筑年代
                                maxlength:"内部编号在15个字之内"
                            },
                            floor:
                            {//单层 1
                                required: "请填写楼层",
                                number:"请正确填写楼层"		
                            },
                            totalfloor:
                            {//单层 2
                                required: "请填写楼层",
                                digits:"请正确填写楼层"	,
                                min:"楼层必须小于总楼层"	
                            },
                            subfloor:
                            {//跃层 1
                                required: "请填写楼层",
                                number:"请正确填写楼层"		
                            },
                            floor2:
                            {//跃层 2
                                required: "请填写楼层",
                                number:"请正确填写楼层"	,
                                min:"楼层必须大于底楼"
                            },
                            totalfloor2:
                            {//跃层 2
                                required: "请填写楼层",
                                digits:"请正确填写楼层"	,
                                min:"楼层必须小于总楼层"
                            },
							fee:
							{
								number:"请正确填写物业费"	
							}
			}
			//debug:true
		})

		$("#jsForm_sell").submit();
	})
	
        
        //模板验证
        $("#template_add").validate({
            errorPlacement:function(error,element) 
            { 
                error.appendTo(element.parents(".jsFgInput").siblings(".textFgErroy"))
            },
            submitHandler:function(form){
                var remark = $('#remark').val().replace(/\s+/g,"").replace("&nbsp;","");
                var obj_value_arr = remark.split("");
                var num = 0;
                for (var i = 0; i < obj_value_arr.length; i++) {
                    num += returnStrLen(obj_value_arr[i]);
                }
                if (remark == '' || num < 20) {
                     $("#jsErrorBox").html("请填写20个字符以上的房源描述！");
                     $("#jsErrorBox").show();
                     return false;
                } else {
                    form.submit();
                }
            },
            rules: 
            {
                template_name:
                {
                    required:true,
                    rangelength:[1,6]
                },
                blockshowname:
                {
                    required:true
                },
                remark:
                {
                    required:true
                }
            },
            messages: 
            {
                template_name:
                {
                    required:"请填写模版名称",
                    rangelength:"模板名称在1-6个字之间"
                },
                blockshowname:
                {
                    required:"请选择小区"
                },
                remark:
                {
                    required:"请填写房源描述"
                }
            }
        })
		
	$.validator.addMethod("buildarea_rent",function(value,element,params){
		//整租和合租状态下面积必须小于租金
		var infotype = $("input[name='infotype']").val();
		var renttype = $("input[name='renttype']:checked").val();
		if ((renttype == '整租' || renttype == '合租') && parseInt(value) >= parseInt($('#price').val())
			&& (infotype == 1 || infotype == 2)) {
			return false;
		} else {
			return true;
		}
	}, "请确认您填写的租金和面积是否有误");
	
	$.validator.addMethod("buildarea_rent_1",function(value,element,params){
		var infotype = $("input[name='infotype']").val();
		//住宅面积大于等于300平米以上就有提示
		if (infotype == 1 && parseInt(value) >= 300) {
			return false;
		} else {
			return true;
		}
	}, "请确认您填写的面积是否准确");
	$.validator.addMethod("buildarea_rent_2",function(value,element,params){
		var renttype = $("input[name='renttype']:checked").val();
		if (renttype == '整租' && parseInt(value) < 20 && $("input[name='infotype']").val() != 4) {
			return false;
		} else {
			return true;
		}
	}, "整租的面积太小了吧？请查实后填写");

	$.validator.addMethod("price_rent",function(value,element,params){
		var renttype = $("input[name='renttype']:checked").val();
		var infotype = $("input[name='infotype']").val();
		if (infotype == 3 || infotype == 4 || infotype ==5) {
			if (renttype == '整租' && parseInt(value) <= 1500000) {
				return true;
			} else {
				return false;
			}
		} else {
			return true;
		}
	}, "您输入的租金过高请核实");

	//出租提交
	$("#jsBtnSubmit_rent").click(function(){
		$("#jsForm_rent").validate({
		
			errorPlacement:function(error,element) 
			{ 
				error.appendTo(element.parents(".jsFgInput").siblings(".textFgErroy"))
			},
			submitHandler:function(form)
			{
				//验证关键字
				$.ajax({
					type: 'get',
					url : '/ajax/banwords/',
					data: {address:encodeURI(encodeURI($('#address').val())),
						remark:encodeURI(encodeURI($('#remark').val()))},
					dataType:'json',
					success: function(data){
						if(data.errorCode == '401')
						{
							jump_win(LoginOut , '请重新登录');
							return false;
						}
						if (data.status == 2) {
							$('#banwords').html('您输入的房源标题中含有敏感词，请重新输入！');
							$('#address').focus();
							openWin('JS_noteHouse4');
							return false;
						} else if (data.status == 3) {
							$('#banwords').html('您输入的房源描述中含有敏感词，请重新输入！');
							$('#remark').focus();
							openWin('JS_noteHouse4');
							return false;
						} else {
							$('#new_login_btn_none').show();
							form.submit();
						}
					}
				});
			},
			rules: 
			{
				blockshowname:
				{
					required: true
				},
				price:
				{
					required: true,
					number:true,
					price : true,
					price_rent : true
				},
				priceunit:
				{
					required: true,
					number:true
				},
				buildarea:
				{
					required: true,
					number:true,
					buildarea_rent:true,
					buildarea_rent_1:true,
					buildarea_rent_2:true
				},
				room:
				{	
					required: true,
					digits:true,
					min : 1
				},
				hall:
				{
					required: true,
					digits:true	
				},
				toilet:
				{
					required: true,
					digits:true	
				},
				forward:
				{//朝向
					required: true
				},
				payment:
				{//支付
					required: true
				},
				fitment:
				{//装修
					required: true
				},
				address:
				{//房源标题
					required: true
				},
				housekindname:
				{//车位属性
					required: true
				},
				ownid:
				{//建筑年代
					
					maxlength:15
				},
						floor:
				{//单层 1
				     required: function(){
						if($("#jsInputRadio1").attr("checked"))
						{
							return true
						}
						else
						{
							return false
						}	
					},
					number:true,
					textInteger:true	
				},
				totalfloor:
				{//单层 2
					required: function(){
						if($("#jsInputRadio1").attr("checked"))
						{
							return true
						}
						else
						{
							return false
						}	
					},
					digits:true,
					min:function(){
						return parseInt($("#floor").val())
					}	
				},
				subfloor:
				{//跃层1
					required:function(){
						if($("#jsInputRadio2").attr("checked"))
						{
							return true
						}
						else
						{
							return false
						}	
					},
					number:true,
					textInteger:true	
				},
				floor2:
				{//跃层1
					required:function(){
						if($("#jsInputRadio2").attr("checked"))
						{
							return true
						}
						else
						{
							return false
						}	
					},
					number:true,
					min:function(){
						return parseInt($("#subfloor").val())
					},
					textInteger:true	
				},
				totalfloor2:
				{//跃层1
					required:function(){
						if($("#jsInputRadio2").attr("checked"))
						{
							return true
						}
						else
						{
							return false
						}	
					},
					digits:true,
					min:function(){
						return parseInt($("#floor2").val())
					}		
				},
				fee:
				{
					number:true	
				}
			},
			 messages: 
			 {
				blockshowname:
				{
					 required: "请选择小区"
				},
				price:
				{
					 required: "请填写租金",
					 number:"请正确填写租金"
				},
				priceunit:
				{
					 required: "请填写租金单位"
					 
				},
				buildarea:
				{
					required: "请填写产证面积",
					number:"请正确填写产证面积"
				},
				room:
				{	
					required: "请填写户型",
					digits:"请正确填写户型"	,
					min : "室必须大于0"
				},
				hall:
				{
					required: "请填写户型",
					digits:"请正确填写户型"	
				},
				toilet:
				{
					required: "请填写户型",
					digits:"请正确填写户型"	
				} ,
				houseType5:
				{
					required: "请填写户型",
					digits:"请正确填写户型"	
				},
				payment:
				{//支付方式
					required: "请选择支付方式"	
				} ,
				forward:
				{//朝向
					required: "请选择朝向"
				},
				fitment:
				{//装修
					required: "请选择装修情况"
				},
				/*housekind:
				{//别墅类型属性
					required: "请选择别墅类型"
				},*/
				address:
				{//房源标题
					required: "请填写房源标题"
				},
				ownid:
				{//建筑年代
					
					maxlength:"内部编号在15个字之内"
				},
				floor:
				{//单层 1
					required: "请填写楼层",
					number:"请正确填写楼层"		
				},
				totalfloor:
				{//单层 2
					required: "请填写楼层",
					digits:"请正确填写楼层"	,
					min:"楼层必须小于总楼层"	
				},
				subfloor:
				{//跃层 1
					required: "请填写楼层",
					number:"请正确填写楼层"		
				},
				floor2:
				{//跃层 2
					required: "请填写楼层",
					number:"请正确填写楼层"	,
					min:"楼层必须大于底楼"
				},
				totalfloor2:
				{//跃层 2
					required: "请填写楼层",
					digits:"请正确填写楼层"	,
					min:"楼层必须小于总楼层"
				},
				fee:
				{
					number:"请正确填写物业费"	
				}
			 }
		})
		$("#jsForm_rent").submit();
	})
	//联想框 历史小区下拉条
	if($("#blockshowname").length >0)
	{
		var positionLeft = $("#blockshowname").offset().left;
		var positionTop = $("#blockshowname").offset().top;
		$("#historyHouse").css({left:positionLeft,top:positionTop+29});
		$(window).resize(function(e) {
			positionLeft = $("#blockshowname").offset().left;
			positionTop = $("#blockshowname").offset().top;
			$("#historyHouse").css({left:positionLeft,top:positionTop+29});
		});
		$("#blockshowname").bind("click",function(){
			if($(".ui-autocomplete").is(":hidden"))
			{
				$("#historyHouse").show();
			}
			else
			{
				$("#historyHouse").hide();		
			}
		});
		$("#blockshowname").bind("keyup",function(){
			if($(this).val() != "")
			{
				$("#historyHouse").hide();
			}
			else
			{
				$("#historyHouse").show()
			}
		})
		$("#historyHouse").bind("click",function(){
			$("#blockshowname").focus();
			$(this).hide();
			
		})

		$("#historyHouse,#blockshowname").bind("click",function(event){
			event.stopPropagation();
		})
	}
	
	//房源模板
	$(".jsTemplateBox .item").click(function() {
		id = $(this).attr('ids');
		$(this).siblings(".item").removeClass("itemAdd");
		if($(this).hasClass("itemAdd"))
		{

			$(this).removeClass("itemAdd");
			$('#jsLabelBlockshowname').show();
			$("#district").val("");
			$("#street").val("");
			$("#streetid").val("");
			$("#blockaddress").val("");
			$("#block_id").val("");
			$("#blockshowname").val("");
			reload_remark();
		}
		else
		{
			$(this).addClass("itemAdd");
			$('#jsLabelBlockshowname').hide();
			$.ajax({
				type: 'get',
				url : '/ajax/find_module_detail/',
				data: 'id='+id,
				dataType:'json',
				success: function(data){
					if(data.errorCode == '401')
					{
						jump_win(LoginOut , '请重新登录');
						return false;
					}
					$("#district").val(data.district);
					$("#street").val(data.street);
					$("#streetid").val(data.streetid);
					$("#blockaddress").val(data.address);
					$("#block_id").val(data.id);
					$("#blockshowname").val(data.block_name);
					//$("#remark").val(data.remark);
					$("#historyHouse").hide();
					getBlockImg(1);
					if ($('#tbl').val() == 'sell') {
				        showblockinfo (data.averprice , data.address ,data.esta_block, data.url_block);
			        }
					setEditorRemark(data.remark);
				}
			});
		}
		return true;
	});
	
	$("#blockshowname").keyup(function(){
		clearblockinfo();
	});
	$(document).click(function(a){
		$("#historyHouse").hide();
	})
});