﻿GRAYS.ImageGallery=function(){};GRAYS.ImageGallery.MarkupFrame='    <div id="modal-mask"></div> \n    <iframe id="ie6HackFrame" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" \n        style="position:absolute;z-index:1000; \n        top:30px; left: 90px; width: 900px; height: 600px; \n        display:block; filter:alpha(opacity=0);"></iframe> \n    <div id="image-gallery-popup" class="modal-popup"><div class="inner"> \n        <p class="header-bar"><a href="#" class="close-link">Close</a></p> \n        <h2>Large images</h2> \n        <p class="large-image"><img /></p> \n        <ol class="thumbs"></ol> \n    </div></div>';
GRAYS.ImageGallery.MarkupThumb="<li><img /></li>";GRAYS.ImageGallery.MarkupNoImages='    <div id="modal-mask"></div> \n    <div id="no-images-gallery-popup" class="modal-popup"> \n        <p class="header-bar"><a href="#" class="close-link">Close</a></p> \n        <p class="no-images">No images available</p> \n    </div>';
GRAYS.ImageGallery.ShowGallery=function(imageHandlerPath,thumbnailSizeCode,largeSizeCode){$.getJSON(imageHandlerPath+"&count=count&jsoncallback=?",function(count){GRAYS.ImageGallery.RenderGallery(imageHandlerPath,thumbnailSizeCode,largeSizeCode,Number(count));
});};GRAYS.ImageGallery.RenderGallery=function(imageHandlerPath,thumbnailSizeCode,largeSizeCode,imageCount){if($("#image-gallery-popup").length>0){return GRAYS.ImageGallery.RemoveGallery();
}if(imageCount==0){$(GRAYS.ImageGallery.MarkupNoImages).prependTo("body");var $popup=$("#no-images-gallery-popup");
$("#modal-mask").height($(document.body).height());var newTop=(GRAYS.browser.indexOf("Safari")>=0?document.body.scrollTop:document.documentElement.scrollTop)+20;
$popup.css("top",newTop+"px");$("a.close-link",$popup).click(function(e){e.preventDefault();
return GRAYS.ImageGallery.RemoveGallery();});}else{$(GRAYS.ImageGallery.MarkupFrame).prependTo("body");
var $popup=$("#image-gallery-popup");$("#modal-mask").height($(document.body).height());
var newTop=(GRAYS.browser.indexOf("Safari")>=0?document.body.scrollTop:document.documentElement.scrollTop)+20;
$popup.add("#ie6HackFrame").css("top",newTop+"px");$("a.close-link",$popup).click(function(e){e.preventDefault();
return GRAYS.ImageGallery.RemoveGallery();});$(".large-image img",$popup).attr({src:imageHandlerPath+"&index=0&s="+largeSizeCode});
var thumbList=$(".thumbs",$popup);for(var index=0;index<imageCount;index++){var thumbSrc=imageHandlerPath+"&index="+index+"&s="+thumbnailSizeCode;
var thumbEntry=$(GRAYS.ImageGallery.MarkupThumb);$("img",thumbEntry).attr({src:thumbSrc});
thumbEntry.appendTo(thumbList);}$(".thumbs img",$popup).hover(function(){var thumbSrc=$(this).attr("src");
var largeSrc=thumbSrc.replace("&s="+thumbnailSizeCode,"&s="+largeSizeCode);$(".large-image img",$popup).attr({src:largeSrc});
});}};GRAYS.ImageGallery.RemoveGallery=function(){$("#modal-mask").remove();$("#image-gallery-popup").remove();
$("#no-images-gallery-popup").remove();$("#ie6HackFrame").remove();return false;};
GRAYS.ItemGallery=function(){};GRAYS.ItemGallery.ApplyGalleryFunctionality=function(element,thumbnailSizeCode,largeSizeCode){if($(element).find(".thumbs img").length==0){return;
}var largeImage=$(element).find(".large-image img");largeImage.click(function(){$(element).find(".gallery-link").click();
});var showThumb=function(){var thumbSrc=$(this).attr("src");var largeSrc=thumbSrc.replace("&s="+thumbnailSizeCode,"&s="+largeSizeCode);
largeImage.attr({src:largeSrc});};$(element).find(".thumbs img").click(showThumb).hover(showThumb,function(){});
$(element).find(".thumbs a").click(function(e){e.preventDefault();});var scrollIndex=0;
var maxScrollIndex=Math.max(0,$(element).find(".thumbs img").length-4);var changeScrollIndex=function(delta){scrollIndex=Math.min(Math.max(0,scrollIndex+delta),maxScrollIndex);
$(element).find(".thumbs ol").css({top:scrollIndex*-60});};$(element).find(".thumbs-scroller-up a").click(function(e){e.preventDefault();
changeScrollIndex(-1);});$(element).find(".thumbs-scroller-down a").click(function(e){e.preventDefault();
changeScrollIndex(1);});};$(document).ready(function(){$(".item-gallery").each(function(i){GRAYS.ItemGallery.ApplyGalleryFunctionality($(this),"gt","n");
});});