﻿var autoPlay=true;var heroImages=null;var curImage=-1;var heroInterval=null;var incrementDelay=8000;var authorFlyoutTemplate="<div id='heroauthorflyout'><h3>{0}</h3><p>by {1}</p><p><address>{2}</address></div>";var productFlyoutTemplate="<div id='heroproductflyout'><img src='ImageHandler.axd?width=80&height=80&constraint=4&async=false&productId={0}' alt='' /><h3>Equipment Used:</h3><h4>{1}</h4><p>${2}</p></div>";var flyoutsShowing=false;var HeroGenericGroupName="Hero Images";var isHeroImageChanging=false;$(document).ready(function(){$("#header-menus > li > ul a").click(function(B){if(heroInterval!==null){window.clearTimeout(heroInterval)}});var A=new Henrys.Web.WebServices.HeroImageService();A.GetHeroImages(HeroGenericGroupName,getHeroImages_complete)});function getHeroImages_complete(C){heroImages=C;var A=$("#heroimagecontainer");A.prepend("<img src='' alt='' style='display:none;' id='heroimage' />");var D=new Sys.StringBuilder();D.append("<ul id='heroimageselector'>");for(var B=0;B<heroImages.length;B++){D.append(String.format("<li class='selector {0}'><a href=\"#\">{1}</a></li>",(B==0?"on":"off"),(B+1+"")))}D.append("<li class='pause off'><a href=\"#\"><span>Pause</span></a></li>");D.append("</ul>");$("#herocontainer").append(D.toString());$("#herocontainer").append("<a href='#' id='heroimageauthortarget'>View Author</a>");$("#herocontainer").append("<a href='#' id='heroimageproducttarget'>View Capture Device</a>");$("#heroimageauthortarget, #heroimageproducttarget").click(function(E){E.preventDefault()});$("#herocontainer").hover(function(E){showAuthorFlyout();showProductFlyout();flyoutsShowing=true},function(E){$("#heroauthorflyout").hide().remove();$("#heroproductflyout").hide().remove();flyoutsShowing=false});$("#heroimageselector > li > a").click(function(G){if(!isHeroImageChanging){var E=$(this).text();var F=(E-0);if(F>0){if((E-1)!=curImage){if(heroInterval!==null){window.clearTimeout(heroInterval)}showImage(E-1);heroInterval=window.setTimeout(incrementHeroImage,incrementDelay)}}else{if(E==="Pause"){if(heroInterval!==null){window.clearTimeout(heroInterval)}$(this).children("span").text("Play");$(this).parent().attr("class","play off")}else{$(this).children("span").text("Pause");$(this).parent().attr("class","pause off");heroInterval=window.setTimeout(incrementHeroImage,incrementDelay)}}}G.preventDefault()});$("#heroimage").load(function(){$(this).fadeIn("slow");isHeroImageChanging=false});showImage(0);if(autoPlay){heroInterval=window.setTimeout(incrementHeroImage,incrementDelay)}}function incrementHeroImage(){if(curImage<(heroImages.length-1)){showImage(curImage+1)}else{showImage(0)}heroInterval=window.setTimeout(incrementHeroImage,incrementDelay)}function showImage(C){isHeroImageChanging=true;$("#heroauthorflyout").hide().remove();$("#heroproductflyout").hide().remove();var B=(curImage>=0);var A=$("#heroimage");if(B){A.fadeOut("slow",function(){$(this).hide("normal",function(){$(this).attr("src",heroImages[C].ImagePath)})})}else{A.attr("src",heroImages[C].ImagePath);isHeroImageChanging=false}var D=curImage;curImage=C;if(heroImages[C].LinkUrl===""){A.unbind("click",heroimage_click);A.css("cursor","default")}else{A.bind("click",heroimage_click);A.css("cursor","pointer")}$("#heroimageselector > li.selector:eq("+D+")").attr("class","selector off");$("#heroimageselector > li.selector:eq("+curImage+")").attr("class","selector on");if(flyoutsShowing){showAuthorFlyout();showProductFlyout()}}function heroimage_click(B){var A=heroImages[curImage];if(A.LinkUrl!==""){window.location.href=A.LinkUrl}B.preventDefault();return false}function showAuthorFlyout(){var A=heroImages[curImage];var B=String.format(authorFlyoutTemplate,A.Title,A.Photographer,A.Location);$("#heroauthorflyout").hide().remove();$("#herocontainer").append(B);$("#heroauthorflyout").mouseleave(function(C){$(this).hide().remove()})}function showProductFlyout(){var A=heroImages[curImage];if(A.CapturedWith!==null){var B=String.format(productFlyoutTemplate,A.CapturedWith.ProductId,A.CapturedWith.Name,(A.CapturedWith.Price-0).toFixed(0));$("#heroproductflyout").hide().remove();$("#herocontainer").append(B);$("#heroproductflyout").mouseleave(function(C){$(this).hide().remove()}).click(function(C){window.location.href=A.CapturedWith.ProductUrl;C.preventDefault()})}}if(typeof (Sys)!=="undefined"){Sys.Application.notifyScriptLoaded()};
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();