var rightImageNum=9;var timerId=0;(function(b){var a;a=b.fn.galleria=function(e){if(!a.hasCSS()){return false}b.historyInit(a.onPageLoad);var h={insert:".galleria_container",history:true,clickNext:true,onImage:function(k,j,i){},onThumb:function(i){},showHeight:0,container:"content"};var f=b.extend(h,e);for(var g in f){b.galleria[g]=f[g]}a.BuildStructure(f.insert,f.container);b(".filmstrip li:first-child").addClass("active");b(".filmstrip").addClass("gallery_demo");b(".filmstrip").width(b(".filmstrip li").size()*97);b("#controller").children().hover(function(){b(this).removeClass("inactive")},function(){b(this).addClass("inactive")});a.PrepFilmstrip(f.filmstrip);var d=(b(f.insert).is(f.insert))?b(f.insert):jQuery(document.createElement("div")).insertBefore(this);var c=b(document.createElement("div")).addClass("galleria_wrapper");d.addClass("galleria_container").append(c);return this.each(function(){b(this).addClass("galleria");b(this).children("li").each(function(p){var l=b(this);var j=b.meta?b.extend({},f,l.data()):f;j.clickNext=b(this).is(":only-child")?false:j.clickNext;var o=b(this).find("a").is("a")?b(this).find("a"):false;var k=b(this).children("img").hide();var q=o?o.attr("href"):k.attr("src");var n=o?o.attr("title"):k.attr("title");var m=new Image();if(j.history&&(window.location.hash&&window.location.hash.replace(/\#/,"")==q)){l.siblings(".active").removeClass("active");l.addClass("active")}b(m).load(function(){b(this).attr("alt",k.attr("alt"));var i=o?o.find("img").addClass("thumb noscale").css("display","none"):k.clone(true).addClass("thumb").css("display","none");if(o){o.replaceWith(i)}i.attr("rel",q);i.attr("title",n);i.click(function(){b.galleria.activate(q)});i.hover(function(){b(this).addClass("hover")},function(){b(this).removeClass("hover")});l.hover(function(){l.addClass("hover")},function(){l.removeClass("hover")});l.prepend(i);i.css("display","block");j.onThumb(jQuery(i));if(l.hasClass("active")){b.galleria.activate(q)}k.remove()}).error(function(){l.html('<span class="error" style="color:red">Error loading image: '+q+"</span>")}).attr("src",q)})})};a.nextSelector=function(c){return b(c).is(":last-child")?b(c).siblings(":first-child"):b(c).next()};a.previousSelector=function(c){return b(c).is(":first-child")?b(c).siblings(":last-child"):b(c).prev()};a.hasCSS=function(){b("body").append(b(document.createElement("div")).attr("id","css_test").css({width:"1px",height:"1px",display:"none"}));var c=(b("#css_test").width()!=1)?false:true;b("#css_test").remove();return c};a.PrepFilmstrip=function(c){if(c){b("#filmstripIndicator").fadeTo(3000,0.5);b(".nav").fadeTo(3000,0.001).hover(b.galleria.TogglerIn,b.galleria.TogglerOut);b(".filmstrip").appendTo(b("#thumbContainer")).show()}else{b(".nav").hide();b("#filmstripIndicator").hide()}};a.BuildStructure=function(d,j){var c=b(document.createElement("div")).addClass("nav");var f=b(document.createElement("div")).attr("id","previous").addClass("inactive").click(b.galleria.prev);var o=b(document.createElement("div")).attr("id","pause").addClass("inactive").click(b.galleria.stop);if(b.browser.msie&&b.browser.version<7){o.css("background","url(../App_themes/Metro/images/Pause.jpg) no-repeat").css("left","20px")}else{o.css("background","url(../App_themes/Metro/images/Pause.png) no-repeat")}var h=b(document.createElement("div")).attr("id","next").click(b.galleria.next).addClass("inactive");var i=b(document.createElement("div")).attr("id","controller").append(f).append(o).append(h);var e=b(document.createElement("img")).attr("id","leftArrow").attr("src","../library/images/LeftActive.png").click(b.galleria.MoveLeft);var k=b(document.createElement("div")).attr("id","thumbContainer");var m=b(document.createElement("img")).attr("id","rightArrow").attr("src","../library/images/RightActive.png").click(b.galleria.MoveRight);var n=b(document.createElement("div")).attr("id","screen");c.append(i).append(e).append(k).append(m).append(n);var l=b(document.createElement("div")).attr("id","filmstripIndicator");var g=b(document.createElement("div")).attr("id","main_image");b(j).append(g).append(c).append(l)};a.onPageLoad=function(h){var f=b(".galleria_wrapper");var g=b('.galleria img[@rel="'+h+'"]');var e=b('#main_image img[@src="'+b.galleria.current+'"]');b.galleria.ControlArrows();if(h){if(b.galleria.history){window.location=window.location.href.replace(/\#.*/,"")+"#"+h}g.parents("li").siblings(".active").removeClass("active");g.parents("li").addClass("active");var d=b(new Image()).attr("src",h).addClass("replaced").hide();b(".caption").remove();var c=b(document.createElement("span")).addClass("caption");f.append(d).append(c);f.children(".caption").text(g.attr("title"));b.galleria.onImage(d,f.siblings(".caption"),g);d.fadeIn(300);e.fadeOut(700,function(){e.remove()});if(b.galleria.clickNext){d.css("cursor","pointer").click(function(){b.galleria.next()})}}else{f.siblings().andSelf().empty();b(".galleria li.active").removeClass("active")}b.galleria.current=h};b.extend({galleria:{stopped:false,play:function(){b("#pause").unbind("click");timerId=setInterval("$.galleria.next()",5000);b("#pause").click(b.galleria.stop).addClass("pause").removeClass("play");b.galleria.next();b.galleria.stopped=false;return true},stop:function(){b("#pause").unbind("click");b("#pause").removeAttr("style");clearInterval(timerId);b("#pause").addClass("play").removeClass("pause").click(b.galleria.play);b.galleria.stopped=true;return true},current:"",onImage:function(){},activate:function(c){if(b.galleria.history){b.historyLoad(c)}else{a.onPageLoad(c)}},next:function(){clearInterval(timerId);timerId=setInterval("$.galleria.next()",5000);var c=b(a.nextSelector(b('.galleria img[@rel="'+b.galleria.current+'"]').parents("li"))).find("img").attr("rel");b.galleria.activate(c)},prev:function(){clearInterval(timerId);timerId=setInterval("$.galleria.next()",5000);var c=b(a.previousSelector(b('.galleria img[@rel="'+b.galleria.current+'"]').parents("li"))).find("img").attr("rel");b.galleria.activate(c)},TogglerIn:function(){b("#filmstripIndicator").hide();b(".nav").fadeTo(500,1)},TogglerOut:function(){b("#filmstripIndicator").show(100);b(".nav").fadeTo(500,0.001)},MoveRight:function(){if(rightImageNum<b(".filmstrip li").size()){rightImageNum++;b(".filmstrip").animate({left:"-=97px"},750);b("#leftArrow").show()}b.galleria.ControlArrows()},MoveLeft:function(){if(rightImageNum>9){rightImageNum--;b(".filmstrip").animate({left:"+=97px"},750)}b.galleria.ControlArrows()},ControlArrows:function(){if(rightImageNum>b(".filmstrip li").size()){b("#rightArrow").hide();b("leftArrow").hide();return}if(rightImageNum==b(".filmstrip li").size()){b("#rightArrow").fadeTo(0.5,0.3)}else{b("#rightArrow").show().fadeTo(0.5,1)}if(rightImageNum==9){b("#leftArrow").fadeTo(0.5,0.3)}else{b("#leftArrow").fadeTo(0.5,1)}}}})})(jQuery);jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyInit:function(d){jQuery.historyCallback=d;var c=location.hash;jQuery.historyCurrentHash=c;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==""){jQuery.historyCurrentHash="#"}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var a=$("#jQuery_history")[0];var b=a.contentWindow.document;b.open();b.close();b.location.hash=c}else{if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true}}jQuery.historyCallback(c.replace(/^#/,""));setInterval(jQuery.historyCheck,100)},historyAddHistory:function(a){jQuery.historyBackStack.push(a);jQuery.historyForwardStack.length=0;this.isFirst=true},historyCheck:function(){if(jQuery.browser.msie){var a=$("#jQuery_history")[0];var d=a.contentDocument||a.contentWindow.document;var f=d.location.hash;if(f!=jQuery.historyCurrentHash){location.hash=f;jQuery.historyCurrentHash=f;jQuery.historyCallback(f.replace(/^#/,""))}}else{if($.browser.safari){if(!jQuery.dontCheck){var b=history.length-jQuery.historyBackStack.length;if(b){jQuery.isFirst=false;if(b<0){for(var c=0;c<Math.abs(b);c++){jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop())}}else{for(var c=0;c<b;c++){jQuery.historyBackStack.push(jQuery.historyForwardStack.shift())}}var e=jQuery.historyBackStack[jQuery.historyBackStack.length-1];if(e!=undefined){jQuery.historyCurrentHash=location.hash;jQuery.historyCallback(e)}}else{if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]==undefined&&!jQuery.isFirst){if(document.URL.indexOf("#")>=0){jQuery.historyCallback(document.URL.split("#")[1])}else{var f=location.hash;jQuery.historyCallback("")}jQuery.isFirst=true}}}}else{var f=location.hash;if(f!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=f;jQuery.historyCallback(f.replace(/^#/,""))}}}},historyLoad:function(d){var e;if(jQuery.browser.safari){e=d}else{e="#"+d;location.hash=e}jQuery.historyCurrentHash=e;if(jQuery.browser.msie){var a=$("#jQuery_history")[0];var c=a.contentWindow.document;c.open();c.close();c.location.hash=e;jQuery.historyCallback(d)}else{if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(d);var b=function(){jQuery.dontCheck=false};window.setTimeout(b,200);jQuery.historyCallback(d);location.hash=e}else{jQuery.historyCallback(d)}}}});