/* -----------------------------------------------------------------------------------

	Thinbox v0.9
	Inspired by Lightbox and Thickbox
	In-page "windowing" system for images, ajax and iframe requests

----------------------------------------------------------------------------------- */

/* Configuration */

var thinboxConfig = {
	// Image path format (helpful to use a resize script; use {img} if so, use null if not)
	// Optional max-width {maxw} / max-height {maxh}
	// The path I chose is directed to a resize script with mod_rewrite, then parsed in PHP
	// imgPathFormat: 'Shrink/{img}/{maxw}/{maxh}',
	imgPathFormat: 'shrink.php?img={img}&w={maxw}&h={maxh}',

	// The directory where the Thinbox images are located
	imgDirectory: '/key/assets/thinbox/',

	// Image paths
	loadingImg: 'loading.gif',
	transparentImg: 'transparent.gif',
	closeImg: 'close.png',
	zoomImg: 'zoom.png',
	backImg: 'back.png',
	nextImg: 'next.png',
	captionImg: 'caption.png',
	alwaysShowCaption: true,
	blackoutImg: null,
	commentBackImg: 'infoshadow.png',
	shadowPrefix: 'thinshadow',

	buttonDirectory: '/key/assets/thinbox/',
	buttonNo: 'button_no.png',
	buttonYes: 'button_yes.png',

	// Positioning (int = px); ajaxWidth & ajaxHeight describe the default dimensions
	// for non-image windows
	top: 40,
	ajaxWidth: 650,
	ajaxHeight: 450,
	minWidth: 250,
	minHeight: 150,

	// Flash video
	flashPlayerPath: '/key/assets/thinbox/flvplayer.swf',
	flashWidth: 640,
	flashHeight: 480,
	flvShowControls: true,

	// Misc options
	dropShadow: true,
	linkPrefix: 'link_',		// $(linkPrefix + [int]) corresponds to
	captionPrefix: 'caption_'	// $(captionPrefix + [int])
}

// -----------------------------------------------------------------------------------

/* Object detection: determine browser capabilities and quirks */

thinboxConfig.isIE = false;
thinboxConfig.isIE5 = false;
thinboxConfig.isIE55 = false;
thinboxConfig.isIE7 = false;
thinboxConfig.isSafari = false;
thinboxConfig.isSafari3 = false;
thinboxConfig.isGecko = false;
thinboxConfig.isOpera = false;

if(document.all && !window.opera)
	thinboxConfig.isIE = true;
if(document.all && !document.fireEvent && !window.opera)
	thinboxConfig.isIE5 = true;
if(document.all && document.fireEvent && !document.createComment)
	thinboxConfig.isIE55 = true;
if((!document.doctype && !thinboxConfig.isIE) || (window.devicePixelRatio && window.getMatchedCSSRules))
	thinboxConfig.isSafari = true;
if(thinboxConfig.isSafari && (window.devicePixelRatio && window.getMatchedCSSRules))
	thinboxConfig.isSafari3 = true;
if((Array.every || window.Iterator || (window.getComputedStyle && !window.opera)) && thinboxConfig.isSafari === false)
	thinboxConfig.isGecko = true;
if(window.opera)
	thinboxConfig.isOpera = true;
if(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined" && !thinboxConfig.isSafari && !thinboxConfig.isGecko && !thinboxConfig.isOpera)
	thinboxConfig.isIE7 = true;

/* Globals: maintain only one set of links;
	this way if images are dynamically loaded a new Thinbox
	may be created without duplicates */

var thinLinks = new Array('');
var thinGroups = new Array('');

// RegExp.escape
RegExp.prototype.escape = function(text) {
  if (!arguments.callee.sRE) {
    var specials = [
      '/', '.', '*', '+', '?', '|',
      '(', ')', '[', ']', '{', '}', '\\'
    ];
    arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
  }
  return text.replace(arguments.callee.sRE, '\\$1');
}

// Array.keynum(value) searches Array for value and returns key
// Caveat: Does not handle duplicate values
Array.prototype.keynum = function(value) {
    for(var x = 0; x < this.length; x++) {
		if(this[x] == value) return x;
	}
	return false;
}

// Event.onDomReady events are executed when the DOM is ready to be worked with,
// rather than after all images load
Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);
   
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDomReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
     
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
       
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
       
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
       
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});

// -----------------------------------------------------------------------------------

/* Refresh CSS to avoid bug in Safari 3 */

if(thinboxConfig.isSafari3) { (function(){var i,a,s;a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}}})(); }

// -----------------------------------------------------------------------------------

/* Create Thinbox Class */

var Thinbox = Class.create();

Thinbox.prototype = {
	WindowOpen: false,

	initialize: function(thinboxConfig) {
		for(x in thinboxConfig) {
			if((x.match(/Img$/) || x == 'shadowPrefix') && thinboxConfig[x] != null) this[x] = thinboxConfig.imgDirectory + thinboxConfig[x];
			else if(x.match(/^button[A-Z]/) && x != 'buttonDirectory') this[x] = thinboxConfig.buttonDirectory + thinboxConfig[x];
			else this[x] = thinboxConfig[x];
			if(typeof this[x] == 'string' && this[x].match(/\.png$/)) {
				this.preloadImg(this[x]);
			}
		}

		// For sites which use the <base> tag, Thinbox assumes this prefix for relative paths
		if(document.getElementsByTagName('base') && document.getElementsByTagName('base').length > 0) {
			this.basehref = document.getElementsByTagName('base')[0].href;
		} else {
			this.basehref = '';
		}

		// Set up Thinbox "window"
		if(!$('thinbox')) {
			this.configWindow();
		}

		if(this.isIE && !this.isIE7) {
			this.cleanImages();
		}

		this.scanLinks();

		// Handle navigation by keyboard
		Event.observe(window, 'keypress', function(e) {
			if(this.WindowOpen) {
				if(!e) e = window.event;
				var keyPressed = e.charCode ? e.charCode : e.keyCode ? e.keyCode : e.which;

				if(this.isSafari && keyPressed > 63200) {
					keyPressed = e.keyCode;
				}

				// alert('charCode: ' + e.charCode + ', keyCode: ' + e.keyCode + ', which: ' + e.which)

				if(keyPressed == 27) {
					// Escape
					this.end();
				} else if(((keyPressed == 39 && e.keyCode !=222) || keyPressed == 40 || keyPressed == 34 || keyPressed == 63235) &&
				this.showingImg) {
					// Right arrow, page down, down arrow
					this.nextImage();
				} else if((keyPressed == 37 || keyPressed == 38 || keyPressed == 33 || keyPressed == 63234) &&
				this.showingImg) {
					// Left arrow, page up, up arrow
					this.backImage();
				}

				if(!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
					Event.stop(e);
				}
			}
		}.bind(this), true);

	},

	cleanImages: function() {
		$$('img[src$="png"]').each(function(image) {
			new cleanPngForIE(image);
		}.bind(this))
	},

	// Scan links
	scanLinks: function() {

		var anchor, imgNum, groupName, keyNum;
		var anchors = document.getElementsByTagName('a');

		for(var x = 0; x < anchors.length; x++) {
			anchor = anchors[x];

			// Find thinbox links, assign onclick event
			if (
				anchor.getAttribute('href') &&
				anchor.rel && 
				(
					anchor.rel.toLowerCase().match(/^lightbox\b/) ||
					anchor.rel.toLowerCase() == 'thinbox' ||
					anchor.rel.toLowerCase() == 'thinconfirm'
				)
			) {
				Event.observe($(anchor), 'click', function(e) {

					var clicked = Event.element(e);
					if(clicked.tagName.toLowerCase() != 'a') {
						clicked = $(clicked).up('a');
					}
					this.start(clicked);
					Event.stop(e);
					return false;
				}.bindAsEventListener(this), true)

				imgNum = thinLinks.length;
				thinLinks[imgNum] = anchor;

				// Group images by className
				if(anchor.className && anchor.href.match(/\.(jpg|jpeg|png|gif)$/i)) {
					// this.preloadImg(anchor.href);
					groupName = anchor.className;
				} else if(anchor.href.match(/\.(jpg|jpeg|png|gif)$/i)) {
					// this.preloadImg(anchor.href);
					groupName = 'noclass';
					anchor.className = groupName;
				} else {
					groupName = 'nogroup';
				}

				if(!thinGroups[groupName]) thinGroups[groupName] = new Array();
				keyNum = thinGroups[groupName].length;
				thinGroups[groupName][keyNum] = anchor;

			}
		}
	},

	preloadImg: function(url) {
		if(!this.preloadArray) this.preloadArray = {};
		if(this.preloadArray[url]) return;
		this.preloadArray[url] = url;
		setTimeout(function() {var image = document.createElement('img');image.src = url;}, 200);
	},
	// Get the computed css property
	getStyle: function(element, cssRule) {
		element = $(element);
		var strValue = "";
		if(document.defaultView && document.defaultView.getComputedStyle){
			strValue = document.defaultView.getComputedStyle(element, "").getPropertyValue(cssRule);
		} else if(element.currentStyle) {
			cssRule = cssRule.replace(/\-(\w)/g, function (strMatch, p1){
				return p1.toUpperCase();
			});
			strValue = element.currentStyle[cssRule];
		}
		return strValue;
	},

	// Set up Thinbox structure, you can skip this, it's boring
	configWindow: function() {
		if(this.alwaysShowCaption) {
			this.addHeight = 80;
			this.ajaxHeight = this.ajaxHeight + this.addHeight;
		} else {
			this.addHeight = 0;
		}
		this.Body = document.getElementsByTagName("body").item(0);
		this.Blackout = document.createElement('div');
		this.Blackout.id = 'thinblackout';
		this.Blackout.style.display = 'none';
		if(this.dropShadow == true) this.makeShadow();
		if(this.blackoutImg==null) {
			this.blackoutImg = this.transparentImg;
		} else {
			// Supports a background image (like fancy web 2.0 gradients!)
			this.blackoutImg = document.createElement('img');
			this.blackoutImg.src = this.blackoutImg;
			this.blackoutImg.style.width = '100%';
			this.blackoutImg.style.height = '100%';
			this.blackoutImg.style.display = 'block';
			this.blackoutImg.style.position = 'absolute';
			this.blackoutImg.style.top = 0;
			this.blackoutImg.style.left = 0;
			this.blackoutImg.alt = '';
			this.Blackout.appendChild(this.blackoutImg);
		}
		this.Blackout.onclick = function() { this.end(); }.bind(this)
		this.Blackout.ondragstart = function() { return false; }
		this.Body.insertBefore(this.Blackout, this.Body.firstChild);
		this.Window = document.createElement('div');
		this.Window.style.display = 'none';
		this.Window.id = 'thinbox';
		this.Window.style.top = this.top + 'px';
		this.Window.style.left = '50%';
		this.Window.style.width = this.ajaxWidth + 'px';
		this.Window.style.height = this.ajaxHeight + 'px';
		if(this.isIE && !this.isIE7) {
			var marginLeftAdjust = (parseInt(this.getStyle($$('body')[0], 'margin-left')) + parseInt(this.getStyle($$('body')[0], 'padding-left')));
			this.Window.style.marginLeft = '-' + (Math.round(this.ajaxWidth / 2) + marginLeftAdjust) + 'px';
		} else {
			this.Window.style.marginLeft = '-' + (Math.round(this.ajaxWidth / 2) + 0) + 'px';
		}
		if(this.isIE && !this.isIE7) this.Window.style.marginLeft = '-' + (Math.round(this.ajaxWidth / 2) + marginLeftAdjust) + 'px';
		this.Window.style.paddingTop = '8px';
		this.Window.style.paddingRight = '20px';
		this.Window.style.paddingBottom = '20px';
		this.Window.style.paddingLeft = '20px';
		this.ConfirmWindow = document.createElement('div');
		this.ConfirmWindow.id = 'thinconfirm';
		this.ConfirmWindow.style.display = 'none';
		this.ConfirmWindow.innerHTML = '<img src="' + thinboxConfig.imgDirectory + '/back_confirm.png" width="535" height="126" alt=" " id="thinconfirmback" /><div id="thinconfirmmsg" class="left">&nbsp;</div><div class="right"><a class="button" id="thinconfirmyes"><img src="' + this.buttonYes + '" width="50" height="22" alt="Yes" /></a> <a class="button" id="thinconfirmno"><img src="' + this.buttonNo + '" width="46" height="22" alt="Yes" /></a></div>'
		this.FlvPlayer = document.createElement('div');
		this.FlvPlayer.id = 'thinflvplayer';
		this.Imgcover = document.createElement('div');
		this.Imgcover.id = 'thinimgcover';
		this.Contents = document.createElement('div');
		this.Contents.id = 'thincontents';
		this.Contents.style.overflow = 'hidden';
		this.Img = document.createElement('img');
		this.Img.style.background = $(this.Imgcover).getStyle('background');
		this.Img.id = 'thinimg';
		this.Img.style.display = 'block';
		this.Img.onload = function(e) {
			this.Body.appendChild(this.Img);
			var wTarget = this.Img.offsetWidth;
			var hTarget = this.Img.offsetHeight;
			this.Contents.appendChild(this.Img);
			if(!this.Img.src.match('http://' + window.location.hostname + this.transparentImg)) {
				Element.show(this.Zoom);
				this.resizeWindow(wTarget, hTarget);
			}
			if(this.alwaysShowCaption && $('thincaptionfulltext').innerHTML.strip() != '') {
				$(this.Caption).show();
			} else {
				$(this.Caption).hide();
			}
			Effect.Fade(this.Imgcover, { duration: 0.4 });
		}.bind(this)
		this.Iframe = document.createElement('iframe');
		this.Iframe.name = 'thinobj';
		this.Iframe.id = 'thinobj';
		this.Iframe.style.width = this.ajaxWidth + 'px';
		this.Iframe.style.height = this.ajaxHeight + 'px';
		if(this.isIE) {
			this.Iframe.border = "0";
			this.Iframe.frameBorder = "0";
			this.Iframe.style.border = "0";
		}
		$(this.Iframe).onload = function() {
			Effect.Fade(this.Imgcover, { beforeStart: function() {
				if(Element.visible(this.Comment)) Element.hide(this.Comment);
			}.bind(this), duration: 0.2 });
		}.bind(this)
		window.onbeforeunload = function() {
			if(this.Iframe.src != 'about:blank' && this.Iframe.src != '//:') {
				this.Iframe.src = 'about:blank';
			}
		}.bind(this)
		$(this.Iframe).hide();
		this.Ajax = document.createElement('div');
		this.Ajax.id = 'thinajax';
		this.Ajax.style.width = this.ajaxWidth + 'px';
		this.Ajax.style.height = this.ajaxHeight + 'px';
		$(this.Ajax).hide();
		this.Caption = document.createElement('div');
		this.Caption.style.display = 'none';
		$(this.Caption).hide();
		if(this.alwaysShowCaption) {
			this.Caption.id = 'thincaptionfull';
			this.Caption.innerHTML = '<div id="thincaptionfulltext"></div>';
			this.Caption.style.height = this.addHeight + 'px';
		} else {
			this.Caption.id = 'thincaption';
			this.CaptionButton = document.createElement('img');
			this.CaptionButton.src = this.captionImg;
			this.CaptionButton.id = 'thincaptionbutton';
			this.CaptionButton.onclick = function() {
				if(this.captionId && typeof this.captionId != 'undefined') this.toggleCaption(this.captionId);
			}.bind(this)
		}
		this.Contents.appendChild(this.Img);
		this.Contents.appendChild(this.Iframe);
		this.Iframe.src = 'about:blank';
		this.Contents.appendChild(this.Ajax);
		this.Contents.appendChild(this.FlvPlayer);
		if(this.alwaysShowCaption) {
			this.Contents.appendChild(this.Caption);
		} else {
			this.Contents.appendChild(this.Caption);
		}
		this.Contents.appendChild(this.Imgcover);
		this.Comment = document.createElement('div');
		this.Comment.id = 'thincomment';
		this.Controls = document.createElement('div');
		this.Controls.id = 'thincontrols';
		this.Controls.style.display = 'none';
		this.Close = document.createElement('img');
		this.Close.id = 'thinclose';
		this.Close.src = this.closeImg;
		this.Close.onclick = function() { this.end(); }.bind(this)
		this.Zoom = document.createElement('img');
		this.Zoom.id = 'thinzoom';
		this.Zoom.src = this.zoomImg;
		this.Zoom.onclick = function() { window.open(this.currentlyViewing, 'fullsize'); }.bind(this)
		this.CommentBack = document.createElement('img');
		this.CommentBack.src = this.commentBackImg;
		this.CommentBack.id = 'thinCommentBack';
		if(this.alwaysShowCaption) {
			// this.CommentBack.style.width = (this.ajaxWidth - 105) + 'px';
		} else {
			// this.CommentBack.style.width = (this.ajaxWidth - 131) + 'px';
		}
		this.Nav = document.createElement('div');
		this.Nav.id = 'thinnav';
		this.Back = document.createElement('img');
		this.Back.id = 'thinback';
		this.Back.src = this.backImg;
		this.Back.onclick = function() { this.backImage(); }.bind(this)
		this.Next = document.createElement('img');
		this.Next.id = 'thinnext';
		this.Next.src = this.nextImg;
		this.Next.onclick = function() { this.nextImage(); }.bind(this)
		this.Controls.appendChild(this.Close);
		this.Controls.appendChild(this.Zoom);
		if(!this.alwaysShowCaption) {
			this.Controls.appendChild(this.CaptionButton);
		}
		this.Controls.appendChild(this.CommentBack);
		this.Controls.appendChild(this.Nav);
		this.Controls.appendChild(this.Back);
		this.Controls.appendChild(this.Next);
		this.Controls.appendChild(this.Comment);
		this.Window.appendChild(this.Contents);
		// this.Window.appendChild(this.Controls);
		this.Body.appendChild(this.Controls);
		this.Body.appendChild(this.Window);
		this.resizeWindow(this.ajaxWidth, this.ajaxHeight);
		this.Body.appendChild(this.ConfirmWindow);
	},
	// Set up drop shadow, you can skip this, it's boring 
	makeShadow: function() {
		this.Shadow = document.createElement('div');
		this.Shadow.style.display = 'none';
		this.Shadow.style.top = (this.top + 1) + 'px';
		this.Shadow.style.left = '50%';
		this.Shadow.style.width = (this.ajaxWidth + 21) + 'px';
		this.Shadow.style.height = (this.ajaxHeight + 22) + 'px';
		this.Shadow.style.marginLeft = '-' + Math.round((this.ajaxWidth - 18) / 2) + 'px';
		this.Shadow.id = 'thinshadow';
		this.ShadowTL = document.createElement('div');
		this.ShadowTL.id = 'tstl';
		this.ShadowImgTL = document.createElement('img');
		this.ShadowImgTL.src = this.shadowPrefix + 'tl.png';
		this.ShadowTL.appendChild(this.ShadowImgTL);

		this.ShadowT = document.createElement('div');
		this.ShadowT.id = 'tst';
		this.ShadowImgT = document.createElement('img');
		this.ShadowImgT.src = this.shadowPrefix + 't.png';
		this.ShadowT.appendChild(this.ShadowImgT);

		this.ShadowTR = document.createElement('div');
		this.ShadowTR.id = 'tstr';
		this.ShadowImgTR = document.createElement('img');
		this.ShadowImgTR.src = this.shadowPrefix + 'tr.png';
		this.ShadowTR.appendChild(this.ShadowImgTR);

		this.ShadowL = document.createElement('div');
		this.ShadowL.id = 'tsl';
		this.ShadowImgL = document.createElement('img');
		this.ShadowImgL.src = this.shadowPrefix + 'l.png';
		this.ShadowL.appendChild(this.ShadowImgL);

		this.ShadowR = document.createElement('div');
		this.ShadowR.id = 'tsr';
		this.ShadowImgR = document.createElement('img');
		this.ShadowImgR.src = this.shadowPrefix + 'r.png';
		this.ShadowR.appendChild(this.ShadowImgR);

		this.ShadowBL = document.createElement('div');
		this.ShadowBL.id = 'tsbl';
		this.ShadowImgBL = document.createElement('img');
		this.ShadowImgBL.src = this.shadowPrefix + 'bl.png';
		this.ShadowBL.appendChild(this.ShadowImgBL);

		this.ShadowB = document.createElement('div');
		this.ShadowB.id = 'tsb';
		this.ShadowImgB = document.createElement('img');
		this.ShadowImgB.src = this.shadowPrefix + 'b.png';
		this.ShadowB.appendChild(this.ShadowImgB);

		this.ShadowBR = document.createElement('div');
		this.ShadowBR.id = 'tsbr';
		this.ShadowImgBR = document.createElement('img');
		this.ShadowImgBR.src = this.shadowPrefix + 'br.png';
		this.ShadowBR.appendChild(this.ShadowImgBR);

		/* IE, you're so pathetic */
		if(this.isIE7) {
			this.ShadowT.style.width = (this.ajaxWidth - 22) + 'px';
			this.ShadowB.style.width = (this.ajaxWidth - 22) + 'px';
			this.ShadowL.style.height = (this.ajaxHeight - 6) + 'px';
			this.ShadowR.style.height = (this.ajaxHeight - 6) + 'px';
			this.ShadowTL.firstChild.style.position = 'relative';
			this.ShadowTR.firstChild.style.position = 'relative';
			this.ShadowBL.firstChild.style.position = 'relative';
			this.ShadowBR.firstChild.style.position = 'relative';
			this.ShadowT.firstChild.style.width = '100%';
			this.ShadowT.firstChild.style.position = 'relative';
			this.ShadowB.firstChild.style.width = '100%';
			this.ShadowB.firstChild.style.position = 'relative';
			this.ShadowL.firstChild.style.height = '100%';
			this.ShadowL.firstChild.style.position = 'relative';
			this.ShadowR.firstChild.style.height = '100%';
			this.ShadowR.firstChild.style.position = 'relative';
		} else if(this.isIE) {
			this.Shadow.style.width = (this.ajaxWidth + 22) + 'px';
			this.ShadowL.style.position = 'absolute';
			this.ShadowL.style.top = (this.top + 29) + 'px';
			this.ShadowL.style.left = '50%';
			this.ShadowL.style.marginLeft = (0 - (this.ajaxWidth / 2)) + 'px';
			this.ShadowR.style.position = 'absolute';
			this.ShadowR.style.top = (this.top + 29) + 'px';
			this.ShadowR.style.left = '50%';
			this.ShadowR.style.marginLeft = (0 + (this.ajaxWidth / 2)) + 'px';
			this.ShadowB.style.position = 'absolute';
			this.ShadowB.style.top = (this.top + this.ajaxHeight + 23) + 'px';
			this.ShadowB.style.left = '50%';
			this.ShadowB.style.marginLeft = (0 - (this.ajaxWidth / 2) + 22) + 'px';
			this.ShadowT.style.position = 'absolute';
			this.ShadowT.style.top = this.top;
			this.ShadowT.style.left = '50%';
			this.ShadowT.style.marginLeft = (0 - (this.ajaxWidth / 2)) + 'px';
			this.ShadowTL.style.position = 'absolute';
			this.ShadowTL.style.left = '50%';
			this.ShadowTL.style.top = this.top;
			this.ShadowTL.style.marginLeft = (0 - (this.ajaxWidth / 2)) + 'px';
			this.ShadowTR.style.position = 'absolute';
			this.ShadowTR.style.left = '50%';
			this.ShadowTR.style.top = this.top;
			this.ShadowTR.style.marginLeft = (0 + (this.ajaxWidth / 2)) + 'px';
			this.ShadowBL.style.position = 'absolute';
			this.ShadowBL.style.top = (this.top + this.ajaxHeight + 23) + 'px';
			this.ShadowBL.style.left = '50%';
			this.ShadowBL.style.marginLeft = (0 - (this.ajaxWidth / 2)) + 'px';
			this.ShadowBR.style.position = 'absolute';
			this.ShadowBR.style.top = (this.top + this.ajaxHeight + 23) + 'px';
			this.ShadowBR.style.left = '50%';
			this.ShadowBR.style.marginLeft = (0 + (this.ajaxWidth / 2)) + 'px';
			this.ShadowT.style.width = (this.ajaxWidth - 22) + 'px';
			this.ShadowB.style.width = (this.ajaxWidth - 22) + 'px';
			this.ShadowL.style.height = (this.ajaxHeight - 6) + 'px';
			this.ShadowR.style.height = (this.ajaxHeight - 6) + 'px';
			this.ShadowTL.firstChild.style.position = 'relative';
			this.ShadowTR.firstChild.style.position = 'relative';
			this.ShadowBL.firstChild.style.position = 'relative';
			this.ShadowBR.firstChild.style.position = 'relative';
			this.ShadowT.firstChild.style.width = '100%';
			this.ShadowT.firstChild.style.position = 'relative';
			this.ShadowB.firstChild.style.width = '100%';
			this.ShadowB.firstChild.style.position = 'relative';
			this.ShadowL.firstChild.style.height = '100%';
			this.ShadowL.firstChild.style.position = 'relative';
			this.ShadowR.firstChild.style.height = '100%';
			this.ShadowR.firstChild.style.position = 'relative';
			if($('thincomment')) {
				$('thincomment').style.left = '50%';
				$('thincomment').style.marginLeft = (0 - ($('thincomment').offsetWidth / 2) + 1) + 'px';
			}
		}
		this.Shadow.appendChild(this.ShadowTL);
		this.Shadow.appendChild(this.ShadowT);
		this.Shadow.appendChild(this.ShadowTR);
		this.Shadow.appendChild(this.ShadowL);
		this.Shadow.appendChild(this.ShadowR);
		this.Shadow.appendChild(this.ShadowBL);
		this.Shadow.appendChild(this.ShadowB);
		this.Shadow.appendChild(this.ShadowBR);
		this.Blackout.appendChild(this.Shadow);
	},
	start: function(anchor) {
		this.WindowOpen = true;
		Element.show(this.Imgcover);
		$(this.Imgcover).show();
		$(this.Imgcover).style.display = 'block';
		link = anchor.href;
		if(anchor.rel == 'thinconfirm') {
			this.confirmlink(anchor);
		} else if(link.match(/\.(jpg|jpeg|png|gif)$/i)) {
			if(this.windowLoaded && $('thincaptionfulltext').innerHTML.strip() != '') {
				$(this.Caption).show();
			} else {
				$(this.Caption).hide();
			}
			this.changeImage(anchor);
			if(!this.Comment.innerHTML.match(/^1 of 1$/)) {
				$(this.Comment).show();
				var w = 0;
				$(this.CommentBack).up().select('img').each(function(img) {
					if(img.width) w += img.width
				}.bind(this));
				this.CommentBack.setStyle({
					width: ($(this.CommentBack).up().offsetWidth - w) + 'px'
				})
				$(this.Next).show();
				$(this.Back).show();
			} else {
				$(this.Next).hide();
				$(this.Back).hide();
			}
		} else if(link.match(/\.(flv|swf)$/i)) {
			$(this.Imgcover).hide();
			this.Img.style.display = 'none';
			this.flashLoad(anchor);
			$(this.Next).hide();
			$(this.Back).hide();
			if(!this.alwaysShowCaption) $(this.CaptionButton).hide();
		} else if(link.match(/^(http:\/\/)/) && (!link.match('http://' + window.location.hostname) || !window.location.hostname.match(/./))) {
			this.Img.style.display = 'none';
			this.objLoad(anchor);
			$(this.Next).hide();
			$(this.Back).hide();
			if(!this.alwaysShowCaption) $(this.CaptionButton).hide();
		} else {
			this.Img.style.display = 'none';
			this.ajaxLoad(anchor);
			$(this.Next).hide();
			$(this.Back).hide();
			if(!this.alwaysShowCaption) $(this.CaptionButton).hide();
		}

		// Safari 2 and IE have bugs with scrolling while Thinbox "window" is visible
		// Clip window contents to prevent scrolling until this.end();
		this.isClipped = false;
		if(this.isSafari && !this.isSafari3 && (this.Body.parentNode.scrollHeight > window.innerHeight || this.Body.parentNode.scrollWidth > window.innerWidth)) {
			this.htmlElement = document.getElementsByTagName('html')[0];
			this.isClipped = true;
			windowTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
			windowBottom = window.innerHeight + windowTop;
			windowLeft = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
			windowRight = window.innerWidth + windowLeft;
			this.Body.style.overflow = 'hidden';
			this.Body.style.width = window.innerWidth + 'px';
			this.Body.style.height = window.innerHeight + 'px';
			this.htmlElement.style.width = window.innerWidth + 'px';
			this.htmlElement.style.height = window.innerHeight + 'px';
			this.Body.scrollTo(windowLeft, windowTop);
			this.Body.style.display = 'block';
			this.Body.style.position = 'fixed';
			this.Body.style.clip = 'rect(' + (windowTop - 5) + 'px ' + windowRight + 'px ' + windowBottom + 'px ' + windowLeft + 'px)';
			if(windowTop != 0 || windowLeft != 0) {
				this.Body.style.top = '-' + windowTop + 'px';
				this.Body.style.left = '-' + windowLeft + 'px';
			} else if(windowTop == 0) {
				this.Body.style.top = '-5px';
				this.Body.style.paddingTop = '5px';
			}
		}
		if(this.isIE && !this.isIE7) {
			this.isClipped = true;
			this.Body.style.overflow = 'hidden';
			document.documentElement.style.overflow = 'hidden';
			this.Window.style.top = (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop) + this.top;
			if(this.dropShadow == true) this.Shadow.style.top = (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop) + this.top + 1;
			this.Blackout.style.top = (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop);
			this.Body.style.height = '100%';
			this.Blackout.style.height = '200%';
		}

		Effect.Appear(this.Blackout, { duration: 0.25, to: 0.70, queue: 'front', afterFinish: function() {
			if(anchor.rel == 'thinconfirm') {
				Element.show(this.ConfirmWindow);
			} else {
				$(this.Controls).show();
				Element.show(this.Window);
				this.Window.setOpacity(1.0);
				if(this.dropShadow == true) Element.show(this.Shadow);
			}
		}.bind(this) });
	},
	/* Thinbox will also support dialogs at 1.0.
		This is not ready. */
	confirmlink: function(anchor) {
		$('thinconfirmmsg').innerHTML = anchor.title;
		$('thinconfirmyes').href = anchor.href;
		$('thinconfirmno').onclick = function() {
			this.end();
			return false;
		}.bind(this)
		return false;
	},
	ajaxLoad: function(anchor) {
		this.currentlyViewing = anchor.href;
		var replace = new RegExp('^https?\:\/\/' + RegExp.escape(window.location.host));
		new Ajax.Updater(
			this.Ajax,
			window.location.protocol + '//' + window.location.host +
				anchor.href.replace(replace, ''),
			{
				method: 'get',
				parameters: '',
				onSuccess: function() {
					$(this.Ajax).show();
					Effect.Fade(this.Imgcover, { beforeStart: function() {
						Element.hide(this.Comment);
					}.bind(this), duration: 0.2 });
				}.bind(this)
			});
		if($('thincaptionfulltext')) {
			$('thincaptionfulltext').innerHTML = '';
		}
		this.resizeWindow(this.ajaxWidth, this.ajaxHeight);
		Element.show(this.Zoom);
	},
	flashLoad: function(anchor) {
		// var width = this.flashWidth || 640;
		// var height = this.flashHeight || 480;
		Element.hide(this.Zoom);
		Element.hide(this.Comment);
		$(this.FlvPlayer).show();
		if(anchor.match(/\.flv$/)) {
			this.flvPlayer = new SWFObject(this.flashPlayerPath, "single", this.flashWidth, this.flashHeight, "7");
			this.flvPlayer.addParam("allowfullscreen","true");
			this.flvPlayer.addVariable("file", anchor);
			this.flvPlayer.addVariable("enablejs", "true");
			if(!this.flvShowControls) {
				this.flvPlayer.addVariable("displayheight", this.flashHeight);
			}
		} else {
			this.flvPlayer = new SWFObject(anchor, "single", this.flashWidth, this.flashHeight, "7");
		}
		this.flvPlayer.addVariable("width",this.flashWidth);
		this.flvPlayer.addVariable("height",this.flashHeight);
		this.flvPlayer.write("thinflvplayer");
		if($('thincaptionfulltext')) {
			$('thincaptionfulltext').innerHTML = '';
		}
		this.resizeWindow(640, 480);
	},

	// Load <iframe> content. Plan to include support for <object>s
	// (this would be great for linking to flv players, for instance)
	objLoad: function(anchor) {
		Element.hide(this.Comment);
		this.isobj = true;
		this.currentlyViewing = anchor.href;
		$(this.Iframe).show();
		this.Iframe.src = anchor.href;
		Element.show(this.Zoom);
		if(this.isIE) Element.hide(this.Imgcover);
		if($('thincaptionfulltext')) {
			$('thincaptionfulltext').innerHTML = '';
		}
		this.resizeWindow(this.ajaxWidth, this.ajaxHeight);
	},
	changeImage: function(imgLink) {
		this.showingImg = true;
		Element.show(this.Zoom);
		/* I hate you, IE. Why don't you obey? */
		Element.show(this.Imgcover);
		this.isimg = true;
		this.captionId = imgLink.id.replace(this.linkPrefix, this.captionPrefix);
		if($(this.captionId)) {
			this.CaptionText = $(this.captionId);
			this.caption = true;
			if(this.alwaysShowCaption) {
				$('thincaptionfulltext').innerHTML = this.CaptionText.innerHTML;
			} else {
				$(this.CaptionButton).show();
			}
		} else {
			this.caption = false;
			if(!this.alwaysShowCaption) $(this.CaptionButton).hide();
		}
		if($('thincaptionfulltext')) {
			$('thincaptionfulltext').hide();
		} else {
			Element.hide(this.Caption);
		}
		var imgPath;
		if(document.getElementsByTagName('base') && document.getElementsByTagName('base').length > 0) {
			imgPath = imgLink.href.replace(document.getElementsByTagName('base')[0].href, '');
		} else imgPath = imgLink.href;

		// Format image location
		if(this.imgPathFormat != null && this.imgPathFormat.match('{img}')) {
			imgPath = this.imgPathFormat.replace('{img}', imgPath);

			// If dimensions specified, calculate max dimensions... leave a little room for margins
			if(imgPath.match('{maxw}')) {
				var maxw = (window.innerWidth || document.body.offsetWidth) - 100;
				imgPath = imgPath.replace('{maxw}', maxw);
			}
			if(imgPath.match('{maxh}')) {
				var maxh = (window.innerHeight || document.body.offsetHeight) - 100 - this.addHeight - this.top;
				imgPath = imgPath.replace('{maxh}', maxh);
			}
		}

		this.Img.style.display = 'block';
		if(this.Img.src == this.basehref + imgPath) Effect.Fade(this.Imgcover, { duration: 0.3 });
		if(this.Img.src=='' || this.Img.src != this.basehref + imgPath || imgPath!=this.Img.src.replace('http://' + window.location.hostname, '')) this.Img.src = imgPath;
		else {
			// Effect.Fade(this.Imgcover, { duration: 0.3 });
			this.resizeWindow(this.Img.offsetWidth, this.Img.offsetHeight);
		}
		if(imgLink.className) {
			this.groupName = imgLink.className;
		} else {
			this.groupName = 'noclass';
		}
			this.groupKey = thinGroups[this.groupName].keynum(imgLink);
			this.groupTotal = thinGroups[this.groupName].length;
			if(this.groupTotal > 1) {
				$(this.Next).show();
				$(this.Back).show();
			}
			this.Comment.innerHTML = (this.groupKey + 1) + ' of ' + this.groupTotal;

			if(thinGroups[this.groupName].length > 2) {
				if((this.groupKey + 1) == thinGroups[this.groupName].length) {
					var nextKey = 0;
				} else {
					var nextKey = this.groupKey + 1;
				}
				if(this.groupKey == 0) {
					var prevKey = (thinGroups[this.groupName].length - 1);
				} else {
					var prevKey = this.groupKey - 1;
				}
				this.preloadImg(thinGroups[this.groupName][nextKey]);
				this.preloadImg(thinGroups[this.groupName][prevKey]);
			} else if(thinGroups[this.groupName].length > 1) {
				if(this.groupKey == 0) {
					this.preloadImg(thinGroups[this.groupName][1]);
				} else if(this.groupKey == 1) {
					this.preloadImg(thinGroups[this.groupName][0]);
				}
			}

		this.imgKey = thinLinks.keynum(imgLink);
		if(!this.alwaysShowCaption) {
			this.CaptionButton.style.opacity = '';
			this.CaptionButton.style.mozOpacity = '';
			this.CaptionButton.style.filter = '';
		}
		this.currentlyViewing = thinGroups[this.groupName][this.groupKey].href;
	},

	// Go back and forward within the group
	backImage: function() {
		if(thinGroups[this.groupName].length > 1) {
			Element.show(this.Imgcover);
			Effect.Appear(this.Imgcover, { duration: 0.1 });
		}
		else return;

		if(this.groupKey > 0) {
			this.groupKey = this.groupKey - 1;
			this.nextKey = this.groupKey + 1;
		} else {
			this.groupKey = thinGroups[this.groupName].length - 1;
			this.nextKey = 0;
		}
		this.backKey = this.groupKey - 1;
		this.changeImage(thinGroups[this.groupName][this.groupKey]);
	},
	nextImage: function() {
		if(thinGroups[this.groupName].length > 1) {
			Element.show(this.Imgcover);
			Effect.Appear(this.Imgcover, { duration: 0.1 });
		}
		else return;

		if(this.groupKey < (thinGroups[this.groupName].length - 1)) {
			this.groupKey = this.groupKey + 1;
			this.backKey = this.groupKey - 1;
		} else {
			this.groupKey = 0;
			this.backKey = thinGroups[this.groupName].length - 1;
		}
		this.nextKey = this.groupKey + 1;
		this.changeImage(thinGroups[this.groupName][this.groupKey]);
	},

	resizeWindow: function(imgWidth, imgHeight) {
		wTarget = imgWidth >= this.minWidth ? imgWidth : this.minWidth;
		hTarget = imgHeight >= this.minHeight ? imgHeight : this.minHeight;

		if(this.alwaysShowCaption && $('thincaptionfulltext').innerHTML != '') {
			// this.Caption.style.width = wTarget + 'px';
			// if(this.Window.offsetHeight + this.Window.offsetTop > 0) {
			// 	this.Caption.style.top = (hTarget + this.top + 30) + 'px';
			// }
			// this.Caption.style.left = '50%';
			// this.Caption.style.marginLeft = '-' + ((wTarget / 2) - 20) + 'px';
			// this.Contents.style.paddingBottom = this.addHeight + 'px';
			$(this.Caption).show();
			$('thincaptionfulltext').show();
			hTarget = hTarget + this.addHeight;
		} else if(this.alwaysShowCaption && $('thincaptionfulltext').innerHTML == '') {
			$(this.Caption).hide();
			$('thincaptionfulltext').hide();
		}

		if(imgWidth < this.minWidth || imgHeight < this.minHeight) $('thincontents').style.background = '#989295';
		else $('thincontents').style.background = '';
		var mLeft = Math.round(wTarget / 2);
		if(this.isIE && !this.isIE7) {
			var marginLeftAdjust = (parseInt(this.getStyle($$('body')[0], 'margin-left')) + parseInt(this.getStyle($$('body')[0], 'padding-left')));
			mLeft += marginLeftAdjust;
		}
		this.Window.style.width = wTarget + 'px';
		if(this.alwaysShowCaption) {
			if(this.isIE && !this.isIE7) {
				// this.Comment.style.width = (wTarget - 150) + 'px';
			}
			// this.CommentBack.style.width = (wTarget - 104) + 'px';
		} else {
			if(this.isIE && !this.isIE7) {
				// this.Comment.style.width = (wTarget - 150) + 'px';
			}
			// this.CommentBack.style.width = (wTarget - 130) + 'px';
		}
		this.Window.style.height = hTarget + 'px';
		this.Window.style.marginLeft = '-' + mLeft + 'px';
		if(this.dropShadow == true) {
			this.Shadow.style.width = (wTarget + 22) + 'px';
			this.Shadow.style.height = (hTarget + 22) + 'px';
			this.Shadow.style.marginLeft = '-' + Math.round((wTarget - 18) / 2) + 'px';
		}

		/* IE needs special attention */
		if(this.isIE7 && this.dropShadow == true) {
			this.Shadow.style.marginLeft = '-' + Math.round((wTarget - 18) / 2) + 'px';
			this.ShadowT.style.width = (wTarget - 22) + 'px';
			this.ShadowB.style.width = (wTarget - 22) + 'px';
			this.ShadowL.style.height = (hTarget - 28) + 'px';
			this.ShadowR.style.height = (hTarget - 28) + 'px';
		} else if(this.isIE) {
			if(this.alwaysShowCaption) {
				// this.CommentBack.style.width = (wTarget - 103) + 'px';
			} else {
				// this.CommentBack.style.width = (wTarget - 129) + 'px';
			}
			this.Window.style.marginLeft = '-' + (mLeft + 29) + 'px';
			if(this.dropShadow == true) {
				this.Shadow.style.marginLeft = '-' + Math.round((wTarget - 18) / 2) + 'px';
				this.ShadowT.style.width = (wTarget - 22) + 'px';
				this.ShadowB.style.width = (wTarget - 22) + 'px';
				this.ShadowL.style.height = (hTarget - 26) + 'px';
				this.ShadowR.style.height = (hTarget - 26) + 'px';
				this.ShadowT.style.marginLeft = (0 - Math.round(wTarget / 2) + 22) + 'px';
				this.ShadowB.style.top = (hTarget + this.top + 3) + 'px';
				this.ShadowB.style.marginLeft = (0 - Math.round(wTarget / 2) + 22) + 'px';
				this.ShadowL.style.marginLeft = (0 - Math.round(wTarget / 2)) + 'px';
				this.ShadowR.style.marginLeft = (0 + Math.floor(wTarget / 2)) + 'px';
				this.ShadowTL.style.marginLeft = (0 - Math.round(wTarget / 2)) + 'px';
				this.ShadowBL.style.marginLeft = (0 - Math.round(wTarget / 2)) + 'px';
				this.ShadowBL.style.top = (hTarget + this.top + 3) + 'px';
				this.ShadowTR.style.marginLeft = (0 + Math.floor(wTarget / 2)) + 'px';
				this.ShadowBR.style.marginLeft = (0 + Math.floor(wTarget / 2)) + 'px';
				this.ShadowBR.style.top = (hTarget + this.top + 3) + 'px';
			}
			if($('thincomment')) {
				$('thincomment').style.left = '50%';
					$('thincomment').style.marginLeft = (0 - ($('thincomment').offsetWidth / 2)) + 'px';
			}
		}

		// Effect.Fade(this.Imgcover, { duration: 0.4 });
	},
	toggleCaption: function() {
		if(!this.caption) {
			$('thincaptionfulltext').innerHTML = '';
			return;
		}
		if(!Element.visible(this.Caption)) {
			this.Caption.innerHTML = this.CaptionText.innerHTML;
			Effect.Appear(this.Caption, { duration: 0.25, to: 0.8 });
		} else {
			if(!this.isIE) this.CaptionButton.style.opacity = '';
			if(!this.isIE) this.CaptionButton.style.mozOpacity = '';
			if(this.isIE) this.CaptionButton.style.filter = '';
			Effect.Fade(this.Caption, {duration: 0.25 });
		}
	},

	// Cleaning up
	end: function() {
		delete this.captionId;
		this.WindowOpen = false;
		this.showingImg = false;
		if(this.Iframe.src != 'about:blank') {
			this.Iframe.src = 'about:blank';
		}
		$(this.Iframe).hide();
		$(this.Ajax).hide();
		$(this.FlvPlayer).hide();
		$(this.FlvPlayer).update('');
		this.currentlyViewing = null;
		this.isimg = false; this.isobj = false;
		this.imgKey = null;
		if(this.isIE && !this.isIE7) {
			this.Blackout.style.position = 'absolute';
		}
		if($(this.ConfirmWindow).visible()) {
			new Effect.Fade(this.ConfirmWindow, { duration: 0.15, afterFinish: function() {
				$(this.Blackout).hide();
			}.bind(this) });
		} else {
			$(this.Controls).hide();
			new Effect.Fade(this.Shadow, { duration: 0.1, queue: 'front', afterFinish: function() {
				new Effect.Fade(this.Window, { duration: 0.3, afterFinish: null, afterFinish: function() {
					if(this.alwaysShowCaption) {
						$('thincaptionfulltext').hide();
						this.windowLoaded = true;
					} else {
						$(this.Caption).hide();
					}
					this.Blackout.hide();
					this.Img.src = this.transparentImg;
					if(this.Img.parentNode != this.Contents) {
						this.Contents.appendChild(this.Img);
					}
					Element.show(this.Comment);
					if(this.dropShadow == true) Element.hide(this.Shadow);
					this.Contents.style.overflow = 'hidden';
					this.Img.style.display = 'block';
					$(this.Imgcover).show();
					if(this.isSafari && !this.isSafari3 && this.isClipped) {
						document.body.style.overflow = '';
						document.body.style.clip = '';
						document.body.style.width = '';
						document.body.style.height = '';
						this.htmlElement.style.width = '';
						this.htmlElement.style.height = '';
						this.Body.style.display = '';
						this.Body.style.position = '';
						this.Body.style.top = '';
						this.Body.style.left = '';
						this.Body.style.paddingTop = '';
						window.scrollTo(windowLeft, windowTop);
					}
					if(this.isIE && !this.isIE7 && this.isClipped) {
						this.Body.style.height = '';
						this.Body.style.overflow = '';
						document.documentElement.style.overflow = '';
					}
					if(this.alwaysShowCaption) {
						$(this.Caption).hide();
						this.Contents.style.paddingBottom = '';
					}
				}.bind(this) });
			}.bind(this) })
			
		}
	}
}

var cleanPngForIE = Class.create();
cleanPngForIE.prototype = {
	transparentImage: '/key/assets/thinbox/transparent.gif',
	initialize: function(img) {
		if(img.src && img.src.match(/\.png$/)) {
			this.src = img.src;
			img.src = this.transparentImage;
			img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='scale')";
			$(img).show();
		} else {
			$(img).show();
			return false;
		}
	}
}

if(!thinboxConfig.isIE5) {
	Event.onDomReady(function() {
		myThinbox = new Thinbox(thinboxConfig);
	});
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;