/**
 * 检测用户登录之后
 * @param UsName 登录名
 * @param PsdWord 密码
 * @param FormName 窗体名称
 */
function CheckLogin(UsName,PsdWord,FormName)
{
    if(UsName=="" || PsdWord=="")
    {
        alert("请输入登录名和密码");
        return;
    }
    FormName.submit();
	setTimeout("document.getElementById('ShopLogin').innerHTML=\"<span style='color:#000000;'>正在登录...<span>\"",100);
}

/**
 * 点击下接列表,跳转的页面
 * @param PageValue
 */
function PP_jumpPage(PageValue)
{
	location.replace("pic.jsp?showpage="+PageValue);
}

/**
 * 点击刷新,变验证码
 * @param url 生成验证码的JSP文件
 */
function reloadImage(url)
{
    document.getElementById("img").src = url;
}


/**
 * 4S店留言
 * @param FormName
 */
function CheckMessage(FormName)
{
    var name=document.getElementById("name").value.replace(/(^\s+|\s+$)/g,"");
    var tel=document.getElementById("tel").value.replace(/(^\s+|\s+$)/g,"");
    var title=document.getElementById("title").value.replace(/(^\s+|\s+$)/g,"");
    var con=document.getElementById("con").value.replace(/(^\s+|\s+$)/g,"");
    var code=document.getElementById("code").value.replace(/(^\s+|\s+$)/g,"");
    if(name=="" || tel=="" || title==""
            || con=="" || code=="")
    {
        alert("请输入完整的信息之后,在发布");
        return;
    }
    FormName.submit();
	setTimeout("document.getElementById('MessageSend').innerHTML=\"<span style='color:#000000;'>请在发布...<span>\"",100);
}

/**
 * 4s店首页滑块
 * @param cityid 唯一ID号
 */
function SS_MM_city(cityid)
{
    for(var i=0;i<11;i++)
    {
        if(cityid==i)
        {
            document.getElementById("ShowCity"+i).className="btnover";
            document.getElementById("ShowCar"+i).style.display="";
        }
        else
        {
            document.getElementById("ShowCity"+i).className="btn";
            document.getElementById("ShowCar"+i).style.display="none";
        }
    }
}


/**
 * 4s店首页搜索
 * @param keyvar 关键字
 * @param FormName 窗体名称
 */
function SS_Search(keyvar,FormName)
{
    if(keyvar=="")
    {
        alert("请输入关键字搜索");
        return;
    }
    FormName.submit();
	setTimeout("document.getElementById('SearchSend').innerHTML=\"<span style='color:#000000;'>请在提交...<span>\"",100);
}


//创建AJAX对象
var xmlHttp;
function createXMLHttpRequest()
{
    if(window.ActiveXObject)
    {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        xmlHttp=new XMLHttpRequest();
    }
}

/**
 * 4S资讯列表
 * @param YearMonth Ex:200901
 */
function _AUTO_LIST_AJAX(YearMonth)
{
    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);
}


/**
 * 刷新时,请时间定位到现在时候
 */
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.getElementById("Getyear").value.replace(/-/g,"\/")==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;
        }
    }
}


/**
 * 装载的时候调用
 */
function ShowNews()
{
    //alert(date.getYear()+date.getMonth());

    window.onload = function()
    {
        _AUTO_LIST_AJAX("");
        SelectDate();
    }
}

/**
 * 选择月份时调用
 */
function SelectChange()
{
    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);
    }
}
