if(window.FD){FD.SuperGallery=new Class({Extends:FD.Gallery,Implements:Events,options:{rotateSpeeds:[5000,3500,1500],rotateClasses:["slow","med","fast"],adSwapCount:1,adIslandId:"AdPlaceholder-island"},toggles:["about","moreGalleries","emailAFriend","endOfShow","emailFailure","emailResponse"],errors:{name:"Please enter your friend's name",email:"Please enter your friend's email address",yourName:"Please enter your name",yourEmail:"Please enter your email address"},initialize:function(){if(typeof(window.FDGalleryOptions)!="object"){FDGalleryOptions={}
}this.options=$merge(this.options,FDGalleryOptions);this.options.adSwapCountCalc=true;this.parent(this.options);for(var g=0;g<this.toggles.length;g++){var h=this.toggles[g];if(h){this.parseInnerButtons($(h+"Screen"));var a=$(h);if(a){a.addEvent("click",this.toggle.bindWithEvent(this,h))}}}var c=$(this.options.idImgDesc);if(c){this.defaultDescHeight=c.getStyle("height").toInt();this.defaultOpenPos=this.options.openPos;var d=this.getNav()}this.checkDesc();this.setupEmailForm();var f=$("share");var e=f.getElements("ul")[0];
if(f&&e){f.addEvent("mouseenter",this.show.bind(this,e));f.addEvent("mouseleave",this.hide.bind(this,e))}this.addEvent("swap",this.checkDesc.bind(this));this.addEvent("swap",this.doDynB.bind(this));this.addEvent("navOpen",this.setThumbsTitle.bind(this,"Hide Thumbs"));this.addEvent("navClosed",this.setThumbsTitle.bind(this,"Show Thumbs"));var b=$("thumbnails");if(b){b.addEvent("click",this.closeNav.bind(this))}},setThumbsTitle:function(a){if(a){var b=$("thumbnails");if(b){b.empty().innerHTML=a}}},appendMouseE:function(a){var b=$("thumbnails");
var c=this.getNav();if(b){b.addEvent("mouseenter",this.checkNav.bind(this));c.addEvent("mouseleave",this.closeNav.bind(this))}},setupEmailForm:function(){var a=$("emailAFriendScreen");if(a){var b=a.getElements("form")[0];if(b){b.addEvent("submit",this.validateEmailForm.bindWithEvent(this,b))}}},validateEmailForm:function(b,d){if(b){new Event(b).stop()}$("btnSend").set("disabled",true);var g=d.getElements("input");var f=$("validationError");if(f){for(var a=0;a<g.length;a++){var e=g[a];f.empty();if(e.type!="submit"){var c=e.getParent();
if(c&&((e.name.toLowerCase().indexOf("email")>-1&&!this.validateEmail(e.value))||e.value.trim()=="")){c.addClass("error");c.setStyle("display","block");f.empty().innerHTML=this.errors[e.name];e.focus();e.select();$("btnSend").set("disabled",false);return false}else{c.removeClass("error")}}}}var h={url:d.action,method:"POST",onSuccess:this.updateForm.bind(this),onFailure:this.emailAFriendFailure.bind(this)};new Request(h).post(d)},emailAFriendFailure:function(a){$("btnSend").set("disabled",false);
if(a){var b=$("emailFailureScreen");if(b){b.setHTML(a);this.toggle(null,"emailFailure");this.parseInnerButtons(b)}}},updateForm:function(){$("btnSend").set("disabled",false);var a=$("emailResponseScreen");if(a){this.toggle(null,"emailResponse");this.parseInnerButtons(a);a.getElements("h4").setStyle("margin","0");a.getElements("p").setStyle("margin","200px auto")}},validateEmail:function(f){if(f.length>0){var c=f.indexOf("@");if(c>0){var b=f.lastIndexOf("@");if(c==b){var g=f.substr(0,b+1);var d=/^([a-zA-Z0-9_\.\-\+])+\@/;
if(!d.test(g)){return false}}else{return false}}else{return false}var e=f.substr(f.indexOf("@")+1,f.length);var a=/^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;if(!a.test(e)){return false}return true}},moveBy:function(e,a){var b=$("adspot-300x250-video-preroll");if(b){b.empty()}var c=$("adspot-300x250");if(c){c.style.display="block"}if(e){new Event(e).stop()}else{var e=null}if(this.disabled){if(this.imgPos!=(this.imgC-1)){this.closeAllToggles()}}if(this.options.hotZone>0){if(e){this.closeNav()}}else{if(this.navOn){this.toggleNav()
}}var d=this.imgPos+a;if((d==this.imgC&&!this.disabled)||(a<0&&this.disabled)){this.toggle(e,"endOfShow")}this.swap(e,d);this.moveNavToCurrentImage(a)},toggle:function(d,e){var h=false;if(d){new Event(d).stop()}if(e){this.checkNav();for(var f=0;f<this.toggles.length;f++){var g=this.toggles[f];var b=$(g+"Screen");if(b){var c="hidden";var a=b.getStyle("visibility");if(a=="hidden"&&e==g){c="visible";h=true;if(this.rotating){this.rotate()}}b.setStyle("visibility",c)}}this.disabled=h}},show:function(a){if(a){a.setStyle("visibility","visible")
}},hide:function(a){if(a){a.setStyle("visibility","hidden")}},parseInnerButtons:function(c){if(c){var e=c.getElements("a.close");for(var d=0,b=e.length;d<b;d++){e[d].addEvent("click",this.toggle.bindWithEvent(this,c))}var a=c.getElements(".email");for(var d=0,b=a.length;d<b;d++){a[d].addEvent("click",this.toggle.bindWithEvent(this,"emailAFriend"))}}},toggleRotate:function(){if(this.disabled){if((this.imgC-1)==this.imgPos){this.reset()}else{this.closeAllToggles();this.disabled=false}}this.sentRotateReq=false;
this.rotate()},doDynB:function(){var e=this.options.adSwapCount;if((window.s.prop3||window.s.channel)&&this.options.adSwapCountCalc){var b=new Array();b.domain=3;b.news=3;if(window.s.channel&&b[window.s.channel]){e=b[window.s.channel]}var b=new Array();for(var d in b){if(window.s.prop3&&window.s.prop3.indexOf(d)>-1){e=b[d]}}this.options.adSwapCountCalc=false}this.options.adSwapCount=e;if(this.clickNo>0&&this.clickNo%this.options.adSwapCount==0){if(document.dcdAdsR){document.refreshAds(this.options.adId)
}else{FD.refreshAd(this.options.adIslandId)}var a=$(this.options.idMainImg);if(a&&a.getParent().get("tag")=="a"){var c=a.getParent();c.href=window.location.href;var f;if(window.s_pageName){f=s_pageName}else{if(window.s){f=s.pageName}}}}if(!this.rotating||(this.rotating&&!this.sentRotateReq)){FD.doNielsonImpression.delay(50,FD,[f,c]);this.sentRotateReq=true}},closeAllToggles:function(){this.disabled=false;var c=this.toggles;for(var a=0;a<c.length;a++){var b=$(c[a]+"Screen");if(b){b.setStyle("visibility","hidden")
}}},initRotate:function(){var h=$(this.options.idRotate);if(h){var b=$(this.options.idRotate+"Switch");if(b){b.addEvent("click",this.toggleRotate.bindWithEvent(this));var f=h.getElements("."+this.options.idRotate);var a=this.options.rotateClasses;var d=this.options.rotateSpeeds;if($type(a)=="array"){for(var e=0,c=f.length;e<c;e++){for(var g=0;g<a.length;g++){if(f[e].hasClass(a[g])){f[e].addEvent("click",this.setRotateSpeed.bindWithEvent(this,[d[g],e,f]))}}}}}}},setRotateSpeed:function(b,c,d,a){if(b){new Event(b).stop()
}if($type(c)=="number"){this.options.rotateDur=c;if(this.rotating){$clear(this.rotateID);this.rotateID=false;this.rotating=false}this.rotate();for(var e=0;e<a.length;e++){if(d==e){a[e].addClass(this.options.classSelected)}else{a[e].removeClass(this.options.classSelected)}}}},checkDesc:function(){var b=$(this.options.idImgDesc);var c=this.getNav();if(b){var d=b.offsetHeight;var e=this.options.galH-(d+10);this.options.openPos=this.options.galH-d-(c.offsetHeight-15);if(this.navOn){e=this.options.openPos
}if(!this.navTrans){c.setStyle("top",e+"px")}else{this.closeNav()}}var g=$(this.options.idMainImg);var a=g.getParent();if(this.setMImgTitle&&g){g.set("alt",b.get("html"));if(FDGalleryDesc){var f=FDGalleryDesc[this.imgPos+1]||FDGalleryDesc[0]}a.set("title",f)}else{this.setMImgTitle=true}}});function initFDSuperGallery(){if(window.FDGalleryOptions){window.FDSuperGallery=new FD.SuperGallery(FDGalleryOptions)}}FD.register("FDSuperGallery")};
