Array.prototype.unique=function(){var c=new Array();o:for(var b=0,e=this.length;b<e;b++){for(var a=0,d=c.length;a<d;a++){if(c[a]==this[b]){continue o}}c[c.length]=this[b]}return c};function resSort(b,e,d){var c=null;var a=null;switch(b){case 1:$(".dw-position").each(function(){c=this.id;a=c.replace("position_","")+"_div";if($("#"+c).html()!=e&&$("#"+a+":visible").length==1){$("#"+a).hide()}});if(!d){addFilter("reSort_actPosition",e,"refinePosition",1)}break;case 2:$(".dw-brand").each(function(){c=this.id;a=c.replace("brand_","")+"_div";if($("#"+c).html()!=e&&$("#"+a+":visible").length==1){$("#"+a).hide()}});if(!d){addFilter("reSort_actBrand",e,"refineBrand",2)}break;case 3:$(".dw-quality").each(function(){c=this.id;a=c.replace("quality_","")+"_div";if($("#"+c).html()!=e&&$("#"+a+":visible").length==1){$("#"+a).hide()}});if(!d){addFilter("reSort_actQuality",e,"refieQuality",3)}break;case 4:$(".result").each(function(){a=this.id;var g=$("#"+a).attr("rel");if(g.indexOf(e)==-1){$("#"+a).hide()}else{var h=a.replace("div","ul");$("#"+h+" li span.reSortYear").each(function(){if($(this).html()!=e){$(this).parent("li").hide()}})}});$(".dw-syear").html(e+"&nbsp;");if(!d){addFilter("reSort_actYear",e,"reSortOpt_yearna",4);setYearOptions(e)}break;case 5:var f="";$(".result").each(function(){a=this.id;if($("#"+a+":visible").length==1){$("#"+a+" .reSortTrim").each(function(){if($("#"+this.id+":visible").length==1){f+=$(this).html()+"-"}});if(f.indexOf(e)==-1){$("#"+a).hide()}}f=""});if(!d){addFilter("reSort_actTrim",e,"refieTrim",5)}break}c=null;a=null;buildFilter();$("#loading-overlay").remove()}function reSortYear(a){$("#dw_body_m").append('<div id="loading-overlay"><div class="ui-overlay"><div class="ui-widget-overlay"></div><div class="ui-widget-shadow ui-corner-all" style="width: 460px; height: 152px; position: absolute; left: 50px; top: 30px;"></div></div><div style="position: absolute; width: 437px; height: 130px;left: 50px; top: 30px; padding: 10px;" class="ui-widget ui-widget-content ui-corner-all"><div class="ui-dialog-content ui-widget-content" style="background: none; border: 0; padding:40px 0 0 41px"><p>Loading part data... Please wait as this can take up to 20 sec</p></div></div></div>');setTimeout("resSort(4, "+a+", false)",200)}function setYearOptions(e){var a=e+" "+veh();$("#dw_lnav_pl_data").after('<div id="lnav_veh_parts"><div class="ui-widget-header ui-corner-all dw_lnav_title" id="dw_lnav_pl_year"><span class="ui-icon ui-icon-wrench"></span>'+a+'</div><div id="dw_lnav_pl_data_year"><img src="/images/loader-cir-drip_ob.gif" id="dw_lnav_loadimg" /></div></div>');$("#dw_lnav_pl_data").hide();$("#dw_lnav_pl").hide();$(".s_t, .c_4_b").hide();setLeftNavVehicle(e+"-"+vehid());var b=getCookie("cvehArr");if(b==""){$("#dw_garage_d").html("")}var f=document.location.toString();f=f.split("/");var d=f[4];addCustomerVeh(a,"/garage/"+e+"-"+d+".html");setCustomerVeh();a=null;b=null;d=null;f=null;var c=getCookie("tipC");if(c==""){$("#reSort_act").after('<div id="filterTip"><span class="ui-icon ui-icon-triangle-1-n" style="margin:105px 0 0 35px; position:absolute; z-index:180"></span><div class="ui-widget" style="position:absolute; margin:95px 0 0 7px; z-index:150"><div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;"><p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span><strong>Did you know?</strong> You can now refine your result using the filter options above! Simply select one of the filter options to help trim down the results to find the part you are searching for.</p></div></div></div>');setTimeout(function(){$("#filterTip").hide()},6000);setCookie("tipC","true",365)}}function setLeftNavVehicle(a){var b,c;var d='{"arr":"'+a+'"}';$.ajax({type:"POST",url:"/wpac_data.asmx/leftnavallpartsveh",data:d,contentType:"application/json; charset=utf-8",dataType:"json",success:function(e){$("#dw_lnav_pl_data_year").html(e.d);$(".expand-veh").click(function(){c=$(this);b=c.attr("id").replace("toggle","cat");c.toggleClass("collapse");$("#"+b).slideToggle("normal")});$("#dw_lnav_pl_data_year ul").addClass("ui-widget-content");setHoverStates();var f=document.location.toString();var g=f.split("/")[5]+"/";f=null;$(".expand-veh").each(function(){c=$(this);b=c.attr("id").replace("toggle","cat");$("#"+b+" li a").each(function(){if($(this).attr("href").indexOf(g)!=-1){c.attr("style","font-weight:bold;color:#fa9300");c.toggleClass("collapse");$("#"+b).slideToggle("normal");$("#"+b+" li a").each(function(){if($(this).attr("href").indexOf(g)!=-1){$(this).attr("style","font-weight:bold;color:#fa9300")}})}})})}});b=null;c=null}function buildFilter(){if($("#dw_res_filter").length){$("#dw_res_filter").html("<center>Loading...</center>")}else{$("#reSort_act").after('<div id="dw_res_filter"><center>Loading...</center></div>')}var e="";var c="";var b="";var d="";var a="";if($("#reSort_actTrim").length==0){$(".reSortTrim").each(function(){var f=$(this).attr("id").substring($(this).attr("id").indexOf("_")+1)+"_div";if($(this).html()!=""&&$("#"+f+":visible").length==1&&$(this).parent("li").css("display")!="none"){c+=$(this).html()+"|"}});if(c!=""){c=c.substring(0,c.length-1);c=c.split("|");c=c.unique()}}else{c=""}e=(c.length>1&&$(".result:visible").length>1)?'<img src="/images/res_fil_vehicle_i.gif" id="res_fil_veh" />':"";c=null;if($("#reSort_actBrand").length==0){$(".dw-brand").each(function(){var f=$(this).attr("id").replace("brand_","")+"_div";if($(this).html()!=""&&$("#"+f+":visible").length==1&&$(this).parent("li").css("display")!="none"){b+=$(this).html()+"|"}});if(b!=""){b=b.substring(0,b.length-1);b=b.split("|");b=b.unique()}}else{b=""}e+=(b.length>1)?'<img src="/images/res_fil_brand_i.gif" id="res_fil_brand" />':"";b=null;if($("#reSort_actQuality").length==0){$(".dw-quality").each(function(){var f=$(this).attr("id").replace("quality_","")+"_div";if($(this).html()!=""&&$("#"+f+":visible").length==1&&$(this).parent("li").css("display")!="none"){d+=$(this).html()+"|"}});if(d!=""){d=d.substring(0,d.length-1);d=d.split("|");d=d.unique()}}else{d=""}e+=(d.length>0)?'<img src="/images/res_fil_quality_i.gif" id="res_fil_quality" />':"";d=null;if($("#reSort_actPosition").length==0){$(".dw-position").each(function(){var f=$(this).attr("id").replace("position_","")+"_div";if($(this).html()!=""&&$("#"+f+":visible").length==1&&$(this).parent("li").css("display")!="none"){a+=$(this).html()+"|"}});a=a.substring(0,a.length-1);a=a.split("|");a=a.unique()}else{a=""}e+=(a.length>1)?'<img src="/images/res_fil_position_i.gif" id="res_fil_position" />':"";a=null;if(e.length>0){$("#dw_res_filter").html(e);e=null;$("#dw_res_filter img").hover(function(){var f=$(this).attr("src").substring(0,$(this).attr("src").length-5);$(this).attr("src",f+"a.gif")},function(){var f=$(this).attr("src");if(f.indexOf("_c")==-1){f=f.substring(0,f.length-5);$(this).attr("src",f+"i.gif")}});$("#dw_res_filter img").click(function(){setFilOptDefault();setOptionsPanel();$("body").prepend('<div id="filter-pan-arrow"><img src="/images/fil_pnl_arr.png"  /></div>');var n=$(this).offset();var m=n.left;var l=n.top;var k=$(this).width()-23;var j=(m+k)+"px";var g=(l+34)+"px";$("#filter-pan-arrow").css({top:g,left:j});var h=$(this).attr("id");var f=$(this).attr("src").substring(0,$(this).attr("src").length-5);$(this).attr("src",f+"c.gif");switch(h){case"res_fil_veh":setTimeout("setTrimFilterO()",200);break;case"res_fil_brand":setTimeout("setBrandFilterO()",200);break;case"res_fil_quality":setTimeout("setQualityFilterO()",200);break;case"res_fil_position":setTimeout("setPositionFilterO()",200);break}})}else{$("#dw_res_filter").remove()}}function setFilOptDefault(){$("#dw_res_filter img").each(function(){var a=$(this).attr("src");a=a.substring(0,a.length-5);$(this).attr("src",a+"i.gif");a=null})}function setDefault(){$(".s_t, .c_4_b").show();$("#dw_lnav_pl_data").show();$("#dw_lnav_pl").show();$("#dw_res_filter").remove();$("#lnav_veh_parts").remove();$("#reSort_act").attr("rel","");$("#reSort_act").html("");$(".result").show();$(".result li").show();$(".dw-syear").html("");if($("#filter-pan").length){$("#filter-pan").remove();$("#filter-pan-arrow").remove()}$("#loading-overlay").remove()}function clearSort(a){setFilterLoadingRemove();var b=$("#reSort_act").attr("rel").toString();if(b.length<=1){b=b+","}if(!$.isArray(b)){b=b.split(",")}for(i=0;i<b.length;i++){if(a==b[i]){b.splice(i,1)}}removeFilter(a);if(b.length>0&&a!=4){$("#reSort_act").attr("rel",b.toString());$(".result").show();setTimeout("resSort(4, '"+$("#reSort_actYear").attr("title")+"', true)",400);for(i=0;i<b.length;i++){switch(parseFloat(b[i])){case 1:setTimeout("resSort("+parseFloat(b[i])+", '"+$("#reSort_actPosition").attr("title")+"', true)",400);break;case 2:setTimeout("resSort("+parseFloat(b[i])+", '"+$("#reSort_actBrand").attr("title")+"', true)",400);break;case 3:setTimeout("resSort("+parseFloat(b[i])+", '"+$("#reSort_actQuality").attr("title")+"', true)",400);break;case 5:setTimeout("resSort("+parseFloat(b[i])+", '"+$("#reSort_actTrim").attr("title")+"', true)",400);break}}}else{$("#reSort_act").attr("rel","")}}function removeFilter(a){switch(a){case 1:$("#reSort_actPosition").remove();break;case 2:$("#reSort_actBrand").remove();break;case 3:$("#reSort_actQuality").remove();break;case 4:setDefault();break;case 5:$("#reSort_actTrim").remove();break}}function addFilter(b,a,c,e){$("#reSort_act").append('<div id="'+b+'" class="ui-state-default ui-corner-all reSort_actI" onclick="javascript:clearSort('+e+')" title="'+a+'"><span class="ui-icon ui-icon-close" title="Remove Filter"></span>'+a+"</div>");var d=$("#reSort_act").attr("rel");if(d!=""){$("#reSort_act").attr("rel",d+","+e)}else{$("#reSort_act").attr("rel",e)}$(".reSort_actI").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")});d=null}function removeFilOptPnl(){$("#filter-pan").remove();$("#filter-pan-arrow").remove();setFilOptDefault()}function setOptionsPanel(){if($("#filter-pan").length){$("#filter-pan").remove();$("#filter-pan-arrow").remove()}var a='<div id="filter-pan"><div class="filter-c"><center><b>Loading Filter Options...</b></center></div><div class="filter-b"><a id="pnl-close-lnk" class="ui-state-default ui-corner-all fil-pnl-remove" href="javascript:void(0)" onclick="javascript:removeFilOptPnl()"><span class="ui-icon ui-icon-close"></span> close</a></div></div>';$("#reSort_act").after(a);a=null;$("#pnl-close-lnk").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")})}function setFilterLoading(){$("#dw_body_m").append('<div id="loading-overlay"><div class="ui-overlay"><div class="ui-widget-overlay"></div><div class="ui-widget-shadow ui-corner-all" style="width: 460px; height: 152px; position: absolute; left: 50px; top: 30px;"></div></div><div style="position: absolute; width: 437px; height: 130px;left: 50px; top: 30px; padding: 10px;" class="ui-widget ui-widget-content ui-corner-all"><div class="ui-dialog-content ui-widget-content" style="background: none; border: 0; padding:40px 0 0 41px"><p>Filtering data... Please wait as this can take up to 20 sec...</p></div></div></div>')}function setFilterLoadingRemove(){$("#dw_body_m").append('<div id="loading-overlay"><div class="ui-overlay"><div class="ui-widget-overlay"></div><div class="ui-widget-shadow ui-corner-all" style="width: 460px; height: 152px; position: absolute; left: 50px; top: 30px;"></div></div><div style="position: absolute; width: 437px; height: 130px;left: 50px; top: 30px; padding: 10px;" class="ui-widget ui-widget-content ui-corner-all"><div class="ui-dialog-content ui-widget-content" style="background: none; border: 0; padding:40px 0 0 41px"><p>Removing Filter... Please wait as this can take up to 20 sec...</p></div></div></div>')}function setFilterAction(b,a){removeFilOptPnl();setFilterLoading();setTimeout("resSort("+a+", '"+b+"', false)",200)}function setTrimFilterO(){var a;$(".reSortTrim").each(function(){var c=$(this).attr("id").substring($(this).attr("id").indexOf("_")+1)+"_div";if($(this).html()!=""&&$("#"+c+":visible").length==1&&$(this).parent("li").css("display")!="none"){a+="|"+$(this).html()}});a=a.split("|");a=a.unique();var b="<span>Select your vehicle trim:</span>";jQuery.each(a,function(){if(this!=""&&this!="undefined"){var c="'"+this+"'";b+='<a href="javascript:setFilterAction('+c+', 5)">'+this+"</a>"}});b+="";$(".filter-c").html(b);$(".filter-c a").prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>');a=null;b=null}function setBrandFilterO(){var a="";$(".dw-brand").each(function(){var c=$(this).attr("id").replace("brand_","")+"_div";if($(this).html()!=""&&$("#"+c+":visible").length==1&&$(this).parent("li").css("display")!="none"){a+="|"+$(this).html()}});a=a.split("|");a=a.unique();var b="<span>Select a brand:</span>";jQuery.each(a,function(){if(this!=""){var c="'"+this+"'";b+='<a href="javascript:setFilterAction('+c+', 2)">'+this+"</a>"}});b+="";$(".filter-c").html(b);$(".filter-c a").prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>');a=null;b=null}function setPositionFilterO(){var a="";$(".dw-position").each(function(){var c=$(this).attr("id").replace("position_","")+"_div";if($(this).html()!=""&&$("#"+c+":visible").length==1&&$(this).parent("li").css("display")!="none"){a+="|"+$(this).html()}});a=a.split("|");a=a.unique();var b="<span>Select a position:</span>";jQuery.each(a,function(){if(this!=""){var c="'"+this+"'";b+='<a href="javascript:setFilterAction('+c+', 1)">'+this+"</a>"}});b+="";$(".filter-c").html(b);$(".filter-c a").prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>');a=null;b=null}function setQualityFilterO(){var a="";$(".dw-quality").each(function(){var c=$(this).attr("id").replace("quality_","")+"_div";if($(this).html()!=""&&$("#"+c+":visible").length==1&&$(this).parent("li").css("display")!="none"){a+="|"+$(this).html()}});a=a.split("|");a=a.unique();var b="<span>Select part quality:</span>";jQuery.each(a,function(){if(this!=""){var c="'"+this+"'";b+='<a href="javascript:setFilterAction('+c+', 3)">'+this+"</a>"}});b+="";$(".filter-c").html(b);$(".filter-c a").prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>');a=null;b=null};