var showingDetail=false;var isVerticalImage;var isGalleryVisible=false;var totalImageNum=0;function stretchImage(){var e=$(".greatImg");var f=0;var d=$(window).width()-305;var c=$(window).height()-f;var b=c/d;var h=e.height()/e.width();var g=d-220;if(e.height()<e.width()){isVerticalImage=false;e.css("margin-top",f+"px");e.width(d);var a=d*h;if(a>c){e.height(c);e.width(c/h)}else{e.height(a)}$("#big-img").css("left","auto");$("#big-img").css("right","40px")}else{isVerticalImage=true;e.height(c+f);e.width((c+f)/h);e.css("margin-top","0px");$("#big-img").css("right","auto");$("#big-img").css("left",(g/2-(e.width()+70)/2))}$("#big-img").width(e.width());$("#big-img").fadeIn("fast")}function showScroll(){$("#slideshow-activator").css("z-index","10");$("#selected-thumb .button-caption").hide();$("#slideshow-countdown").show();$("#gallery-grayer").show();$("#caption").hide();$("#credits").hide();$("#captioncommon").hide();isGalleryVisible=true}function hideScroll(){$("#slideshow-activator").css("z-index","3");$("#selected-thumb .button-caption").show();$("#gallery-grayer").hide();if($("#caption").html()!=""){$("#caption").show()}if($("#credits").html()!=""){$("#credits").show()}if($("#captioncommon").html()!=""){$("#captioncommon").show()}isGalleryVisible=false}function scrollToThumb(a,d){var b=$("#"+a);var c=$("#slideshow-countdown").offset().top-b.offset().top-b.height()-1;$("#slideshow-countdown").animate({top:c},1000,"swing",d)}function showThrobber(){var e=$(".greatImg");var d=$("#throbber");var b=e.offset();var c=e.width();var a=e.height();d.css({top:b.top+"px",left:b.left+"px",width:c+"px",height:a+"px"});d.fadeIn("fast")}function hideThrobber(){$("#throbber").fadeOut("fast")}function updateNavigationLinks(b){var a=sprintf("/%s/%s/%s/%s/",brand,season,gender,page);if(b>0){$("#previous-link").parent().attr("href",a+b)}else{$("#previous-link").parent().attr("href","#")}$("#next-link").parent().attr("href",a+(b+2))}function updateImageNumber(a){$("#gallery-actual-index").html(a)}function positionateCaption(){var a=0;if(a<0){a=0}var b=$(window).height()/100*7;$("#credits").css({right:a,bottom:b});if($("#credits").html()!=""){b+=21}$("#captioncommon").css({right:a,bottom:b});if($("#captioncommon").html()!=""){b+=21}$("#caption").css({right:a,bottom:b})}function updateCaption(d){var a=$("#caption");var c=$("#credits");var b=$("#captioncommon");if(alwaysShowCaptionCommon=="true"){$("#captioncommon").html(captioncommon)}if(d!=null){if(gallery[d].caption!=""){a.html(gallery[d].caption)}else{if(captioncommon!=""&&alwaysShowCaptionCommon=="false"){a.html(captioncommon)}else{a.hide();a.html("")}}c.html(gallery[d].credits)}positionateCaption()}function udpateDetail(b){if(gallery[b].detail_visible=="True"){var a=$("#detail-button img");$("#detail-button").attr("class","detail-"+b);a.attr("src",gallery[b].detail_thumb);positionateDetail();$("#detail-button").show()}else{$("#detail-button").hide()}}function showDetail(c,a){var b=$(".greatImg");if(showingDetail){if(!a){showThrobber();selectImage(c)}$("#detail-button-caption").html("Detail");$("#bigx").hide();showingDetail=false}else{$("#caption").hide();$("#credits").hide();$("#captioncommon").hide();$("#big-img").fadeOut("fast",function(){$(".greatImg").remove();var d=loadImage(gallery[c].detail_big,{},function(){$(d).attr("class","greatImg");$("#big-img").appendChild(d);stretchImage();hideThrobber()})}).fadeIn("fast");$("#detail-button-caption").html("Close");$("#bigx").show();showingDetail=true}}var arrowover=function(){$(this).css("opacity","0.8")};var arrowout=function(){$(this).css("opacity","1")};$(document).ready(function(){var d=220+2;var p=$("#gallery");var c=0;var r=0;var f=$("#footer").height();var a=$("#slideshow-countdown");var i=$("#slideshow-countdown ul:eq(0) a").length;var h=$("#slideshow-countdown ul:eq(1) a").length;var g=$("#slideshow-countdown ul:eq(2) a").length;var t=Math.max(i,h,g);var m=d*t;var b=m;var q=$(window).width();var e=$(window).height()-f-22-26-126;var k=$(window).width()-r;var n=p.position().left+(k/2);var o=p.css("left").split("px")[0];if(!/[-0-9\.]/gi.exec(o)){o=0}var j=null;var l=null;var s=null;if(t>1){a.css("width",b);if(navigator.appName!="Microsoft Internet Explorer"){p.css("width",k)}hideScroll();beginScrollThumbs=function(){var u=0;if(s){newMouseX=Math.round((s/1.007)*1000)/1000;if(s!=newMouseX){s=newMouseX}else{s=0}newMouseX=null;if((s>0&&s<1)||(s<=0&&s>-1)){s=0}u=(s/k)}else{if(l){u=(l/k)}}if(u){u*=-8;u*=u*=u}if(u>60){u-=60}else{if(u<-60){u+=60}}if(u!=0){if(s&&((u<0.5&&u>0)||(u>-0.5&&u<0))){return}scrollThumbsWithDelta(u)}scrollThread=setTimeout("beginScrollThumbs()",100)};scrollThumbsWithDelta=function(w){var v=a.position().left;if(v+w>=0){w=0;v=0}else{if(v+w<-(b-$(window).width()+r)){w=0;v=-(b-$(window).width()+r+1)}}var u=Math.ceil(v+w);a.css({left:u+"px"})};$("#slideshow-activator").bind("mouseleave",function(){hideScroll();clearTimeout(scrollThread)});$("#selthumb-img").bind("mouseleave",function(){hideScroll()});$("#slideshow-activator").bind("mouseenter",function(){showScroll()});$("#selthumb-img").bind("mouseenter",function(){showScroll()});p.bind("mouseenter",function(){showScroll();if(b>($(window).width()-o-r)){s=null;beginScrollThumbs()}});p.bind("mouseleave",function(){clearTimeout(scrollThread);s=l;l=null;beginScrollThumbs()});$("*").mousemove(function(u){l=u.pageX-n});$("#slideshow-countdown img").click(function(v){var u=$(this).attr("id");showThrobber();selectImage(u-1);selectGalleryThumb(u)});$("#previous-link").bind("mouseleave",arrowout);$("#previous-link").bind("mouseenter",arrowover);$("#next-link").bind("mouseleave",arrowout);$("#next-link").bind("mouseenter",arrowover);$(window).keydown(function(v){if(v.keyCode==37){var u=parseInt($("#gallery-actual-index").html());if(u-1<1){u=t+1}showThrobber();selectImage(u-2);selectGalleryThumb(u-1)}else{if(v.keyCode==39){var u=parseInt($("#gallery-actual-index").html());if(u>=t){u=0}showThrobber();selectImage(u);selectGalleryThumb(u+1)}}});$("#previous-link").click(function(v){v.preventDefault();var u=parseInt($("#gallery-actual-index").html());if(u-1<1){u=t+1}showThrobber();selectImage(u-2);selectGalleryThumb(u-1)});$("#next-link").click(function(v){v.preventDefault();var u=parseInt($("#gallery-actual-index").html());if(u>=t){u=0}showThrobber();selectImage(u);selectGalleryThumb(u+1)})}else{$("#gallery-navigation").css("visibility","hidden");$("#selected-thumb").css("visibility","hidden");$("#slideshow-activator").css("visibility","hidden")}$("#detail-button").click(function(v){var u=$(this).attr("class").split("-")[1];showThrobber();showDetail(u,false)});$("#detail-button").bind("mouseleave",arrowout);$("#detail-button").bind("mouseenter",arrowover);p.css({width:q,height:e});$(window).resize(function(){stretchImage();positionateCaption();q=$(window).width();n=p.position().left+(q/2);p.css({width:q,height:e})})});$(window).load(function(){stretchImage();positionateCaption()});init=function(){};
