/*********************************************************************************************************
* Floatbox v2.30
*
* Image and IFrame viewer by Byron McGregor
*	Apr. 19, 2008
*   Website: http://randomous.com
* License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)
* Credit: Derived from Lytebox v3.22, the original work of Markus F. Hay
*   Website: http://www.dolem.com/lytebox
*   Lytebox was originally derived from the Lightbox class (v2.02) that was written by Lokesh Dhakar
*   Website: http://huddletogether.com/projects/lightbox2/
**********************************************************************************************************/

function Floatbox() {
this.setDefaultOptions = function() {

//***** BEGIN OPTIONS CONFIGURATION *****//

/***<Global Options>***/
  this.theme          = 'black';    // color themes: black, white, blue, yellow, red, custom.  Custom is for defining your own styles in the css
  this.overlayOpacity = 80;         // 0-100. Higher opacity = darker overlay
  this.padding        = 12;         // padding in pixels between the displayed item and floatbox edges (the floatbox background)
  this.panelPadding   = 8;          // padding in pixels above and below the lower panel content
  this.outerBorder    = 4;          // width in pixels of the outer border around the floatbox
  this.innerBorder    = 1;          // width in pixels of the inner border around the image or iframe content
  this.navType        = 'lower';     // 'upper', 'lower', 'both' or 'none'.  upper = "Prev/Next" image overlay, lower = "<<prev||next>>" on lower panel
  this.navOpacity     = 60;         // opacity of the upper prev and next navigation buttons
  this.upperNavWidth  = 42;         // 0-50. Percent width of each upper nav panel. 50 means prev and next nav panels meet in the middle, 40 leaves a 20% gap between panels, etc.
  this.autoResize     = true;      // resize images and iframes down to the browser window size if necessary (images are shrunk but never made larger)
  this.showHints      = true;       // display mouseover hint messages for the nav and control buttons. Useful for informing users about keyboard shortcuts
  this.showCaption    = true;       // display caption pulled from the anchor's title attribute
  this.showItemNumber = true;       // display 'image/page X of Y' below the caption.  Text is configurable below in .imageCount and .iframeCount
  this.showClose      = true;       // display the close button
  this.hideFlash      = true;       // hide Flash objects so they don't bleed through the overlay nor continue to present distracting activity
  this.resizeDuration      = 5;     // 0-10. 0 = no resize animation, 1 is fast, 10 is slooow.  Unit-less, not seconds!
  this.imageFadeDuration   = 1;     // 0-10. 0 = no image fade-in, 1 is fast, 10 is slooow.  Unit-less, not seconds!
  this.overlayFadeDuration = 0;     // 0-10. 0 = no overlay fading in or out, 1 is fast, 10 is slooow.  Unit-less, not seconds!
  this.enableKeyboardNav   = true;  // enable/disable keyboard handler for prev, next, pause/play and close (If you disable keyboard nav you should also set showHints to false or change the default text displayed in the hints)
  this.outsideClickCloses  = true;  // clicking on the overlay closes floatbox
  this.disableScroll       = false; // use fixed positioning that blocks scrollbar functionality if the content fully fits the screen (not recommended)
  this.enableCookies       = false; // use session cookies to remember user preferences.  Set this to false if you are setting up floatbox and testing option changes here.  Set to true if you have a cookie-based way for users to select display preferences on your pages
/***</Global Options>***/

/***<Slideshow Options>***/
  this.slideInterval  = 3.9;        // number of seconds to show each image during a slideshow
  this.endTask        = 'exit';     // 'halt' (default), 'exit' or 'cont'.  What to do when all the images have been shown: stop the slideshow but leave the last pic up, close the image display, or continuous looping
  this.showPlayPause  = true;       // display the slideshow play & pause buttons
  this.startPaused    = false;      // true to start slideshow in paused state, false to have the slideshow auto-play on start
  this.pauseOnNext    = false;      // true to pause the slideshow when the 'Next'" button is clicked or when 'next' keyboard action is fired
  this.pauseOnPrev    = true;       // true to pause the slideshow when the 'Prev' button is clicked or when 'prev' keyboard action is fired
/*** </Slideshow Options> ***/

/***<String Localization>***/
  this.hintClose      = "keybd: Esc";       // shortcut: 'Escape' or 'X' or 'C'
  this.hintNext       = "keybd: rt.arrow";  // shortcut: 'Right Arrow' or 'N'
  this.hintPrev       = "keybd: lt.arrow";  // shortcut: 'Left Arrow' or 'P'
  this.hintPlayPause  = "keybd: space";     // shortcut: 'Spacebar'
  this.imageCount     = "Image x of y";     // text below the caption for images.  'x' and 'y' will be replaced by item number and item count
  this.iframeCount    = "Page x of y";      // text below the caption for iframes.  'x' and 'y' will be replaced by item number and item count
/*** </String Localization> ***/

//***** END OPTIONS CONFIGURATION *****//
};

	this.doc = top.document;
	this.body = this.doc.body;
  	this.arrAnchors = new Array();
  	this.arrImageHrefs = new Array();
  	this.arrItems = new Array();
	this.arrResize	= new Array();
	this.objTimeouts = new Object();
  	this.objImagePreloads = new Object();
	this.autoStart = null;
	var ie = !!document.all && !window.opera;
	this.ie6 = ie && /*@cc_on @if(@_jscript_version < 5.7) ! @end @*/ false;
	this.ieQuirks = ie && this.doc.compatMode == 'BackCompat';
	this.operaQuirks = !!window.opera && this.doc.compatMode == 'BackCompat';
	this.ff2 = /firefox\/[12]/i.test(navigator.userAgent);
this.parseOptions = function(qs) {
	if (!qs) return;
	qs = qs.replace(/\s*[:=]\s*/g, ':')
	qs = qs.replace(/\s*[;&]\s*/g, ' ')
	qs = qs.replace(/^\s+|\s+$/g, '')
	var aVars = qs.toLowerCase().split(/\s+/);
	var i = aVars.length;  while (i--) {
		var aThisVar = aVars[i].split(':');
		this.setOption(aThisVar[0], aThisVar[1]);
	}
};
this.setCookieOptions = function() {
	var optionNames = new Array('theme','overlayOpacity','padding','panelPadding','outerBorder','innerBorder','navType','navOpacity','upperNavWidth','autoResize','showHints','showCaption','showItemNumber','showClose','hideFlash','resizeDuration','imageFadeDuration','overlayFadeDuration','enableKeyboardNav','outsideClickCloses','disableScroll','slideInterval','endTask','showPlayPause','startPaused','pauseOnNext','pauseOnPrev');
	var i = optionNames.length;  while (i--) {
		var name = optionNames[i];
		var cookieVal = this.getCookie(name);
		if (cookieVal) {
			this.setOption(name, cookieVal);
		} else {
			this.setCookie(name, this[name]);
		}
	}
};
this.setOption = function(name, value) {
	if (!value) return;
	var n = name.toLowerCase();
	var v = value.toLowerCase();
	if      (n == 'theme') this.theme = v;
	else if (n == 'overlayopacity') this.overlayOpacity = parseInt(v);
	else if (n == 'padding') this.padding = parseInt(v);
	else if (n == 'panelpadding') this.panelPadding = parseInt(v);
	else if (n == 'outerborder') this.outerBorder = parseInt(v);
	else if (n == 'innerborder') this.innerBorder = parseInt(v);
	else if (n == 'navtype') this.navType = v;
	else if (n == 'navopacity') this.navOpacity = parseInt(v);
	else if (n == 'uppernavwidth') this.upperNavWidth = parseInt(v);
	else if (n == 'autoresize') this.autoResize = (v == 'true');
	else if (n == 'showhints') this.showHints = (v == 'true');
	else if (n == 'showcaption') this.showCaption = (v == 'true');
	else if (n == 'showitemnumber') this.showItemNumber = (v == 'true');
	else if (n == 'showclose') this.showClose = (v == 'true');
	else if (n == 'hideflash') this.hideFlash = (v == 'true');
	else if (n == 'resizeduration') this.resizeDuration = parseFloat(v);
	else if (n == 'imagefadeduration') this.imageFadeDuration = parseFloat(v);
	else if (n == 'overlayfadeduration') this.overlayFadeDuration = parseFloat(v);
	else if (n == 'enablekeyboardnav') this.enableKeyboardNav = (v == 'true');
	else if (n == 'outsideclickcloses') this.outsideClickCloses = (v == 'true');
	else if (n == 'disablescroll') this.disableScroll = (v == 'true');
	else if (n == 'enablecookies') this.enableCookies = (v == 'true');
	else if (n == 'slideinterval') this.slideInterval = parseFloat(v);
	else if (n == 'endtask') this.endTask = v;
	else if (n == 'showplaypause') this.showPlayPause = (v == 'true');
	else if (n == 'startpaused') this.startPaused = (v == 'true');
	else if (n == 'pauseonnext') this.pauseOnNext = (v == 'true');
	else if (n == 'pauseonprev') this.pauseOnPrev = (v == 'true');
	else if (n == 'modal') this.modal = (v == 'true');
	else if (n == 'doslideshow') this.doSlideshow = (v == 'true');
	else if (n == 'loadpageonclose') this.loadPageOnClose = v;
};
this.tagAnchors = function(doc) {
	var regExIsFbxd = new RegExp('^(gallery|iframe|slideshow|lytebox|lyteshow|lyteframe|lightbox)', 'i');
	var regExIsImg = new RegExp('\.(jpg|jpeg|png|gif|bmp)\s*$', 'i');
	var anchors = doc.getElementsByTagName('a');
	for (var i = 0, len = anchors.length; i < len; i++) {
		var anchor = anchors[i];
		var href = anchor.getAttribute('href');
		var rel = anchor.getAttribute('rel');
		var rev = anchor.getAttribute('rev');
		if (regExIsFbxd.test(rel)) {
			this.arrAnchors.push(anchor);
			anchor.onclick = function () { fb.start(this); return false; };
			if (regExIsImg.test(href)) this.arrImageHrefs.push(href);
			if (/autoStart:true/i.test(rev)) fb.autoStart = anchor;
		}
	}
};
this.loadNextImage = function() {
	for (var i = 0, len = this.arrImageHrefs.length; i < len; i++) {
		var href = this.arrImageHrefs[i];
		if (!this.objImagePreloads[href]) {
			this.objImagePreloads[href] = new Image();
			this.objImagePreloads[href].onload = this.objImagePreloads[href].onerror = function() { fb.loadNextImage() };
			this.objImagePreloads[href].src = href;
			return;
		}
	}
};
this.setNode = function(nodeType, id, parentNode, className, title) {
	var node = this.doc.getElementById(id);
 		if (!node) {
		node = this.doc.createElement(nodeType);
		if (id) node.id = id;
		if (nodeType == 'a') node.setAttribute('href', '#');
		if (title) node.setAttribute('title', title);
		if (nodeType == 'iframe') {
			node.setAttribute('name', id);
			node.setAttribute('scrolling', this.itemScrolling);
			node.setAttribute('frameBorder', '0');
			node.setAttribute('align', 'middle');
		}
		parentNode.appendChild(node);
	}
	if (className) node.className = id + '_' + className;
	node.style.display = 'none';
	return node;
};
this.buildDOM = function() {
	this.fbOverlay		= this.setNode('div', 'fbOverlay', this.body, this.theme);
	this.fbFloatbox		= this.setNode('div', 'fbFloatbox', this.body, this.theme);
	this.fbLoader		= this.setNode('div', 'fbLoader', this.fbFloatbox, this.theme);
	this.fbContentPanel	= this.setNode('div', 'fbContentPanel', this.fbFloatbox);
	if (this.upperNav) {
		this.fbLeftNav	= this.setNode('a', 'fbLeftNav', this.fbContentPanel, this.theme);
		this.fbUpperPrev= this.setNode('a', 'fbUpperPrev', this.fbLeftNav, this.theme, this.showHints? this.hintPrev : '');
		this.fbRightNav	= this.setNode('a', 'fbRightNav', this.fbContentPanel, this.theme);
		this.fbUpperNext= this.setNode('a', 'fbUpperNext', this.fbRightNav, this.theme, this.showHints? this.hintNext : '');
	}
	this.fbInfoPanel	= this.setNode('div', 'fbInfoPanel', this.fbContentPanel);
	this.fbCaption		= this.setNode('span', 'fbCaption', this.fbInfoPanel, this.theme);
	this.fbItemNumber	= this.setNode('span', 'fbItemNumber', this.fbInfoPanel, this.theme);
	this.fbControlPanel	= this.setNode('div', 'fbControlPanel', this.fbContentPanel);
	this.fbLowerNav		= this.setNode('div', 'fbLowerNav', this.fbControlPanel);
	this.fbLowerPrev	= this.setNode('a', 'fbLowerPrev', this.fbLowerNav, this.theme, this.showHints? this.hintPrev : '');
	this.fbLowerNext	= this.setNode('a', 'fbLowerNext', this.fbLowerNav, this.theme, this.showHints? this.hintNext : '');
	this.fbControls		= this.setNode('div', 'fbControls', this.fbControlPanel);
	this.fbClose		= this.setNode('a', 'fbClose', this.fbControls, this.theme, this.showHints? this.hintClose : '');
	this.fbPlayPause	= this.setNode('div', 'fbPlayPause', this.fbControls);
	this.fbPlay			= this.setNode('a', 'fbPlay', this.fbPlayPause, this.theme, this.showHints? this.hintPlayPause : '');
	this.fbPause		= this.setNode('a', 'fbPause', this.fbPlayPause, this.theme, this.showHints? this.hintPlayPause : '');
};
this.start = function(itemLink) {
	this.arrItems.length = 0;
	this.itemsShown = 0;
	var href = itemLink.getAttribute('href');
	var rel = itemLink.getAttribute('rel');
	var rev = itemLink.getAttribute('rev');
	rev = rev? rev.toLowerCase() : '';
	this.isIframe = /^(iframe|lyteframe)/i.test(rel);
	if (/^(gallery|iframe|lytebox|lyteframe|lightbox)$/i.test(rel)) {
		this.arrItems.push( {'href': href, 'title': itemLink.getAttribute('title'), 'rev': rev, 'seen': false} );
	} else {
		for (var i = 0, len = this.arrAnchors.length; i < len; i++) {
			var rev_i = this.arrAnchors[i].getAttribute('rev');
			rev_i = rev_i? rev_i.toLowerCase() : '';
			if (this.arrAnchors[i].getAttribute('rel') == rel && rev_i.indexOf('showthis:false') == -1) {
				this.arrItems.push( {'href': this.arrAnchors[i].getAttribute('href'),
									 'title': this.arrAnchors[i].getAttribute('title'),
									 'rev': rev_i, 'seen': false} );
			}
		}
	}
	this.itemCount = this.arrItems.length;
	this.modal = this.doSlideshow = this.loadPageOnClose = false;
	this.setDefaultOptions();
	if (typeof(top.setFloatboxOptions) == 'function') top.setFloatboxOptions();
	if (typeof(self.setFloatboxOptions) == 'function') self.setFloatboxOptions();
	if (this.enableCookies) this.setCookieOptions();
	this.parseOptions(window.location.search.substring(1));
	this.parseOptions(rev);
	this.theme = this.theme.toLowerCase();
	if (this.theme == 'grey') this.theme = 'white';
	if (!/^(black|white|blue|yellow|red|custom)$/.test(this.theme)) this.theme='black';
	this.isSlideshow = this.itemCount > 1 && (/^(slideshow|lyteshow)/i.test(rel) || this.doSlideshow);
	this.isPaused = this.startPaused;
	if (this.modal && (this.isSlideshow || this.isIframe)) {
		this.navType = 'none';
		this.showClose = false;
		this.showPlayPause = false;
		this.showCaption = false;
		this.showItemNumber = false;
		this.enableKeyboardNav = false;
		this.outsideClickCloses = false;
	}
	this.navType = this.navType.toLowerCase();
	if (!/^(upper|lower|both|none)$/.test(this.navType)) this.navType = 'both';
	if (this.itemCount <= 1) {
		this.navType = 'none';
		this.showItemNumber = false;
	} else if (this.isIframe && /upper|both/.test(this.navType)) {
		this.navType = 'lower';
	}
	this.upperNav = /upper|both/.test(this.navType);
	this.lowerNav = /lower|both/.test(this.navType);
	if (this.upperNav) {
		if (this.upperNavWidth < 0) this.upperNavWidth = 0;
		if (this.upperNavWidth > 50) this.upperNavWidth = 50;
	}
	this.buildDOM();
	this.fbPlay.onclick = function() { fb.setPause(false); return false; };
	this.fbPause.onclick = function() { fb.setPause(true); return false; };
	this.fbClose.onclick = function() { fb.end(); return false; };
	if (this.outsideClickCloses) this.fbOverlay.onclick = function() { fb.end(); return false; };
	this.fbLowerPrev.onclick = function() {
		fb.loadItem((fb.activeItem == 0)? fb.itemCount - 1 : fb.activeItem - 1);
		if (fb.isSlideshow  && fb.pauseOnPrev && !fb.isPaused && fb.showPlayPause) {
			fb.setPause(true);
		}
		return false;
	};
	this.fbLowerNext.onclick = function() {
		fb.loadItem((fb.activeItem == fb.itemCount - 1)? 0 : fb.activeItem + 1);
		if (fb.isSlideshow && fb.pauseOnNext && !fb.isPaused && fb.showPlayPause) {
			fb.setPause(true);
		}
		return false;
	};
	if (this.upperNav) {
		this.fbLeftNav.onclick = this.fbLowerPrev.onclick;
		this.fbRightNav.onclick = this.fbLowerNext.onclick;
		this.fbLeftNav.onmouseover = this.fbLeftNav.onmousemove = function() {
			if (!fb.objTimeouts.fbContentPanel) fb.fbUpperPrev.style.visibility = 'visible';
		};
		this.fbRightNav.onmouseover = this.fbRightNav.onmousemove = function() {
			if (!fb.objTimeouts.fbContentPanel) fb.fbUpperNext.style.visibility = 'visible';
		};
		this.fbLeftNav.onmouseout = function() { fb.fbUpperPrev.style.visibility = 'hidden'; };
		this.fbRightNav.onmouseout = function() { fb.fbUpperNext.style.visibility = 'hidden'; };
		this.fbUpperPrev.onmouseout = this.fbUpperNext.onmouseout = function() { this.title = ''; };
	}
	this.fbPlay.onmouseover = this.fbPause.onmouseover = this.fbClose.onmouseover =
	this.fbLowerPrev.onmouseover = this.fbLowerNext.onmouseover =
		function() { this.style.backgroundPosition = 'bottom left'; };
	this.fbPlay.onmouseout = this.fbPause.onmouseout = this.fbClose.onmouseout =
	this.fbLowerPrev.onmouseout = this.fbLowerNext.onmouseout =
		function() { this.style.backgroundPosition = 'top left'; this.title = ''; };
	if (this.ie6 || this.ieQuirks) {
		this.setVisibility('select', 'hidden');
		this.fbOverlay.style.position = 'absolute';
		top.attachEvent('onresize', fb.stretchOverlay);
	}
	if (this.ie6 && this.isIframe) this.innerBorder = 0;
	if (this.hideFlash) {
		this.setVisibility('object', 'hidden');
		this.setVisibility('embed', 'hidden');
	}
	this.fade(this.fbOverlay, 10, this.overlayOpacity);
	this.fbFloatbox.style.left = (this.getDisplayWidth() / 2 + this.getXScroll()) + 'px';
	this.fbFloatbox.style.top = (this.getDisplayHeight() / 3 + this.getYScroll()) + 'px';
	this.fbFloatbox.style.width = this.fbFloatbox.style.height = '0';
	this.fbFloatbox.style.borderWidth = this.outerBorder + 'px';
	this.fbFloatbox.style.visibility = this.fbContentPanel.style.visibility = 'hidden';
	this.fbFloatbox.style.display = '';
	this.fbContentPanel.style.display = '';
	if (this.upperNav) {
		this.fbLeftNav.style.display = this.fbRightNav.style.display = '';
		this.fbLeftNav.style.top = this.fbRightNav.style.top = this.fbLeftNav.style.left = this.fbRightNav.style.right = (this.padding + this.innerBorder) + 'px';
		if (this.navOpacity < 100 && !window.opera) {
			this.fade(this.fbUpperPrev, this.navOpacity);
			this.fade(this.fbUpperNext, this.navOpacity);
		} else {
			this.fbUpperPrev.style.display = this.fbUpperNext.style.display = '';
		}
	}
	if (this.lowerNav) {
		this.fbLowerNav.style.display = this.fbLowerPrev.style.display = this.fbLowerNext.style.display = '';
	}
	if (!this.isSlideshow) this.showPlayPause = false;
	if (this.showClose || this.showPlayPause || this.lowerNav) {
		this.fbControlPanel.style.display = '';
		this.fbControlPanel.style.right = Math.max(this.padding, 8) + 'px';
	}
    var controlsWidth = 0;
	if (this.showClose) {
		this.fbControls.style.display = '';
		this.fbClose.style.display = '';
		controlsWidth = this.fbClose.offsetWidth;
	}
	if (this.showPlayPause) {
		this.fbControls.style.display = '';
		this.fbPlayPause.style.display = '';
		this[this.isPaused? 'fbPlay' : 'fbPause'].style.display = '';
		controlsWidth += this.fbPlayPause.offsetWidth;
	}
	this.fbControls.style.width = controlsWidth + 'px';
	this.fbControlPanel.style.width = (this.fbLowerNav.offsetWidth + this.fbControls.offsetWidth) + 'px';
	this.xFramework = 2*(this.outerBorder + this.innerBorder + this.padding);
	this.yFramework = this.xFramework - this.padding;
	if (this.enableKeyboardNav) {
		this.priorOnkeydown = document.onkeydown;
		document.onkeydown = this.keyboardAction;
	}
	if (window.opera) {
		this.priorOnkeypress = document.onkeypress;
		document.onkeypress = function() { return false; };
	}
	for (i = this.itemCount - 1; i > 0 ; i--) if (this.arrItems[i].href == href) break;
	this.loadItem(i);
};
this.loadItem = function(newItem) {
	this.clearTimeout('slideshow');
	this.clearTimeout('resizeGroup');
	this.activeItem = newItem;
	self.focus();
	var width = 0, height = 0;
	this.itemScrolling = 'auto';
	var options = this.arrItems[this.activeItem].rev;
	if (options) {
		options = options.replace(/\s*[:=]\s*/g, ':')
		options = options.replace(/\s*[;&]\s*/g, ' ')
		options = options.replace(/^\s+|\s+$/g, '')
		var aOptions = options.toLowerCase().split(/\s+/);
		var i = aOptions.length;  while (i--) {
			var aThisOption = aOptions[i].split(':');
			if (aThisOption[1]) {
				switch(aThisOption[0]) {
					case 'width': {
						width = aThisOption[1];
						if (width != 'max') width = parseInt(width);
						break;
					}
					case 'height': {
						height = aThisOption[1];
						if (height != 'max') {
							height = parseInt(height);
						} else {
							this.limitHeight = true;
						}
						break;
					}
					case 'scrolling': {
						if (this.isIframe && /yes|no/i.test(aThisOption[1])) {
							this.itemScrolling = aThisOption[1];
						}
					}
				}
			}
		}
	}
	if (typeof(this.panelHeight) == 'undefined') {
		this.panelHeight = (this.showCaption || this.showItemNumber)? 16 + 2*this.panelPadding : this.padding;
	}
	var maxWidth = this.getDisplayWidth() - this.xFramework - 12;
	if (width == 'max') width = maxWidth;
	var maxHeight = this.getDisplayHeight() - this.yFramework - this.panelHeight - 8;
	if (height == 'max') height = maxHeight;
	this.fbContentPanel.style.visibility = 'hidden';
	if (this.fbItem) {
		this.fbContentPanel.removeChild(this.fbItem);
		delete this.fbItem;
	};
	this.objTimeouts.loader = setTimeout('fb.fbLoader.style.display = ""', 250);
	if (this.upperNav) {
		this.fbUpperPrev.style.visibility = this.fbUpperNext.style.visibility = 'hidden';
		this.fbLeftNav.style.height = this.fbRightNav.style.height = '0';
	}
	var loader = new Image();
	loader.onload = function() {
		width = width || parseInt(this.width) || 500;
		height = height || parseInt(this.height) || 300;
		if (fb.autoResize) {
			if (width > maxWidth) {
				height = Math.round(height * (maxWidth/width));
				width = maxWidth;
			}
			if (height > maxHeight) {
				width = Math.round(width * (maxHeight/height));
				height = maxHeight;
			}
		}
		fb.itemWidth = width;
		fb.itemHeight = height;
		fb.resize();
	};
	if (this.isIframe) {
		setTimeout(loader.onload, 20);
	} else {
		loader.src = this.arrItems[this.activeItem].href;
	}
};
this.resize = function() {
	this.fbCaption.style.display = this.fbItemNumber.style.display = 'none';
	var sCaption = '';
	if (this.showCaption) {
		sCaption = this.arrItems[this.activeItem].title;
		if (sCaption == 'href') sCaption = this.arrItems[this.activeItem].href;
		this.fbCaption.innerHTML = sCaption;
		if (sCaption) this.fbCaption.style.display = '';
	}
	var sCount = '';
	if (this.showItemNumber) {
		sCount = this.isIframe? this.iframeCount : this.imageCount;
		sCount = sCount.replace(/\bx\b/i, this.activeItem + 1);
		sCount = sCount.replace(/\by\b/i, this.itemCount);
		this.fbItemNumber.innerHTML = sCount;
		if (sCount) this.fbItemNumber.style.display = '';
	}
 	this.newWidth = this.itemWidth + this.xFramework;
 	this.infoPanelHeight = 0;
	this.fbInfoPanel.style.display = this.fbControlPanel.style.display = '';
	if (sCaption || sCount) {
		var ipWidth = this.newWidth - 2*(this.outerBorder + Math.max(this.padding, 8)) - 30 - this.fbControlPanel.offsetWidth;
		if (ipWidth > 50) {
			this.fbInfoPanel.style.width = ipWidth + 'px';
			this.fbInfoPanel.style.left = '-9999px';
			this.infoPanelHeight = this.fbInfoPanel.offsetHeight;
		}
	}
	this.panelHeight = Math.max(this.infoPanelHeight, this.fbControlPanel.offsetHeight);
	this.fbInfoPanel.style.display = this.fbControlPanel.style.display = 'none';
	if (this.panelHeight) this.panelHeight += 2*this.panelPadding;
	this.panelHeight = Math.max(this.panelHeight, this.padding);
	this.newHeight = this.yFramework + this.itemHeight + this.panelHeight;
	if ((this.autoResize || this.limitHeight) && this.newHeight > this.getDisplayHeight()) {
		if (!this.reResized) {
			this.reResized = true;
			return this.loadItem(this.activeItem);
		}
	}
	this.reResized = false;
	this.limitHeight = false;
	var freeSpace = this.getDisplayWidth() - this.newWidth;
	var newLeft = (freeSpace <= 0)? 0 : parseInt(freeSpace/2);
	var displayHeight = this.getDisplayHeight();
	var freeSpace = displayHeight - this.newHeight;
	var freePortion = freeSpace / displayHeight;
	if (freePortion <= .15) var factor = 2;
	else if (freePortion >= .3) var factor = 3;
	else factor = 2 + (freePortion - .15)/.15;
	var newTop = (freeSpace <= 0)? 0 : parseInt(freeSpace/factor);
	if (this.getXScroll() || this.getYScroll()) {
		if (this.fbFloatbox.style.position == 'fixed') {
			this.fbFloatbox.style.left = (this.fbFloatbox.offsetLeft + this.getXScroll()) + 'px';
			this.fbFloatbox.style.top = (this.fbFloatbox.offsetTop + this.getYScroll()) + 'px';
		}
		this.fbFloatbox.style.display = 'none';
		if (this.ie6 || this.ieQuirks) this.stretchOverlay();
		newLeft += this.getXScroll();
		newTop += this.getYScroll();
	}
	this.fbFloatbox.style.position = 'absolute';
	this.fbFloatbox.style.display = '';
	this.arrResize.length = 0;
	var oldWidth = this.fbFloatbox.offsetWidth;
	var oldHeight = this.fbFloatbox.offsetHeight;
	var leftTop = this.getLeftTop(this.fbFloatbox);
	var oldLeft = leftTop[0];
	var oldTop = leftTop[1];
	var borderAdjust = this.ieQuirks? 0 : 2*this.outerBorder;
	if (oldWidth != this.newWidth) this.arrResize.push([this.fbFloatbox, 'width', oldWidth - borderAdjust, this.newWidth - borderAdjust]);
	if (oldLeft != newLeft) this.arrResize.push([this.fbFloatbox, 'left', oldLeft, newLeft]);
	if (oldHeight != this.newHeight) this.arrResize.push([this.fbFloatbox, 'height', oldHeight - borderAdjust, this.newHeight - borderAdjust]);
	if (oldTop != newTop) this.arrResize.push([this.fbFloatbox, 'top', oldTop, newTop]);
	this.fbInfoPanel.style.left = Math.max(this.padding, 8) + 'px';
	this.fbFloatbox.style.visibility = 'visible';
	if (this.arrResize.length) {
		this.resizeGroup('fb.showContent()');
	} else {
		this.showContent();
	}
};
this.showContent = function() {
	if (this.ie6 || this.ieQuirks) this.stretchOverlay();
	if (((this.disableScroll && !(this.ie6 || this.ieQuirks || this.operaQuirks)) || (this.ff2 && this.isIframe)) && this.newWidth <= this.getDisplayWidth() && this.newHeight < this.getDisplayHeight()) {
		this.fbFloatbox.style.position = 'fixed';
		this.fbFloatbox.style.left = (this.fbFloatbox.offsetLeft - this.getXScroll()) + 'px';
		this.fbFloatbox.style.top = (this.fbFloatbox.offsetTop - this.getYScroll()) + 'px';
	}
	this.fbItem = this.setNode((this.isIframe? 'iframe' : 'img'), 'fbItem', this.fbContentPanel, this.theme);
	this.fbItem.width = this.itemWidth;
	this.fbItem.height = this.itemHeight;
	this.fbItem.src = this.arrItems[this.activeItem].href;
	this.fbItem.style.left = this.fbItem.style.top = this.padding + 'px';
	this.fbItem.style.borderWidth = this.innerBorder + 'px';
	this.fbItem.style.display = '';
	if (this.upperNav) {
		this.fbLeftNav.style.width = this.fbRightNav.style.width = Math.max(this.upperNavWidth/100 * this.itemWidth, this.fbUpperPrev.offsetWidth) + 'px';
		this.fbLeftNav.style.height = this.fbRightNav.style.height = this.itemHeight + 'px';
	}
	var panelTop = this.itemHeight + 2*this.innerBorder + this.padding;
	if (this.infoPanelHeight) {
		this.fbInfoPanel.style.display = '';
		this.fbInfoPanel.style.top = (panelTop + (this.panelHeight - this.fbInfoPanel.offsetHeight) / 2) + 'px';
	}
	if (this.showClose || this.showPlayPause || this.lowerNav) {
		this.fbControlPanel.style.display = '';
		this.fbControlPanel.style.top = (panelTop + (this.panelHeight - this.fbControlPanel.offsetHeight) / 2) + 'px';
	}
	setTimeout('fb.showContent2()', 10);
};
this.showContent2 = function() {
	this.fade(this.fbContentPanel, 10, 100);
	this.clearTimeout('loader');
	this.fbLoader.style.display = 'none';
	if (!this.arrItems[this.activeItem].seen) {
		this.arrItems[this.activeItem].seen = true;
		this.itemsShown++;
	}
	this.panelHeight = (this.showCaption || this.showItemNumber)? 16 + 2*this.panelPadding : this.padding;
	if (!this.isIframe) {
		var nextHref = (this.activeItem + 1 < this.itemCount)? this.arrItems[this.activeItem + 1].href : this.arrItems[0].href;
		if (!this.objImagePreloads[nextHref]) {
			this.arrImageHrefs.splice(0, 0, nextHref);
			this.loadNextImage();
		}
	}
	if (this.isSlideshow && !this.isPaused) {
		if (this.endTask == 'cont' || this.itemsShown < this.itemCount) {
			var nextItem = (this.activeItem < this.itemCount - 1)? this.activeItem + 1 : 0;
			this.objTimeouts.slideshow = setTimeout('fb.loadItem(' + nextItem + ')', this.slideInterval*1000);
		} else if (this.endTask == 'exit')  {
			this.objTimeouts.slideshow = setTimeout('fb.end()', this.slideInterval*1000);
		} else {
			this.objTimeouts.slideshow = setTimeout('fb.setPause(true)', this.slideInterval*1000);
			var i = this.itemCount;
			while (i--) this.arrItems[i].seen = false;
			this.itemsShown = 0;
		}
	}
};
this.end = function() {
	for (var key in this.objTimeouts) {
		this.clearTimeout(key);
	}
	if (this.enableKeyboardNav) {
		document.onkeydown = this.priorOnkeydown;
	}
	if (window.opera) document.onkeypress = this.priorOnkeypress;
	this.fbOverlay.onclick = null;
	this.fbFloatbox.style.display = 'none';
	this.fade(this.fbOverlay, this.overlayOpacity, 0, 'fb.fbOverlay.style.display = "none"');
	if (this.ie6 || this.ieQuirks) {
		this.setVisibility('select', '');
		top.detachEvent('onresize', fb.stretchOverlay);
	}
	if (this.hideFlash) {
		this.setVisibility('object', '');
		this.setVisibility('embed', '');
	}
	function remove(el) { el.parentNode.removeChild(el); };
	if (this.upperNav) {
		remove(this.fbUpperPrev); delete this.fbUpperPrev;
		remove(this.fbUpperNext); delete this.fbUpperPrev;
		remove(this.fbLeftNav); delete this.fbLeftNav;
		remove(this.fbRightNav); delete this.fbRightNav;
	}
	if (this.fbItem) { remove(this.fbItem); delete this.fbItem; }
	remove(this.fbCaption); delete this.fbCaption;
	remove(this.fbItemNumber); delete this.fbItemNumber;
	remove(this.fbInfoPanel); delete this.fbInfoPanel;
	if (this.loadPageOnClose) {
		if (this.loadPageOnClose == 'this') location.reload(true);
		else if (this.loadPageOnClose == 'back') history.back();
		else location.replace(this.loadPageOnClose);
	}
};
this.keyboardAction = function(e) {
	if (!e) var e = window.event;
	switch(e.which || e.keyCode) {
		case 88: case 67: case 27: {
			fb.end();
			if (e.returnValue) e.returnValue = false;
			return false;
		}
		case 78: case 39: {
			if (fb.itemCount > 1) {
				fb.loadItem((fb.activeItem == fb.itemCount - 1)? 0 : fb.activeItem + 1);
				if (fb.isSlideshow && fb.pauseOnNext && !fb.isPaused && fb.showPlayPause) {
					fb.setPause(true);
				}
			}
			if (e.returnValue) e.returnValue = false;
			return false;
		}
		case 80: case 37: case 8: {
			if (fb.itemCount > 1) {
				fb.loadItem((fb.activeItem == 0)? fb.itemCount - 1 : fb.activeItem - 1);
				if (fb.isSlideshow && fb.pauseOnPrev && !fb.isPaused && fb.showPlayPause) {
					fb.setPause(true);
				}
			}
			if (e.returnValue) e.returnValue = false;
			return false;
		}
		case 32: {
			if (fb.isSlideshow) fb.setPause(!fb.isPaused);
		}
		case 13: {
			if (e.returnValue) e.returnValue = false;
			return false;
		}
	}
};
this.setPause = function(bPause) {
	this.isPaused = bPause;
	if (bPause) {
		this.clearTimeout('slideshow');
	} else {
		this.loadItem((this.activeItem < this.itemCount - 1)? this.activeItem + 1 : 0);
	}
	if (this.showPlayPause) {
		this.fbPause.style.display = bPause? 'none' : '';
		this.fbPlay.style.display = bPause? '' : 'none';
	}
};
this.fade = function(obj, startOp, finishOp, strOnComplete) {
	if (typeof(finishOp) == 'undefined') finishOp = startOp;
	var fadeIn = (startOp <= finishOp && finishOp > 0);
	this.clearTimeout(obj.id);
	var duration = (obj.id == 'fbOverlay')? this.overlayFadeDuration : this.imageFadeDuration;
	if (duration > 10) duration = 10;
	if (duration < 0) duration = 0;
	if (duration == 0) {
		startOp = finishOp;
		var incr = 100;
	} else {
		var root = Math.pow(100, .1);
		var power = duration + ((10 - duration)/9) * (Math.log(2)/Math.log(root) - 1);
		var incr = Math.round(100/Math.pow(root, power));
	}
	if (!fadeIn) incr = -incr;
	this.setOpacity(obj, startOp, finishOp, incr, fadeIn, strOnComplete);
	if (fadeIn) {
		obj.style.display = '';
		obj.style.visibility = 'visible';
	}
};
this.setOpacity = function(obj, thisOp, finishOp, incr, fadeIn, strOnComplete) {
	if (strOnComplete) arguments.callee.oncomplete = strOnComplete;
	if ((fadeIn && thisOp >= finishOp) || (!fadeIn && thisOp <= finishOp)) thisOp = finishOp;
	obj.style.opacity = (thisOp / 100);
	obj.style.MozOpacity = (thisOp / 100);
	obj.style.KhtmlOpacity = (thisOp / 100);
	obj.style.filter = 'alpha(opacity=' + thisOp + ')';
	if (thisOp == finishOp) {
		this.objTimeouts[obj.id] = null;
		if (finishOp >= 100) {
			try { obj.style.removeAttribute('filter'); } catch(e) {}
		}
		if (arguments.callee.oncomplete) {
			eval(arguments.callee.oncomplete);
			delete arguments.callee.oncomplete;
		}
	} else {
		this.objTimeouts[obj.id] = setTimeout('fb.setOpacity(fb.' + obj.id + ', ' + (thisOp + incr) + ', ' + finishOp + ', ' + incr + ', ' + fadeIn + ')', 20);
	}
};
this.resizeGroup = function(strOnComplete) {
	var i = this.arrResize.length;
	if (!i) return;
	var diff = 0;
	while (i--) diff = Math.max(diff, Math.abs(this.arrResize[i][3] - this.arrResize[i][2]));
	this.clearTimeout('resizeGroup');
	var rate = (diff && this.resizeDuration)? Math.pow(Math.max(1, 2.2 - this.resizeDuration/10), (Math.log(diff))) / diff : 1;
	i = this.arrResize.length;
	while (i--) {
		this.arrResize[i][3] -= this.arrResize[i][2]
	}
	this.setSize(rate, 1, strOnComplete);
};
this.setSize = function(rate, count, strOnComplete) {
	if (strOnComplete) arguments.callee.oncomplete = strOnComplete;
	var increment = rate * count;
	if (increment > 1) increment = 1;
	var i = this.arrResize.length;
	while (i--) {
		var obj = this.arrResize[i][0];
		var prop = this.arrResize[i][1];
		var startPx = this.arrResize[i][2];
		var diff = this.arrResize[i][3];
		obj.style[prop] = (startPx + diff * increment) + 'px';
	}
	if (increment >= 1) {
		this.objTimeouts.resizeGroup = null;
		if (arguments.callee.oncomplete) {
			eval(arguments.callee.oncomplete);
			delete arguments.callee.oncomplete;
		}
	} else {
		this.objTimeouts.resizeGroup = setTimeout('fb.setSize(' + rate + ', ' + (count + 1) + ')', 20);
	}
};
this.getXScroll = function() {
	return top.pageXOffset || this.body.scrollLeft || this.doc.documentElement.scrollLeft || 0;
};
this.getYScroll = function() {
	return top.pageYOffset || this.body.scrollTop || this.doc.documentElement.scrollTop || 0;
};
this.getDisplayWidth = function() {
	return (this.doc.documentElement && this.doc.documentElement.clientWidth) || this.body.clientWidth;
};
this.getDisplayHeight = function() {	
	if (this.doc.childNodes && !this.doc.all && !navigator.taintEnabled && !this.doc.evaluate) {
		return top.innerHeight;
	}
	if (window.opera) {
		var h = this.body.clientHeight;
		if (this.body.currentStyle) {
			if (this.body.currentStyle.borderTopStyle != 'none') {
				h += parseInt(this.body.currentStyle.borderTopWidth);
			}
			if (this.body.currentStyle.borderBottomStyle != 'none') {
				h += parseInt(this.body.currentStyle.borderBottomWidth);
			}
		}
		return h;
	}
	var elementHeight = (this.doc.documentElement && this.doc.documentElement.clientHeight) || 0;
	if (!elementHeight || (this.doc.compatMode && this.doc.compatMode == 'BackCompat')) {
		return this.body.clientHeight;
	}
	return elementHeight;
};
this.getLeftTop = function(el) {
	var left = el.offsetLeft || 0;
	var top = el.offsetTop || 0;
	var parent = el;
	while (parent = parent.offsetParent) {
		left += parent.offsetLeft || 0;
		top += parent.offsetTop || 0;
	}
	return [left, top];
};
this.setVisibility = function(tagName, state, thisWindow) {
	if (!thisWindow) {
		arguments.callee(tagName, state, top)
	} else {
		try {
			var els = thisWindow.document.getElementsByTagName(tagName);
			var i = els.length; while (i--) {
				els[i].style.visibility = state;
			}
		} catch(e) {}
		var frames = thisWindow.frames;
		i = frames.length; while (i--) {
			if (typeof(frames[i].window) == 'object') arguments.callee(tagName, state, frames[i].window);
		}
	}
};
this.clearTimeout = function(key) {
	if (this.objTimeouts[key]) {
		clearTimeout(this.objTimeouts[key]);
		this.objTimeouts[key] = null;
	}
};
this.stretchOverlay = function() {
	if (arguments.length == 1) {
		fb.clearTimeout('onresize');
		fb.objTimeouts.onresize = setTimeout('fb.stretchOverlay()', 100);
	} else {
		fb.objTimeouts.onresize = null;
		var width = fb.fbFloatbox.offsetLeft + fb.fbFloatbox.offsetWidth;
		var height = fb.fbFloatbox.offsetTop + fb.fbFloatbox.offsetHeight;
		var style = fb.fbOverlay.style;
		style.width = style.height = '0';
		style.width = Math.max(width, fb.body.scrollWidth, fb.body.clientWidth, fb.getDisplayWidth()) + 'px';
		style.height = Math.max(height, fb.body.scrollHeight, fb.body.clientHeight, fb.doc.documentElement.clientHeight, fb.getDisplayHeight()) + 'px';
	}
};
this.setCookie = function(name, value, days) {
	if (!arguments.callee.path) {
		var tlp = top.location.pathname;
		arguments.callee.path = '; path=' + tlp.substring(0, tlp.lastIndexOf('/') + 1);
	}
	var expires = '';
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + days*86400000);
		expires = '; expires=' + date.toGMTString();
	}
	this.doc.cookie = name + '=' + escape(value) + expires + arguments.callee.path;
};
this.getCookie = function(name) {
	var aCookies = this.doc.cookie.split('; ');
	var i = aCookies.length;  while (i--) {
		var cookie = aCookies[i].split('=');
		if (cookie[0] == name) return unescape(cookie[1]);
	}
	return null;
};
this.deleteCookie = function(name) {
	this.setCookie(name, '', -1);
};
};
function initfb() {
	if (arguments.callee.done) return;
  	arguments.callee.done = true;
	if (!top.floatbox) top.floatbox = new Floatbox();
	fb = top.floatbox;
	fb.tagAnchors(self.document);
	if (fb.autoStart) fb.start(fb.autoStart);
};
/*@cc_on
/*@if (@_win32 || @_win64)
	intervalID = setInterval(function() {
		try {
			document.documentElement.doScroll('left');
			clearInterval(intervalID);
			initfb();
		} catch (e) {}
	}, 50);
@else @*/
	if (/Apple|KDE/i.test(navigator.vendor)) {
		intervalID = setInterval(function() {
			if (/loaded|complete/.test(document.readyState)) {
				clearInterval(intervalID);
				initfb();
			}
		}, 50);
	} else if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", initfb, false);
	}
/*@end
@*/
prevOnload = window.onload;
window.onload = function() {
	initfb();
	fb.loadNextImage();
	if (typeof(prevOnload) == 'function') prevOnload();
};
