$(document).ready(function() {
    GetMonth();
	cc =  location.href.split("html")[1];
	if (cc == ""){
		GetNewsList(1,'','');
	}
	else{
	    if(cc.indexOf("wd") == true){
		    GetSearchList(1);
		}
		else
		{
	        car =  location.href.split("car=")[1];
		    GetNewsList(1,car,'');
		}
	}
});

function GetMonth(){
    var myDate = new Date();
	var m = myDate.getMonth() + 1;
	$("<option value='' selected>请选择月份</option>").appendTo("#nmonth");
	for (i = m; i >= 1; i--)
	{
		var mm = myDate.getFullYear() + "年" + i + "月";
		var vm = myDate.getFullYear() + "/" + i + "/1";
		$("<option value='"+vm+"'>"+mm+"</option>").appendTo("#nmonth");
	}
	for (j = 12; j >= 1; j--)
	{
		var mm2 = "2010年" + j + "月";
		var vm2 = "2010/" + j + "/1";
		$("<option value='"+vm2+"'>"+mm2+"</option>").appendTo("#nmonth");
	}
}

function GetNewsList(cpage,car,month) {
    $("#news_list").html("<img src='images/loading.gif' width='20px' height='20px'>");
    $.ajax({
        type: "GET",
        cache: false,
        dataType: "html",
        url: "InterFace/NewsList.aspx?cpage="+cpage+"&car="+car+"&month="+month,
        data: "",
        success: function(msg) {
            $("#news_list").html(msg);
        }
    });
}

function RightList(){
    month = $("#nmonth").val();
    car = $("#ncar").val();
    GetNewsList(1,car,month);
}

function GetSearchList(spage){
	searchw = location.href.split("wd=")[1];
    $("#news_list").html("<img src='images/loading.gif' width='20px' height='20px'>");
    $.ajax({
        type: "GET",
        cache: false,
        dataType: "html",
        url: "InterFace/SearchList.aspx?spage="+spage+"&search="+searchw,
        data: "",
        success: function(msg) {
            $("#news_list").html(msg);
        }
    });
}

