$(function(){
	$("#jsModListBdList .item").each(function(index, element) {
		$(this).click(function(){
			$(this).addClass("itemOn").siblings(".item").removeClass("itemOn");
			$("#jsShowHouseBox").find(".details").eq(index).show().siblings(".details").hide();
		})
	});
});

$(function(){
		$(".js_show_nav").click(function(){
				$(this).find(".js_s_h").toggleClass("s_h_on");
				$(this).parent().siblings(".js_show_nav_mod").slideToggle(150);
		})
})						
						

charset="gb2312"
;(function($){
	$.fn.hcheckbox=function(options){
		$(':checkbox+label',this).each(function(){
			$(this).addClass('checkbox');
            if($(this).prev().is(':disabled')==false){
                if($(this).prev().is(':checked'))
				    $(this).addClass("checked");
            }else{
                $(this).addClass('disabled');
            }
		}).click(function(event){
				
				if(!$(this).prev().is(':checked')){
					
					$(this).siblings().attr('checked',true);
				    $(this).addClass("checked");
                    $(this).prev()[0].checked = true;

					$(this).parents('.list-inner').addClass('selects')
                }
                else{
					$(this).siblings().attr('checked',false);
                    $(this).removeClass('checked');			
                    $(this).prev()[0].checked = false;
					$(this).parents('.list-inner').removeClass('selects')
                }
                event.stopPropagation();
			}
		).prev().hide();
	}



})(jQuery);


//selectBox插件
(function($){
	var defaults = {
	};
	$.fn.selectSimulate= function(options){
		options = $.extend({},defaults,options);
		return this.each(function(){
			var self = $(this);
			var selectList = self.find('.selectSimulate-list');
			var selectVal = self.find('.selectSimulate-value');
			var selectInput = self.find('.selectSimulate-input')
			//var selectList = $("#JS_searchSelectList");
			self.click(function(event){
				selectList.toggle(0);
				event.stopPropagation();
				//$("#JS_searchSelectValue").toggleClass("search-select-value-on");
			});
			
			selectList.find("li").live('click',function(event){
				var _this = $(this);
				var sValue = _this.attr("rel");
				var sText = _this.text();
				selectVal.text(sText);
				selectInput.val(sValue);  //传值，与后台关联
				//_this.addClass("current").siblings().removeClass("current");
				selectList.hide();
				event.stopPropagation();
			}).live('mouseover',function(){
			 	$(this).addClass("mouseover").siblings("li").removeClass("mouseover");	
			}).live('mouseout',function(){
				$(this).removeClass("hover");
			})

			$(document).click(function(event){
				selectList.hide();
			});
		});
	}
})(jQuery);


$(function(){
	$('#select-all-btn,.chk').hcheckbox();
	$('.sel-all').click(function()
	{
		if(!$(this).prev().is(':checked')){
			$('.chk :checkbox').each(function(){
				$(this).siblings().removeClass('checked');
				$(this).attr('checked',false);
				$(this).parents('.list-inner').removeClass('selects')
			});	
		}
		else{
			$('.chk :checkbox').each(function(){
				$(this).siblings().addClass('checked');
				$(this).attr('checked',true)
				$(this).parents('.list-inner').addClass('selects')
			});	
		}
	});

});

$(function(){
	$(".new-source-Tip").click(function(){
		var _link = $(this).find("a").attr("href");
		window.open(_link);	
		//alert(_link)
	});
	 $(".new-source-Tip").find("a").click(function(event){
        event.stopPropagation();
   });
	
	
	$('.list-inner').hover(function(){
		$(this).addClass('hover')
	},function(){
		$(this).removeClass('hover')
	});
	
	$('.mes-name').toggle(function(){
		mes.open(this)
	},function(){
		mes.close(this)
	}).hover(function(){
		$(this).addClass("mes-nameHover");
	},function(){
		$(this).removeClass("mes-nameHover");
	});

	var mes = {
		open : function(obj){
		//	$(obj).text('收起').addClass('mes-open');
			var opHeight = $(obj).siblings('.mes-txt').find('p').outerHeight();
			$(obj).siblings('.mes-txt').css({'height' :opHeight + 'px' });
			$(obj).parents('.mes-inner').addClass('read-over');
		},
		close : function(obj)
		{
			//$(obj).text('详情').removeClass('mes-open');
			$(obj).parents('.mes-inner').find('.mes-txt').css({'height' : 24 + 'px' })
		}
	};
	

	
	//求租求购 - 查看
	(function(){
		
		$(document).click(function(){
			//showBox.closed()
		})
		
		$('.showBox').click(function(event){
			event.stopPropagation();
		})
		
		$('.lookFor').click(function(event){
			event.stopPropagation();
			var _y = $(window).scrollTop();
			showBox.opens(_y,this);
			var id = $(this).attr('want_id');
			var want_type = $('#want_type').val();
			var iframe_url = 'want_matched_window/'+want_type+'/'+id;
			$('#matched_window').attr('src',iframe_url);
		});
		
		$('a.showBox-close').click(function(){
			showBox.closed()
		});
		
		$('.look-no').click(function(){
			$(this).parent('.list').remove()
		})
		
		$('.table-style-a').find('tr:not(:first)').hover(function(){
			$(this).addClass('hover')
		},function(){
			$(this).removeClass('hover')
		})
		
		$('.showBox .list').hover(function(){
			$(this).addClass('hover')
		},function(){
			$(this).removeClass('hover')
		})
		
		var showBox = {
			opens : function(_y,obj){
				if(_y + 400 > $(window).height())
				{
					$('.showBox').css({
						'top' : _y - 358 + 'px'
					}).show();
				}
				else
				{
					$('.showBox').css({
						'top' : _y + 38 + 'px'
					}).show();
				}
				$(obj).addClass('on').parents('tr').siblings().find('.lookFor').removeClass('on');
				$(obj).parents('tr').addClass('selects').siblings().removeClass('selects')
			},
			closed : function(){
				$('.showBox').hide();
				$('.lookFor').removeClass('on').parents('tr').removeClass('selects');
			}
		}
		
	})();

	//select模拟
	(function(){
		$('.selectSimulate').selectSimulate();
	})();
	
	//图表切换
	(function(){
		var _cur = $('.chart-tab .cur').find('a');
		var _index = 0;
		_cur.click(function(){
			_index = $(this).index();
			$(this).addClass('on').siblings().removeClass('on');
			$('.chart-tab .panel').eq(_index).show().siblings().hide()
		})
		
	})();
	
	//aud-top
	(function(){
		$('.auditing-none').hover(function(){
			$(this).siblings('.auditing-tip').show()
		},function(){
			$(this).siblings('.auditing-tip').hide()
		})
	})();
	
	
	//我要推广
	/*(function(){
		$('.extend').click(function(event){
			event.stopPropagation();
			var _y = $(this).offset().top;
			payBox.opens(_y,this);
		});
		
		$('a.payBox-close').click(function(){
			payBox.closed()
		});
		
		$(document).click(function(){
			//payBox.closed()
		})
		
		var payBox = {
			opens : function(_y,obj){
				if(_y + 400 > $(window).height())
				{
					$('.payBox').css({
						'top' : _y - 228 + 'px'
					}).show();
				}
				else
				{
					$('.payBox').css({
						'top' : _y + 28 + 'px'
					}).show();
				}
				$(obj).addClass('on')
				$(obj).parents('.list-inner').addClass('selects').siblings().removeClass('selects')
			},
			closed : function(){
				$('.payBox').hide();
				$('.extend').removeClass('on').parents('.list-inner').removeClass('selects');
			}
		}
		
		var seletBtn = $('.pay-panel').find('label');
		seletBtn.click(function(){
			$(this).find('div').addClass('on').parent().siblings().find('div').removeClass('on');
			$(this).find('input').attr('checked',true)
		});
		$('.pay-btn').click(function(){
			payBox.closed()
			pay_ok_pop();
		})
		
		
	})();*/

	(function(){
		$('a.xiugai').click(function(){
			$(this).hide();
			$(this).siblings('.saveVal').hide().siblings('.changeBox').show()
		})
	})()
	

});


function pop_tip(text)
{
	var pop_dom = '<div class="pop" style="width:390px;height:160px; position:absolute;left:50%;top:50%;margin-left:-85px;margin-top:-80px;-moz-box-shadow: 0 0 34px #cacaca;-webkit-box-shadow: 0 0 34px #cacaca;box-shadow: 0 0 34px #cacaca;">';
	pop_dom+='<div class="hd" style="height:40px;background:#FF8400">';
	pop_dom+='<h2 style="font-size:14px;color:#fff;font-weight:800; position:absolute;left:10px;top:10px">提示</h2>';
	pop_dom+='<a href="javascript:void(0)" class="close-pop" style="display:block;width:30px;height:30px;background:url(images/pop-ico.gif) 0 -80px no-repeat; position:absolute;right:10px;top:6px; text-indent:-999px; overflow:hidden">关闭</a>';
	pop_dom+='</div>';
	pop_dom+='<div class="bd" style="background:#fff;height:120px">';
	pop_dom+='<div style="width:70px;height:80px;background:url(images/pop-ico.gif) no-repeat; position:absolute;left:70px;top:60px"></div>';
	pop_dom+='<p style="position:absolute;left:160px;top:85px;font-size:14px">'+text+'</p>';
	pop_dom+='</div>';
	pop_dom+='</div>';
	
	$(pop_dom).appendTo('body');
	$('.close-pop').live('click',function(){
		$('.pop').remove()
	})
	$('.form').submit()
}

function refresh_pop(ste)
{
	var pop_dom1 = '<div class="pop_win" id="pop_win_1" style="width:390px;height:200px; position:absolute;left:50%;top:50%;margin-left:-85px;margin-top:-100px;-moz-box-shadow: 0 0 34px #cacaca;-webkit-box-shadow: 0 0 34px #cacaca;box-shadow: 0 0 34px #cacaca; z-index:9999">';
	pop_dom1+='<div class="hd" style="height:40px;background:#FF8400">';
	pop_dom1+='<h2 style="font-size:14px;color:#fff;font-weight:800; position:absolute;left:10px;top:10px">提示</h2>';
	pop_dom1+='<a href="javascript:void(0)" class="close-pop_win" style="display:block;width:30px;height:30px;background:url(images/pop-ico.gif) 0 -80px no-repeat; position:absolute;right:10px;top:6px; text-indent:-999px; overflow:hidden">关闭</a>';
	pop_dom1+='</div>';
	pop_dom1+='<div class="bd" style="background:#fff;height:160px">';
	pop_dom1+='<div style="width:70px;height:80px;background:url(images/pop-ico.gif) no-repeat -2px -113px; position:absolute;left:70px;top:60px"></div>';
	pop_dom1+='<p style="position:absolute;left:140px;top:85px;font-size:14px">你确定要刷新这条房源么？</p>';
	pop_dom1+='<div style="text-align:center;position:absolute;top:155px;width:100%"><a href="javascript:void(0)" class="refresh-ok" style="background:#29B966;color:#fff;padding:7px 15px;margin:0 5px;border:1px solid #26AB5E">确定</a><a href="javascript:void(0)" class="close-pop_win"  style="background:#F5F5F5;color:#666;padding:7px 15px;margin:0 5px;border:1px solid #CCCCCC">取消</a></div>';
	pop_dom1+='</div>';
	pop_dom1+='</div>';
	
	var pop_dom2 = '<div class="pop_win" id="pop_win_2" style="width:390px;height:200px; position:absolute;left:50%;top:50%;margin-left:-85px;margin-top:-100px;-moz-box-shadow: 0 0 34px #cacaca;-webkit-box-shadow: 0 0 34px #cacaca;box-shadow: 0 0 34px #cacaca; z-index:9999">';
	pop_dom2+='<div class="hd" style="height:40px;background:#FF8400">';
	pop_dom2+='<h2 style="font-size:14px;color:#fff;font-weight:800; position:absolute;left:10px;top:10px">提示</h2>';
	pop_dom2+='<a href="javascript:void(0)" class="close-pop_win" style="display:block;width:30px;height:30px;background:url(images/pop-ico.gif) 0 -80px no-repeat; position:absolute;right:10px;top:6px; text-indent:-999px; overflow:hidden">关闭</a>';
	pop_dom2+='</div>';
	pop_dom2+='<div class="bd" style="background:#fff;height:160px">';
	pop_dom2+='<div style="width:70px;height:80px;background:url(images/pop-ico.gif) no-repeat; position:absolute;left:70px;top:60px"></div>';
	pop_dom2+='<p style="position:absolute;left:140px;top:85px;font-size:14px">刷新成功，今天还剩<span style="color:#FF8400">1</span>次</p>';
	pop_dom2+='<div style="text-align:center;position:absolute;top:155px;width:100%"><a href="javascript:void(0)" class="ok-refresh" style="background:#29B966;color:#fff;padding:7px 15px;margin:0 5px;border:1px solid #26AB5E">确定</a><a href="javascript:void(0)" class="close-pop_win" style="background:#F5F5F5;color:#666;padding:7px 15px;margin:0 5px;border:1px solid #CCCCCC">取消</a></div>';
	pop_dom2+='</div>';
	pop_dom2+='</div>';
	
	var pop_dom3 = '<div class="pop_win" id="pop_win_3" style="width:390px;height:200px; position:absolute;left:50%;top:50%;margin-left:-85px;margin-top:-100px;-moz-box-shadow: 0 0 34px #cacaca;-webkit-box-shadow: 0 0 34px #cacaca;box-shadow: 0 0 34px #cacaca; z-index:9999">';
	pop_dom3+='<div class="hd" style="height:40px;background:#FF8400">';
	pop_dom3+='<h2 style="font-size:14px;color:#fff;font-weight:800; position:absolute;left:10px;top:10px">提示</h2>';
	pop_dom3+='<a href="javascript:void(0)" class="close-pop_win" style="display:block;width:30px;height:30px;background:url(images/pop-ico.gif) 0 -80px no-repeat; position:absolute;right:10px;top:6px; text-indent:-999px; overflow:hidden">关闭</a>';
	pop_dom3+='</div>';
	pop_dom3+='<div class="bd" style="background:#fff;height:160px">';
	pop_dom3+='<div style="width:70px;height:80px;background:url(images/pop-ico.gif) 0 -191px no-repeat; position:absolute;left:70px;top:60px"></div>';
	pop_dom3+='<p style="position:absolute;left:140px;top:85px;font-size:14px">您今日没有刷新次数了</p>';
	pop_dom3+='<div style="text-align:center;position:absolute;top:155px;width:100%"><a href="javascript:void(0)" class="go-pay" style="background:#FF8F16;color:#fff;padding:7px 15px;margin:0 5px;border:1px solid #E47600">付费刷新</a><a href="javascript:void(0)" class="close-pop_win" style="background:#F5F5F5;color:#666;padding:7px 15px;margin:0 5px;border:1px solid #CCCCCC">取消</a></div>';
	pop_dom3+='</div>';
	pop_dom3+='</div>';
	
	if(ste == '1')
	{
		$(pop_dom1).appendTo('body');
	}
	else if(ste == '0')
	{
		$(pop_dom3).appendTo('body');
	}
	
	$('.refresh-ok').live('click',function(){
		$('#pop_win_1').remove();
		$(pop_dom2).appendTo('body');
	})
	
	
	
	$('.close-pop_win').live('click',function(){
		$('.pop_win').remove()
	})
	
}

function pay_ok_pop()
{
	var pop_dom = '<div class="pop_win" style="width:390px;height:160px; position:absolute;left:50%;top:50%;margin-left:-85px;margin-top:-80px;-moz-box-shadow: 0 0 34px #cacaca;-webkit-box-shadow: 0 0 34px #cacaca;box-shadow: 0 0 34px #cacaca;">';
	pop_dom+='<div class="hd" style="height:40px;background:#FF8400">';
	pop_dom+='<h2 style="font-size:14px;color:#fff;font-weight:800; position:absolute;left:10px;top:10px">支付提示信息</h2>';
	pop_dom+='<a href="javascript:void(0)" class="close-pop_win" style="display:block;width:30px;height:30px;background:url(images/pop-ico.gif) 0 -80px no-repeat; position:absolute;right:10px;top:6px; text-indent:-999px; overflow:hidden">关闭</a>';
	pop_dom+='</div>';
	pop_dom+='<div class="bd" style="background:#fff;height:120px">';
	pop_dom+='<p style="position:absolute;left:20px;top:55px;font-size:12px;line-height:22px">请在新打开的支付页面上完成付款，付款完成前请不要关闭此窗口。如您在支付过程中遇到问题，请联系客服：<span style="color:#2280FF">025-84645315</span></p>';
	pop_dom+='<div style="text-align:center;position:absolute;top:125px;width:100%"><a href="javascript:void(0)" class="close-pop_win" style="background:#29B966;color:#fff;padding:7px 10px;margin:0 5px;border:1px solid #26AB5E">已完成支付</a><a href="javascript:void(0)" class="re-pay" style="background:#F5F5F5;color:#666;padding:7px 10px;margin:0 5px;border:1px solid #CCCCCC">重新支付</a></div>';
	pop_dom+='</div>';
	pop_dom+='</div>';
	
	$(pop_dom).appendTo('body');
	$('.close-pop_win').live('click',function(){
		$('.pop_win').remove()
	})
	
}


var openWin = function(obj){
	var winHeght = $(document).height() ;
	var winElemt = $('#'+ obj);
	
	var win = {
		
		height : function(){
			return winElemt.outerHeight();
		},
		
		width : function(){
			return winElemt.outerWidth();
		},
		
		show : function(){
			winElemt.css({
				'position':'absolute',
				'z-index':'9999902',
				'left':'50%',
				'margin-left':'-' + win.width() / 2 + 'px',
				'top':$(window).height()/2 - (win.height()/2) + $(window).scrollTop() + 'px'
			}).show();
		},
		
		hide : function(){
			winElemt.hide();
		}
	
	};
	win.show();
	$('.close-win').click(function(){
		win.hide();
	});
};



         //取cookies函数
    function getCookie(name)
    {
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
    }
    //两个参数，一个是cookie的名子，一个是值
    function SetCookie(name,value)
    {
    var Days = 1; //此 cookie 将被保存 1 天
    var exp = new Date(); //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
    }
	
	
	/****2014.05.21 修改 王小任****/
$(function(){
	$(".jsUpLoadNum").hover(function(){
		$(this).siblings(".jsUpLoadText").css("display","block");
	},function(){
			$(this).siblings(".jsUpLoadText").css("display","none")
	})
})
