function HideSelectCarsInfoAndDealerInfo(){$("#selectTrimInfoDiv").hide(500),$("#selectTrimInfoDiv").empty(),$("#selectSeriesDiv").hide(500),$("#selectSeriesDiv").empty(),$("#noDealerInfoDiv").hide(500),$(".dc_online_xuanze").empty(),$("#HideDealerIDs").val("0"),$("#dealerInfoDiv").hide(500),$("#defaultSelectDealerDiv").show(500)}function GetUsedCarsColor(n,t,i){$.getJSON("/ashx/UsedCarsAjax/AjaxGetUsedCarsColor.ashx",{trimId:n,area:"",ZIP:Math.random()},function(n){n&&($("#"+i).empty(),$("#"+i).html(""),$.each(n,function(n,t){$(" ").appendTo("#"+i)}),$("#"+i).removeAttr("disabled"))})}function GetQuoteProvince(n,t){$.getJSON("/ashx/UsedCarsAjax/AjaxGetCityOrProvince.ashx",{type:n,province:t,ZIP:Math.random()},function(n){n&&($.each(n.ListProvince,function(n,t){$(" ").appendTo("#selProvince")}),n.DefaultCityInfo&&(GetQuoteCitys(n.DefaultCityInfo.CityCode.substr(0,4)),setTimeout(function(){$("#selProvince").val(n.DefaultCityInfo.CityCode.substr(0,4)),$("#selCity").removeAttr("disabled"),$("#selCity option[id='"+n.DefaultCityInfo.CityCode+"']").attr("selected",!0),$("#successSelectCity").show(),$("#errorSelectCity").hide()},500)))})}function GetQuoteCitys(n){$.getJSON("/ashx/UsedCarsAjax/AjaxGetCityOrProvince.ashx",{type:"0",province:n,ZIP:Math.random()},function(n){n&&$.each(n,function(n,t){$(" ").appendTo("#selCity")})})}function CheckFormParmsQuate(){var t,n;if($("#selProvince").val()=="-1"||$("#selCity").val()=="-1")return $("#errorSelectCity").show(),$("#successSelectCity").hide(),$("#selProvince").focus(),!1;if($("#selBrand").val()=="-1")return $("#errorSelectBrand").show(),$("#successSelectBrand").hide(),$("#selBrand").focus(),!1;if($("#selSeries").val()=="-1")return $("#errorSelectSeries").show(),$("#successSelectSeries").hide(),$("#selSeries").focus(),!1;if($.trim($("#quoteUserName").val())=="")return $("#successUserName").hide(),$("#errorUserName").show(),$("#quoteUserName").focus(),!1;if($("#quoteUserTel").val()!=""){t=/(^(0\d{2})-(\d{8})$)|(^(0\d{3})-(\d{7,8})$)|(^(0\d{2})-(\d{8})-(\d+)$)|(^(0\d{3})-(\d{7,8})-(\d+)$)|(^(0\d{10,11})$)|^13\d{9}|18\d{9}|15\d{9}$/;if(!t.test($("#quoteUserTel").val()))return $("#successUserTel").hide(),$("#errorUserTel").text("请输入正确的联系方式"),$("#errorUserTel").show(),$("#quoteUserTel").focus(),!1}else return $("#successUserTel").hide(),$("#errorUserTel").text("请输入联系电话"),$("#errorUserTel").show(),$("#quoteUserTel").focus(),!1;if($("#userEmail").val()!=""){n=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;if(!n.test($("#userEmail").val()))return $("#successEmail").hide(),$("#errorEmail").text("请输入正确的邮箱格式"),$("#errorEmail").show(),$("#userEmail").focus(),!1}}function GetSelectCarsHtml(n){var r=$("#selCity").val(),t="",i="";$.getJSON("/ashx/UsedCarsAjax/AjaxGetTrimInfoForAskedPrice.ashx",{brandid:$("#selBrand").val(),seriesid:$("#selSeries").val(),carid:$("#selTrim").val(),area:r,site:$("#selCity").val(),ZIP:Math.random()},function(r){var f,u;r&&(n==1&&(f=r.CarsDealerUrl+"/"+$("#selBrand option:selected").attr("id")+"-"+$("#selSeries option:selected").attr("id")+"-"+$("#selTrim").val()+"/",t=t+"
",t=t+" 已选择车型
",t=t+" ",$("#selectTrimInfoDiv").empty(),$("#selectTrimInfoDiv").html(t),$("#selectTrimInfoDiv").show(500),$("#selectSeriesDiv").hide(500),GetCarsStars("selTrim",5)),n==2&&(u=r.CarsDealerUrl+"/"+$("#selBrand option:selected").attr("id")+"-"+$("#selSeries option:selected").attr("id")+"/",i=i+" ",i=i+" 已选择系列
",i=i+" ",$("#selectSeriesDiv").empty(),$("#selectSeriesDiv").html(i),$("#selectTrimInfoDiv").hide(500),$("#selectSeriesDiv").show(500),GetCarsStars("selSeries",0)))})}function GetCarsStars(n,t){var i="/ashx/GetCarSeriesGrade.ashx?type='GetJson'&CommentType="+t+"&id="+$("#"+n).val()+"&date="+new Date;$.getJSON(i,function(n){if(n!=null){var t=eval(n);t.Table[0].SumAvg!=0&&$("#AvgPointDiv").html(t.Table[0].SumAvg),$("#starDiv").rater(null,{maxvalue:5,curvalue:GetScore(t.Table[0].SumAvg),spaceWidth:0,starWidth:17,ratingClass:"smallrating",enabled:!1})}})}function GetUsedCarsDealerInfo(n,t,i,r){var u="";$.getJSON("/ashx/UsedCarsAjax/AjaxGetDealerInfoForAskedPrice.ashx",{carid:n,seriesid:t,brandid:i,area:r,ZIP:Math.random()},function(n){n&&($.each(n,function(n,t){u=u+" ",u=u+" - ",u=t.ShortDealerName.length>8?u+""+t.ShortDealerName.substr(0,8)+"...":u+""+t.ShortDealerName,t.ServiceType>0&&(u=u+"【荐】"),u=u+"
- ",u=u+"
",t.Phone400?u=u+"电话:"+t.Phone400.substr(0,3)+"-"+t.Phone400.substr(3,3)+"-"+t.Phone400.substr(6)+"":t.ExtPhone?u=u+"电话:"+t.ExtPhone+"":t.Phone&&(u=u+"电话:"+t.Phone+""),u=u+"
",t.Address&&(u=t.Address.length>14?u+"地址:"+t.Address.substring(0,14)+"...":u+"地址:"+t.Address+""),u=u+"
",t.MaxPrice!=""&&t.MinPrice!=""&&(u=t.MaxPrice==t.MinPrice?u+"- "+t.MinPrice+"万
":u+"- "+t.MinPrice+"-"+t.MaxPrice+"万
"),u=u+"
"}),$(".dc_online_xuanze").empty(),$("#HideDealerIDs").val("0"),n.length<6?$(".dc_online_xuanze").attr("style","height:auto"):$(".dc_online_xuanze").attr("style","height:440px"),$(".dc_online_xuanze").html(u),n.length>0?($("#selectAllDealer").attr("checked",!1),$("#defaultSelectDealerDiv").hide(),$("#noDealerInfoDiv").hide(),$("#dealerInfoDiv").show(500),$("#selectAllDealer").bind("click",function(){if($("#selectAllDealer").attr("checked")){$("input[id^='checkDealer']").attr("checked","checked");var n="";$("input[id^='checkDealer']:checked").each(function(){n+=$(this).val()+","}),$("#HideDealerIDs").val(n)}else $("input[id^='checkDealer']").removeAttr("checked"),$("#HideDealerIDs").val("0")})):($("#noDealerInfoDiv").show(500),$("#dealerInfoDiv").hide(500),$("#HideDealerIDs").val("0"),$("#defaultSelectDealerDiv").hide(500)))})}function CheckDealer(){var t="";$("input[id^='checkDealer']:checked").each(function(){t+=$(this).val()+","}),t!=""?$("#HideDealerIDs").val(t):$("#HideDealerIDs").val("0"),$("input[id^='checkDealer']:checked").length==$("input[id^='checkDealer']").length?$("#selectAllDealer").attr("checked",!0):$("#selectAllDealer").attr("checked",!1)}function RefreshTrimSelectEx(n,t,i,r,u,f){ResetSelect(2,r,u),n>0&&$.getJSON("/ashx/GetCarSelect.ashx",{seriesId:n,isNewCar:t,isInMarket:i},function(n){var t;$.each(n,function(n,i){t!=i.TrimYear&&($("").appendTo("#"+u),t=i.TrimYear),$("").val(i.TrimId).text(i.TrimName).appendTo("#"+u)}),$("#"+f).attr("checked")?$("#"+u).attr("disabled",!0):$("#"+u).removeAttr("disabled")})}$(document).ready(function(){GetQuoteProvince("0","-1"),$("#selProvince").change(function(){$("#selCity").empty(),$("#selCity").html(""),$("#selCity").removeAttr("disabled"),$("#successSelectCity").hide(),$("#errorSelectCity").hide(),$(this).val()!="-1"?GetQuoteCitys($(this).val()):$("#selCity").attr("disabled",!0),HideSelectCarsInfoAndDealerInfo()}),$("#selCity").change(function(){$(this).val()!="-1"?($("#successSelectCity").show(),$("#errorSelectCity").hide(),$("#selSeries").val()!="-1"&&($("#selTrim").val()!="-1"?GetSelectCarsHtml(1):GetSelectCarsHtml(2),GetUsedCarsDealerInfo($("#selTrim").val(),$("#selSeries").val(),$("#selBrand").val(),$("#selCity").val()))):($("#successSelectCity").hide(),$("#errorSelectCity").hide(),HideSelectCarsInfoAndDealerInfo())}),LoadBrand("selBrand"),$("#selSeries").attr("disabled",!0),$("#selTrim").attr("disabled",!0),$("#selCarsColor").attr("disabled",!0),$("#selBrand").change(function(){RefreshSeriesSelect($(this).val(),"1","1","0","selSeries","selTrim"),$(this).val()!="-1"?($("#errorSelectBrand").hide(),$("#successSelectBrand").show()):($("#errorSelectBrand").hide(),$("#successSelectBrand").hide()),$("#errorSelectSeries").hide(),$("#successSelectSeries").hide(),$("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").hide(),$("#chkOtherTrim").attr("checked",!1),$("#otherTrimInput").parent("div").hide(),$("#otherTrimInput").val(""),$("#selCarsColor").empty(),$("#selCarsColor").html(""),$("#selCarsColor").attr("disabled",!0),$("#successSelectCarsColor").hide(),HideSelectCarsInfoAndDealerInfo()}),$("#selSeries").change(function(){RefreshTrimSelectEx($(this).val(),"1","1","selSeries","selTrim","chkOtherTrim"),$(this).val()!="-1"?($("#errorSelectSeries").hide(),$("#successSelectSeries").show()):($("#errorSelectSeries").hide(),$("#successSelectSeries").hide()),$("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").hide(),$("#chkOtherTrim").attr("checked",!1),$("#otherTrimInput").parent("div").hide(),$("#otherTrimInput").val(""),$("#selCarsColor").empty(),$("#selCarsColor").html(""),$("#selCarsColor").attr("disabled",!0),$("#successSelectCarsColor").hide(),$("#selectTrimInfoDiv").hide(500),$("#selectTrimInfoDiv").empty(),$(this).val()!="-1"?$("#selCity").val()!="-1"&&(GetSelectCarsHtml(2),GetUsedCarsDealerInfo($("#selTrim").val(),$("#selSeries").val(),$("#selBrand").val(),$("#selCity").val())):HideSelectCarsInfoAndDealerInfo()}),$("#selTrim").change(function(){$(this).val()!="-1"?($("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").show(),GetUsedCarsColor($(this).val(),"","selCarsColor")):($("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").hide(),$("#selectTrimInfoDiv").hide(500),$("#selectTrimInfoDiv").empty()),$("#selCarsColor").empty(),$("#selCarsColor").html(""),$("#selCarsColor").attr("disabled",!0),$("#successSelectCarsColor").hide(),$("#selCity").val()!="-1"?($(this).val()!="-1"?GetSelectCarsHtml(1):GetSelectCarsHtml(2),GetUsedCarsDealerInfo($("#selTrim").val(),$("#selSeries").val(),$("#selBrand").val(),$("#selCity").val())):($("#successSelectCity").hide(),$("#errorSelectCity").show(),$("#selCity").focus(),HideSelectCarsInfoAndDealerInfo())}),$("#chkOtherTrim").bind("click",function(){if($("#selBrand").val()!="-1"&&$("#selSeries").val()!="-1")$(this).attr("checked")?($("#otherTrimInput").parent("div").show(),$("#selTrim").val("-1"),$("#selTrim").attr("disabled",!0),$("#otherTrimInput").bind("blur",function(){$.trim($(this).val())!=""?($(this).val($.trim($(this).val())),$("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").show()):($("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").hide(),$(this).val(""))}),$("#selectTrimInfoDiv").hide(500),$("#selectTrimInfoDiv").empty()):($("#selTrim").children().length>1?$("#selTrim").removeAttr("disabled"):$("#selTrim").val("-1"),$("#otherTrimInput").parent("div").hide(),$("#otherTrimInput").val("")),$("#errorCheckOtherTrim").hide(),$("#successCheckOtherTrim").hide(),$("#selCarsColor").empty(),$("#selCarsColor").html(""),$("#selCarsColor").attr("disabled",!0),$("#successSelectCarsColor").hide(),$("#selCity").val()!="-1"?(GetSelectCarsHtml(2),GetUsedCarsDealerInfo($("#selTrim").val(),$("#selSeries").val(),$("#selBrand").val(),$("#selCity").val())):HideSelectCarsInfoAndDealerInfo();else{if($("#selBrand").val()=="-1")return $("#errorSelectBrand").show(),$("#successSelectBrand").hide(),!1;if($("#selSeries").val()=="-1")return $("#errorSelectSeries").show(),$("#successSelectSeries").hide(),HideSelectCarsInfoAndDealerInfo(),!1}}),$("#quoteUserName").bind("blur",function(){var n=$.trim($(this).val());n.IsEmpty()?($("#errorUserName").text("请输入姓名"),$("#successUserName").hide(),$("#errorUserName").show()):n.Verify()?($("#successUserName").show(),$("#errorUserName").hide()):($("#successUserName").hide(),$("#errorUserName").show(),$("#errorUserName").text("姓名不能含有无效字符"))}),$("#quoteUserTel").bind("blur",function(){var n=$.trim($(this).val());n.IsEmpty()?($("#successUserTel").hide(),$("#errorUserTel").text("请输入联系电话"),$("#errorUserTel").show(),$(this).val("")):n.IsMobile()||n.IsPhone()?($("#successUserTel").show(),$("#errorUserTel").hide()):($("#successUserTel").hide(),$("#errorUserTel").text("请输入正确的联系方式"),$("#errorUserTel").show())}),$("#userEmail").bind("blur",function(){if($(this).val()!=""){var n=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;n.test($(this).val())?($("#successEmail").show(),$("#errorEmail").hide()):($("#successEmail").hide(),$("#errorEmail").text("请输入正确的邮箱格式"),$("#errorEmail").show())}else $("#successEmail").hide(),$("#errorEmail").hide()}),$("#selCarsColor").change(function(){$(this).val()!="-1"?$("#successSelectCarsColor").show():$("#successSelectCarsColor").hide()}),$("#userDescript").bind("keyup",function(){$.trim($(this).val()).length>500?$(this).val($(this).val().substring(0,500)):$(this).val($.trim($(this).val()))})});