var IndexScripts=function(){function n(t){n.Instance=this;n.Instance.jsParam=t}return n.prototype.DocumentReady=function(){var i=this,t=i.jsParam.Regioncode,r=document.getElementById(t),n;r!=null&&(n=document.getElementById(t),n.setAttribute("src",n.getAttribute("data-src")))},n.Instance=null,n}(),LocationScripts=function(){function n(t){n.Instance=this;n.Instance.jsParam=t}return n.prototype.DocumentReady=function(){function i(){var n=document.getElementById("small-map-cover"),t=document.getElementById("smallMap");typeof n!="undefined"&&n!=null&&(n.style.display="block",n.style.width="105px",n.style.height="105px",n.style.left=$(t).offset().left,n.style.top=$(t).offset().top)}function t(){var r="",u="",i,t;$("select#Locations").prop("selectedIndex")>0&&(u=$("select#Locations").val());$("#PostalCode1").val().length>0&&(r=$("#PostalCode1").val());lm.Omniture.doTagNearestLocationSelect("@Aurora.Models.AuroraIdentity.Current.MemberId");i=$("#nearest-location > #nearest-location-loading");t=$("#nearest-location > #nearest-location-complete");t.addClass("hidden");t.html("");i.removeClass("hidden");$.ajax({type:"POST",url:n.jsParam.Nearestlocation,data:{zipcode:r,yardnumber:u},success:function(n){i.addClass("hidden");t.html(n);t.removeClass("hidden")}})}function r(n){return/(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/i.test(n)}function u(n){return/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(n)}var n=this;i();$("select#Locations option").length>0&&$("select#Locations option").each(function(){$.isNumeric($(this).val())?$(this).addClass("nearestlocation_yard"):($(this).addClass("nearestlocation_yardcountry"),$(this).attr("disabled","disabled"))});$("#changelocation").click(function(){var i=$("#nearest-location > #nearest-location-loading"),t=$("#nearest-location > #nearest-location-complete");t.addClass("hidden");t.html("");i.removeClass("hidden");$.ajax({url:n.jsParam.ChangeLocationurl,success:function(n){i.addClass("hidden");t.html(n);t.removeClass("hidden")}})});$("#submityard").click(function(){$("li.liPostalCode").removeClass("error");$("li.liPostalCode .optional").html("");$("li.liLocation").removeClass("error");$("li.liLocation .optional").html("");$("li.liErrorMessage").show();$("li.liErrorMessage").html("");$("#PostalCode1").val().length<1&&$("select#Locations").prop("selectedIndex")<1?($("li.liPostalCode").addClass("error"),$("li.liPostalCode .optional").html("<span class='field-validation-error'><\/span>"+n.jsParam.FieldValidationErrorZipCode),$("li.liLocation").addClass("error"),$("li.liLocation .optional").html("<span class='field-validation-error'><\/span>"+n.jsParam.FieldValidation),$("li.liErrorMessage").hide()):n.jsParam.Geo=="us"&&$("#PostalCode1").val().length>0?r($("#PostalCode1").val())?t():($("li.liPostalCode").addClass("error"),$("li.liPostalCode .optional").html("<span class='field-validation-error'><\/span>"+n.jsParam.LocationErrors),$("li.liErrorMessage").hide()):n.jsParam.Geo=="uk"&&$("#PostalCode1").val().length>0?u($("#PostalCode1").val())?t():($("li.liPostalCode").addClass("error"),$("li.liPostalCode .optional").html("<span class='field-validation-error'><\/span>"+n.jsParam.LocationErrors),$("li.liErrorMessage").hide()):$("select#Locations").prop("selectedIndex")>0&&t()})},n.Instance=null,n}(),VehicleFinderScripts=function(){function n(t){n.Instance=this;n.Instance.jsParam=t}return n.prototype.DocumentReady=function(){function b(n){return/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(n)}function k(n){return/(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/i.test(n)}function e(){$("#errormessageZIP").hide();var n=document.getElementById("validErrorZIP");n.innerHTML=""}function o(){$("#vehicleFinderDiv").height("auto");$(".full-width").css("position","relative")}function c(n){var r=document.getElementById(n),u=r.parentNode,i=r.cloneNode(!1),t;return i.disabled=!0,u.replaceChild(i,r),t=document.createElement("option"),t.text="All Models",t.value="",i.add(new Option(t.text,t.value),null),i}function y(n){for(var i,r=document.getElementById("ddlModels"),t=0;t<n.length;t++)n[t].VehicleModel.length>0&&(i=document.createElement("option"),i.text=n[t].VehicleModel,i.value=n[t].VehicleModel,r.add(new Option(i.text,i.value,null)));r.selectedIndex=0;r.disabled=!1}function d(t){var t=$("#ddlMakes").val();$("#vehicleType").val()!="C"&&(t!=""?(document.getElementById("ddlModels").disabled=!0,$.get(n.jsParam.GetModel,{make:t},function(){}).success(function(n){c("ddlModels");y(JSON.parse(n));$.event.trigger({type:"modelChange"})})):c("ddlModels"))}function g(){document.getElementById("ddlMakes").disabled=!0;document.getElementById("ddlModels").disabled=!0;$("#ddlModels").val("");$("#vehicleType").val()!=""&&$.post(n.jsParam.GetMakes,{vehicleType:$("#vehicleType").val()},function(t){var r=$("#ddlMakes"),u=r.prop("options"),i;$("option",r).remove();i=document.createElement("option");i.text=n.jsParam.SelectMakeDropdown;i.value="";u[0]=new Option(i.text,i.value);$.each(t,function(n,t){i=document.createElement("option");i.text=t.MakeDesc;i.value=t.VehicleMake;u[n+1]=new Option(i.text,i.value)});document.getElementById("ddlMakes").disabled=!1;$.event.trigger({type:"makeChange"})},"json")}function nt(){$("#vehicleType").val()!=""&&($("#vehicleType").val()=="H"?(document.getElementById("yearFrom").disabled=!0,document.getElementById("yearTo").disabled=!0):(document.getElementById("yearFrom").disabled=!1,document.getElementById("yearTo").disabled=!1))}function r(n,t){return $(n).prop("disabled")||$(n+" :selected").index()<=t?!1:!0}var n=this,i,l,s,a,h,v,u,p,t,w;for(function(n){n.widget("aurora.vehicleFinder",{options:{modelValSelector:null,modelsSelector:null,makesSelector:null,getModelsAction:null},_create:function(){this._bindEvents();this._ensureControls()},_bindEvents:function(){var i=this,t=this.options,u=this.element.find(t.makesSelector),r;u.live("change",function(){i.element.find(t.makesSelector).val(n(this).val())});r=this.element.find(t.modelsSelector);r.live("change",function(){i.element.find(t.modelValSelector).val(n(this).val())})},_onModelChanged:function(t){var r=this,i=this.options;this.element.find(i.modelsSelector).attr("disabled","disabled");n.get(i.getModelsAction,{make:t},function(){}).success(function(t){c("ddlModels");y(JSON.parse(t));var u=n(i.modelValSelector);r.element.find(i.modelsSelector).find("option").filter(function(){return n(this).val()==u.val()}).attr("selected",!0)})},_ensureControls:function(){var r=n(".vehicle-finder-location input[type=radio]:checked"),t,i,u;r.length>0&&r.closest("tr").addClass("active").next("tr.selector").show();t=this.options;i=this.element.find(t.makesSelector).val();i!=""?this._onModelChanged(i):(u=this.element.find(t.modelsSelector),u.attr("disabled","disabled"))}})}(jQuery),$("#zip").focus(function(){e()}),$("#vehicleType").change(function(){g();nt()}),$("#ddlMakes").change(function(){d()}),i=document.getElementById("vehicleType"),$("#RadioGroup1_0").click(function(){$("#rowLocation").show();$("#rowState").hide();$("#rowZip").hide();var i=$("#vehicleFinderDiv"),n=$("#yearFrom").val(),t=$("#yearTo").val(),r=$("#companyCode_vf").val();parseInt(n)>parseInt(t)&&o();e()}),$("#RadioGroup1_1").click(function(){$("#rowLocation").hide();$("#rowState").show();$("#rowZip").hide();e()}),$("#RadioGroup1_2").click(function(){$("#rowLocation").hide();$("#rowState").hide();$("#rowZip").show()}),$.fn.sortOptions=function(){$(this).each(function(){var n=$(this).children("option");return n.sort(function(n,t){return n.text>t.text?1:-1}),$(this).empty().append(n)})},l=document.getElementById("location"),l&&(s=document.createElement("option"),s.text="",l.add(new Option(s.text,s.value,null,!0))),$("#stateFacility").sortOptions(),a=document.getElementById("stateFacility"),h=document.createElement("option"),h.text="All Locations",h.value="",a.insertBefore(h,a.options[0]),$("#location").sortOptions(),$("#location").prop("selectedIndex",0),$("#stateFacility").prop("selectedIndex",0),$("#RadioGroup1_0").prop("checked",!0),$("#RadioGroup1_0").click(),t=0;t<i.options.length;t++)if(i.options[t].value=="V"){i.selectedIndex=t;break}for(v=document.getElementById("ddlMakes"),u=document.createElement("option"),u.text="Select a Make",u.text=n.jsParam.SelectMakeDropdown,u.value="",v.insertBefore(u,v.options[0]),$("#ddlMakes").prop("selectedIndex",0),i=document.getElementById("yearFrom"),p=document.getElementById("yearTo"),t=0;t<i.options.length;t++)if(i.options[t].value==p.value-11){i.selectedIndex=t;break}if($("form#searchbytype").vehicleFinder({modelValSelector:".vehicle_model_value",modelsSelector:"#ddlModels",makesSelector:"#ddlMakes",getModelsAction:n.jsParam.GetModelz}),w=n.jsParam.Postal,w!=""&&$("input[name=RadioGroup][value=Zip/Postal Code]").attr("checked",!0),$("#btnSubmit").click(function(t){var p=$("#yearFrom").val(),w=$("#yearTo").val(),f="true",h,i,u,v,y;parseInt(p)>parseInt(w)?($("#vfYearError").show(),f="false",o(),t.preventDefault()):$("#vfYearError").hide();var s=$("#companyCode_vf").val(),c=$("#zip").val(),l=!0,a=document.getElementById("validErrorZIP");$("#Sort").val("sd");$("#RadioGroup1_2").is(":checked")&&($("#Sort").val("zip"),h=App.Util.GetSearchPreferencesFromCookie(),h.SortZip=$("#zip").val(),App.Util.SetSearchPreferencesToCookie(h),$("#rowLocation").hide(),$("#zip").val().length==0?($("#errormessageZIP").show(),a.innerHTML=s=="US"?n.jsParam.VehicleZip:n.jsParam.UKZip,f="false",o(),t.preventDefault()):(l=s=="UK"?b(c):k(c),l||($("#errormessageZIP").show(),a.innerHTML=s=="US"?n.jsParam.VehicleInvalidZip:n.jsParam.VehicleInvalidUKZip,f="false",o(),t.preventDefault())));$("[name^='RadioGroup']").click(function(){e()});i=(r("#yearFrom",-1)?$("#yearFrom option:selected").text():"")+(r("#yearTo",-1)?"-":"")+(r("#yearTo",-1)?$("#yearTo option:selected").text():"")+(r("#yearFrom",-1)||r("#yearTo",-1)?",":"")+(r("#ddlMakes",0)?$("#ddlMakes option:selected").val():"")+(r("#ddlModels",0)?",":"")+(r("#ddlModels",0)?$("#ddlModels option:selected").val():"");u=i;s=="UK"&&($("#ddlDocumentTypes :selected").index()!=0&&(i=i.concat(","),u=u.concat(","+$("#ddlDocumentTypes option:selected").val())),i=i.concat($("#ddlDocumentTypes :selected").index()!=0?$("#ddlDocumentTypes option:selected").text():""),i.substring(0,1)==","&&(i=i.substring(1,i.length)));$("#RadioGroup1_0").is(":checked")&&(i=i.concat($("#ddlModels :selected").index()!=0||$("#ddlMakes :selected").index()!=0||$("ddlDocumentTypes :selected").index()!=0?",":"").concat($("#stateFacility :selected").index()!=0?$("#stateFacility option:selected").text():""),u=u.concat($("#ddlModels :selected").index()!=0||$("#ddlMakes :selected").index()!=0||$("ddlDocumentTypes :selected").index()!=0?",":"").concat($("#stateFacility :selected").index()!=0?"loc":""));$("#RadioGroup1_2").is(":checked")&&(i=i.concat($("#ddlModels :selected").index()!=0||$("#ddlMakes :selected").index()!=0||$("ddlDocumentTypes :selected").index()!=0?",":"").concat($("#zip").val().length!=0?$("#zip").val():""),u=u.concat($("#ddlModels :selected").index()!=0||$("#ddlMakes :selected").index()!=0||$("ddlDocumentTypes :selected").index()!=0?",":"").concat($("#zip").val().length!=0?"zip":""));$("#searchTitle").val(i.toString());$("#cn").val(u.toString());v=$("#ddlDocumentTypes :selected").index()!=0?$("#ddlDocumentTypes option:selected").val():"";$("#vf_titlgroup").val(v);y=$("#searchbytype").serialize();App.Util.SetVehicleFinderCookie(y);f=="true"&&($("#RadioGroup1_0").is(":checked")&&($("#location").prop("selectedIndex",0),$("#zip").val("")),$("#RadioGroup1_1").is(":checked")&&($("#stateFacility").prop("selectedIndex",0),$("#zip").val("")),$("#RadioGroup1_2").is(":checked")&&($("#location").prop("selectedIndex",0),$("#stateFacility").prop("selectedIndex",0)))}),$.cookie("vehicleFinder")!=null){var f=App.Util.GetVehicleFinderCookie(),tt=$("#companyCode_vf").val(),it=GetFormFieldValue(f,"companyCode_vf"),rt=GetFormFieldValue(f,"Make"),ut=GetFormFieldValue(f,"ModelGroups");if(tt==it){$(document).on("makeChange",function(){$("#ddlMakes").val(rt);$(document).off("makeChange")});$(document).on("modelChange",function(){$("#ddlModels").val(ut);$(document).off("modelChange")});DeserializeForm(f,"#searchbytype");RaiseFormEvents(f,"#searchbytype")}}},n.Instance=null,n}()