function getObjectName(o){if(o===undefined||o===null){return "";}else{var _1=/function (.{1,})\(/;var _2=(_1).exec(o.constructor.toString());return (_2&&_2.length>1)?_2[1]:"";}};function isFunction(f){return getObjectName(f)==="Function";};function whenAvailable(_3,_4){var _5=100;window.setTimeout(function(){if(typeof eval(_3)!=="undefined"){return _4();}else{window.setTimeout(arguments.callee,_5);}},_5);};(function($){$.fn.appear=function(f,o){var s=$.extend({one:true},o);return this.each(function(){var t=$(this);t.appeared=false;if(!f){t.trigger("appear",s.data);return;}var w=$(window);var c=function(){if(!t.is(":visible")){t.appeared=false;return;}var a=w.scrollLeft();var b=w.scrollTop();var o=t.offset();var x=o.left;var y=o.top;if(y+t.height()>=b-150&&y<=b+w.height()+150&&x+t.width()>=a&&x<=a+w.width()){if(!t.appeared){t.trigger("appear",s.data);}}else{t.appeared=false;}};var m=function(){t.appeared=true;if(s.one){w.unbind("scroll",c);var i=$.inArray(c,$.fn.appear.checks);if(i>=0){$.fn.appear.checks.splice(i,1);}}f.apply(this,arguments);};if(s.one){t.one("appear",s.data,m);}else{t.bind("appear",s.data,m);}w.scroll(c);$.fn.appear.checks.push(c);(c)();});};$.extend($.fn.appear,{checks:[],timeout:null,checkAll:function(){var l=$.fn.appear.checks.length;if(l>0){while(l--){($.fn.appear.checks[l])();}}},run:function(){if($.fn.appear.timeout){clearTimeout($.fn.appear.timeout);}$.fn.appear.timeout=setTimeout($.fn.appear.checkAll,20);}});$.each(["append","prepend","after","before","attr","removeAttr","addClass","removeClass","toggleClass","remove","css","show","hide"],function(i,n){var u=$.fn[n];if(u){$.fn[n]=function(){var r=u.apply(this,arguments);$.fn.appear.run();return r;};}});})(jQuery);$j.img={cache:[],preload:function(_6){var _7=document.createElement("img");_7.src=_6;this.cache.push(_7);}};$j.spotlights={quit:function(){if(!$j.spotlights.a.navUsed){trackEvent("Spolight A navigation used","None");}if(!$j.spotlights.b.navUsed){trackEvent("Spolight B navigation used","None");}return false;},a:{images:[],currentItem:0,currentPage:0,currentPanel:0,currentURL:"",loopTimeout:null,nextItemInterval:null,navUsed:false,init:function(){var _8=this;this.currentItem=0;this.currentPage=0;this.resetPanels(0);this.resetPages(0);this.resetItems(0);this.togglePanels();this.togglePages();this.toggleItems();this.load_active_thumbs();$j(".sp-nav-items-wrapper, .sp-main-caption").mouseleave(function(){$j(".nav-group .nav-group-items li").removeClass("mouseover");if(_8.loopTimeout===null){_8.loopTimeout=window.setTimeout("$j.spotlights.a.startLoop()",4500);}}).mouseenter(function(){$j(".nav-group.active .nav-group-items.active li.active").addClass("mouseover");_8.killLoop();});this.restartLoop(6000);$j(".sp-main-shadow, .sp-main-caption").click(function(e){if(getObjectName(e.srcElement)!="HTMLInputElement"&&getObjectName(e.srcElement)!="HTMLAnchorElement"){window.location=_8.currentURL;}});whenAvailable("FB",$j.spotlights.a.show_social_buttons);$j(".pagination_micro").mouseover(function(){_8.load_active_thumbs(true);});trackEvent("Spolight A navigation used","Tab viewed","Newest");window.onbeforeunload=function(){$j.spotlights.quit();};},killLoop:function(){window.clearTimeout(this.loopTimeout);this.loopTimeout=null;window.clearInterval(this.nextItemInterval);this.nextItemInterval=null;},startLoop:function(){this.killLoop();if(this.nextItemInterval===null){this.gotoNextSlide();this.nextItemInterval=window.setInterval("$j.spotlights.a.gotoNextSlide()",4500);}},restartLoop:function(t){if(t===undefined){t=2500;}this.killLoop();this.loopTimeout=window.setTimeout("$j.spotlights.a.startLoop()",t);},gotoNextSlide:function(){var _9=3;if(this.currentItem<_9){this.resetItems(this.currentItem+1);}else{this.resetItems(0);}},preloadImages:function(){$j(".sp-nav-items .item-inner .image img").each(function(){$j.img.preload($j(this).attr("src"));});},togglePanels:function(){inst=this;$j(".sp-nav-bar .menu-tabs a").click(function(){$j(".sp-nav-bar .menu-tabs li").removeClass("active");$j(this).parents("li").addClass("active");var i=$j(".sp-nav-bar .menu-tabs li").index($j(this).parent("li"));inst.resetPanels(i);inst.load_active_thumbs(true);var _a;switch(i){case 0:_a="Newest";break;case 1:_a="Most Popular";break;}trackEvent("Spolight A navigation used","Tab viewed",_a);return false;});},resetPanels:function(i){this.currentPanel=i;$j(".sp-nav-items ul li.nav-group").each(function(){$j(this).removeClass("active").hide();});$j(".nav-group-items").each(function(){$j(this).removeClass("active");});$j(".sp-nav-items ul li.nav-group:eq("+i+")").show().addClass("active");this.resetPages(0);this.restartLoop();},togglePages:function(){inst=this;$j(".menu-scroll .pagination_micro .next").click(function(){var p=$j(".nav-group.active ul").length-1;if(p>inst.currentPage){inst.resetPages(inst.currentPage+1);trackEvent("Spolight A navigation used","Page navigation used","Next");}else{inst.resetPages(0);trackEvent("Spolight A navigation used","Page navigation used","Next");}return false;});$j(".menu-scroll .pagination_micro .prev").click(function(){if(inst.currentPage>0){inst.resetPages(inst.currentPage-1);trackEvent("Spolight A navigation used","Page navigation used","Previous");}else{inst.resetPages(4);trackEvent("Spolight A navigation used","Page navigation used","Previous");}return false;});},resetPages:function(i){this.currentPage=i;inst=this;$j(".nav-group").each(function(){$j(this).css("left",0);});$j(".nav-group.active .nav-group-items").removeClass("active");$j(".nav-group.active .nav-group-items:eq("+i+")").addClass("active");var l=-1*(i*316);$j(".nav-group.active").css("left",l);var _b="page_"+(this.currentPage+1);$j(".menu-scroll .pagination_micro span").attr("class","").addClass(_b);this.resetItems(0);this.restartLoop();this.show_social_buttons();},toggleItems:function(){inst=this;$j(".item-inner").mouseover(function(){var i=$j(".nav-group.active .nav-group-items.active li").index($j(this).parent("li"));if(inst.currentItem!=i){inst.resetItems(i);}});},resetItems:function(i){$j(".nav-group .nav-group-items li").removeClass("mouseover");$j(".nav-group.active .nav-group-items.active li").removeClass("active");$j(".sp-main-right ul li").removeClass("active");this.makeItemActive(i);},makeItemActive:function(i){this.currentItem=i;var e=$j(".nav-group.active .nav-group-items.active li:eq("+i+")");e.addClass("active");$j(".sp-main-right ul li:eq("+i+")").addClass("active");var _c=e.find(".image").attr("img-url");var _d=e.find(".title").text();var _e=e.find(".caption").html();var _f=parseInt(e.find(".comments").text());var _10=$j(".sp-main-image img").attr("src");var _11=e.find(".url").text();var t="<a href=\""+_11+"\">"+_d+"</a>";if(_f>0){t+=" <span class=\"comment_count white\">"+_f+"</span>";}this.currentURL=_11;$j(".sp-main-image").css("background-image","url("+_10+")");$j(".sp-main-image img").stop().css("opacity",0).attr("src",_c).animate({opacity:1},{queue:false,duration:333});$j(".sp-main-caption h5").html(t);$j(".sp-main-caption p").html(_e);},show_social_buttons:function(){$j(".nav-group.active .nav-group-items.active li").each(function(){if(!$j(this).attr("rnd-fb")||!isDefined($j(this).attr("rnd-fb"))){var _12=$j(this).find(".fb-like-button").attr("fb-data-url");var _13="<fb:like layout=\"button_count\" show_faces=\"false\" show_faces=\"false\" href=\""+_12+"\"></fb:like>";$j(this).find(".fb-like-button").html(_13);if(typeof FB!=="undefined"){FB.XFBML.parse(document.getElementById("sp-a"));}$j(this).attr("rnd-fb",true);}});},load_active_thumbs:function(_14){var p;if(isDefined(_14)&&_14){p=$j("li.nav-group.active .nav-group-items li");}else{p=$j("li.nav-group.active .nav-group-items.active li");}p.each(function(){if(!$j(this).attr("rnd-thumb")||!isDefined($j(this).attr("rnd-thumb"))){var url=$j(this).find(".thumb").attr("img-url");var _15="<img src=\""+url+"\" width=\"128\" height=\"80\" />";$j(this).find(".thumb a").html(_15);$j.img.preload($j(this).find(".image").attr("img-url"));$j(this).attr("rnd-thumb",true);}});}},b:{navUsed:false,currentPage:1,twitterAccount:"",init:function(){var _16=this;switch(vitalPage.getSite()){case "bmx":_16.twitterAccount="vitalbmx";break;case "mtb":_16.twitterAccount="vitalmtb";break;case "mx":_16.twitterAccount="vitalmx";break;}trackEvent("Spolight B navigation used","Tab viewed","Newest");$j(".sp-b-text h6 a").mouseover(function(){$j(this).parents(".sp-b-item").find(".sp-b-thumb a").addClass("rollover");}).mouseout(function(){$j(this).parents(".sp-b-item").find(".sp-b-thumb a").removeClass("rollover");});$j(".sp-b-thumb a").mouseover(function(){$j(this).parents(".sp-b-item").find(".sp-b-text h6 a").addClass("rollover");}).mouseout(function(){$j(this).parents(".sp-b-item").find(".sp-b-text h6 a").removeClass("rollover");});$j(".spb-nav-bar .menu-tabs a").click(function(){$j.spotlights.b.loadTab($j(this).attr("id"),1,true);});$j("#spotlight_pages a").click(function(e){e.preventDefault();var _17=parseInt($j("span.current").html());if($j(this).attr("class")=="next_page"){_17++;}else{if($j(this).attr("class")=="prev_page"){_17--;}else{_17=$j(this).html();}}$j.scrollTo("#spb-items",200);$j.spotlights.b.loadTab($j(".spb-nav-bar li.active a").attr("id"),_17,false);prepOutboundLinks();this.currentPage=_17;});this.show_init_thumbs();whenAvailable("twttr.widgets",$j.spotlights.b.show_social_buttons);$j(window).scroll(function(){whenAvailable("twttr.widgets",$j.spotlights.b.show_all_thumbs);});},loadTab:function(_18,_19,_1a){if(!isDefined(_1a)){_1a=false;}var _1b=$j(".spb-nav-bar li.active a").attr("id");if(_18&&_18!=_1b){$j(".spb-nav-bar .menu-tabs li").removeClass("active");$j("#"+_18).parent("li").addClass("active");_1a=true;}var url;var _1c;switch(_18){case "spbNew":url="/homepage/spotlights_page?spotlight_page="+_19+"&show=newest";_1c="Newest";break;case "spbPop":url="/homepage/spotlights_page?spotlight_page="+_19+"&show=popular";_1c="Most Popular";break;}var _1d=this;if(_1b!=_18||this.currentPage!=_19){$j("#spb-items").fadeTo(333,0.5,function(){$j(this).load(url,function(){_1d.show_all_thumbs();_1d.show_social_buttons();$j.wait($j("#spb-items").fadeTo(333,1),1000);if(_1a){trackEvent("Spolight B navigation used","Tab viewed",_1c);}});});}this.currentPage=_19;},show_init_thumbs:function(){$j(".sp-b-item .sp-b-thumb").appear(function(){var url=$j(this).attr("img-url");var _1e="<img src=\""+url+"\" width=\"235\" height=\"132\" />";$j(this).find("a").html(_1e);});},show_all_thumbs:function(){$j(".sp-b-item .sp-b-thumb").unbind("appear").each(function(){if($j(this).find("a img").length==0){var url=$j(this).attr("img-url");var _1f="<img src=\""+url+"\" width=\"235\" height=\"132\" />";$j(this).find("a").html(_1f);}});},show_social_buttons:function(){var _20=$j.spotlights.b.twitterAccount;$j(".sp-b-item .share-buttons-wrapper").appear(function(){var _21=$j(this).find(".share-buttons-inner").attr("fb-data-url");var _22=$j(this).find(".share-buttons-inner").attr("twttr-data-url");var _23=$j(this).parent(".sp-b-text").find(".title").text().replace("\"","&quot;");var _24="<fb:like layout=\"button_count\" show_faces=\"false\" href=\""+_21+"\"></fb:like>";var _25="<a href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-url=\""+_22+"\" data-via=\""+_20+"\" data-lang=\"en\" data-text=\""+_23+"\">Tweet</a>";$j(this).find(".share-button-fb").html(_24);$j(this).find(".share-button-twitter").html(_25);if(typeof FB!=="undefined"){FB.XFBML.parse(document.getElementById("spb-items"));}if(typeof twttr!=="undefined"&&typeof twttr.widgets!=="undefined"){twttr.widgets.load();}});}}};function homepage_init(){_26("forum_activity","/homepage/forums_page?forum_page=","forum_page_");_26("product_reviews","/homepage/product_reviews_page?review_page=","review_page_");_26("press_releases","/homepage/press_releases_page?press_page=","press_page_");function _26(id,url,_27){mini_pagination_init(_27);$j("div#"+id+" .pagination_mini a").click(function(e){e.preventDefault();var _28=_28=$j(this).html();$j("div#"+id).load(url+_28,function(){_26(id,url,_27);});});switch(id){case "forum_activity":forum_module_init();break;}};$j("#new_poll_vote").submit(function(e){e.preventDefault();if($j("#poll_data input:radio:checked").val()){$j.post($j(this).attr("action"),$j(this).serialize(),function(_29){$j("#poll_submit").html(_29);$j("#poll_submit").fadeOut(2000);trackMemberAction("Misc","Voted on homepage poll");});}});$j("#view_poll_results a").click(function(e){$j(this).blur();e.preventDefault();if($j(this).text()=="View Results"){$j("#poll_results").load("/poll_votes/"+$j("#poll_vote_poll_id").val(),function(){$j("#poll_data").hide();$j("#view_poll_results a").text("Back to Poll");var _2a=266;$j("div#poll_results th").each(function(){var _2b=parseInt($j(this).parent().next().find("td").text().replace(/(^\s+)(\s+$)/,""));if(_2b==NaN){_2b=0;}var _2c=Math.floor(_2b*_2a/100)-300;$j(this).parent().css({"background":"url(http://cdn.vitalmtb.com/assets/images/poll_result_bg.gif) "+_2c+"px 50% no-repeat"});});});}else{$j("#poll_data").show();$j("#view_poll_results a").text("View Results");$j("#poll_results").html("");}});};function forum_module_init(){var _2d=30;$j("div.forum_activity ul li").each(function(){var _2e=parseInt($j(this).find("span.comment_count").text());var _2f=Math.floor(_2e/_2d)+1;if(_2f>1){var _30=$j(this).find("p.topic_title a").attr("href");_30+="?page="+_2f;$j(this).find("p.topic_title a").attr("href",_30);}});};
