function PostSell(formname)
{
    var title=document.getElementById("title").value.replace(/(^\s+|\s+$)/g,"");//标题
    var type=document.getElementById("type").value.replace(/(^\s+|\s+$)/g,"");//类别
    var Bpic=document.getElementById("Bpic").value.replace(/(^\s+|\s+$)/g,"");//产地
    var Spic=document.getElementById("Spic").value.replace(/(^\s+|\s+$)/g,"");//生产厂商
    var AutoType=document.getElementById("AutoType").value.replace(/(^\s+|\s+$)/g,"");//车型系列
    var license=document.getElementById("license").value.replace(/(^\s+|\s+$)/g,"");//牌照情况
    var buyyear=document.getElementById("buyyear").value.replace(/(^\s+|\s+$)/g,"");//首次上牌时间
    var buymonth=document.getElementById("buymonth").value.replace(/(^\s+|\s+$)/g,"");//类别
    var txsgl=document.getElementById("txsgl").value.replace(/(^\s+|\s+$)/g,"");//行驶里程
    var price=document.getElementById("price").value.replace(/(^\s+|\s+$)/g,"");//出售价格
//    var dpaizhao=document.getElementById("dpaizhao").value.replace(/(^\s+|\s+$)/g,"");//是否带牌照
//    var dbaoxian=document.getElementById("dbaoxian").value.replace(/(^\s+|\s+$)/g,"");//是否带保险
    var tbs=document.getElementById("tbs").value.replace(/(^\s+|\s+$)/g,"");//变速方式

    if(title=="" || type=="" || Bpic=="" || Spic==""
            || AutoType=="" || license=="" || buyyear=="" || buymonth==""
             || txsgl=="" || price=="" || tbs=="")
    {
        document.getElementById("S").style.fontWeight="bolder";
        document.getElementById("S").innerHTML="标有*的项目必须填写";
        return;
    }
    formname.submit();
	setTimeout("document.getElementById('P').innerHTML=\"<span style='color:#000000;'>正在提交，请稍候......<span>\"",100);
}

function ClickSell(formname)
{
    var title=document.getElementById("title").value.replace(/(^\s+|\s+$)/g,"");//标题
    var type=document.getElementById("type").value.replace(/(^\s+|\s+$)/g,"");//类别
    var Bpic=document.getElementById("Bpic").value.replace(/(^\s+|\s+$)/g,"");//产地
    var Spic=document.getElementById("Spic").value.replace(/(^\s+|\s+$)/g,"");//生产厂商
    var AutoType=document.getElementById("AutoType").value.replace(/(^\s+|\s+$)/g,"");//车型系列
    var license=document.getElementById("license").value.replace(/(^\s+|\s+$)/g,"");//牌照情况
    var buyyear=document.getElementById("buyyear").value.replace(/(^\s+|\s+$)/g,"");//首次上牌时间
    var buymonth=document.getElementById("buymonth").value.replace(/(^\s+|\s+$)/g,"");//类别
    var txsgl=document.getElementById("txsgl").value.replace(/(^\s+|\s+$)/g,"");//行驶里程
    var price=document.getElementById("price").value.replace(/(^\s+|\s+$)/g,"");//出售价格
//    var dpaizhao=document.getElementById("dpaizhao").value.replace(/(^\s+|\s+$)/g,"");//是否带牌照
//    var dbaoxian=document.getElementById("dbaoxian").value.replace(/(^\s+|\s+$)/g,"");//是否带保险
    var tbs=document.getElementById("tbs").value.replace(/(^\s+|\s+$)/g,"");//变速方式
    var contact=document.getElementById("contact").value.replace(/(^\s+|\s+$)/g,"");//联系人
    var address=document.getElementById("address").value.replace(/(^\s+|\s+$)/g,"");//地址
    var tel=document.getElementById("tel").value.replace(/(^\s+|\s+$)/g,"");//联系电话

    if(title=="" || type=="" || Bpic=="" || Spic==""
            || AutoType=="" || license=="" || buyyear=="" || buymonth==""
             || txsgl=="" || price=="" || tbs=="" || contact=="" || address=="" || tel=="")
    {
        document.getElementById("S").style.fontWeight="bolder";
        document.getElementById("S").innerHTML="标有*的项目必须填写";
        return;
    }
    formname.submit();
	setTimeout("document.getElementById('P').innerHTML=\"<span style='color:#000000;'>正在提交，请稍候......<span>\"",100);
}


/**
 * 发布求购信息
 * @param formname
 */
function ClickBuy(formname)
{
    var Bpic=document.getElementById("Bpic").value.replace(/(^\s+|\s+$)/g,"");//产地
    var Spic=document.getElementById("Spic").value.replace(/(^\s+|\s+$)/g,"");//生产厂商
    var AutoType=document.getElementById("AutoType").value.replace(/(^\s+|\s+$)/g,"");//车型系列
    var tbs=document.getElementById("tbs").value.replace(/(^\s+|\s+$)/g,"");//变速方式
    var buyyear=document.getElementById("buyyear").value.replace(/(^\s+|\s+$)/g,"");//首次上牌时间
    var buymonth=document.getElementById("buymonth").value.replace(/(^\s+|\s+$)/g,"");//月
    var txsgl=document.getElementById("txsgl").value.replace(/(^\s+|\s+$)/g,"");//行驶里程
    var price=document.getElementById("price").value.replace(/(^\s+|\s+$)/g,"");//出售价格
    var contact=document.getElementById("contact").value.replace(/(^\s+|\s+$)/g,"");//联系人
    var tel=document.getElementById("tel").value.replace(/(^\s+|\s+$)/g,"");//联系电话
    var address=document.getElementById("address").value.replace(/(^\s+|\s+$)/g,"");//地址

    if(Bpic=="" || Spic==""|| AutoType=="" || tbs=="" || buyyear==""
            || buymonth==""|| txsgl=="" || price==""
            || contact=="" || tel==""|| address=="" )
    {
        document.getElementById("S").style.fontWeight="bolder";
        document.getElementById("S").innerHTML="标有*的项目必须填写";
        return;
    }
    formname.submit();
	setTimeout("document.getElementById('P').innerHTML=\"<span style='color:#000000;'>正在提交，请稍候......<span>\"",100);
}


var attachnum = 0;
function addattachment()
{
    if(attachnum <7)
    {
        attachnum++;
        findobj("attach_"+attachnum).style.display = "";
    }
    if(attachnum>=7)
    {
        findobj("addattachlink").disabled=true;
    }
}
function findobj(n, d) {
	var p, i, x;
	if(!d) d = document;
	if((p = n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if(x != d[n] && d.all) x = d.all[n];
	for(i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
	for(i = 0; !x && d.layers && i < d.layers.length; i++) x = findobj(n, d.layers[i].document);
	if(!x && document.getElementById) x = document.getElementById(n);
	return x;
}

var AllowImgSize=1024;
function load(Obj,sid)
{
    var tempImg=new Image();
    tempImg.onerror=function()
    {
        alert('对不起！您的照片格式不对，请上传*.jpg或*.jpeg或*.pmb格式的照片。');
        Obj.outerHTML=Obj.outerHTML;
        load_img("","img_s"+sid,sid);
    };

    tempImg.onreadystatechange=function()
    {
            this.ImgFileSize=Math.round(this.fileSize/1024*100)/100;
            if(AllowImgSize<this.ImgFileSize){
                Obj.outerHTML=Obj.outerHTML;
                alert("对不起！你的照片大小为"+this.ImgFileSize+"KB，超过允许大小：1024KB，请调整大小后上传！");
                load_img("","img_s"+sid,sid);
            }
    };
    tempImg.src=Obj.value;
}
function new_load_img_ie7(p_src,write_id)
{
//    var t_html;
//    if(p_src!='')
//    {
//        if(write_id=="img_s"+sid)
//        {
//            //t_html="<img src='"+p_src+"' onLoad='javascript:if(this.width>120){this.width=120;}if(this.height>120){this.height=120;}'>";
//            t_html="<img src='"+p_src+"' width='125'>";
//        }
//        else
//        {
//            t_html="<img src='"+p_src+"' width='125'>";
//        }
//    }
//    else
//    {
//        t_html="";
//    }
//    document.getElementById(write_id).innerHTML=t_html;

    if(p_src!="")
    {
        var newPreview = document.getElementById(write_id);
        newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = p_src.value;
        newPreview.style.width = "80px";
        newPreview.style.height = "60px";
    }
}
/**
 * 点击刷新,变验证码
 * @param url 生成验证码的JSP文件
 */
function reloadImage(url)
{
    document.getElementById("img").src = url;
}

/**
 * 二手车经销商留言
 * @param FormName
 */
function CheckMessage()
{
    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,"");
    var usedshopid=document.getElementById("usedshopid").value.replace(/(^\s+|\s+$)/g,"");
    if(name=="" || tel=="" || title==""
            || con=="" || code=="" || usedshopid=="")
    {
        alert("请输入完整的信息之后,在发布");
        return;
    }
    else
    {
        _MSGPOST_AJAX(usedshopid,name,tel,title,con,code);
        document.getElementById("Me").disabled=true;
        setTimeout('document.getElementById("Me").disabled=false',5000);
    }

}


function AutoQuery(formname)
{
    var Bpic=document.getElementById("Bpic").value.replace(/(^\s+|\s+$)/g,"");//选择品牌
    var Spic=document.getElementById("Spic").value.replace(/(^\s+|\s+$)/g,"");//选择车系
    var AutoType=document.getElementById("AutoType").value.replace(/(^\s+|\s+$)/g,"");//选择车型
    var buyyear=document.getElementById("buyyear").value.replace(/(^\s+|\s+$)/g,"");//上牌时间
    var SelKey=document.getElementById("SelKey").value.replace(/(^\s+|\s+$)/g,"");//关键字
    if(Bpic=="" && Spic=="" && AutoType==""&& buyyear=="" && SelKey=="")
    {
        alert("请至少选择一项条件进行查询");
        return;
    }
    formname.submit();
	setTimeout("document.getElementById('q').innerHTML=\"<span style='color:#000000;'>查询中<span>\"",100);
}


//创建AJAX对象
var xmlHttp;
function createXMLHttpRequest()
{
    if(window.ActiveXObject)
    {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        xmlHttp=new XMLHttpRequest();
    }
}

/**
 * 留言
 * @param UsedShopID Ex:经销商ID
 */
function _MSGPOST_AJAX(UsedShopID,Name,Tel,Title,Con,Code)
{
    createXMLHttpRequest();
    xmlHttp.open("POST","/2shou/messageaction.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("Sid").innerHTML="正在发表....";
                    document.getElementById("Sid").innerHTML=xmlHttp.responseText;
                    document.getElementById("name").value="";
                    document.getElementById("tel").value="";
                    document.getElementById("title").value="";
                    document.getElementById("con").value="";
                    document.getElementById("code").value="";
                }
                else
                {
                    document.getElementById("Sid").innerHTML="出现错误,请重试....";
                }
            }
        }
    xmlHttp.send("usedshopid="+UsedShopID+"&name="+Name+"&tel="+Tel+"&title="+Title+"&con="+Con+"&code="+Code);
}


/**
 * 求购信息查询
 * @param FormName form名称
 */
function _BUYCAR_SEARCH(FormName)
{
    var carage=document.getElementById("carage").value.replace(/(^\s+|\s+$)/g,"");//车龄
    var carprice=document.getElementById("carprice").value.replace(/(^\s+|\s+$)/g,"");//价格
    var Bpic=document.getElementById("Bpic").value.replace(/(^\s+|\s+$)/g,"");//产地
    var Spic=document.getElementById("Spic").value.replace(/(^\s+|\s+$)/g,"");//汽车品牌
    var AutoType=document.getElementById("AutoType").value.replace(/(^\s+|\s+$)/g,"");//车型系列
    if(carage=="" && carprice=="" && Bpic==""&& Spic==""&& AutoType=="")
    {
        alert("请至少选择一个条件查询");
        return;
    }
    else
    {
        FormName.submit();
        setTimeout("document.getElementById('S').innerHTML=\"<span style='color:#000000;'>查询中<span>\"",100);

    }
}


function _SEARCH_(FormName)
{
    var Bpic=document.getElementById("Bpic").value.replace(/(^\s+|\s+$)/g,"");//产地
    var Spic=document.getElementById("Spic").value.replace(/(^\s+|\s+$)/g,"");//汽车品牌
    var AutoType=document.getElementById("AutoType").value.replace(/(^\s+|\s+$)/g,"");//车型系列
    var price=document.getElementById("price").value.replace(/(^\s+|\s+$)/g,"");//价格
    var buyyear=document.getElementById("buyyear").value.replace(/(^\s+|\s+$)/g,"");//价格
    var buymonth=document.getElementById("buymonth").value.replace(/(^\s+|\s+$)/g,"");//价格
    var tbs=document.getElementById("tbs").value.replace(/(^\s+|\s+$)/g,"");//价格

    if(Bpic==""&& Spic==""&& AutoType=="" && price=="" && buyyear=="" && buymonth=="" && tbs=="")
    {
        alert("请至少选择一个条件查询");
        return;
    }
    else
    {
        FormName.submit();
        setTimeout("document.getElementById('S').innerHTML=\"<span style='color:#000000;'>查询中<span>\"",100);

    }
}

function _SEARCH_LIKE_(FormName)
{
    var SeardCode=document.getElementById("SeardCode").value.replace(/(^\s+|\s+$)/g,"");//产地
    if(SeardCode=="")
    {
        alert("请输入编号查询");
        return;
    }
    else
    {
        FormName.submit();
        setTimeout("document.getElementById('LD').innerHTML=\"<span style='color:#000000;'>查询中<span>\"",100);

    }
}


/**
 * 检测用户登录之后
 * @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);
}


function _SEARCH_KEY_(FormName)
{
    var key=document.getElementById("key").value.replace(/(^\s+|\s+$)/g,"");//产地
    if(key=="")
    {
        alert("请输入关键字查询");
        return;
    }
    else
    {
        FormName.submit();
        setTimeout("document.getElementById('k').innerHTML=\"<span style='color:#FFFFFF;'>查询中<span>\"",100);

    }
}