/*  
 *  
 */

var Imagegallery = {
  Version: '1.0.0',
  // Configuration
  options: {
    backgroundColor: '#ffffff',                            // Background color of the view
    border: 12,                                            // Size of the border
    buttons: {
      opacity: {                                           // Opacity of inner buttons
        disabled: 0.4,
        normal: 0.75,
        hover: 1
      },
      side: { display: true },                             // Toggle side buttons
      innerPreviousNext: { display: true },                // Toggle the inner previous and next button
      slideshow: { display: true },                        // Toggle slideshow button
      topclose: { side: 'right' }                          // 'right' or 'left'                    
    },
    controller: {                                          // The controller is used on sets
      backgroundColor: '#4d4d4d',
      border: 6,
      buttons: {
        innerPreviousNext: true,
        side: false
      },
      margin: 18,
      opacity: 0.7,
      radius: 6,
      setNumberTemplate: '#{position} / #{total}'
    },
    cyclic: false,                                         // Makes galleries cyclic, no end/begin
    effectDurations: {
      resize: .45,
      sideButtons:{
    	show:  .2,
    	hide:  .2
      },
      content: {
    	appear: .2,
    	fade:   .2
      }
    },
    images: '../images/imagegallery/',                        // relative location of the images
    imgNumberTemplate: '#{position} / #{total}',
    keyboard: true,                                        // Toggle keyboard buttons
    menubarPadding: 6,                                     // Space between menubar and content in px
    overlay: {                                             // Overlay
      background: '#000',                                  // Background color, Mac Firefox & Mac Safari use overlay.png
      close: true,
      opacity: 0.75,
      display: true
    },
    preloadHover: false,                                   // Preload images on mouseover
    radius: 12,                                            // Corner radius of the border
    removeTitles: true,                                    // Set to false if you want to keep title attributes intact
    slideshowDelay: 5,                                     // Delay in seconds before showing the next slide
    titleSplit: '::',                                      // The characters you want to split title with
    transition: function(pos) {                            // Or your own transition
      return ((pos/=0.5) < 1 ? 0.5 * Math.pow(pos, 4) :
        -0.5 * ((pos-=2) * Math.pow(pos,3) - 2));
    },
    viewport: true,                                        // Stay within the viewport, true is recommended
    zIndex: 5000,                                          // zIndex of #imagegallery, #overlay is this -1

    startDimensions: {                                     // Dimensions Imagegallery starts at
      width: 100,
      height: 100
    },
    closeDimensions: {                                     // Close button images
      large: { width: 77, height: 22 },
      small: { width: 25, height: 22 }
    },
    sideDimensions: {                                      // Side button images
      width: 16,
      height: 22
    },

    defaultOptions: {                                      // Default options for each type of view
      image: {
        menubar: 'bottom',
        closeButton: 'large'
      },
      gallery: {
        menubar: 'bottom',
        closeButton: 'large'
      },
      ajax:   {
        width: 400,
        height: 300,
        menubar: 'top',
        closeButton: 'small',
        overflow: 'auto'
      },
      iframe: {
        width: 400,
        height: 300,
        menubar: 'top',
        scrolling: true,
        closeButton: 'small'
      },
      inline: {
        width: 400,
        height: 300,
        menubar: 'top',
        closeButton: 'small',
        overflow: 'auto'
      },
      flash: {
        width: 400,
        height: 300,
        menubar: 'bottom',
        closeButton: 'large'
      },
      quicktime: {
        width: 480,
        height: 220,
        autoplay: true,
        controls: true,
        closeButton: 'large'
      }
    }
  },
  classids: {
    quicktime: 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
    flash: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
  },
  codebases: {
    quicktime: 'http://www.apple.com/qtactivex/qtplugin.cab',
    flash: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0'
  },
  errors: {
    requiresPlugin: "<div class='message'>The content your are attempting to view requires the <span class='type'>#{type}</span> plugin.</div><div class='pluginspage'><p>Please download and install the required plugin from:</p><a href='#{pluginspage}' target='_blank'>#{pluginspage}</a></div>"
  },
  mimetypes: {
    quicktime: 'video/quicktime',
    flash: 'application/x-shockwave-flash'
  },
  pluginspages: {
    quicktime: 'http://www.apple.com/quicktime/download',
    flash: 'http://www.adobe.com/go/getflashplayer'
  },
  // used with auto detection
  typeExtensions: {
    flash: 'swf',
    image: 'bmp gif jpeg jpg png',
    iframe: 'asp aspx cgi cfm htm html jsp php pl php3 php4 php5 phtml rb rhtml shtml txt',
    quicktime: 'avi mov mpg mpeg movie'
  }
}

function l(a)
{
	var b = {};
	Object.keys(a).each(function (c)
	{
		b[c] = a[c] + "px"
	});
	return b
}

function s(a, b)
{
	("" + b).length == 1 && (b = "0" + b);
	var c = ("" + a).length,
		d = ("" + b).length;
	c < d && (a = "0".times(d - c) + a);
	return {
		position: a,
		total: b
	}
}
var q = !! document.createElement("canvas").getContext,
	n = Prototype.Browser.IE &&
function (a)
{
	return (a = /MSIE ([\d.]+)/.exec(a)) ? parseFloat(a[1]) : -1
}(navigator.userAgent) < 7, o = Prototype.Browser.WebKit && !document.evaluate, p = Prototype.Browser.Gecko &&
function ()
{
	var a = navigator.userAgent.match(/rv\:(\d+)/);
	return a && parseFloat(a[1]) < 2
}(navigator.userAgent), r = !! navigator.userAgent.match(/mac/i) && (o || p);
Object.extend(Imagegallery.options.effectDurations, {
	topclose: {
		show: 0.15,
		delay: 0.15
	}
});
Object.extend(Imagegallery, {
	REQUIRED_Prototype: "1.7",
	REQUIRED_Scriptaculous: "1.8.3",
	queue: {
		position: "end",
		scope: "imagegallery"
	},
	require: function (a)
	{
		if (typeof window[a] == "undefined" || this.convertVersionString(window[a].Version) < this.convertVersionString(this["REQUIRED_" + a])) throw "Imagegallery requires " + a + " >= " + this["REQUIRED_" + a];
	},
	convertVersionString: function (a)
	{
		var b = a.replace(/_.*|\./g, "");
		b = parseInt(b + "0".times(4 - b.length));
		return a.indexOf("_") > -1 ? b - 1 : b
	},
	load: function ()
	{
		this.require("Prototype");
		window.Effect && !window.Scriptaculous && this.require("Scriptaculous");
		if (/^(https?:\/\/|\/)/.test(this.options.images)) this.images = this.options.images;
		else
		{
			var a = /imagegallery(?:-[\w\d.]+)?\.js(.*)/;
			this.images = (($$("script[src]").find(function (b)
			{
				return b.src.match(a)
			}) || {}).src || "").replace(a, "") + this.options.images
		}
		q || (document.documentMode >= 8 && !document.namespaces.ns_vml ? document.namespaces.add("ns_vml", "urn:schemas-microsoft-com:vml", "#default#VML") : document.observe("dom:loaded", function ()
		{
			document.createStyleSheet().cssText = "ns_vml\\:*{behavior:url(#default#VML)}"
		}))
	},
	start: function ()
	{
		this.radius = this.options.radius;
		this.border = this.radius > this.options.border ? this.radius : this.options.border;
		this.closeDimensions = this.options.closeDimensions;
		this.sideDimensions = this.options.sideDimensions;
		this.build()
	}
});
Object.extend(Imagegallery, {
	_imagegalleryLoadedEvents: 14,
	_imagegalleryLoadedEvent: function ()
	{
		var a = arguments.callee;
		a.counter++;
		a.counter == this._imagegalleryLoadedEvents && Event.fire.defer(document.body, "imagegallery:loaded")
	}
});
Imagegallery._imagegalleryLoadedEvent.counter = 0;
Object.extend(Imagegallery, {
	build: function ()
	{
		this.imagegallery = new Element("div", {
			id: "imagegallery"
		});
		var a, b, c = l(this.sideDimensions);
		o && (this.imagegallery.hide = function ()
		{
			this.setStyle("left:-9500px;top:-9500px;visibility:hidden;");
			return this
		}, this.imagegallery.show = function ()
		{
			this.setStyle("visibility:visible");
			return this
		}, this.imagegallery.visible = function ()
		{
			return this.getStyle("visibility") == "visible" && parseFloat(this.getStyle("top").replace("px", "")) > -9500
		});
		$(document.body).insert(this.overlay = (new Element("div", {
			id: "ig_overlay"
		})).setStyle(
		{
			zIndex: this.options.zIndex - 1,
			position: !p && !n ? "fixed" : "absolute",
			background: r ? "url(" + this.images + "overlay.png) top left repeat" : this.options.overlay.background
		}).setOpacity(r ? 1 : this.options.overlay.opacity).hide()).insert(this.imagegallery.setStyle(
		{
			zIndex: this.options.zIndex,
			top: "-9500px",
			left: "-9500px"
		}).setOpacity(0).insert(this.container = (new Element("div", {
			className: "ig_Container"
		})).insert(this.sideButtons = (new Element("ul", {
			className: "ig_Sides"
		})).insert(this.prevSide = (new Element("li", {
			className: "ig_PrevSide"
		})).setStyle(b = Object.extend(
		{
			marginLeft: -1 * this.sideDimensions.width + "px"
		}, c)).insert(this.prevButtonImage = (new Element("div", {
			className: "ig_Wrapper"
		})).setStyle(Object.extend(
		{
			marginLeft: this.sideDimensions.width + "px"
		}, c)).insert(new Element("div", {
			className: "ig_Button"
		})))).insert(this.nextSide = (new Element("li", {
			className: "ig_NextSide"
		})).setStyle(Object.extend(
		{
			marginRight: -1 * this.sideDimensions.width + "px"
		}, c)).insert(this.nextButtonImage = (new Element("div", {
			className: "ig_Wrapper"
		})).setStyle(b).insert(new Element("div", {
			className: "ig_Button"
		}))))).insert(this.topButtons = (new Element("div", {
			className: "ig_topButtons"
		})).insert(this.topcloseButtonImage = (new Element("div", {
			className: "ig_Wrapper ig_topcloseButtonImage"
		})).insert(this.topcloseButton = new Element("div", {
			className: "ig_Button"
		})))).insert((new Element("ul", {
			className: "ig_Frames"
		})).insert((new Element("li", {
			className: "ig_Frame ig_FrameTop"
		})).insert(a = (new Element("div", {
			className: "ig_Liquid"
		})).setStyle(
		{
			height: this.border + "px"
		}).insert((new Element("ul", {
			className: "ig_Half ig_HalfLeft"
		})).insert((new Element("li", {
			className: "ig_CornerWrapper"
		})).insert(new Element("div", {
			className: "ig_Corner"
		})).insert((new Element("div", {
			className: "ig_Fill"
		})).setStyle(
		{
			left: this.border + "px"
		})))).insert(new Element("div", {
			className: "ig_Filler"
		})).insert((new Element("ul", {
			className: "ig_Half ig_HalfRight"
		})).insert((new Element("li", {
			className: "ig_CornerWrapper"
		})).setStyle("margin-top: " + -1 * this.border + "px").insert(new Element("div", {
			className: "ig_Corner"
		})).insert((new Element("div", {
			className: "ig_Fill"
		})).setStyle("left: " + -1 * this.border + "px")))))).insert(this.resizeCenter = (new Element("li", {
			className: "ig_Center"
		})).setStyle("height: " + (150 - this.border) + "px").insert((new Element("div", {
			className: "ig_WrapUp"
		})).insert((new Element("div", {
			className: "ig_WrapDown"
		})).setStyle("margin-top: " + this.border + "px").insert(this.center = (new Element("div", {
			className: "ig_WrapCenter"
		})).setOpacity(0).setStyle("padding: 0 " + this.border + "px").insert(this.contentTop = new Element("div", {
			className: "ig_contentTop ig_Fill"
		})).insert(this.menubar = (new Element("div", {
			className: "ig_MenuBar clearfix"
		})).insert(this.closeButton = (new Element("div", {
			className: "ig_Button ig_Close"
		})).setStyle(l(this.options.closeDimensions.large)).setStyle(
		{
			background: this.options.backgroundColor
		}).setOpacity(this.options.buttons.opacity.normal)).insert(this.data = (new Element("ul", {
			className: "ig_Data"
		})).insert(this.dataText = (new Element("li", {
			className: "ig_DataText"
		})).insert(this.title = new Element("div", {
			className: "ig_Title"
		})).insert(this.caption = new Element("div", {
			className: "ig_Caption"
		}))).insert(this.innerController = (new Element("div", {
			className: "ig_innerController"
		})).insert(this.innerPrevNext = (new Element("li", {
			className: "ig_innerPrevNext"
		})).insert(this.innerPrevButton = (new Element("div", {
			className: "ig_Button ig_innerPrevButton"
		})).setOpacity(this.options.buttons.opacity.normal).setStyle(
		{
			backgroundColor: this.options.backgroundColor
		}).setPngBackground(this.images + "inner_prev.gif", {
			backgroundColor: this.options.backgroundColor
		})).insert(this.imgNumber = new Element("div", {
			className: "ig_ImgNumber"
		})).insert(this.innerNextButton = (new Element("div", {
			className: "ig_Button ig_innerNextButton"
		})).setOpacity(this.options.buttons.opacity.normal).setStyle(
		{
			backgroundColor: this.options.backgroundColor
		}).setPngBackground(this.images + "inner_next.gif", {
			backgroundColor: this.options.backgroundColor
		}))).insert(this.slideshow = (new Element("li", {
			className: "ig_Slideshow"
		})).insert(this.slideshowButton = (new Element("div", {
			className: "ig_Button"
		})).setOpacity(this.options.buttons.opacity.normal).setStyle(
		{
			backgroundColor: this.options.backgroundColor
		}).setPngBackground(this.images + "inner_slideshow_play.gif", {
			backgroundColor: this.options.backgroundColor
		})))))).insert(this.contentBottom = new Element("div", {
			className: "ig_contentBottom "
		}))))).insert(this.loading = (new Element("div", {
			className: "ig_Loading"
		})).insert(this.loadingButton = (new Element("div", {
			className: "ig_Button"
		})).setStyle("background: url(" + this.images + "loading.gif) top left no-repeat")))).insert((new Element("li", {
			className: "ig_Frame ig_FrameBottom"
		})).insert(a.cloneNode(true))).insert(this.prevnext = (new Element("li", {
			className: "ig_PrevNext"
		})).hide().setStyle("margin-top: " + this.border + "px; background: url(" + this.images + "blank.gif) top left repeat"))))).insert((new Element("div", {
			id: "imagegalleryError"
		})).hide());
		var d = new Image;
		d.onload = function ()
		{
			d.onload = Prototype.emptyFunction;
			this.sideDimensions = {
				width: d.width,
				height: d.height
			};
			var f = l(this.sideDimensions),
				j;
			this.sideButtons.setStyle(
			{
				marginTop: 0 - (d.height / 2).round() + "px",
				height: d.height + "px"
			});
			this.prevSide.setStyle(j = Object.extend(
			{
				marginLeft: -1 * this.sideDimensions.width + "px"
			}, f));
			this.prevButtonImage.setStyle(Object.extend(
			{
				marginLeft: f.width
			}, f));
			this.nextSide.setStyle(Object.extend(
			{
				marginRight: -1 * this.sideDimensions.width + "px"
			}, f));
			this.nextButtonImage.setStyle(j);
			this._imagegalleryLoadedEvent()
		}.bind(this);
		d.src = this.images + "prev.png";
		$w("center title caption imgNumber")._each(function (f)
		{
			this[f].setStyle(
			{
				backgroundColor: this.options.backgroundColor
			})
		}.bind(this));
		var e = this.container.select(".ig_Corner");
		$w("tl tr bl br").each(function (f, j)
		{
			this.radius > 0 ? this.createCorner(e[j], f) : e[j].insert(new Element("div", {
				className: "ig_Fill"
			}));
			e[j].setStyle(
			{
				width: this.border + "px",
				height: this.border + "px"
			}).addClassName("ig_Corner" + f.capitalize());
			this._imagegalleryLoadedEvent()
		}.bind(this));
		this.imagegallery.select(".ig_Filler", ".ig_Fill", ".ig_WrapDown").invoke("setStyle", {
			backgroundColor: this.options.backgroundColor
		});
		var g = {};
		$w("prev next topclose").each(function (f)
		{
			this[f + "ButtonImage"].side = f;
			var j = this.images + f + ".png";
			f == "topclose" ? (g[f] = new Image, g[f].onload = function ()
			{
				g[f].onload = Prototype.emptyFunction;
				this.closeDimensions[f] = {
					width: g[f].width,
					height: g[f].height
				};
				var m = this.options.buttons.topclose.side,
					t = Object.extend(
					{
						"float": m,
						marginTop: this.closeDimensions[f].height + "px"
					}, l(this.closeDimensions[f]));
				t["padding" + m.capitalize()] = this.border + "px";
				this[f + "ButtonImage"].setStyle(t);
				this.topButtons.setStyle(
				{
					height: g[f].height + "px",
					top: -1 * this.closeDimensions[f].height + "px"
				});
				this[f + "ButtonImage"].down().setPngBackground(j).setStyle(l(this.closeDimensions[f]));
				this._imagegalleryLoadedEvent()
			}.bind(this), g[f].src = this.images + f + ".png") : this[f + "ButtonImage"].setPngBackground(j)
		}, this);
		var h = {};
		$w("large small").each(function (f)
		{
			h[f] = new Image;
			h[f].onload = function ()
			{
				h[f].onload = Prototype.emptyFunction;
				this.closeDimensions[f] = {
					width: h[f].width,
					height: h[f].height
				};
				this._imagegalleryLoadedEvent()
			}.bind(this);
			h[f].src = this.images + "close_" + f + ".gif"
		}, this);
		var i = new Image;
		i.onload = function ()
		{
			i.onload = Prototype.emptyFunction;
			this.loading.setStyle(
			{
				width: i.width + "px",
				height: i.height + "px",
				marginTop: -0.5 * i.height + 0.5 * this.border + "px",
				marginLeft: -0.5 * i.width + "px"
			});
			this._imagegalleryLoadedEvent()
		}.bind(this);
		i.src = this.images + "loading.gif";
		var k = new Image;
		k.onload = function ()
		{
			k.onload = Prototype.emptyFunction;
			var f = {
				width: k.width + "px",
				height: k.height + "px"
			};
			this.slideshow.setStyle(f);
			this.slideshowButton.setStyle(f);
			this._imagegalleryLoadedEvent()
		}.bind(this);
		k.src = this.images + "inner_slideshow_stop.gif";
		$w("prev next").each(function (f)
		{
			var j = f.capitalize(),
				m = new Image;
			m.onload = function ()
			{
				m.onload = Prototype.emptyFunction;
				this["inner" + j + "Button"].setStyle(
				{
					width: m.width + "px",
					height: m.height + "px"
				});
				this._imagegalleryLoadedEvent()
			}.bind(this);
			m.src = this.images + "inner_" + f + ".gif";
			this["inner" + j + "Button"].prevnext = f
		}, this);
		$w("slideshow innerPrevNext imgNumber").each(function (f)
		{
			this[f].hide = this[f].hide.wrap(function (j, m)
			{
				this.style.position = "absolute";
				j(m);
				return this
			});
			this[f].show = this[f].show.wrap(function (j, m)
			{
				this.style.position = "relative";
				j(m);
				return this
			})
		}, this);
		this.imagegallery.select("*").invoke("setStyle", {
			zIndex: this.options.zIndex + 1
		});
		this.imagegallery.hide();
		this._imagegalleryLoadedEvent()
	},
	prepare: function ()
	{
		Effect.Queues.get("imagegallery")._each(function (a)
		{
			a.cancel()
		});
		this.scaledInnerDimensions = null;
		this.view.isSet() ? (this.controllerHeight = this._controllerHeight, this.controller && !this.controller.visible() && (this.controller.setStyle("visibility:hidden").show(), this.controllerCenter.setOpacity(0))) : (this.controllerHeight = null, this.controller.hide());
		!this.view.options.topclose && this.topcloseButtonImage.retrieve("visible") && this.toggleTopClose(false);
		this.hideOverlapping();
		this.hideContent();
		new Effect.Event(
		{
			queue: this.queue,
			afterFinish: function ()
			{
				$w("top bottom").each(function (a)
				{
					var b = a.capitalize();
					this["content" + b].remove();
					var c = {};
					this["content" + b] = (new Element("div", {
						className: "ig_content" + b
					})).hide();
					c[a] = this["content" + b];
					this.center.insert(c)
				}.bind(this))
			}.bind(this)
		});
		this.disableKeyboardNavigation();
		this.views = null
	},
	restoreInlineContent: function ()
	{
		this.inlineContent && this.inlineMarker && (this.inlineMarker.insert(
		{
			before: this.inlineContent.setStyle(
			{
				display: this.inlineContent._inlineDisplayRestore
			})
		}), this.inlineMarker.remove(), this.inlineMarker = null)
	},
	show: function (a, b)
	{
		this.element = null;
		var c = Object.isString(a);
		if (Object.isElement(a) || c)
		{
			if (c && a.startsWith("#"))
			{
				this.show(
				{
					href: a,
					options: Object.extend(
					{
						autosize: true
					}, b || {})
				});
				return
			}
			this.element = $(a);
			if (!this.element) return;
			this.element.blur();
			this.view = this.element._view || new Imagegallery.View(this.element)
		}
		else a.href ? (this.element = $(document.body), this.view = new Imagegallery.View(a)) : Object.isNumber(a) && (this.element = this.getSet(this.view.rel)[a], this.view = this.element._view);
		if (this.view.href)
		{
			this.prepare();
			if (this.view.isGallery() || this.view.isSet())
			{
				this.extendSet(this.view.rel);
				this.views = this.getViews(this.view.rel);
				this.view.isSet() && (this.controllerOffset = this.views.length > 1 ? this._controllerOffset : 0, this.isSetGallery = this.views.all(function (e)
				{
					return e.isImage()
				}))
			}
			this.restoreCenter();
			this.appear();
			if (this.view.href != "#imagegalleryError" && Object.keys(Imagegallery.Plugin).join(" ").indexOf(this.view.type) >= 0 && !Imagegallery.Plugin[this.view.type])
			{
				$("imagegalleryError").update((new Template(this.errors.requiresPlugin)).evaluate(
				{
					type: this.view.type.capitalize(),
					pluginspage: this.pluginspages[this.view.type]
				}));
				c = $("imagegalleryError").getDimensions();
				this.show(
				{
					href: "#imagegalleryError",
					title: this.view.type.capitalize() + " plugin required",
					options: c
				});
				return false
			}
			c = Object.extend(
			{
				menubar: "bottom",
				topclose: false,
				wmode: "transparent",
				innerPreviousNext: this.view.isGallery() && this.options.buttons.innerPreviousNext.display,
				keyboard: this.options.keyboard,
				slideshow: this.view.isGallery() && this.options.buttons.slideshow.display || this.isSetGallery,
				overflow: "hidden",
				overlayClose: this.options.overlay.close,
				viewport: this.options.viewport
			}, this.options.defaultOptions[this.view.type] || {});
			this.view.options = Object.extend(c, this.view.options);
			this.view.isSet() && (this.view.options.topclose = this.views.length <= 1);
			!(this.view.title || this.view.caption || this.views && this.views.length > 1) && this.view.options.topclose && (this.view.options.menubar = false);
			this._contentPosition = "content" + (this.view.options.menubar == "top" ? "Bottom" : "Top");
			if (this.view.isImage())
			{
				if (!q && !this.view._VMLPreloaded)
				{
					this.view._VMLPreloaded = true;
					var d = (new Element("ns_vml:image", {
						src: this.view.href,
						display: "none"
					})).setStyle("height:1px;width:1px;");
					$(document.body).insert(d);
					Element.remove.delay(0.1, d)
				}
				if (this.view.isGallery() || this.view.isSet())
				{
					this.position = this.views.indexOf(this.view);
					this.preloadSurroundingImages()
				}
				if (this.innerDimensions = this.view.preloadedDimensions) this.afterEffect();
				else
				{
					this.startLoading();
					d = new Image;
					d.onload = function ()
					{
						d.onload = Prototype.emptyFunction;
						this.stopLoading();
						this.innerDimensions = {
							width: d.width,
							height: d.height
						};
						this.afterEffect()
					}.bind(this);
					d.src = this.view.href
				}
			}
			else
			{
				this.view.isSet() && (this.position = this.views.indexOf(this.view));
				this.innerDimensions = this.view.options.fullscreen ? document.viewport.getDimensions() : {
					width: this.view.options.width,
					height: this.view.options.height
				};
				this.afterEffect()
			}
		}
	},
	insertContent: function ()
	{
		function a(c, d, e)
		{
			c = $(c);
			e = l(e);
			c.update((new Element("img", {
				id: "imagegalleryContent",
				src: d,
				alt: "",
				galleryimg: "no"
			})).setStyle(e))
		}
		var b = function ()
			{
				function c(e, g, h)
				{
					e = $(e);
					var i = l(h),
						k = new Image;
					k.onload = function ()
					{
						canvas = new Element("canvas", i);
						e.update(canvas);
						try
						{
							canvas.getContext("2d").drawImage(k, 0, 0, h.width, h.height)
						}
						catch (f)
						{
							a(e, g, h)
						}
					}.bind(this);
					k.src = g
				}

				function d(e, g, h)
				{
					e = $(e);
					h = Object.extend(
					{
						"float": "left"
					}, l(h));
					g = (new Element("ns_vml:image", {
						src: g,
						id: "imagegalleryContent"
					})).setStyle(h);
					e.update(g);
					g.outerHTML = g.outerHTML
				}
				return q ? c : d
			}();
		return function ()
		{
			this.detectExtension(this.view.href);
			var c = this.scaledInnerDimensions || this.innerDimensions;
			if (this.view.isImage())
			{
				this[this._contentPosition].setStyle(l(c));
				this.scaledInnerDimensions ? b(this[this._contentPosition], this.view.href, c) : a(this[this._contentPosition], this.view.href, c)
			}
			else if (this.view.isExternal()) switch (this.view.type)
			{
			case "ajax":
				c = Object.clone(this.view.options.ajax) || {};
				var d = function ()
					{
						this.stopLoading();
						this.view.options.autosize && (this[this._contentPosition].setStyle(
						{
							width: "auto",
							height: "auto"
						}), this.innerDimensions = this.getHiddenDimensions(this[this._contentPosition]));
						new Effect.Event(
						{
							queue: this.queue,
							afterFinish: this.resizeWithinViewport.bind(this)
						})
					}.bind(this);
				c.onComplete ? c.onComplete = c.onComplete.wrap(function (g, h)
				{
					d();
					g(h)
				}) : c.onComplete = d;
				this.startLoading();
				new Ajax.Updater(this[this._contentPosition], this.view.href, c);
				break;
			case "iframe":
				this.scaledInnerDimensions && (c.height -= this.menubarDimensions.height);
				this[this._contentPosition].update(this.iframe = (new Element("iframe", {
					frameBorder: 0,
					hspace: 0,
					src: this.view.href,
					id: "imagegalleryContent",
					name: "imagegalleryContent_" + (Math.random() * 99999).round(),
					scrolling: this.view.options && this.view.options.scrolling ? "auto" : "no"
				})).setStyle(Object.extend(
				{
					border: 0,
					margin: 0,
					padding: 0
				}, l(c))));
				break;
			case "inline":
				c = this.view.href;
				c = $(c.substr(c.indexOf("#") + 1));
				if (!c || !c.tagName) break;
				var e = c.getDimensions();
				c.insert(
				{
					before: this.inlineMarker = (new Element(c.tagName)).hide()
				});
				c._inlineDisplayRestore = c.getStyle("display");
				this.inlineContent = c.show();
				this[this._contentPosition].update(this.inlineContent);
				this[this._contentPosition].select("select, object, embed").each(function (g)
				{
					this.overlappingRestore.each(function (h)
					{
						h.element == g && g.setStyle(
						{
							visibility: h.visibility
						})
					})
				}.bind(this));
				this.view.options.autosize && (this.innerDimensions = e, new Effect.Event(
				{
					queue: this.queue,
					afterFinish: this.resizeWithinViewport.bind(this)
				}))
			}
			else
			{
				e = {
					tag: "object",
					id: "imagegalleryContent",
					width: c.width,
					height: c.height
				};
				switch (this.view.type)
				{
				case "quicktime":
					Object.extend(e, {
						pluginspage: this.pluginspages[this.view.type],
						children: [
						{
							tag: "param",
							name: "autoplay",
							value: this.view.options.autoplay}, {
							tag: "param",
							name: "scale",
							value: "tofit"}, {
							tag: "param",
							name: "controller",
							value: this.view.options.controls}, {
							tag: "param",
							name: "enablejavascript",
							value: true}, {
							tag: "param",
							name: "src",
							value: this.view.href}, {
							tag: "param",
							name: "loop",
							value: this.view.options.loop || false}]
					});
					Object.extend(e, Prototype.Browser.IE ? {
						codebase: this.codebases[this.view.type],
						classid: this.classids[this.view.type]
					} : {
						data: this.view.href,
						type: this.mimetypes[this.view.type]
					});
					break;
				case "flash":
					Object.extend(e, {
						data: this.view.href,
						type: this.mimetypes[this.view.type],
						quality: "high",
						wmode: this.view.options.wmode,
						pluginspage: this.pluginspages[this.view.type],
						children: [
						{
							tag: "param",
							name: "movie",
							value: this.view.href}, {
							tag: "param",
							name: "allowFullScreen",
							value: "true"}]
					});
					this.view.options.flashvars && e.children.push(
					{
						tag: "param",
						name: "FlashVars",
						value: this.view.options.flashvars
					})
				}
				this[this._contentPosition].setStyle(l(c)).update(this.createHTML(e)).setStyle("visibility:hidden").show();
				this.view.isQuicktime() &&
				function ()
				{
					try
					{
						"SetControllerVisible" in $("imagegalleryContent") && $("imagegalleryContent").SetControllerVisible(this.view.options.controls)
					}
					catch (g)
					{}
				}.bind(this).defer()
			}
		}
	}(),
	getHiddenDimensions: function (a)
	{
		a = $(a);
		var b = a.ancestors(),
			c = [],
			d = [];
		b.push(a);
		b.each(function (e)
		{
			if (e == a || !e.visible())
			{
				c.push(e);
				d.push(
				{
					display: e.getStyle("display"),
					position: e.getStyle("position"),
					visibility: e.getStyle("visibility")
				});
				e.setStyle(
				{
					display: "block",
					position: "absolute",
					visibility: "visible"
				})
			}
		});
		b = {
			width: a.clientWidth,
			height: a.clientHeight
		};
		c.each(function (e, g)
		{
			e.setStyle(d[g])
		});
		return b
	},
	clearContent: function ()
	{
		var a = $("imagegalleryContent");
		if (a) switch (a.tagName.toLowerCase())
		{
		case "object":
			if (Prototype.Browser.WebKit && this.view.isQuicktime())
			{
				try
				{
					a.Stop()
				}
				catch (b)
				{}
				a.innerHTML = ""
			}
			a.parentNode ? a.remove() : a = Prototype.emptyFunction;
			break;
		case "iframe":
			a.remove();
			Prototype.Browser.Gecko && window.frames.imagegalleryContent && delete window.frames.imagegalleryContent;
			break;
		default:
			a.remove()
		}
		$w("Top Bottom").each(function (c)
		{
			this["content" + c].setStyle("width:auto;height:auto;").update("").hide()
		}, this)
	},
	adjustDimensionsToView: function ()
	{
		var a = this.scaledInnerDimensions || this.innerDimensions;
		if (this.view.options.controls) switch (this.view.type)
		{
		case "quicktime":
			a.height += 16
		}
		this[(this.scaledInnerDimensions ? "scaledI" : "i") + "nnerDimensions"] = a
	},
	afterEffect: function ()
	{
		new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.afterShow.bind(this)
		})
	},
	afterShow: function ()
	{
		this.fillMenuBar();
		this.view.isAjax() || this.stopLoading();
		this.view.options.autosize && this.view.isInline() || this.view.isAjax() || this.resizeWithinViewport();
		this.view.isIframe() || new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.insertContent.bind(this)
		});
		this.view.options.topclose && new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.toggleTopClose.bind(this, true)
		})
	},
	finishShow: function ()
	{
		new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.showContent.bind(this)
		});
		this.view.isIframe() && new Effect.Event(
		{
			delay: 0.2,
			queue: this.queue,
			afterFinish: this.insertContent.bind(this)
		});
		this.sliding && new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.nextSlide.bind(this)
		});
		(this.view.isQuicktime() || this.view.isFlash()) && new Effect.Event(
		{
			queue: this.queue,
			delay: 0.1,
			afterFinish: Element.setStyle.bind(this, this[this._contentPosition], "visibility:visible")
		})
	},
	previous: function ()
	{
		Effect.Queues.get(Imagegallery.queue.scope).effects.length || this.show(this.getSurroundingIndexes().previous)
	},
	next: function ()
	{
		Effect.Queues.get(Imagegallery.queue.scope).effects.length || this.show(this.getSurroundingIndexes().next)
	},
	resizeWithinViewport: function ()
	{
		this.adjustDimensionsToView();
		var a = this.getInnerDimensions(),
			b = this.getBounds();
		if (this.view.options.viewport && (a.width > b.width || a.height > b.height)) if (this.view.options.fullscreen)
		{
			this.scaledInnerDimensions = b;
			this.fillMenuBar();
			a = b
		}
		else
		{
			a = this.getOuterDimensions();
			if (this.view.isMedia())
			{
				b = [b.height / a.height, b.width / a.width, 1].min();
				this.scaledInnerDimensions = {
					width: (this.innerDimensions.width * b).round(),
					height: (this.innerDimensions.height * b).round()
				}
			}
			else this.scaledInnerDimensions = {
				width: a.width > b.width ? b.width : a.width,
				height: a.height > b.height ? b.height : a.height
			};
			this.fillMenuBar();
			a = Object.clone(this.scaledInnerDimensions);
			this.view.isMedia() && (a.height += this.menubarDimensions.height)
		}
		else
		{
			this.fillMenuBar();
			this.scaledInnerDimensions = null
		}
		this._resize(a)
	},
	resize: function (a)
	{
		this._resize(a, {
			duration: 0
		})
	},
	_resize: function ()
	{
		var a, b, c, d, e, g = function ()
			{
				var h, i, k;
				n ? k = function (f)
				{
					this.imagegallery.setStyle(
					{
						width: (a.width + f * b).toFixed(0) + "px",
						height: (a.height + f * c).toFixed(0) + "px"
					});
					this.resizeCenter.setStyle(
					{
						height: i - 1 * this.border + "px"
					})
				} : p ? k = function ()
				{
					var f = this.getViewportDimensions(),
						j = document.viewport.getScrollOffsets();
					this.imagegallery.setStyle(
					{
						position: "absolute",
						marginLeft: 0,
						marginTop: 0,
						width: h + "px",
						height: i + "px",
						left: (j[0] + f.width / 2 - h / 2).floor() + "px",
						top: (j[1] + f.height / 2 - i / 2).floor() + "px"
					});
					this.resizeCenter.setStyle(
					{
						height: i - 1 * this.border + "px"
					})
				} : k = function ()
				{
					this.imagegallery.setStyle(
					{
						position: "fixed",
						width: h + "px",
						height: i + "px",
						marginLeft: ((0 - h) / 2).round() + "px",
						marginTop: ((0 - i) / 2 - d).round() + "px"
					});
					this.resizeCenter.setStyle(
					{
						height: i - 1 * this.border + "px"
					})
				};
				return function (f)
				{
					h = (a.width + f * b).toFixed(0);
					i = (a.height + f * c).toFixed(0);
					k.call(this, f)
				}
			}();
		return function (h, i)
		{
			var k = i || {};
			a = this.imagegallery.getDimensions();
			e = 2 * this.border;
			width = h.width ? h.width + e : a.width;
			height = h.height ? h.height + e : a.height;
			this.hidePrevNext();
			if (a.width == width && a.height == height) new Effect.Event(
			{
				queue: this.queue,
				afterFinish: this._afterResize.bind(this, h)
			});
			else
			{
				var f = {
					width: width + "px",
					height: height + "px"
				};
				b = width - a.width;
				c = height - a.height;
				parseInt(this.imagegallery.getStyle("marginLeft").replace("px", ""));
				parseInt(this.imagegallery.getStyle("marginTop").replace("px", ""));
				d = this.controller.visible() ? this.controllerOffset / 2 : 0;
				n || Object.extend(f, {
					marginLeft: 0 - width / 2 + "px",
					marginTop: 0 - height / 2 + "px"
				});
				k.duration == 0 ? g.call(this, 1) : this.resizing = new Effect.Tween(this.imagegallery, 0, 1, Object.extend(
				{
					duration: this.options.effectDurations.resize,
					queue: this.queue,
					transition: this.options.transition,
					afterFinish: this._afterResize.bind(this, h)
				}, k), g.bind(this))
			}
		}
	}(),
	_afterResize: function (a)
	{
		if (this.menubarDimensions)
		{
			var b = this[this._contentPosition],
				c;
			this.view.options.overflow == "auto" && (c = b.getDimensions());
			b.setStyle(
			{
				height: a.height - this.menubarDimensions.height + "px",
				width: a.width + "px"
			});
			if (this.view.options.overflow != "hidden" && (this.view.isAjax() || this.view.isInline())) if (Prototype.Browser.IE) if (this.view.options.overflow == "auto")
			{
				var d = b.getDimensions();
				b.setStyle("overflow:visible");
				var e = {
					overflowX: "hidden",
					overflowY: "hidden"
				},
					g = 0;
				c.height > a.height && (e.overflowY = "auto", e.width = d.width - 15, e.paddingRight = "15px", g = 15);
				c.width - g > a.width && (e.overflowX = "auto", e.height = d.height - 15, e.paddingBottom = "15px");
				b.setStyle(e)
			}
			else b.setStyle(
			{
				overflow: this.view.options.overflow
			});
			else b.setStyle(
			{
				overflow: this.view.options.overflow
			});
			else b.setStyle("overflow:hidden");
			this.restoreCenter();
			this.resizing = null;
			this.finishShow()
		}
	},
	showContent: function ()
	{
		new Effect.Event(
		{
			queue: this.queue,
			beforeStart: this.hidePrevNext.bind(this)
		});
		new Effect.Event(
		{
			queue: this.queue,
			afterFinish: function ()
			{
				this[this._contentPosition].show();
				this.fillMenuBar();
				this.menubar.visible() && this.menubar.setStyle("visibility:visible").setOpacity(1)
			}.bind(this)
		});
		new Effect.Parallel([new Effect.Opacity(this.center, {
			sync: true,
			from: 0,
			to: 1
		}), new Effect.Appear(this.sideButtons, {
			sync: true
		})], {
			queue: this.queue,
			duration: this.options.effectDurations.content.appear,
			afterFinish: function ()
			{
				this.element && this.element.fire("imagegallery:opened")
			}.bind(this)
		});
		(this.view.isGallery() || this.isSetGallery && this.options.controller.buttons.side) && new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.showPrevNext.bind(this)
		})
	},
	hideContent: function ()
	{
		function a(c)
		{
			this.center.setOpacity(c);
			this.sideButtons.setOpacity(c)
		}

		function b()
		{
			this.restoreInlineContent();
			this.clearContent()
		}
		return function ()
		{
			this.imagegallery.visible() ? new Effect.Tween(this.imagegallery, 1, 0, {
				duration: 0.2,
				queue: this.queue,
				afterFinish: b.bind(this)
			}, a.bind(this)) : (this.center.setOpacity(0), this.sideButtons.setOpacity(0), this.clearContent())
		}
	}(),
	hideData: function ()
	{
		$w("innerController data dataText title caption imgNumber innerPrevNext innerNextButton innerPrevButton slideshow closeButton").each(function (a)
		{
			Element.hide(this[a])
		}, this);
		this.menubar.setStyle("visibility:hidden").setOpacity(0)
	},
	fillMenuBar: function ()
	{
		this.hideData();
		this.view.options.menubar ? this.menubar.show() : (this.menubarDimensions = {
			width: 0,
			height: 0
		}, this.closeButtonWidth = 0, this.menubar.hide());
		if (this.view.title || this.view.caption)
		{
			this.dataText.show();
			this.data.show()
		}
		this.view.title && this.title.update(this.view.title).show();
		this.view.caption && this.caption.update(this.view.caption).show();
		if (this.views && this.views.length > 1) if (this.view.isSet())
		{
			var a = s(this.position + 1, this.views.length);
			this.setNumber.update((new Template(this.options.controller.setNumberTemplate)).evaluate(
			{
				position: a.position,
				total: a.total
			}));
			this.controller.getStyle("visibility") == "hidden" && (this.controller.setStyle("visibility:visible"), this._controllerCenterEffect && Effect.Queues.get("imagegallery").remove(this._controllerCenterEffect), this._controllerCenterEffect = new Effect.Appear(this.controllerCenter, {
				queue: this.queue,
				duration: 0.1
			}))
		}
		else
		{
			this.data.show();
			if (this.view.isImage())
			{
				this.innerController.show();
				this.innerPrevNext.show();
				a = s(this.position + 1, this.views.length);
				this.imgNumber.show().update((new Template(this.options.imgNumberTemplate)).evaluate(
				{
					position: a.position,
					total: a.total
				}));
				this.view.options.slideshow && (this.slideshowButton.show(), this.slideshow.show())
			}
		}
		var b = this.view.isSet();
		if ((this.view.options.innerPreviousNext || b) && this.views.length > 1)
		{
			var c = {
				prev: this.options.cyclic || this.position != 0,
				next: this.options.cyclic || (this.view.isGallery() || b) && this.getSurroundingIndexes().next != 0
			};
			$w("prev next").each(function (d)
			{
				var e = d.capitalize(),
					g = c[d] ? "pointer" : "auto";
				b ? this["controller" + e].setStyle(
				{
					cursor: g
				}).setOpacity(c[d] ? 1 : this.options.buttons.opacity.disabled) : this["inner" + e + "Button"].setStyle(
				{
					cursor: g
				}).setOpacity(c[d] ? this.options.buttons.opacity.normal : this.options.buttons.opacity.disabled)
			}.bind(this));
			if (this.view.options.innerPreviousNext || this.options.controller.innerPreviousNext)
			{
				this.innerPrevButton.show();
				this.innerNextButton.show();
				this.innerPrevNext.show()
			}
		}
		this.controllerSlideshow.setOpacity(this.isSetGallery ? 1 : this.options.buttons.opacity.disabled).setStyle(
		{
			cursor: this.isSetGallery ? "pointer" : "auto"
		});
		this.setCloseButtons();
		this.menubar.childElements().find(Element.visible) || (this.menubar.hide(), this.view.options.menubar = false);
		this.setMenubarDimensions()
	},
	setCloseButtons: function ()
	{
		var a = this.closeDimensions.small.width,
			b = this.closeDimensions.large.width,
			c = this.scaledInnerDimensions ? this.scaledInnerDimensions.width : this.innerDimensions.width,
			d = 0,
			e = this.view.options.closeButton || "large",
			g = this.options.borderColor;
		this.view.options.topclose || this.view.isSet() || !this.view.options.closeButton ? g = null : c >= 180 + a && c < 180 + b ? (g = "small", d = a) : c >= 180 + b && (g = e, d = this.closeDimensions[e].width);
		d > 0 ? (this.data.show(), this.closeButton.setStyle(
		{
			width: d + "px"
		}).show()) : this.closeButton.hide();
		g && this.closeButton.setPngBackground(this.images + "close_" + g + ".gif", {
			backgroundColor: this.options.backgroundColor
		});
		this.closeButtonWidth = d
	},
	startLoading: function ()
	{
		this.loading.show()
	},
	stopLoading: function ()
	{
		this.loadingEffect && Effect.Queues.get("imagegallery").remove(this.loadingEffect);
		new Effect.Fade(this.loading, {
			duration: 0.2,
			queue: this.queue,
			delay: 0.2
		})
	},
	setPrevNext: function ()
	{
		if (this.view.isImage())
		{
			var a = this.options.cyclic && this.views.length > 1 || this.position != 0,
				b = this.options.cyclic && this.views.length > 1 || (this.view.isGallery() || this.view.isSet()) && this.getSurroundingIndexes().next != 0;
			this.prevButtonImage[a ? "show" : "hide"]();
			this.nextButtonImage[b ? "show" : "hide"]();
			var c = this.scaledInnerDimensions || this.innerDimensions;
			this.prevnext.setStyle(
			{
				height: c.height + "px",
				marginTop: this.border + (this.view.options.menubar == "top" ? this.menubar.getHeight() : 0) + "px"
			});
			c = (c.width / 2 - 1 + this.border).floor();
			a && (this.prevnext.insert(this.prevButton = (new Element("div", {
				className: "ig_Button ig_PrevButton"
			})).setStyle(
			{
				width: c + "px"
			})), this.prevButton.side = "prev");
			b && (this.prevnext.insert(this.nextButton = (new Element("div", {
				className: "ig_Button ig_NextButton"
			})).setStyle(
			{
				width: c + "px"
			})), this.nextButton.side = "next");
			(a || b) && this.prevnext.show()
		}
	},
	showPrevNext: function ()
	{
		!this.view || !this.options.buttons.side.display || !this.view.isImage() || (this.setPrevNext(), this.prevnext.show())
	},
	hidePrevNext: function ()
	{
		this.prevButton && (this.prevButton = null);
		this.nextButton && (this.nextButton = null);
		this.prevnext.update("").hide();
		this.prevButtonImage.hide().setStyle(
		{
			marginLeft: this.sideDimensions.width + "px"
		});
		this.nextButtonImage.hide().setStyle(
		{
			marginLeft: -1 * this.sideDimensions.width + "px"
		})
	},
	appear: function ()
	{
		function a()
		{
			this.imagegallery.setOpacity(1)
		}
		o || (a = a.wrap(function (b, c)
		{
			b(c);
			this.imagegallery.show()
		}));
		return function ()
		{
			this.imagegallery.getStyle("opacity") == 0 && (this.options.overlay.display ? new Effect.Appear(this.overlay, {
				duration: 0.2,
				from: 0,
				to: r ? 1 : this.options.overlay.opacity,
				queue: this.queue,
				beforeStart: this.maxOverlay.bind(this),
				afterFinish: a.bind(this)
			}) : a.call(this))
		}
	}(),
	hide: function ()
	{
		Prototype.Browser.IE && this.iframe && this.view.isIframe() && this.iframe.remove();
		if (o && this.view.isQuicktime())
		{
			var a = $$("object#imagegalleryContent")[0];
			if (a) try
			{
				a.Stop()
			}
			catch (b)
			{}
		}
		if (this.imagegallery.getStyle("opacity") != 0)
		{
			this.stopSlideshow();
			this.prevnext.hide();
			(!Prototype.Browser.IE || !this.view.isIframe()) && this.center.hide();
			if (!(Effect.Queues.get("imagegallery_hide").effects.length > 0))
			{
				Effect.Queues.get("imagegallery").each(function (c)
				{
					c.cancel()
				});
				new Effect.Event(
				{
					queue: this.queue,
					afterFinish: this.restoreInlineContent.bind(this)
				});
				new Effect.Opacity(this.imagegallery, {
					duration: 0.1,
					from: 1,
					to: 0,
					queue: {
						position: "end",
						scope: "imagegallery_hide"
					}
				});
				new Effect.Fade(this.overlay, {
					duration: 0.16,
					queue: {
						position: "end",
						scope: "imagegallery_hide"
					},
					afterFinish: this.afterHide.bind(this)
				})
			}
		}
	},
	afterHide: function ()
	{
		this.clearContent();
		this.imagegallery.hide();
		this.center.setOpacity(0).show();
		this.prevnext.update("").hide();
		this.contentTop.update("").hide();
		this.contentBottom.update("").hide();
		this.disableKeyboardNavigation();
		this.showOverlapping();
		this.toggleTopClose(false, 0);
		new Effect.Event(
		{
			queue: this.queue,
			afterFinish: this.resize.bind(this, this.options.startDimensions)
		});
		new Effect.Event(
		{
			queue: this.queue,
			afterFinish: function ()
			{
				this.element && this.element.fire("imagegallery:hidden");
				$w("element views view scaledInnerDimensions isSetGallery _openEffect content")._each(function (a)
				{
					this[a] = null
				}.bind(this))
			}.bind(this)
		})
	},
	setMenubarDimensions: function ()
	{
		this.menubar.setStyle("padding:0;");
		var a = {};
		a = this[(this.scaledInnerDimensions ? "scaledI" : "i") + "nnerDimensions"].width;
		this.menubar.setStyle(
		{
			width: a + "px"
		});
		this.data.setStyle(
		{
			width: a - this.closeButtonWidth - 1 + "px"
		});
		a = this.getHiddenDimensions(this.menubar);
		if (this.view.options.menubar)
		{
			a.height += this.options.menubarPadding;
			switch (this.view.options.menubar)
			{
			case "bottom":
				this.menubar.setStyle("padding:" + this.options.menubarPadding + "px 0 0 0");
				break;
			case "top":
				this.menubar.setStyle("padding: 0 0 " + this.options.menubarPadding + "px 0")
			}
		}
		this.menubar.setStyle(
		{
			width: "100%"
		});
		this.menubarDimensions = this.view.options.menubar ? a : {
			width: a.width,
			height: 0
		}
	},
	restoreCenter: function ()
	{
		var a, b, c;
		n ? c = function ()
		{
			this.imagegallery.setStyle(
			{
				top: "50%",
				left: "50%"
			})
		} : o || p ? c = function ()
		{
			var d = this.getViewportDimensions(),
				e = document.viewport.getScrollOffsets();
			this.imagegallery.setStyle(
			{
				marginLeft: 0,
				marginTop: 0,
				left: (e[0] + d.width / 2 - a.width / 2).floor() + "px",
				top: (e[1] + d.height / 2 - a.height / 2).floor() + "px"
			})
		} : c = function ()
		{
			this.imagegallery.setStyle(
			{
				position: "fixed",
				left: "50%",
				top: "50%",
				marginLeft: (0 - a.width / 2).round() + "px",
				marginTop: (0 - a.height / 2 - b).round() + "px"
			})
		};
		return function ()
		{
			a = this.imagegallery.getDimensions();
			b = this.controller.visible() ? this.controllerOffset / 2 : 0;
			c.call(this)
		}
	}(),
	startSlideshow: function ()
	{
		this.stopSlideshow();
		this.sliding = true;
		this.next.bind(this).delay(0.25);
		this.slideshowButton.setPngBackground(this.images + "inner_slideshow_stop.gif", {
			backgroundColor: this.options.backgroundColor
		}).hide();
		this.controllerSlideshow.setPngBackground(this.images + "controller_slideshow_stop.png", {
			backgroundColor: this.options.controller.backgroundColor
		})
	},
	stopSlideshow: function ()
	{
		this.sliding && (this.sliding = false);
		this.slideTimer && clearTimeout(this.slideTimer);
		this.slideshowButton.setPngBackground(this.images + "inner_slideshow_play.gif", {
			backgroundColor: this.options.backgroundColor
		});
		this.controllerSlideshow.setPngBackground(this.images + "controller_slideshow_play.png", {
			backgroundColor: this.options.controller.backgroundColor
		})
	},
	toggleSlideshow: function ()
	{
		(!this.view.isSet() || this.isSetGallery) && this[(this.sliding ? "stop" : "start") + "Slideshow"]()
	},
	nextSlide: function ()
	{
		this.sliding && (this.slideTimer = this.next.bind(this).delay(this.options.slideshowDelay))
	},
	updateViews: function ()
	{
		$$("a[class~=imagegallery], area[class~=imagegallery]").each(function (a)
		{
			var b = a._view;
			!b || (b._title && a.writeAttribute("title", b._title), a._view = null)
		})
	},
	getSet: function (a)
	{
		var b = a.indexOf("][");
		b > -1 && (a = a.substr(0, b + 1));
		return $$('a[rel^="' + a + '"], area[rel^="' + a + '"]')
	},
	getViews: function (a)
	{
		return this.getSet(a).pluck("_view")
	},
	addObservers: function ()
	{
		$(document.body).observe("click", this.delegateClose.bindAsEventListener(this));
		$w("mouseover mouseout").each(function (b)
		{
			this.prevnext.observe(b, function (c)
			{
				var d = c.findElement("div");
				!d || (this.prevButton && this.prevButton == d || this.nextButton && this.nextButton == d) && this.toggleSideButton(c)
			}.bindAsEventListener(this))
		}.bind(this));
		this.prevnext.observe("click", function (b)
		{
			if (b = b.findElement("div"))(b = this.prevButton && this.prevButton == b ? "previous" : this.nextButton && this.nextButton == b ? "next" : null) && this[b].wrap(function (c, d)
			{
				this.stopSlideshow();
				c(d)
			}).bind(this)()
		}.bindAsEventListener(this));
		$w("prev next").each(function (b)
		{
			var c = b.capitalize(),
				d = function (g, h)
				{
					this.stopSlideshow();
					g(h)
				},
				e = function (g, h)
				{
					var i = h.element().prevnext;
					(i == "prev" && (this.options.cyclic || this.position != 0) || i == "next" && (this.options.cyclic || (this.view.isGallery() || this.view.isSet()) && this.getSurroundingIndexes().next != 0)) && g(h)
				};
			this[b + "ButtonImage"].observe("mouseover", this.toggleSideButton.bindAsEventListener(this)).observe("mouseout", this.toggleSideButton.bindAsEventListener(this)).observe("click", this[b == "next" ? b : "previous"].wrap(d).bindAsEventListener(this));
			this["inner" + c + "Button"].observe("click", this[b == "next" ? b : "previous"].wrap(e).wrap(d).bindAsEventListener(this)).observe("mouseover", Element.setOpacity.curry(this["inner" + c + "Button"], this.options.buttons.opacity.hover).wrap(e).bindAsEventListener(this)).observe("mouseout", Element.setOpacity.curry(this["inner" + c + "Button"], this.options.buttons.opacity.normal).wrap(e).bindAsEventListener(this));
			this["controller" + c].observe("click", this[b == "next" ? b : "previous"].wrap(e).wrap(d).bindAsEventListener(this))
		}, this);
		var a = [this.closeButton, this.slideshowButton];
		o ? a.invoke("setOpacity", 1) : a.each(function (b)
		{
			b.observe("mouseover", Element.setOpacity.bind(this, b, this.options.buttons.opacity.hover)).observe("mouseout", Element.setOpacity.bind(this, b, this.options.buttons.opacity.normal))
		}, this);
		this.slideshowButton.observe("click", this.toggleSlideshow.bindAsEventListener(this));
		this.controllerSlideshow.observe("click", this.toggleSlideshow.bindAsEventListener(this));
		if (o || p)
		{
			a = function (b, c)
			{
				this.imagegallery.getStyle("top").charAt(0) != "-" && b(c)
			};
			Event.observe(window, "scroll", this.restoreCenter.wrap(a).bindAsEventListener(this));
			Event.observe(window, "resize", this.restoreCenter.wrap(a).bindAsEventListener(this))
		}
		p && Event.observe(window, "resize", this.maxOverlay.bindAsEventListener(this));
		if (n)
		{
			a = function ()
			{
				this.controller && this.controller.setStyle(
				{
					left: ((document.documentElement.scrollLeft || 0) + document.viewport.getWidth() / 2).round() + "px"
				})
			};
			Event.observe(window, "scroll", a.bindAsEventListener(this));
			Event.observe(window, "resize", a.bindAsEventListener(this))
		}
		this.options.preloadHover && (this._preloadImageHover = function (b)
		{
			var c = b.findElement("a[class~=imagegallery], area[class~=imagegallery]");
			!c || (b.stop(), c._view || new Imagegallery.View(c), this.preloadImageHover(c))
		}.bindAsEventListener(this), $(document.body).observe("mouseover", this._preloadImageHover))
	},
	toggleTopClose: function (a)
	{
		if (!a || !this.topcloseButtonImage.retrieve("visible"))
		{
			this._topCloseEffect && Effect.Queues.get("imagegallery_topCloseEffect").remove(this.topCloseEffect);
			this._topCloseEffect = new Effect.Morph(this.topcloseButtonImage, {
				style: {
					marginTop: (a ? 0 : this.closeDimensions.topclose.height) + "px"
				},
				duration: a ? this.options.effectDurations.topclose.show : 0,
				queue: this.queue,
				delay: a ? this.options.effectDurations.topclose.delay : 0,
				afterFinish: function ()
				{
					this.topcloseButtonImage.store("visible", a)
				}.bind(this)
			})
		}
	},
	getScrollDimensions: function ()
	{
		var a = {};
		$w("width height").each(function (b)
		{
			var c = b.capitalize(),
				d = document.documentElement;
			a[b] = Prototype.Browser.IE ? [d["offset" + c], d["scroll" + c]].max() : Prototype.Browser.WebKit ? document.body["scroll" + c] : d["scroll" + c]
		});
		return a
	},
	maxOverlay: function ()
	{
		!p || this.overlay.setStyle(l(this.getScrollDimensions()))
	},
	delegateClose: function ()
	{
		return function (a)
		{
			this.view && this.view.options && a.findElement(".ig_Close, .ig_topButtons .ig_Button, .ig_Loading, .ig_controllerClose" + (this.view.options.overlayClose ? ", #ig_overlay" : "")) && this.hide()
		}
	}(),
	toggleSideButton: function (a)
	{
		var b = a.target.side,
			c = this.sideDimensions.width;
		c = {
			marginLeft: (a.type == "mouseover" ? 0 : b == "prev" ? c : -1 * c) + "px"
		};
		this.sideEffect || (this.sideEffect = {});
		this.sideEffect[b] && Effect.Queues.get("imagegallery_side" + b).remove(this.sideEffect[b]);
		this.sideEffect[b] = new Effect.Morph(this[b + "ButtonImage"], {
			style: c,
			duration: this.options.effectDurations.sideButtons[a.type == "mouseout" ? "hide" : "show"],
			queue: {
				scope: "imagegallery_side" + b,
				limit: 1
			},
			delay: a.type == "mouseout" ? 0.1 : 0
		})
	},
	getSurroundingIndexes: function ()
	{
		if (this.views)
		{
			var a = this.position,
				b = this.views.length;
			return {
				previous: a <= 0 ? b - 1 : a - 1,
				next: a >= b - 1 ? 0 : a + 1
			}
		}
	},
	createCorner: function (a, b, c)
	{
		c = c || this.options;
		var d = c.radius,
			e = c.border;
		position = {
			top: b.charAt(0) == "t",
			left: b.charAt(1) == "l"
		};
		if (q)
		{
			b = new Element("canvas", {
				className: "cornerCanvas" + b.capitalize(),
				width: e + "px",
				height: e + "px"
			});
			b.setStyle("float:left");
			a.insert(b);
			a = b.getContext("2d");
			a.fillStyle = c.backgroundColor;
			a.arc(position.left ? d : e - d, position.top ? d : e - d, d, 0, Math.PI * 2, true);
			a.fill();
			a.fillRect(position.left ? d : 0, 0, e - d, e);
			a.fillRect(0, position.top ? d : 0, e, e - d)
		}
		else
		{
			c = (new Element("ns_vml:roundrect", {
				fillcolor: c.backgroundColor,
				strokeWeight: "1px",
				strokeColor: c.backgroundColor,
				arcSize: (d / e * 0.5).toFixed(2)
			})).setStyle(
			{
				width: 2 * e - 1 + "px",
				height: 2 * e - 1 + "px",
				position: "absolute",
				left: (position.left ? 0 : -1 * e) + "px",
				top: (position.top ? 0 : -1 * e) + "px"
			});
			a.insert(c);
			c.outerHTML = c.outerHTML
		}
	},
	hideOverlapping: function ()
	{
		function a()
		{
			return $$("object, embed, select")
		}
		Prototype.Browser.IE && document.documentMode >= 8 && (a = function ()
		{
			return document.querySelectorAll("object, embed, select")
		});
		return function ()
		{
			if (!this.preventingOverlap)
			{
				var b = a();
				this.overlappingRestore = [];
				for (var c = 0, d = b.length; c < d; c++)
				{
					var e = b[c];
					this.overlappingRestore.push(
					{
						element: e,
						visibility: e.style.visibility
					});
					e.style.visibility = "hidden"
				}
				this.preventingOverlap = true
			}
		}
	}(),
	showOverlapping: function ()
	{
		this.overlappingRestore.each(function (a)
		{
			a.element.style.visibility = a.visibility
		});
		delete this.overlappingRestore;
		this.preventingOverlap = false
	},
	getInnerDimensions: function ()
	{
		return {
			width: this.innerDimensions.width,
			height: this.innerDimensions.height + this.menubarDimensions.height
		}
	},
	getOuterDimensions: function ()
	{
		var a = this.getInnerDimensions(),
			b = 2 * this.border;
		return {
			width: a.width + b,
			height: a.height + b
		}
	},
	getBounds: function ()
	{
		var a = 2 * this.sideDimensions.height + 21,
			b = this.getViewportDimensions();
		return {
			width: b.width - a,
			height: b.height - a
		}
	},
	getViewportDimensions: function ()
	{
		var a = document.viewport.getDimensions();
		this.controller && this.controller.visible() && this.views && this.views.length > 1 && (a.height -= this.controllerOffset);
		return a
	}
});
(function ()
{
	function a(b, c)
	{
		!this.view || b(c)
	}
	$w("fillMenuBar insertContent").each(function (b)
	{
		this[b] = this[b].wrap(a)
	}, Imagegallery)
})();
Object.extend(Imagegallery, {
	enableKeyboardNavigation: function ()
	{
		!this.view.options.keyboard || (this.keyboardEvent = this.keyboardDown.bindAsEventListener(this), document.observe("keydown", this.keyboardEvent))
	},
	disableKeyboardNavigation: function ()
	{
		this.keyboardEvent && document.stopObserving("keydown", this.keyboardEvent)
	},
	keyboardDown: function (a)
	{
		var b = String.fromCharCode(a.keyCode).toLowerCase(),
			c = a.keyCode,
			d = (this.view.isGallery() || this.isSetGallery) && !this.resizing,
			e = this.view.options.slideshow,
			g;
		this.view.isMedia() ? (a.stop(), g = c == Event.KEY_ESC || ["x", "c"].member(b) ? "hide" : c == 37 && d && (this.options.cyclic || this.position != 0) ? "previous" : c == 39 && d && (this.options.cyclic || this.getSurroundingIndexes().next != 0) ? "next" : b == "p" && e && d ? "startSlideshow" : b == "s" && e && d ? "stopSlideshow" : null, b != "s" && this.stopSlideshow()) : g = c == Event.KEY_ESC ? "hide" : null;
		g && this[g]();
		d && (c == Event.KEY_HOME && this.views.first() != this.view && this.show(0), c == Event.KEY_END && this.views.last() != this.view && this.show(this.views.length - 1))
	}
});
Imagegallery.afterShow = Imagegallery.afterShow.wrap(function (a, b)
{
	this.enableKeyboardNavigation();
	a(b)
});
Object.extend(Imagegallery, {
	extendSet: function (a)
	{
		a = this.getSet(a);
		!a || a._each(Imagegallery.Extend)
	},
	preloadSurroundingImages: function ()
	{
		if (this.views.length != 0)
		{
			var a = this.getSurroundingIndexes();
			this.preloadFromSet([a.next, a.previous])
		}
	},
	preloadFromSet: function (a)
	{
		var b = this.views && this.views.member(a) || Object.isArray(a) ? this.views : a.rel ? this.getViews(a.rel) : null;
		if (b) $A(Object.isNumber(a) ? [a] : a.type ? [b.indexOf(a)] : a).uniq().each(function (c)
		{
			this.preloadImageDimensions(b[c])
		}, this)
	},
	setPreloadedDimensions: function (a, b)
	{
		a.preloadedDimensions = {
			width: b.width,
			height: b.height
		}
	},
	preloadImageDimensions: function (a)
	{
		if (!(a.preloadedDimensions || a.isPreloading || !a.href))
		{
			var b = new Image;
			b.onload = function ()
			{
				b.onload = Prototype.emptyFunction;
				a.isPreloading = null;
				this.setPreloadedDimensions(a, b)
			}.bind(this);
			a.isPreloading = true;
			b.src = a.href
		}
	},
	preloadImageHover: function (a)
	{
		(a = a._view) && a.preloadedDimensions || a.isPreloading || !a.isImage() || this.preloadImageDimensions(a)
	}
});
Element.addMethods(
{
	setPngBackground: function (a, b, c)
	{
		a = $(a);
		c = Object.extend(
		{
			align: "top left",
			repeat: "no-repeat",
			sizingMethod: "scale",
			backgroundColor: ""
		}, c || {});
		a.setStyle(n ? {
			filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + b + "'', sizingMethod='" + c.sizingMethod + "')"
		} : {
			background: c.backgroundColor + " url(" + b + ") " + c.align + " " + c.repeat
		});
		return a
	}
});
Object.extend(Imagegallery, {
	detectType: function (a)
	{
		var b;
		$w("flash image iframe quicktime").each(function (c)
		{
			RegExp("\\.(" + this.typeExtensions[c].replace(/\s+/g, "|") + ")(\\?.*)?", "i").test(a) && (b = c)
		}.bind(this));
		if (b) return b;
		if (a.startsWith("#")) return "inline";
		if (document.domain && document.domain != a.replace(/(^.*\/\/)|(:.*)|(\/.*)/g, "")) return "iframe";
		return "image"
	},
	detectExtension: function (a)
	{
		return (a = a.gsub(/\?.*/, "").match(/\.([^.]{3,4})$/)) ? a[1] : null
	},
	createHTML: function (a)
	{
		var b = "<" + a.tag,
			c;
		for (c in a)["children", "html", "tag"].member(c) || (b += " " + c + '="' + a[c] + '"');
		/^(?:area|base|basefont|br|col|frame|hr|img|input|link|isindex|meta|param|range|spacer|wbr)$/i.test(a.tag) ? b += "/>" : (b += ">", a.children && a.children.each(function (d)
		{
			b += this.createHTML(d)
		}.bind(this)), a.html && (b += a.html), b += "</" + a.tag + ">");
		return b
	}
});
(function ()
{
	document.observe("dom:loaded", function ()
	{
		function a(c)
		{
			var d = false;
			if (b) d = $A(navigator.plugins).pluck("name").join(",").indexOf(c) >= 0;
			else try
			{
				d = new ActiveXObject(c)
			}
			catch (e)
			{}
			return !!d
		}
		var b = navigator.plugins && navigator.plugins.length;
		b ? window.Imagegallery.Plugin = {
			flash: a("Shockwave Flash"),
			quicktime: a("QuickTime")
		} : window.Imagegallery.Plugin = {
			flash: a("ShockwaveFlash.ShockwaveFlash"),
			quicktime: a("QuickTime.QuickTime")
		}
	})
})();
Imagegallery.View = Class.create(
{
	initialize: function (a)
	{
		if (!a._view)
		{
			var b = Object.isElement(a);
			b && !a._view && (a._view = this, a.title && (a._view._title = a.title, Imagegallery.options.removeTitles && a.setAttribute("title", "")));
			this.href = b ? a.getAttribute("href") : a.href;
			this.href.indexOf("#") >= 0 && (this.href = this.href.substr(this.href.indexOf("#")));
			var c = b ? a.getAttribute("rel") : a.rel;
			if (c)
			{
				this.rel = c;
				if (c.startsWith("gallery")) this.type = "gallery";
				else if (c.startsWith("set")) if (c.include("]["))
				{
					c = c.split("][");
					var d = c[1].match(/([a-zA-Z]*)/)[1];
					if (d)
					{
						this.type = d;
						c = c[0] + "]";
						a.writeAttribute("rel", c);
						this.rel = c
					}
				}
				else this.type = Imagegallery.detectType(this.href);
				else this.type = c
			}
			else this.rel = this.type = Imagegallery.detectType(this.href);
			$w("ajax flash gallery iframe image inline quicktime external media set")._each(function (e)
			{
				var g = e.capitalize(),
					h = e.toLowerCase();
				"image gallery media external set".indexOf(e) < 0 && (this["is" + g] = function ()
				{
					return this.type == h
				}.bind(this))
			}.bind(this));
			if (b && a._view._title)
			{
				a = a._view._title.split(Imagegallery.options.titleSplit).invoke("strip");
				a[0] && (this.title = a[0]);
				a[1] && (this.caption = a[1]);
				this.options = (a = a[2]) && Object.isString(a) ? eval("({" + a + "})") : {}
			}
			else
			{
				this.title = a.title;
				this.caption = a.caption;
				this.options = a.options || {}
			}
			this.options.ajaxOptions && (this.options.ajax = Object.clone(this.options.ajaxOptions), delete this.options.ajaxOptions)
		}
	},
	isGallery: function ()
	{
		return this.type.startsWith("gallery")
	},
	isSet: function ()
	{
		return this.rel.startsWith("set")
	},
	isImage: function ()
	{
		return this.isGallery() || this.type == "image"
	},
	isExternal: function ()
	{
		return "iframe inline ajax".indexOf(this.type) >= 0
	},
	isMedia: function ()
	{
		return !this.isExternal()
	}
});
Imagegallery.Extend = function (a)
{
	var b = $(a);
	new Imagegallery.View(a);
	return b
};
(function ()
{
	function a(d)
	{
		var e;
		e = d.target;
		var g = d.type;
		(d = d.currentTarget) && d.tagName && (g === "load" || g === "error" || g === "click" && d.tagName.toLowerCase() === "input" && d.type === "radio") && (e = d);
		e.nodeType == Node.TEXT_NODE && (e = e.parentNode);
		if (e = e)
		{
			var h;
			if (e)
			{
				h = e.className;
				h = h.length > 0 && (h == "imagegallery" || /(^|\s)imagegallery(\s|$)/.test(h))
			}
			h && this.Extend(e)
		}
	}

	function b(d)
	{
		d = d.findElement("a[class~=imagegallery], area[class~=imagegallery]");
		!d || this.Extend(d)
	}

	function c(d)
	{
		var e = d.findElement("a[class~=imagegallery], area[class~=imagegallery]");
		!e || (d.stop(), this.Extend(e), this.show(e))
	}
	document.observe("imagegallery:loaded", function ()
	{
		$(document.body).observe("click", c.bindAsEventListener(Imagegallery));
		Imagegallery.options.removeTitles && Prototype.Browser.IE && document.documentMode >= 8 ? $(document.body).observe("mouseover", a.bindAsEventListener(Imagegallery)) : $(document.body).observe("mouseover", b.bindAsEventListener(Imagegallery))
	})
})();
Object.extend(Imagegallery, {
	buildController: function ()
	{
		var a = this.options.controller,
			b = a.border;
		$(document.body).insert(this.controller = (new Element("div", {
			id: "imagegalleryController"
		})).setStyle(
		{
			zIndex: this.options.zIndex + 1,
			marginBottom: a.margin + "px",
			position: "absolute",
			visibility: "hidden"
		}).insert(this.controllerTop = (new Element("div", {
			className: "ig_controllerTop"
		})).insert((new Element("div", {
			className: "ig_controllerCornerWrapper ig_controllerCornerWrapperTopLeft"
		})).setStyle("margin-left: " + b + "px").insert(new Element("div", {
			className: "ig_Corner"
		}))).insert((new Element("div", {
			className: "ig_controllerBetweenCorners"
		})).setStyle(
		{
			margin: "0 " + b + "px",
			height: b + "px"
		})).insert((new Element("div", {
			className: "ig_controllerCornerWrapper ig_controllerCornerWrapperTopRight"
		})).setStyle("margin-left: -" + b + "px").insert(new Element("div", {
			className: "ig_Corner"
		})))).insert(this.controllerMiddle = (new Element("div", {
			className: "ig_controllerMiddle clearfix"
		})).insert(this.controllerCenter = (new Element("ul", {
			className: "ig_controllerCenter"
		})).setStyle("margin: 0 " + b + "px").insert((new Element("li", {
			className: "ig_controllerSetNumber"
		})).insert(this.setNumber = new Element("div"))).insert((new Element("li", {
			className: "ig_ButtonWrapper ig_controllerPrev"
		})).insert(this.controllerPrev = (new Element("div", {
			className: "ig_Button"
		})).setPngBackground(this.images + "controller_prev.png", {
			backgroundColor: a.backgroundColor
		}))).insert((new Element("li", {
			className: "ig_ButtonWrapper ig_controllerNext"
		})).insert(this.controllerNext = (new Element("div", {
			className: "ig_Button"
		})).setPngBackground(this.images + "controller_next.png", {
			backgroundColor: a.backgroundColor
		}))).insert((new Element("li", {
			className: "ig_ButtonWrapper ig_controllerSlideshow"
		})).insert(this.controllerSlideshow = (new Element("div", {
			className: "ig_Button"
		})).setPngBackground(this.images + "controller_slideshow_play.png", {
			backgroundColor: a.backgroundColor
		}))).insert((new Element("li", {
			className: "ig_ButtonWrapper ig_controllerClose"
		})).insert(this.controllerClose = (new Element("div", {
			className: "ig_Button"
		})).setPngBackground(this.images + "controller_close.png", {
			backgroundColor: a.backgroundColor
		}))))).insert(this.controllerBottom = (new Element("div", {
			className: "ig_controllerBottom"
		})).insert((new Element("div", {
			className: "ig_controllerCornerWrapper ig_controllerCornerWrapperBottomLeft"
		})).setStyle("margin-left: " + b + "px").insert(new Element("div", {
			className: "ig_Corner"
		}))).insert((new Element("div", {
			className: "ig_controllerBetweenCorners"
		})).setStyle(
		{
			margin: "0 " + b + "px",
			height: b + "px"
		})).insert((new Element("div", {
			className: "ig_controllerCornerWrapper ig_controllerCornerWrapperBottomRight"
		})).setStyle("margin-left: -" + b + "px").insert(new Element("div", {
			className: "ig_Corner"
		})))));
		$w("prev next").each(function (d)
		{
			this["controller" + d.capitalize()].prevnext = d
		}, this);
		o && (this.controller.hide = function ()
		{
			this.setStyle("left:-9500px;top:-9500px;visibility:hidden;");
			return this
		}, this.controller.show = function ()
		{
			this.setStyle("visibility:visible");
			return this
		}, this.controller.visible = function ()
		{
			return this.getStyle("visibility") == "visible" && parseFloat(this.getStyle("top").replace("px", "")) > -9500
		});
		this.controller.select(".ig_ButtonWrapper div").invoke("setStyle", l(this.controllerButtonDimensions));
		var c = this.controller.select(".ig_Corner");
		$w("tl tr bl br").each(function (d, e)
		{
			a.radius > 0 ? this.createCorner(c[e], d, a) : c[e].insert(new Element("div", {
				className: "ig_Fill"
			}));
			c[e].setStyle(
			{
				width: a.border + "px",
				height: a.border + "px"
			}).addClassName("ig_Corner" + d.capitalize())
		}, this);
		this.controller.down(".ig_controllerMiddle").setStyle("width:100%;");
		this.controller.setStyle(n ? {
			position: "absolute",
			top: "auto",
			left: ""
		} : {
			position: "fixed",
			top: "auto",
			left: "50%"
		});
		this.controller.select(".ig_controllerBetweenCorners", ".ig_controllerMiddle", ".ig_Button", ".ig_Fill").invoke("setStyle", {
			backgroundColor: a.backgroundColor
		});
		this.setNumber.update((new Template(a.setNumberTemplate)).evaluate(
		{
			position: 999,
			total: 999
		}));
		this.setNumber.setStyle(
		{
			width: this.setNumber.getWidth() + "px",
			height: this.controllerCenter.getHeight() + "px"
		});
		this._fixateController();
		this.setNumber.update("");
		this.controller.hide().setStyle("visibility:visible");
		this.addObservers();
		this._imagegalleryLoadedEvent()
	},
	_fixateController: function ()
	{
		var a, b, c = this.options.controller,
			d = c.border;
		n ? (a = this.controllerCenter.getDimensions(), b = a.width + 2 * d, this.controllerCenter.setStyle(
		{
			width: a.width + "px",
			margin: 0
		}), this.controllerMiddle.setStyle("width:auto;"), this.controllerCenter.setStyle(
		{
			paddingLeft: d + "px"
		}), this.controllerMiddle.setStyle(
		{
			width: b + "px"
		}), $w("top bottom").each(function (e)
		{
			this["controller" + e.capitalize()].setStyle(
			{
				width: b + "px"
			})
		}, this), this.controller.setStyle("margin-left:-" + (b / 2).round() + "px")) : (this.controllerMiddle.setStyle("width:auto"), a = this.controllerMiddle.getDimensions(), this.setNumber.up().setStyle(
		{
			lineHeight: a.height + "px",
			width: this.setNumber.getDimensions().width + "px"
		}), this.controller.setStyle(
		{
			width: a.width + "px",
			marginLeft: 0 - (a.width / 2).round() + "px"
		}), this.controllerMiddle.setStyle(
		{
			width: a.width + "px"
		}), $w("top bottom").each(function (e)
		{
			this["controller" + e.capitalize()].setStyle(
			{
				width: a.width + "px"
			})
		}, this));
		this._controllerOffset = c.margin + a.height + 2 * d;
		this._controllerHeight = this.controller.getHeight();
		this.setNumber.setStyle(
		{
			lineHeight: a.height + "px"
		})
	}
});
Imagegallery.buildController = Imagegallery.buildController.wrap(function (a, b)
{
	var c = new Image;
	c.onload = function ()
	{
		c.onload = Prototype.emptyFunction;
		this.controllerButtonDimensions = {
			width: c.width,
			height: c.height
		};
		a(b)
	}.bind(this);
	c.src = this.images + "controller_prev.png";
	(new Image).src = this.images + "controller_slideshow_stop.png"
});
Imagegallery.build = Imagegallery.build.wrap(function (a, b)
{
	a(b);
	this.buildController()
});
Imagegallery.hide = Imagegallery.hide.wrap(function (a, b)
{
	this.view && this.view.isSet() && (this.controller.hide(), this.setNumber.update(""));
	a(b)
})
Imagegallery.load();
document.observe("dom:loaded", Imagegallery.start.bind(Imagegallery));
