(function(){var h=this,d=h.jQuery,b=(h.DDC=(h.DDC||{})),g=false,i=false,c=false,e,f,a=function(j){d("#modelSelector, #makeSelector").height(parseInt(j,10));if(d.browser.msie&&(d.browser.version==="6.0")){d("#showroom .default #primaryContent").css({height:parseInt(j,10)+100})}};d.extend({lazyLoad:function(l){l=d.extend({prefix:"",packages:[],callback:function(){}},l);var k=0,j=function(){if((l.packages instanceof Array)&&l.packages.length){d.getScript((l.prefix||"")+l.packages[k],function(){if(k===l.packages.length-1){if(typeof l.callback==="function"){l.callback.apply(h)}}else{k++;j()}})}};d(j)},viewer:function(j){j=d.extend(true,{packages:[],thickboxPackage:"/v8/global/js/thickbox/thickbox-3.1-mod.pack.js",selectedTab:null,data:{labels:b.i18n.labels,title:d("#primaryContent > h3:eq(0)").text(),exteriorImages:null,interiorImages:null,colors:null,spins:null,videos:null}},j);var l=function(){g=true;d("body").append('<div id="viewerWrapper"><div id="viewer"></div></div>');(new h.EJS({url:"/v8/tools/automotive/showroom/v4/components/viewer.ejs",type:"["})).update("viewer",j.data);d("#viewer .ui-tabs-nav a").each(function(){d(this).attr("href","#"+d(this).attr("href").replace(/.*\#/,""))});e=d("#viewer .ui-tabs-nav").tabs({select:function(o,n){if(d(n.tab).attr("href").indexOf("#viewerExt")!==-1){d("#viewerExt ul.photos:not(.slideshow)").slideshow({thumbs:"#viewerExtThumbs"})}if((d(n.tab).attr("href").indexOf("#viewerSpin")!==-1)&&!i){i=true;d("#viewerSpin li:eq(0)").click()}if((d(n.tab).attr("href").indexOf("#viewerVid")!==-1)&&!c){c=true;d("#viewerVid li:eq(0)").click()}}});d("#viewer .jcarousel-list:not(.jcarousel-exclude)").jcarousel({buttonNextHTML:"<a />",buttonPrevHTML:"<a />"});d("#viewer ul.swatches").swatches("#viewerColorImage img","#viewer span.colorName");d("#viewer li.spinLink").click(function(){d("#viewerSpinMovie").attachQuickTimeMovie(d("a",this).attr("href"));return false});d("#viewerInt ul.photos").slideshow({thumbs:"#viewerIntThumbs"});d("#viewer li.videoLink").click(function(){b.embedVideoPlayer({divName:"ddcvideoplayer",playlistXmlPath:d("a",this).attr("href"),swfId:"ddcvideoplayer_000",autoPlay:true,width:"385",height:"290"});d("#viewerVid > p").text(d("a",this).attr("title"));return false})},m=function(){setTimeout(function(){d("body").removeClass("mediaGallery")},500)},k=function(){h.tb_show("","#TB_inline?height=500&width=760&inlineId=viewerWrapper",null);d("body").addClass("mediaGallery");if(j.selectedTab){f=d("a",e).index(d("a[href*=#"+j.selectedTab+"]",e));d(e).tabs("select",f);if(!isNaN(j.selectedSwatch)){d("#viewer ul.swatches a").eq(j.selectedSwatch).click()}}d("#TB_closeAjaxWindow, #TB_overlay").click(m)};if(!h.tb_show&&j.packages&&j.thickboxPackage){j.packages.push(j.thickboxPackage)}if(!g&&j.packages){d.lazyLoad({packages:j.packages,callback:function(){l();k()}})}else{k()}return d}});d.fn.extend({filterSlider:function(j){var k=function(q,p){var l=q.toString().split("."),o=l[0],m=l.length>1?"."+l[1]:"",n=/(\d+)(\d{3})/;while(n.test(o)){o=o.replace(n,"$1,$2")}return p?(p+o+m):(o+m)};return d(this).each(function(){var n=parseInt(d("span.min",d(this).parent()).attr("rel"),10)||0,l=parseInt(d("span.max",d(this).parent()).attr("rel"),10)||100,q=parseInt(d("span.min",d(this).parent().parent()).attr("rel"),10)||0,m=parseInt(d("span.max",d(this).parent().parent()).attr("rel"),10)||100,r=true,o,p=d(this).slider({min:n,max:l,step:1,values:[q,m],range:true,slide:function(v,u){var t=d(u.handle).parents("#price").size()?"$":"",s=k(Math.round(u.value),t);d(u.handle).attr("title",s);d(d(u.handle).hasClass("ui-slider-handle-min")?".min":".max",d(u.handle).parent().parent().parent()).text(s).attr("rel",Math.round(u.value));if(r){clearTimeout(o);o=setTimeout(function(){d(p).trigger("change",[d(u.handle).parent().parent().parent().parent()[0].id,d(u.handle).parent().parent().parent().find("span.min").attr("rel"),d(u.handle).parent().parent().parent().find("span.max").attr("rel")])},250)}}}).hover(function(){d(this).addClass("ui-slider-hover")},function(){d(this).removeClass("ui-slider-hover")}).bind("reset",function(){var u=d(p).parent().parent().is("#price")?"$":"",s=k(Math.round(q),u),t=k(Math.round(m),u);d(".ui-slider-handle-min",this).attr("rel",q).attr("title",s);d(".ui-slider-handle-max",this).attr("rel",m).attr("title",t);d(this).slider("values",0,[q]);d(this).slider("values",1,[m]);d(p).trigger("change",[d(p).parent().parent()[0].id,d(p).parent().parent().find(".min").text(s).attr("rel",q).attr("rel"),d(p).parent().parent().find(".max").text(t).attr("rel",m).attr("rel")])});d("a",this).attr("href","#").click(function(){return false});d(".ui-slider-handle",this).hover(function(){d(this).addClass("ui-slider-handle-hover")},function(){d(this).removeClass("ui-slider-handle-hover")})})},attachQuickTimeMovie:function(l,k,j){return d(this).each(function(){var n=this,m;if(navigator.userAgent.indexOf("MSIE")!==-1){n.innerHTML=['<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="',(k)?parseInt(k,10):320,'" height="',(j)?parseInt(j,10):240,'" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="',l,'"><param name="autoplay" value="true"><param name="controller" value="false"></object>'].join("")}else{m=document.createElement("embed");m.type="video/quicktime";m.src=l;m.width=(k)?parseInt(k,10):"320";m.height=(j)?parseInt(j,10):"240";m.autoplay="true";m.controller="false";this.innerHTML="";this.appendChild(m)}})},slideshow:function(n){n=d.extend({thumbs:null,prevLabel:"Previous",nextLabel:"Next",speed:500,timeout:8000},n);var m=this,k=d("li",this),l=d("li",n.thumbs),j=parseInt(Math.random()*1000000,10),o=d(l).size()<2?" hidden":"";d(this).parent().prepend('<a id="prevImage'+j+'" class="prev'+o+'" href="#"><span>'+n.prevLabel+'</span></a><a id="nextImage'+j+'" class="next'+o+'" href="#"><span>'+n.nextLabel+"</span></a>");d("a",this).click(function(){return false});if(d(l).size()===1){d(l).click(function(){return false})}d(this).cycle({speed:n.speed,timeout:n.timeout,pause:true,next:"#nextImage"+j,prev:"#prevImage"+j,before:function(p,t){var q=d(k).index(this),s=d(this).next("li"),r=d(s).next("li");d(l).removeClass("selected").eq(q).addClass("selected");if(d("> span span",this).size()){d("> span",this).html('<img src="'+d("> span span",this).attr("title")+'" alt="" />')}if(d("> span span",s).size()){d("> span",s).html('<img src="'+d("> span span",s).attr("title")+'" alt="" />')}if(d("> span span",r).size()){d("> span",r).html('<img src="'+d("> span span",r).attr("title")+'" alt="" />')}},pager:n.thumbs,pagerAnchorBuilder:function(p){return n.thumbs+" li:eq("+p+") a"},pagerClick:function(){d(m).show().cycle("resume");return false}});return d(this).addClass("slideshow")},swatches:function(k,j){return d(this).each(function(){var m={img:k,title:j},n=d("li:not(:eq(0))",this),r=d(n).size(),o=d(n).filter(".noImage").size(),q=d(m.img).attr("src"),p=function(){d(this).addClass("selected").siblings().removeClass("selected");d(m.img).attr("src",d("a",this).attr("href")||q);d(m.title).text(d(this).text());if(d(m.img).parent().find(".disclaimer").size()>0){var s=d(m.img).parent().find(".disclaimer");var t=d("a",this).attr("rel").split("_");d(".vehciletrim .data",s).text(t[0]);d(".vehcileprice .data",s).text(t[1])}if(d.fn.ifixpng){d("#vehicleImage img[src$=png]").ifixpng()}return false},l=function(){d(this).addClass("selected").siblings().removeClass("selected");d(m.title).text(d(this).text());return false};if(m.img&&m.title&&(r!==o)){d(n).unbind("click.swatch").bind("click.swatch",p)}else{if(m.img&&m.title&&(r===o)){d(n).unbind("mouseover.swatch").bind("mouseover.swatch",l).unbind("click.swatch").bind("click.swatch",function(){var s=d("a",n).index(d("a",this));if(d(this).is(".popupImage")){d("a",this).trigger("swatchClick",[s])}return false})}}})}});b.Showroom=b.Showroom||{};b.Showroom.onUpdate=a}());