﻿	$(function(){
		GetNews(1, filter, path);
		GetNews(2, filter, path);
		GetCommNum(filter);
		GetBBS(1, path);
		GetBBS(2, path);
		GetBBS(3, path);
		$("#select1").css("width","100px");
		$("#select2").css("width","100px");
		$.area();

		$(".scroll_one").jScroll();
		$(".scroll_two").jScroll({vertical: true});
		$(".scroll_three").jScroll();
		$(".lpkx").jScroll({auto: 600, vertical: true});

		$(".tab_one").jTab({
			menutag: "#tab_one_menu strong",
			boxtag: "#tab_one_box > ul"
		});
		$(".tab_two").jTab({
			menutag: "#tab_two_menu strong",
			boxtag: "#tab_two_box > table"
		});
		$(".tab_three").jTab({
			menutag: "#tab_three_menu li",
			boxtag: "#tab_three_box > ul"
		});

		$(".comm a:eq(1)").toggle(function(){
			$(".commpub").slideDown();
			return false;
		}, function(){
			$(".commpub").slideUp();
			return false;
		});

		$("#commform").validate({
			errorElement: "em",
			rules: { comm_Cnt: {required:true, rangelength:[2,200]} },
			messages: { comm_Cnt: {required:"请输入评论内容", rangelength:"评论内容长度应在2~200之间"} }
		});
	});

	function GetBBS(no, path) {
		$.ajax({
			type:"GET",
			cache:false,
			url:path + "do.asp",
			data:"task=GetBBS&no=" + no,
			error:function(){$("#bbs"+ no).html("获取数据失败");},
			success:function(bbs_data){
				$("#bbs"+ no).html(bbs_data);
			}
		});
	}

	function GetNews(no, filter, path) {
		$.ajax({
			type:"GET",
			cache:false,
			url:path + "do.asp",
			data:"task=GetNews&no=" + no + "&filter=" + filter,
			error:function(){$("#news"+ no +" ul").html("获取数据失败");},
			success:function(news_data){
				if(news_data == "0"){
					$("#news"+ no).hide();
				}else{
					$("#news"+ no +" ul").html(news_data);
				}
			}
		});
	}

	function GetCommNum(filter) {
		$.ajax({
			type:"GET",
			cache:false,
			url:path + "do.asp",
			data:"task=GetCommNum&filter=" + filter,
			success:function(comm_data){
				$(".comm_num em").text(comm_data);
			}
		});
	}

	(function($){
	$.fn.selInit = function(){return $(this).html("<option value=''>请选择</option>");};
	$.area = function(){
		$("#select1").selInit();
		$("#select2").selInit();
		var area = {
			新闻:{标题:"",正文:""},
			新房:{城中板块:"",城东板块:"",城南板块:"",城北板块:"",河西板块:"",仙林板块:"",江宁板块:"",江北板块:"",其他板块:""},
			二手房:{"30万以下":"","30-40万":"","40-50万":"","50-70万":"","70-90万":"","90-120万":"","120万以上":""}
		};
		$.each(area,function(p){$("#select1").append("<option value='"+p+"'>"+p+"</option>");});
		$("#select1").change(function(){
			$("#select2").selInit();
			$.each(area,function(p,x){
				if($("#select1 option:selected").text() == p)
				{
					$.each(x,function(c,cx){
						$("#select2").append("<option value='"+c+"'>"+c+"</option>");
					});
				}
			});
		});
	};
	})(jQuery);
