/* Version: 0.1.8 - branched */
$(document).ready(function(){if($.browser.msie){iFrameRequired=true;iFrameObj=$('<iframe style="display:none"></iframe>').appendTo(document.body).get(0);iFrame=iFrameObj.contentWindow.document}$(".productNav a[class!=downloadpdf]").click(function(){var b=$(this).attr("href");var a=$(this).parents(".panel").attr("id");loadPanel(a,b,$(this));return false});$(".hijaxBrief").livequery("click",function(){loadPanel("brief",$(this).attr("href"));return false});$(".hijaxDetail").livequery("click",function(){loadPanel("detail",$(this).attr("href"));return false});$("#"+startClosedPanel).addClass("panelClosed");$("#content").css("top","537px");$(".panel").append(indicator).find(".panelIndicator").hide();$(".window0, .window1").addClass("clearfix");$("#inspire").css({overflow:"hidden",height:"460px"});$("#flashMenuWrapper").css({width:"940px",marginLeft:"-470px",left:"50%"});$("body").prepend('<div id="pseudoCanvas"></div>');$("#pseudoCanvas").css({position:"absolute",top:"0",left:"0",width:"1px"});$("body").css({backgroundImage:"none"});twoPanels=(!$("#brief").length||!$("#detail").length)?false:true;if(debug){trace()}if(!twoPanels){trace("One panel mode")}$("#jqProcess").change(function(){process=($(this).is(":checked"))?true:false});$("#jqPause").change(function(){pause=($(this).is(":checked"))?true:false})});var debug=false;var process=false;var pause=false;if(getHttpGetParameters("debug")=="true"){debug=true}if(getHttpGetParameters("process")=="true"){process=true}if(getHttpGetParameters("pause")=="true"){pause=true}trace=function(a,c){if(debug&&(c==undefined||process)){if(pause&&a){alert(a)}if(!$("#jqDebug").length){try{$("body").prepend('<div id="jqDebug" style="background:#eee;position:fixed;z-index:99999;bottom:0;right:0;width:350px;text-align:left;padding:3px;"><p style="float:right;margin:0;padding:0;"><input type="checkbox" id="jqProcess"> <label for="jqProcess">Log Process</label> <input type="checkbox" id="jqPause"> <label for="jqPause">Pause</label> | <a href="javascript:FL(flashID).stopProcessing();">stopProcessing</a>/<a href="javascript:FL(flashID).startProcessing();">startProcessing</a></p><ol style="clear:both;"></ol></div>')}catch(b){}}if(a){$("#jqDebug ol").append("<li>"+a+"</li>")}}};function toggleIndicator(b,a){indicatorsOn=$("#"+b+" .indicatorOn");if(a==1){$("#"+b+" .panelIndicator").fadeIn("normal");$("#"+b+" .panelIndicator").addClass("indicatorOn")}else{inProgress=false;$("#"+b+" .panelIndicator").fadeOut("normal");$("#"+b+" .panelIndicator").removeClass("indicatorOn")}}var indicator='<img class="panelIndicator" src="/_assets/presentation/loading.gif" />';var flashID="inspireFlash";var FLASHMODECOMPACT="minimised";var FLASHMODEFULL="maximised";var FLASHMODEDEFAULT="default";var SPEED=new Array(9);SPEED.pOpen=1000;SPEED.pClose=1000;SPEED.pResize=1000;SPEED.pFadeIn=500;SPEED.pFadeOut=500;SPEED.sTop=750;SPEED.mMin=500;SPEED.mMax=500;SPEED.mDefault=500;var INSPIREHEIGHTCOMPACT=267;var INSPIREHEIGHTDEFAULT=537;var PSEUDOQUERYSTRING=location.href;var flashMode=FLASHMODEFULL;var blurPanel="";var focusPanel="";var lastPanel="";var briefIndex=1;var detailIndex=1;var paused=false;var panelData;var contentID;var lastContentID;var contentFolder="/cars/"+productFolder+"/content/";var twoPanels=true;var inspirePanelReady=true;var insightWaiting=false;var url="";var lastLocation="";var deeplinkPrefix="#";var iFrameRequired=false;var iFrame=false;var iFrameObj=false;var pageLoad=true;var loop;var model;var inProgress=false;function loadPanelFromFlash(b,a){loadPanel(b,a)}function loadPanel(c,a,b){PSEUDOQUERYSTRING=a;a=a.split("?")[0];pageLoad=false;panelInitialise=undefined;contentID=getContentID(a);blurPanel=(c=="brief")?"detail":"brief";focusPanel=c;if(contentID!=lastContentID){$("#pseudoCanvas").height($(document).height());scroller(function(){minmiseFlash();lastPanel=focusPanel;lastContentID=contentID})}else{$(b).shake(2,3,300)}}function minmiseFlash(){toggleIndicator(focusPanel,1);if(inspirePanelReady==true){trace('Calling FL.changePanelState("'+FLASHMODECOMPACT+'")');if(flashMode!=FLASHMODECOMPACT&&FL(flashID)){try{FL(flashID).changePanelState(FLASHMODECOMPACT)}catch(a){trace(a)}}else{animatePanels()}}else{if(model=="Insight"){trace("Waiting for Insight inspireReady call");insightWaiting=true}}}function inspireReady(b,a){trace("inspireReady() called\nState="+b+"\nCar="+a);inspirePanelReady=true;if(b=="default"&&a=="insight"&&insightWaiting==true){trace("This is an Insight page which has been waiting to load a page");minmiseFlash()}}function scroller(c){var b=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;var a=document.all?b.scrollTop:pageYOffset;if(a>0&&(!$("#content").hasClass("pseudoInspireMin")||focusPanel!=lastPanel)){$("html").animate({scrollTop:0},SPEED.sTop,function(){$("#pseudoCanvas").css({height:"auto"});c()})}else{c()}}jQuery.fn.shake=function(a,c,b){this.each(function(){$(this).css({position:"relative"});for(var d=1;d<=a;d++){$(this).animate({left:(c*-1)},(((b/a)/4))).animate({left:c},((b/a)/2)).animate({left:0},(((b/a)/4)))}});return this};var flashObject;function maskFlash(a){$("#"+focusPanel+"Content div.window"+a+" object[@type='application/x-shockwave-flash']").each(function(){var c=$(this).attr("width");var d=$(this).attr("height");var b="<div class='flashMask' style='width:"+c+"px; height:"+d+"px; display:block;'></div>";$(this).hide();$(this).after(b)})}function unmaskFlash(a){$("#"+focusPanel+"Content div.window"+a+" .flashMask").remove();$("#"+focusPanel+"Content div.window"+a+" object[@type='application/x-shockwave-flash']").show()}var animatePanels=function(){trace("Moving Panels",1);if(inProgress==false){inProgress=true;inspirePause();if(flashMode==FLASHMODEFULL){var a=$(window).height();$("#inspireFlash").height((a-$("#header").height()));$("#content").removeClass("pseudoInspireMin");$("body,html").animate({scrollTop:0},SPEED.sTop,function(){$("#content").animate({top:a+"px"},SPEED.mMax,function(){$("#inspire").height((a-$("#header").height()));if(FL(flashID)){try{FL(flashID).changePanelState(FLASHMODEFULL)}catch(b){trace(b)}}})})}else{if(flashMode==FLASHMODEDEFAULT){$("#content").removeClass("pseudoInspireMin");$("#content").animate({top:"537px"},SPEED.mDefault,function(){if(FL(flashID)){try{FL(flashID).changePanelState(FLASHMODEDEFAULT)}catch(b){trace(b)}}})}else{closeInspire(function(){if(twoPanels==true){togglePanel("close",blurPanel,function(){animatePartTwo()})}else{animatePartTwo()}})}}}};function animatePartTwo(){paused=false;var windowIndex=eval(focusPanel+"Index");thisWindow=$("#"+focusPanel+" .window"+windowIndex);thisWindow.empty();thisWindow.css("display","block");thisWindow.css("position","absolute");thisWindow.css("visibility","hidden");var parentWidth=$("#"+focusPanel).width();if(focusPanel=="brief"){thisWindow.css("width","960px")}else{thisWindow.css("width","940px")}thisWindow.hide();var contentFile=fileFromID(contentID);loadContent(contentFolder+contentFile,function(data){thisWindow.html(data);updateProductNav(contentID);maskFlash(windowIndex);if(!paused){panelPlay()}})}function fileFromID(e){var d=[],c;if(e.indexOf("/")>-1){var d=e.split("/");c=d[0]}else{c=e}for(var a in contentLookup){if(a==c){var b=contentLookup[a]}}if(d.length>1){switch(c){case"accessories":b+="?product="+productFolder+"&accessoryGroup="+d[1];break}}if(c=="options"){b+="?product="+productFolder}return b}function panelPause(){paused=true}function panelPlay(){if(pageLoad){}else{togglePanel("open",focusPanel,function(){toggleIndicator(focusPanel,0);try{panelCallback("ready")}catch(a){trace(a)}})}}function inspirePause(){trace("FL.stopProcessing",1);if(FL(flashID)){try{FL(flashID).stopProcessing()}catch(a){trace(a)}}}function loadContent(a,b){trace("loadContent() loading "+a,1);$.ajax({url:a,cache:false,success:function(c){b(c);doLogging(PSEUDOQUERYSTRING)},error:function(c,e,d){b('<div style="padding:20px 40px;"><h2>Page does not exist</h2><p>Sorry, the page you have requested does not exist.</p></div>')}})}function inspireCallback(a,b){trace("Flash has called inspireCallback("+a+", "+b+")");inProgress=false;switch(a){case"swapMode":flashMode=b;animatePanels();break;case"freezeFlash":break}}function closeInspire(a){trace("closeInspire(callback) called",1);if(!$("#content").hasClass("pseudoInspireMin")){$("#content").animate({top:INSPIREHEIGHTCOMPACT+"px"},SPEED.mMin,function(){$("#content").addClass("pseudoInspireMin");a()})}else{a()}}function exploreInspire(b){alert("exploreInspire");var a=$(window).height();$("body,html").animate({scrollTop:0},500,function(){$("#content").animate({top:a+"px"},500)})}function updateIndex(a){if(a=="brief"){briefIndex=1-briefIndex}else{detailIndex=1-detailIndex}}function togglePanel(b,c,h){var g;if(c=="brief"){var f=$("#brief .window"+briefIndex);var e=briefIndex}else{var f=$("#detail .window"+detailIndex);var e=detailIndex}var d=f.height();if(!$("#"+c).hasClass("panelClosed")){if(c=="brief"){var a=$("#brief .window"+(1-briefIndex))}else{var a=$("#detail .window"+(1-detailIndex))}}if(b=="close"&&!$("#"+c).hasClass("panelClosed")){trace("Close "+c+" panel",1);maskFlash(e);$("#"+c+"Content").slideUp(SPEED.pClose,function(){$("#"+c).addClass("panelClosed");$("#"+c+"Content").css("display","block");f.empty();f.css("display","block");a.empty();a.css("display","block");h()})}else{if(b=="open"&&$("#"+c).hasClass("panelClosed")){trace("Animate height from "+$("#"+c+"Content").height()+" to "+d,1);f.hide();$("#"+c+"Content").animate({height:d+"px"},SPEED.pOpen,function(){$(this).hide();f.css("visibility","visible");f.css("position","static");$(this).fadeIn(SPEED.pFadeIn,function(){unmaskFlash(e);$("#"+c).removeClass("panelClosed");$(this).css("height","auto");h();updateIndex(c);if(d>=g){$("#pseudoCanvas").css({height:"auto"})}g=d})})}else{if(b=="open"&&!$("#"+c).hasClass("panelClosed")){trace("Resize "+c+" panel",1);panelHeight=$("#"+c+"Content").height();$("#"+c+"Content").height(panelHeight);$("#"+c+"Content").fadeOut(SPEED.pFadeOut,function(){a.hide();a.empty();a.css("display","block");try{panelCallback("blurred")}catch(j){trace(j)}$(this).animate({height:d+"px"},SPEED.pResize,null,function(){$(this).hide();f.css("visibility","visible");f.css("position","static");$(this).fadeIn(SPEED.pFadeIn,function(){unmaskFlash(e);$("#"+c).removeClass("panelClosed");$(this).css("height","auto");h();updateIndex(c);if(d>=g){$("#pseudoCanvas").css({height:"auto"})}g=d})})})}else{h()}}}}function sameSection(a){alert(a+" == "+lastContentID);var b=false}function updateProductNav(c){removeClassFromSelector("body","prodNav1");removeClassFromSelector("body","prodNav2");var b=getProductNavObj(c);if(b){var a=b.className;var d=$(b).parents("ul").parents("li").attr("class");d=(!d)?a:d;$("body").addClass("prodNav1"+d);if(a!=d){$("body").addClass("prodNav2"+a)}}}function getProductNavObj(c){var b=null;var a=$(".productNav").children();$(a).each(function(){thisContentID=getChildContentID(this);if(thisContentID==c){b=this}subNav=$(this).contents("ul").children();$(subNav).each(function(){thisContentID=getChildContentID(this);if(thisContentID==c){b=this}})});return b}function getChildContentID(a){nav=a.className;navLink=$("."+nav+" a").attr("href");navContentID=getContentID(navLink);return navContentID}function getContentID(b){var c="";var a=["accessories","options"];var d=b.split("/");if(d[0]==""){d.shift()}if(d[d.length-1]==""){d.pop()}c=d[d.length-1];if(d.length>1){for(i=0;i<a.length;i++){if(a[i]==d[d.length-2]){c=a[i]+"/"+c}}}return c};
