poc=organic;try{if(!poc.exists){throw"pocObjUndefined";}poc.homepage={num_backgrounds:0,current_background:false,nextBg:0,crossfade:false,animationTimeout:null,overlayTimeout:null,nextTimeout:null,bgSpeed:250,fgSpeed:250,bgCached:false,fgCached:false,randomBool:false,animationAllowed:false,fullStop:false,rotationInited:false,currentBackgroundIndex:null,activeOverlay:null,iFrameActivate:null,init:function(){poc.homepage.bgCached=jQuery("#bg div");poc.homepage.fgCached=jQuery("#fg div");if(poc.homepage.bgCached.size()!=0){poc.homepage.preload();}},fadeBG:function(d,b){var c=poc.homepage.current_background;(jQuery("#ytf"))?jQuery("#ytf").remove():"";(jQuery("#close_ytf"))?jQuery("#close_ytf").remove():"";function a(){var f=d;poc.homepage.bgCached.eq(f).fadeIn(poc.homepage.bgSpeed,function(){poc.homepage.fgCached.eq(f).fadeIn(poc.homepage.fgSpeed,function(){poc.homepage.current_background=f;poc.homepage.nextBg=poc.homepage.current_background+1;});});}if(c>=0){poc.homepage.fgCached.eq(c).fadeOut(poc.homepagefgSpeed,function(){poc.homepage.bgCached.eq(c).fadeOut(poc.homepage.bgSpeed,function(){if(!b){a();}jQuery(".controls").removeClass("active");jQuery(".controls").eq(d).addClass("active");});if(b){a();}});changeVeh(poc.homepage.veh[poc.homepage.nextBg]);}else{a();}},preload:function(){function d(){jQuery("body#homepage #flash_content").css({background:"none"});}var h=new Array();for(var g=0;g<poc.homepage.bgCached.length;g++){var f=poc.homepage.bgCached.eq(g);var c=f.css("background-image");var b=c.split("url(")[1];var a=b.split(")")[0];var j=a.replace(/["']/gi,"");h[g]=jQuery("<img>");if(g==0){h[0].bind("load",d);}h[g].attr("src",j);}poc.homepage.populateButtons();},initRotation:function(){poc.homepage.rotationInited=true;poc.homepage.activateButtons();if(poc.homepage.fullStop!=true){var a=function(){poc.homepage.animationAllowed=true;};poc.homepage.animationTimeout=setTimeout(a,500);poc.homepage.rotateBool=true;if(poc.homepage.randomBool==true&&poc.homepage.current_background!=false){poc.homepage.nextBg=-1;}if(poc.homepage.current_background===false){if(poc.homepage.randomBool==true&&poc.homepage.current_background===false){poc.homepage.nextBg=Math.floor(Math.random()*poc.homepage.bgCached.size());}else{poc.homepage.nextBg=0;}poc.homepage.nextBackground();poc.homepage.hideGifLoader();}}},nextBackground:function(){if(poc.homepage.animationAllowed==true&&c!=-1){var c=poc.homepage.nextBg;var a=Number(poc.homepage.bgCached.eq(c).find(".holdTime").val());if(a===0){poc.homepage.stopRotation("true");}poc.homepage.fadeBG(c,"true");if(poc.homepage.randomBool==false){var b=function(){if(c>=poc.homepage.bgCached.size()){poc.homepage.nextBg=0;}poc.homepage.nextBackground();};poc.homepage.nextTimeout=setTimeout(b,a);}else{poc.homepage.animationAllowed=false;}}else{if(c!=-1){var b=function(){poc.homepage.nextBackground();};setTimeout(b,1000);}}},immediateNext:function(b){poc.homepage.animationAllowed=true;poc.homepage.hideOverlay();var a=function(){clearTimeout(poc.homepage.nextTimeout);if(b){poc.homepage.nextBg=b;}poc.homepage.nextBackground();};setTimeout(a,poc.homepage.fgSpeed+poc.homepage.bgSpeed);},stopRotation:function(a){clearTimeout(poc.homepage.animationTimeout);poc.homepage.animationAllowed=false;if(!a){poc.homepage.showOverlay();}else{if(a){poc.homepage.fullStop=true;}}},stopFlashRotation:function(a){clearTimeout(poc.homepage.animationTimeout);poc.homepage.animationAllowed=false;},showOverlay:function(oID){var activeOverlay=poc.homepage.activeOverlay;console.log("[ showOverlay | "+oID+"]");clearTimeout(poc.homepage.overlayTimeout);var overlayDiv=jQuery("#overlay");if(overlayDiv.size()>0){overlayDiv.show().fadeTo(100,0.7).addClass("visible");poc.homepage.fgCached.eq(poc.homepage.current_background).fadeOut("fast");}jQuery("#main_flash_embed").css({"z-index":3});poc.homepage.fgCached.css({"z-index":1});poc.homepage.stopFlashRotation("true");(null!=activeOverlay)?eval("poc.homepage."+activeOverlay+"()"):"";(null!=oID&&"null"!=oID)?eval("poc.homepage."+oID+"()"):"";},hideOverlay:function(){console.log("[ hideOverlay | AO : "+poc.homepage.activeOverlay+" | CBI : "+poc.homepage.currentBackgroundIndex+" | CB : "+poc.homepage.current_background+"]");var activeOverlay=poc.homepage.activeOverlay;if(null==poc.homepage.currentBackgroundIndex){poc.homepage.animationAllowed=true;var code=function(){poc.homepage.fgCached.eq(poc.homepage.current_background).fadeIn("fast");jQuery("#overlay").animate({opacity:"0"},100,function(){jQuery(this).hide().removeClass("visible");});jQuery("#main_flash_embed").css({"z-index":1});poc.homepage.fgCached.css({"z-index":3});};}else{var code=function(){jQuery("#overlay").animate({opacity:"0"},100,function(){jQuery(this).hide().removeClass("visible");});};}poc.homepage.overlayTimeout=setTimeout(code,500);(null!=activeOverlay)?eval("poc.homepage."+activeOverlay+"()"):"";},populateButtons:function(){var m=Number(poc.homepage.nextBg);var l=jQuery("#background_controls.dots");var k=jQuery("#background_controls.flags");var f=jQuery("#background_controls.numbered");if(f.size()>0||l.size()>0||k.size()>0){for(var g=0;g<poc.homepage.bgCached.length;g++){if(g===m){var c="active";}else{var c="";}var j=g+1;var h=jQuery("#background_controls").append("<div class='controls "+c+"'><a href='#' name='&lid=image_scroll&lpos=content'>"+j+"</a></div>");}var b=f.find("div");if(b.length>0){var d=480-((b.length*21)/2);f.css({"margin-left":d});}var a=l.find("div");if(a.length>0){var d=480-((a.length*15)/2);l.css({"margin-left":d});}}},activateButtons:function(){jQuery("#background_controls.flags").css({display:"block"});jQuery("#background_controls div").click(function(){jQuery("#background_controls div").removeClass("active");jQuery(this).addClass("active");poc.homepage.nextBg=jQuery(".controls").index(this);poc.homepage.immediateNext(jQuery(".controls").index(this));});jQuery("#background_controls div a").click(function(a){a.preventDefault();});},deActivateButtons:function(){},changeFooter:function(){var a=jQuery("#footer_disclaimer");jQuery("#footer_legal a").toggleClass("active");a.toggleClass("hidden");},showQuotes:function(b){poc.homepage.activeOverlay="hideQuotes";jQuery("#brand_quotes_container").css({display:"block"});var d=poc.homepage.iFrameActivate;var c=(null!=poc.homepage.currentBackgroundIndex)?poc.homepage.currentBackgroundIndex:poc.homepage.current_background;var a=(null!=b)?b:poc.homepage.veh[c]+".html";console.log("[ showQuotes | tempVehicle : "+a+" "+d+"\n CBI : "+poc.homepage.currentBackgroundIndex+" \n CB : "+poc.homepage.current_background+"]");if(a!=d){window.frames.quote_frame.location.href="/en/includes/bhp_quotes/"+a;poc.homepage.iFrameActivate=a;}},hideQuotes:function(){jQuery("#brand_quotes_container").css({display:"none"});poc.homepage.activeOverlay=null;},showSignup:function(){console.log("showSignup");poc.homepage.activeOverlay="hideSignup";jQuery("#brand_form_container").css({display:"block"});(null!=poc.homepage.currentBackgroundIndex)?poc.homepage.current_background=poc.homepage.currentBackgroundIndex:"";jQuery("#brand_form_container #sign_up_image img").attr("src","/shared/images/brandhome/sign_up/"+poc.homepage.signUpImgSrc[poc.homepage.current_background]+".jpg");jQuery("#sign_up_headline").attr("src","/shared/images/brandhome/sign_up/"+poc.homepage.signUpImgSrc[poc.homepage.current_background]+"_headline.png");jQuery("#form_copy p").html(poc.homepage.signUpTextValue[poc.homepage.current_background]);jQuery("#brand_form_container").css({visiblility:"visible"});},hideSignup:function(){console.log("hideSignup");jQuery("#brand_form_container").css({visiblility:"hidden"});jQuery("#brand_form_container #sign_up_image img").attr("src","");jQuery("#sign_up_headline").attr("src","");jQuery("#brand_form_container").css({display:"none"});poc.homepage.activeOverlay=null;},hideGifLoader:function(){jQuery("#wrapper").css("background","none");},signUpTextValue:{0:"",1:"It's back. Faster, yet more efficient. More nimble. More refined. More fun to drive. And still<br />hauls with ease. Get exclusive updates on the completely reengineered, three-row<br />2011 Dodge Durango.",2:"The seventh generation brings the performance, technology and execution of the world's best<br />cars to the iconic American car styling of Dodge. Rediscover driving. The 2011 Dodge Charger<br />arrives late 2010."},signUpImgSrc:{0:"",1:"signup_image_durango",2:"signup_image_charger"},veh:{0:"grand_caravan",1:"durango",2:"charger"},bgActive:function(b){var a=poc.homepage.currentBackgroundIndex;console.log("bgActive | "+b+" | BGI : "+poc.homepage.currentBackgroundIndex+"]");poc.homepage.bgCached.eq(b).fadeIn(poc.homepage.bgSpeed);(null!=poc.homepage.currentBackgroundIndex)?poc.homepage.bgCached.eq(a).fadeOut(poc.homepagefgSpeed):poc.homepage.hideGifLoader();poc.homepage.currentBackgroundIndex=b;}};jQuery(document).ready(function(){poc.homepage.init();});}catch(e){poc.standard_error_handler(e);}
