var resetHomeInterval=false;var currentVideo;var validateCaptcha=0;var thisVideo;preloadImages();window.fbAsyncInit=function(){FB.init({apiKey:"3b6b5992421853c672b7f31e06785f74",status:true,cookie:true,xfbml:true})};if($("#fb-root").length){$(function(){var a=document.createElement("script");a.src=document.location.protocol+"//connect.facebook.net/en_US/all.js";a.async=true;document.getElementById("fb-root").appendChild(a)}())}jQuery(document).ready(function(h){if(h("#home_carosel").length){setInterval("swapHomeSlide()",6000)}h("#home_carosel .thumbNav li").click(function(){resetHomeInterval=false;swapHomeSlide(h(this).index());resetHomeInterval=true});h("#share_facebook_generic").bind("click",function(){FB.ui({method:"feed",name:"POWERADE - Go Stronger for Longer",link:"http://www.powerade.co.nz",picture:window.location.host+"/images/generic/share-image.jpg",description:"Watch behind the scenes footage of The All Blacks and download personal training programs written by Dr. Nic Gill - All Blacks' Strength & Conditioning Coach."});return false});h("#share_twitter_generic").bind("click",function(){window.open("http://twitter.com/share?url="+encodeURIComponent("http://www.powerade.co.nz")+"&text="+encodeURIComponent("I've just checked out the New POWERADE website. Check it out for yourself!"),"tweet","width=640,height=480");return false});h("#share_facebook_best").bind("click",function(){FB.ui({method:"feed",name:"POWERADE - Go Stronger for Longer",link:"http://www.powerade.co.nz",picture:window.location.host+"/images/generic/share-image.jpg",description:"My personal best on the POWERADE challenge is "+h(this).closest(".position").find(".time").text()});return false});h("#share_twitter_best").bind("click",function(){window.open("http://twitter.com/share?url="+encodeURIComponent("http://www.powerade.co.nz")+"&text="+encodeURIComponent("My personal best on the POWERADE challenge is "+h(this).closest(".position").find(".time").text()),"tweet","width=640,height=480");return false});h("#social_challenge_facebook").bind("click",function(){FB.ui({method:"feed",name:"Check out the POWERADE Challenge",link:"http://www.powerade.co.nz/challenge",picture:window.location.host+"/images/challenge/challenge-share-image.jpg",description:"Sign up and receive a kit which includes a wristband that could not only get you on the POWERADE Challenge leader board, but also give you the chance to win loads of POWERADE prizes. Check out the course and join now."});return false});h("#social_challenge_twitter").bind("click",function(){window.open("http://twitter.com/share?url="+encodeURIComponent("http://www.powerade.co.nz/challenge")+"&text="+encodeURIComponent("I've just checked out the New POWERADE website. Check it out for yourself!"),"tweet","width=640,height=480");return false});if(h("#hydration_content").length){var i=parseInt(h("#hydration_content").css("width").replace("px",""));var d=h("#img_container").children().length;var k=h("#div1").width();var g=i/d;var p=(i-k)/(d-1)}var c=Array();h("#img_container div").each(function(q){c[q]=new Array();c[q][0]=(q*g)-(q*k);h(this).css("left",c[q][0]+"px");c[q][1]=(q*p)-(q*k);var r=q;if(r==0){r++}c[q][2]=c[r-1][1]});h("#img_container div").mouseenter(function(){var q=parseInt(h(this).attr("id").replace("div",""))-1;if(h(this).attr("id")!="div1"){h(this).animate({left:c[q][1]},300)}h(this).find("img.off").hide();h(this).find("img.on").show();a(this);m(this)});h("#img_container").mouseleave(function(){h("#img_container div").each(function(q){h(this).animate({left:c[q][0]},300,function(){if(h(this).find("img.on").is(":visible")){h(this).find("img.on").hide();h(this).find("img.off").show()}});h(this).find("img.off").css("opacity",1)})});function m(r){if(h(r).prev().is("div")){var q=parseInt(h(r).attr("id").replace("div",""));if(h(r).prev().attr("id")!="div1"){h(r).prev().animate({left:c[q-2][1]},300)}h(r).prev().find("img.off").css("opacity",0.4);if(h(r).prev().find("img.on").is(":visible")){h(r).prev().find("img.on").hide();h(r).prev().find("img.off").show()}m(h(r).prev())}}function a(r){if(h(r).next().is("div")){var q=parseInt(h(r).attr("id").replace("div",""));h(r).next().animate({left:c[q][2]},300);h(r).next().find("img.off").css("opacity",0.4);if(h(r).next().find("img.on").is(":visible")){h(r).next().find("img.on").hide();h(r).next().find("img.off").show()}a(h(r).next())}}var b={};var e={wmode:"transparent"};var f={};swfobject.embedSWF("/swf/hydration_calculator.swf","hydrationcalculator","960","600","8.0.0","/js/libs/swfobject/expressInstall.swf",b,e,f);swfobject.embedSWF("http://www.nz2011services.com/Countdown2011/RWC_Branded_468x60.swf","rwccounter","468","60","8.0.0","/js/libs/swfobject/expressInstall.swf",b,e,f);swfobject.embedSWF("/swf/launch-timer.swf","launchtimer","500","113","8.0.0","/js/libs/swfobject/expressInstall.swf",b,e,f);h("#contactUS").fancybox({width:780,autoDimensions:false,height:500,overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,scrolling:"no",autoScale:false,margin:5});var o="/images/register/checkbox_uncheck.png";var l="/images/register/checkbox_checked.png";h(".checkboxes .row").live("click",function(){var r=h(this).find("img");var q=h(this).find("input");if(r.hasClass("checked")){r.removeClass("checked").addClass("unchecked").attr("src",o);q.val(0)}else{r.removeClass("unchecked").addClass("checked").attr("src",l);q.val(1)}});h("#btn_close").live("click",h.fancybox.close);h("form#getYouFriendsToMesage").live("submit",function(){var v=isNotEmpty("name");var q=isNotEmpty("email");var u=isNotEmpty("friendName");var s=isNotEmpty("friendEmail");var x=isChecked("email_privacy_policy",true);var w=isChecked("email_friend_confirm",true);if(validateCaptcha==0){validateCaptcha=checkCaptcha("recaptcha_response_field","recaptcha_challenge_field")}if(q){var t=checkEmail("email")}if(s){var r=checkEmail("friendEmail")}if(v&&q&&u&&s&&x&&w&&t&&r&&validateCaptcha){h.post("/send-to-friend/submit",h(this).serialize(),function(){h(".form").fadeOut("fast",function(){h(".thanks").fadeIn("fast")})})}});h("form#register").live("submit",function(){var w=isNotEmpty("register_first_name");var q=isNotEmpty("register_last_name");var r=isNotEmpty("register_email");var u=isChecked("register_check_privacy",true);var v=isChecked("register_check_age",true);var s=isChecked("register_check_updates",false);var x=isChecked("register_check_newvideos",false);var t=isChecked("register_check_thirdparty",false);if(validateCaptcha==0){validateCaptcha=checkCaptcha("recaptcha_response_field","recaptcha_challenge_field")}if(r){var z=checkEmail("register_email")}var y=(s||x||t);if(!y){h("#error_select_an_update").show()}else{h("#error_select_an_update").hide()}if(w&&q&&r&&z&&u&&v&&y&&validateCaptcha){h.post("https://"+window.location.host+"/register/submit",h(this).serialize(),function(B){if(B.result==false){var A=[];h.each(B.messages,function(C,D){A.push('<li id="'+C+'">'+D+"</li>")});h(".errors ul").empty().append(A.join(""));h(".errors").slideDown("fast")}else{h(".errors").hide();h("form#register").fadeOut("fast",function(){h("#thanks").fadeIn("fast")})}},"json")}return false});h("#termsOfUse, #privacyPolicy,#privacy_policy_link,#challenge_privacy_link,.challenge_tc_link,#challenge_popup_declaration_link,.popup_grassroots_promo,#challenge_popup_grassroots_terms_link").fancybox({autoScale:false,margin:5,overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,onComplete:function(){h(".contents").jScrollPane()}});h(".programme_link,#glossary_link").live("click",function(){var r=h(this).attr("href");var s=h(this).parentsUntil("li").attr("id");var q=s.substr(6,15);h.fancybox({href:"/training/disclaimer?slide="+q,type:"ajax",overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,autoScale:false,margin:5,onComplete:function(){h("#trainingDisclaimerAccept").attr("href",r);h("#fancybox-wrap").unbind("mousewheel.fb")}});return false});h("#getAnotherCode").live("click",function(){h("#recaptcha_widget .error").hide()});h("#sendToFriend,#challenge_popup_safety_link").fancybox({overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,autoScale:false,margin:5});h("#challengeDisclaimerAccept").live("click",function(){h.fancybox.close();h.cookie("acceptSafety",1,{expires:7,path:"/"})});var n={overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,cyclic:true,showNavArrows:false,autoScale:false,margin:5,onComplete:function(){h("#fancybox-wrap").unbind("mousewheel.fb");h("#slider ul").anythingSlider({width:894,buildNavigation:false,buildArrows:false,autoPlay:false});h(".popup_nav a:eq("+(h.data(document.body,"slide_index")-1)+")").css({height:"60px","margin-top":"-20px"}).addClass("active");h("#slider ul").anythingSlider(h.data(document.body,"slide_index"))}};h(".slide_jump").live("click",function(){var q=h(this).attr("rel");h(".slide_jump").animate({height:"40px","margin-top":"0px"},"200").removeClass("active");h(this).animate({height:"60px","margin-top":"-20px"},"200").addClass("active");h("#slider ul").anythingSlider(q)});h("#training_content .nav a, .videos_content a").fancybox(n);var j={overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,cyclic:true,showNavArrows:false,width:730,height:422,autoScale:false,margin:5,type:"swf",swf:{wmode:"transparent",allowScriptAccess:"always"},onComplete:function(){currentVideo=getUrlVars(this.href);h("#fancybox-wrap").unbind("mousewheel.fb")}};h(".videos_content a,#commercials_content a,#challenge_video_link").click(function(){if(!swfobject.hasFlashPlayerVersion("9.0.0")){h.fancybox({overlayOpacity:0.95,overlayColor:"#000",showCloseButton:false,titleShow:false,href:"/no-flash"})}else{j.href=this.href;h.fancybox(j)}return false});if(window.location.hash!=""){h(window.location.hash).fancybox(j).trigger("click")}h(".videos_content a").hover(function(){h(this).addClass("hover")},function(){h(this).removeClass("hover")})});function swapHomeSlide(b){if(!resetHomeInterval){var d=1000;var f=$("#home_carosel .slides li.cur");var a=$("#home_carosel .thumbNav li a.cur").parent("li");var e,c;if(b!=null){e=$("#home_carosel .slides li:eq("+b+")");c=$("#home_carosel .thumbNav li:eq("+b+")")}else{e=f.next();c=a.next();if(e.length==0){e=$("#home_carosel .slides li:first-child");c=$("#home_carosel .thumbNav li:first-child")}}f.removeClass("cur").fadeOut(d);a.children("a").removeClass("cur");setTimeout(function(){e.fadeIn(d).addClass("cur");c.children("a").addClass("cur")},(d/2))}else{resetHomeInterval=false}}function isNotEmpty(b){var a=$("#"+b);if(a.val()==""){a.parent().children(".error").show();return false}else{a.parent().children(".error").hide();return true}}function checkEmail(b){var a=/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;if(document.getElementById(b).value.match(a)){$("#"+b).parent().children(".error").hide();return true}else{$("#"+b).parent().children(".error").text("Invalid").show();return false}}function checkCaptcha(a,b){var c=false;jqR=$("#"+a);jqC=$("#"+b);$.ajax({url:"/register/check-captcha",data:"c="+jqC.val()+"&r="+jqR.val(),async:false,type:"post",dataType:"json",success:function(d){if(d.valid==1){$("#recaptcha_widget .error").hide();c=true}else{$("#recaptcha_widget .error").show()}}});return c}function isChecked(b,c){var a=$("#"+b);if(a.val()=="1"){a.parent().children("label").removeClass("error_text");return true}else{if(c){a.parent().children("label").addClass("error_text")}return false}}function closeVideo(){$.fancybox.close()}function goNextVideo(){$.fancybox.next()}function shareTwitter(){window.open("http://twitter.com/share?url="+encodeURIComponent("http://"+window.location.host+"/interviews"+currentVideo.link)+"&text="+encodeURIComponent("I've just checked out the "+currentVideo.title+" video on the new POWERADE website!"),"tweet","width=640,height=480")}function shareFacebook(){if(window.location.pathname=="/challenge/about"){FB.ui({method:"feed",name:"Check out the POWERADE Challenge",link:"http://www.powerade.co.nz/challenge",picture:window.location.host+"/images/challenge/challenge-share-image.jpg",description:"Sign up and receive a kit which includes a wristband that could not only get you on the POWERADE Challenge leader board, but also give you the chance to win loads of POWERADE prizes. Check out the course and join now."})}else{FB.ui({method:"feed",name:"POWERADE - "+currentVideo.title,link:window.location.host+"/interviews"+currentVideo.link,picture:window.location.host+"/images/interviews"+currentVideo.img,description:"Watch behind the scenes footage of The All Blacks and download personal training programs written by Dr. Nic Gill - All Blacks' Strength & Conditioning Coach."})}}function getUrlVars(b){var e=[],d;var a=b.slice(b.indexOf("?")+1).split("&");for(var c=0;c<a.length;c++){d=a[c].split("=");e.push(d[0]);e[d[0]]=d[1]}return e}function swapImgRestore(){var d,b,c=document.sr;for(d=0;c&&d<c.length&&(b=c[d])&&b.oSrc;d++){b.src=b.oSrc}}function preloadImages(){var f=document;if(f.images){if(!f.p){f.p=new Array()}var e,c=f.p.length,b=preloadImages.arguments;for(e=0;e<b.length;e++){if(b[e].indexOf("#")!=0){f.p[c]=new Image;f.p[c++].src=b[e]}}}}function findObj(f,e){var c,b,a;if(!e){e=document}if((c=f.indexOf("?"))>0&&parent.frames.length){e=parent.frames[f.substring(c+1)].document;f=f.substring(0,c)}if(!(a=e[f])&&e.all){a=e.all[f]}for(b=0;!a&&b<e.forms.length;b++){a=e.forms[b][f]}for(b=0;!a&&e.layers&&b<e.layers.length;b++){a=findObj(f,e.layers[b].document)}if(!a&&e.getElementById){a=e.getElementById(f)}return a}function swapImage(){var e,d=0,b,c=swapImage.arguments;document.sr=new Array;for(e=0;e<(c.length-2);e+=3){if((b=findObj(c[e]))!=null){document.sr[d++]=b;if(!b.oSrc){b.oSrc=b.src}b.src=c[e+2]}}};
