//创建AJAX对象
var xmlHttp;
function createXMLHttpRequest()
{
    if(window.ActiveXObject)
    {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        xmlHttp=new XMLHttpRequest();
    }
}

/**
 * 汽车资讯列表
 * @param YearMonth Ex:200901
 * @param AutoType 类别
 */
function _AUTO_LIST_AJAX(YearMonth,AutoType)
{
    createXMLHttpRequest();
    xmlHttp.open("POST","autolist.jsp",true);
    xmlHttp.setRequestHeader("Cache-Control","no-cache");
    xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
                if(xmlHttp.status==200)
                {
                    document.getElementById("AutoList").innerHTML="资讯正在加载中....";
                    document.getElementById("AutoList").innerHTML=xmlHttp.responseText;
                }
                else
                {
                    document.getElementById("AutoList").innerHTML="资讯正在加载中....";
                }
            }
        }
    xmlHttp.send("YearMonth="+YearMonth+"&AutoType="+AutoType);
}


/**
 * 刷新时,请时间定位到现在时候
 */
function SelectDate()
{
    var date=new Date();
    var year=date.getYear();
    var month=date.getMonth()+1;
    for (var i=0;i<document.all.Getyear.options.length;i++)
    {
        if(document.all.Getyear.options[i].text==year)
        {
            document.all.Getyear.options[i].selected=true;
            break;
        }
    }
    for (var i=0;i<document.all.GetMonth.options.length;i++)
    {
        if(document.all.GetMonth.options[i].text==month)
        {
            document.all.GetMonth.options[i].selected=true;
            break;
        }
    }
}


/**
 * 装载的时候调用
 * @param AutoType 类别
 */
function ShowNews(AutoType)
{
    //alert(date.getYear()+date.getMonth());

    window.onload = function()
    {
        _AUTO_LIST_AJAX("",AutoType);
        SelectDate();
    }
}

/**
 * 选择月份时调用
 * @param AutoType 类别
 */
function SelectChange(AutoType)
{
    var Year=document.getElementById("Getyear").value.replace(/-/g,"\/");//年份
    var Month=document.getElementById("GetMonth").value.replace(/-/g,"\/");//月份
    if(Year==""|| Month=="")
    {
        alert("请正确选择时间");
        return false;
    }
    else
    {
        _AUTO_LIST_AJAX(Year+Month,AutoType);
    }
}



/**
 * 东东评车-更多
 * @param YearMonth Ex:200901
 */
function _PC_LIST_AJAX(YearMonth)
{
    createXMLHttpRequest();
    xmlHttp.open("POST","pclistmore.jsp",true);
    xmlHttp.setRequestHeader("Cache-Control","no-cache");
    xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
                if(xmlHttp.status==200)
                {
                    document.getElementById("pc").innerHTML="正在加载中....";
                    document.getElementById("pc").innerHTML=xmlHttp.responseText;
                }
                else
                {
                    document.getElementById("pc").innerHTML="正在加载中....";
                }
            }
        }
    xmlHttp.send("YearMonth="+YearMonth);
}


/**
 * 装载的时候调用--东东评车更多
 */
function ShowPc()
{
    //alert(date.getYear()+date.getMonth());

    window.onload = function()
    {
        _PC_LIST_AJAX("");
        SelectDate();
    }
}

/**
 * 选择月份时调用--东东评车更多
 */
function PcSelectChange()
{
    var Year=document.getElementById("Getyear").value.replace(/-/g,"\/");//年份
    var Month=document.getElementById("GetMonth").value.replace(/-/g,"\/");//月份
    if(Year==""|| Month=="")
    {
        alert("请正确选择时间");
        return false;
    }
    else
    {
        _PC_LIST_AJAX(Year+Month);
    }
}
