var availWidth;var closeWidth;var currentGroup;var moving=false;var flashArray=new Array();var groupArray=new Array();var viewableAmount;var viewableAmountWithArrows;var groupID;var cur_section="features";var textSize=0;var currentAvailabilityID;var deepLinkMoveCount=0;var rightBgSize=10;function feature_init(){if($("vehicle_feature_nav_wrapper")){setUp();highlightFeatureNav();setPageTitleText();}availRender();getTextSize();sizeFlashEmbed();fadeIn();}function setUp(){var a=$$(".feature_nav_group");availWidth=($("vehicle_feature_nav_wrapper").getSize().size.x-$("vehicle_feature_nav_wrapper").getStyle("padding-left").toInt()-$("vehicle_feature_nav_wrapper").getStyle("padding-right").toInt())-a.length*(a[0].getSize().size.x+a[0].getStyle("margin-right").toInt()+a[0].getStyle("margin-left").toInt())-rightBgSize;closeWidth=a[0].getSize().size.x;enableGroups(a);setUpLists();deepLinkNav(a);revealNav();}function enableGroups(a){for(var d=0;d<a.length;d++){a[d].addEvent("click",function(){expand(this.id);});a[d].addEvent("mouseover",function(){$(this.id).addClass("hover");});a[d].addEvent("mouseout",function(){$(this.id).removeClass("hover");});var e=new Group(a[d].getProperty("id"));groupArray.push(e);var c=$$("#"+a[d].getProperty("id")+" .feature_nav_list li");for(var b=0;b<c.length;b++){if(c[b].getProperty("id")==cur_subcat){c[b].addClass("selected");cur_cat=a[d].getProperty("id");a[d].addClass("selected");expand(cur_cat);break;}}}}function setUpLists(){var a=$$(".feature_nav_list");a.each(function(c){c.setStyle("width",c.getChildren().length*(c.getFirst().getStyle("width").toInt()+c.getFirst().getStyle("padding-left").toInt()+c.getFirst().getStyle("padding-right").toInt()+c.getFirst().getStyle("margin-right").toInt()+c.getFirst().getStyle("margin-left").toInt())+5);var b=c.getChildren();var e=b.length*(b[0].getSize().size.x+b[0].getStyle("margin-right").toInt()+b[0].getStyle("margin-left").toInt());if(availWidth<e){var d=availWidth;}else{var d=e;}c.getParent().setStyle("width",d);c.getParent().setStyle("left",closeWidth);arrowCheck(c);});viewableAmount=Math.floor(availWidth/(a[0].getFirst().getSize().size.x+a[0].getFirst().getStyle("margin-right").toInt()+a[0].getFirst().getStyle("margin-left").toInt()));}function deepLinkNav(a){for(var e=0;e<a.length;e++){var d=$$("#"+a[e].getProperty("id")+" .feature_nav_list li");for(var c=0;c<d.length;c++){if(d[c].getProperty("id")==cur_subcat){d[c].addClass("selected");cur_cat=a[e].getProperty("id");a[e].addClass("selected");expand(cur_cat);var h=$$("#"+a[e].getProperty("id")+" .feature_nav_list")[0];if(d.length==viewableAmount&&(h.getStyle("width").toInt()<availWidth)){return;}var b=d.length;var f=b/(viewableAmountWithArrows);if(c+1>viewableAmountWithArrows){var g=viewableAmountWithArrows;for(k=1;k<f;k++){if(c+1>g){deepLinkMoveCount++;}}scrollToDirection("next",d[c].getParent());}break;}}}}function arrowCheck(g){if(g.getStyle("width").toInt()>availWidth){var a=g.getParent().getParent().getProperty("id");var i=$$("#"+a+" .feature_subnav_buttons")[0];i.setStyle("display","block");var j=availWidth-60;i.setStyle("width",j);i.setStyle("left",closeWidth);var d=2*$$("#"+a+" .feature_subnav_buttons a")[0].getSize().size.x;var f=availWidth-d-68;g.getParent().setStyle("width",f);g.getParent().setStyle("left",closeWidth+d*0.5);var c=i.getChildren()[0];var e=i.getChildren()[1];c.addClass("inactive");c.setStyle("opacity",".5");c.addEvent("click",function(){scrollToDirection("prev",g);});e.addEvent("click",function(){if(!this.hasClass("inactive")){scrollToDirection("next",g);}});g.setStyle("left",0);viewableAmountWithArrows=Math.floor((availWidth-d)/(g.getFirst().getSize().size.x+g.getFirst().getStyle("margin-right").toInt()+g.getFirst().getStyle("margin-left").toInt()));}else{var h=g.getParent().childNodes;var b=h.length*(h[0].getStyle("width").toInt()+h[0].getStyle("padding-left").toInt()+h[0].getStyle("padding-right").toInt()+h[0].getStyle("margin-right").toInt()+h[0].getStyle("margin-left").toInt());g.getParent().setStyle("width",b-rightBgSize);}}function expand(f){if(currentGroup!=$(f)&&!moving){if(currentGroup){linkTrack("feature_sub_nav",f);}moving=true;if(currentGroup){currentGroup.removeClass("selected");var c=currentGroup.effect("width",{duration:300,transition:Fx.Transitions.Expo.easeOut});c.start(currentGroup.getStyle("width").toInt(),closeWidth);}currentGroup=$(f);var b=$$("#"+f+" .feature_nav_list li");var e=b.length*(b[0].getStyle("width").toInt()+b[0].getStyle("padding-left").toInt()+b[0].getStyle("padding-right").toInt()+b[0].getStyle("margin-right").toInt()+b[0].getStyle("margin-left").toInt());if(availWidth<e){var a=availWidth+closeWidth;openSize1=a-55;}else{var a=e+closeWidth;openSize1=a;}for(var d=0;d<groupArray.length;d++){if(groupArray[d].name==currentGroup.getProperty("id")){groupID=d;}}currentGroup.addClass("selected");var c=currentGroup.effect("width",{duration:1000,transition:Fx.Transitions.Expo.easeInOut,onComplete:function(){moving=false;fixIEImages(f);}});c.start(currentGroup.getStyle("width").toInt(),openSize1);}}function fixIEImages(b){var a=$$("#"+b+" .feature_nav_list li img");a.each(function(c){if(c.getStyle("text-align")=="center"){c.setStyle("text-align","left");}else{c.setStyle("text-align","center");}});}function scrollToDirection(c,b){var a=groupArray[groupID].currentID;switch(c){case"prev":if(groupArray[groupID].currentID>0){groupArray[groupID].currentID=groupArray[groupID].currentID-viewableAmountWithArrows;if(groupArray[groupID].currentID<0){groupArray[groupID].currentID=0;}scroll(groupArray[groupID].currentID,b);}break;case"next":if(groupArray[groupID].currentID<b.getChildren().length){groupArray[groupID].currentID=groupArray[groupID].currentID+viewableAmountWithArrows;if(groupArray[groupID].currentID<b.getChildren().length&&groupArray[groupID].currentID+viewableAmountWithArrows>=b.getChildren().length){groupArray[groupID].currentID=b.getChildren().length-groupArray[groupID].currentID+a;}scroll(groupArray[groupID].currentID,b);}break;default:break;}}function scroll(d,c){var b=-((c.getChildren()[0].getSize().size.x+c.getChildren()[0].getStyle("margin-left").toInt()+c.getChildren()[0].getStyle("margin-right").toInt())*d);if(deepLinkMoveCount>1){var a=c.effect("left",{duration:500,transition:Fx.Transitions.Expo.easeInOut});deepLinkMoveCount--;if(deepLinkMoveCount>0){scrollToDirection("next",c);}}else{var a=c.effect("left",{duration:1000,transition:Fx.Transitions.Expo.easeInOut});}a.start(c.getStyle("left").toInt(),b);updateArrows(c);}function updateArrows(f){var g=f.getParent().getParent().getProperty("id");var c=$$("#"+g+" .feature_subnav_buttons")[0];var e=c.getChildren()[0];var d=c.getChildren()[1];var b=new Fx.Style(e,"opacity");var a=new Fx.Style(d,"opacity");if(groupArray[groupID].currentID==0){e.addClass("inactive");b.start(0.2);}else{e.removeClass("inactive");b.start(1);}if(groupArray[groupID].currentID>=f.getChildren().length-viewableAmountWithArrows){d.addClass("inactive");a.start(0.2);}else{d.removeClass("inactive");a.start(1);}}function availRender(){if($("availability")){for(var c=0;c<$$("#availability .list_item").length;c++){var b=$$("#availability .list_item")[c];b.setProperty("id","availability_"+c);b.addEvent("click",function(){availabilityUserShowHide(this.id);});b.addEvent("mouseenter",function(){this.addClass("availability_over");});b.addEvent("mouseleave",function(){this.removeClass("availability_over");});var a=b.getFirst().getSize().size.y.toInt();b.setStyle("height",a+"px");b.setStyle("overflow","hidden");}availabilityUserShowHide("availability_0");}}function availabilityShowHide(d){if(currentAvailabilityID!=d){if($("availability")){for(var c=0;c<$$("#availability .list_item").length;c++){var b=$$("#availability .list_item")[c];b.getFirst().getNext().setStyle("display","none");var a=b.getFirst().getSize().size.y.toInt();b.setStyle("height",a+"px");b.addClass("availability_closed");b.addEvent("mouseenter",function(){this.addClass("availability_over");});b.getFirst().removeClass("open");}$(d).removeClass("availability_over");$(d).removeClass("availability_closed");$(d).getFirst().getNext().setStyle("display","block");var a=($(d).getFirst().getSize().size.y+$(d).getFirst().getNext().getSize().size.y).toInt();$(d).setStyle("height",a+"px");$(d).getFirst().addClass("open");$(d).addEvent("mouseenter",function(){this.removeClass("availability_over");});if(currentAvailabilityID){linkTrack("availability",$(d).getFirst().getText());}currentAvailabilityID=d;}}}function availabilityUserShowHide(d){if($("availability")){if($(d).getFirst().hasClass("open")){$(d).getFirst().removeClass("open");var a=($(d).getFirst().getSize().size.y).toInt();$(d).setStyle("height",a+"px");$(d).addEvent("mouseenter",function(){this.addClass("availability_over");});}else{var a=($(d).getFirst().getSize().size.y+$(d).getFirst().getNext().getSize().size.y).toInt();$(d).setStyle("height",a+"px");$(d).removeClass("availability_over");$(d).removeClass("availability_closed");$(d).getFirst().addClass("open");$(d).addEvent("mouseenter",function(){this.removeClass("availability_over");});}for(var c=0;c<$$("#availability .list_item").length;c++){var b=$$("#availability .list_item")[c];b.setStyle("padding-bottom","12px");}if(d){linkTrack("availability",$(d).getFirst().getText());}}}function revealNav(){var b=$("vehicle_feature_nav_wrapper");var a=new Fx.Style(b,"opacity",{duration:1000,wait:false});a.start(0,1);}function sizeFlashEmbed(){if($defined($("feature_media"))){var a=$("module_list");var b=a.getChildren().length;if(b==1){$("feature_media").setStyle("height","405px");}}}function fadeIn(){var wrapper=$("vehicle_feature_body");if(hasFlashMin()){var swfList=$$("#vehicle_feature_body .swf img");var flvList=$$("#vehicle_feature_body .flv img");swfList.each(function(item,index){item.remove();});flvList.each(function(item,index){item.remove();});}var animate=new Fx.Style(wrapper,"opacity",{duration:1500,wait:false,onComplete:function(){var swfList=$$("#vehicle_feature_body .swf");var flvList=$$("#vehicle_feature_body .flv");swfList.each(function(item,index){item.setStyle("visibility","visible");});flvList.each(function(item,index){item.setStyle("visibility","visible");});if($defined($("feature_media"))){$("feature_media").addClass("visible");}if(hasFlashMin()){if(typeof(pageGenre)!="undefined"&&pageGenre>=1){jQuery("#main_flash_embed").height(1);if(typeof(control_type)!="undefined"){cllc.page_ready(function(){var cssOverride=(window.location.toString().indexOf("/en/commercial/")>0)?"commercial_":"";var cssURL="/shared/flash/modulecontroller/"+cssOverride+"module_flash_base.css";showFlash("/crossbrand/shared/flash/modulecontroller/shell.swf","main_flash_embed","&flashDivID=main_flash_embed&cssURL="+cssURL+"&lang=en&text_play_vid=Play Video&viewType="+control_type+"&crossbrandPath=/crossbrand/shared/flash/modulecontroller/&brandPath=/shared/flash/modulecontroller/&divID=feature_media");});}else{cllc.page_ready(function(){var cssOverride=(window.location.toString().indexOf("/en/commercial/")>0)?"commercial_":"";var cssURL="/shared/flash/modulecontroller/"+cssOverride+"module_flash_base.css";showFlash("/crossbrand/shared/flash/modulecontroller/shell.swf","main_flash_embed","&flashDivID=main_flash_embed&cssURL="+cssURL+"&lang=en&text_play_vid=Play Video&viewType=features&crossbrandPath=/crossbrand/shared/flash/modulecontroller/&brandPath=/shared/flash/modulecontroller/&divID=feature_media");});}}else{if(typeof(control_type)!="undefined"){showFlash("/shared/flash/module_controller.swf","feature_media","&lang=en&text_play_vid=Play Video&controllerType="+control_type+"&divID=main_content");}else{showFlash("/shared/flash/module_controller.swf","feature_media","&lang=en&text_play_vid=Play Video&controllerType=features&divID=feature_media");}}for(var i=0;i<flashArray.length;i++){eval(flashArray[i]);}if($("contextual_video_player")){if(typeof(pageGenre)!="undefined"&&pageGenre>=1){showFlash("/crossbrand/shared/flash/flv_module.swf","contextual_video_player","&crossbrandPath=/crossbrand/shared/flash/modulecontroller/&brandPath=/shared/flash/modulecontroller/&id="+title_asset+"&poster="+poster_asset+"&flv="+video_asset+"&disclaimer="+disclaimer_asset);}else{showFlash("/shared/flash/video_player.swf","contextual_video_player","&title="+title_asset+"&poster="+poster_asset+"&flv="+video_asset+"&disclaimer="+disclaimer_asset);}}}else{if($("feature_media")){$("feature_media").style.backgroundColor="#000000";$("feature_media").setStyle("height","405px");var img=$$("#feature_media img.lowband")[0];img.setStyle("visibility","visible");}if($("contextual_video_player")){var posterImg=new Element("img").setProperty("src",poster_asset);posterImg.injectInside("contextual_video_player");}}}});animate.start(1,1);}function toggle(a){a=$(a);if(a.getParent().getParent().getParent().hasClass("one-third")||a.getParent().getParent().getParent().hasClass("three-thirds")){var b="content_tertiary";}else{var b="content_secondary";}linkTrack(b,a.getProperty("id")+"_"+a.getText());if(a.hasClass("more_button")){a.getPrevious().setStyle("display","inline");a.setText("Close");}else{a.getPrevious().setStyle("display","none");a.setText("More");}a.toggleClass("more_button");a.toggleClass("close_button");}function toggleRollOver(a){a=$(a);a.addClass("toggle_over");}function toggleRollOut(a){a=$(a);a.removeClass("toggle_over");}function highlightFeatureNav(){cur_feature_menu=$(cur_cat+"_"+cur_subcat+"_menu");if(cur_feature_menu){cur_feature_menu.addClass("at");}}function setPageTitleText(){var a=cur_cat.toString();var b=a.split("_");a=b.join(" ");var c=cur_subcat.toString();b=c.split("_");c=b.join(" ");c=c.replace("-rball","&#174;");c=c.replace("-trademark","&#8482;");$("cur_cat").setText(a);$("cur_subcat").setHTML(c);}function getTextSize(){if(typeof(userData.featureTextSize)=="number"){setTextPref(userData.featureTextSize);}}function setTextPref(a){userData.featureTextSize=a;Cookie.set("userdata",Json.toString(userData),{duration:365,path:"/"});$("vehicle_feature_body").removeClass("size_"+textSize);$("vehicle_feature_body").addClass("size_"+a);$("text_size_"+textSize).removeClass("on_state");$("text_size_"+textSize).addClass("off_state");$("text_size_"+a).removeClass("off_state");$("text_size_"+a).addClass("on_state");textSize=a;}var Group=new Class({initialize:function(a){this.name=a;this.currentID=0;}});function showAvailability(a){jQuery("#feature_avail").html(a);jQuery("#feature_avail").fadeIn("fast");}function hideAvailability(){jQuery("#feature_avail").fadeOut("fast");}
