// lightwindow.js v2.0
//
// Copyright (c) 2007 stickmanlabs
// Author: Kevin P Miller | http://www.stickmanlabs.com
// 
// LightWindow is freely distributable under the terms of an MIT-style license.
//
// I don't care what you think about the file size...
//   Be a pro: 
//	    http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
//      http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
//

/*-----------------------------------------------------------------------------------------------*/

if(typeof Effect == 'undefined')
  throw("lightwindow.js requires including script.aculo.us' effects.js library!");

// This will stop image flickering in IE6 when elements with images are moved
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

var lightwindow = Class.create();	
lightwindow.prototype = {
	//
	//	Setup Variables
	//
	element : null,
	contentToFetch : null,
	windowActive : false,
	dataEffects : [],
	dimensions : {
		cruft : null,
		container : null,
		viewport : {
			height : null,
			width : null,
			offsetTop : null,
			offsetLeft : null
		}
	},
	pagePosition : {
		x : 0,
		y : 0
	},
	pageDimensions : {
		width : null,
		height : null
	},
	preloadImage : [],
	preloadedImage : [],
	galleries : [],
	resizeTo : {
		height : null,
		heightPercent : null,
		width : null,
		widthPercent : null,
		fixedTop : null,
		fixedLeft : null
	},
	scrollbarOffset : 18,
	navigationObservers : {
		previous : null,
		next : null
	},
	containerChange : {
		height : 0,
		width : 0
	},
	activeGallery : false,
	galleryLocation : {
		current : 0,
		total : 0
	},
	//
	//	Initialize the lightwindow.
	//
	initialize : function(options) {
		this.options = Object.extend({
			resizeSpeed : 8,
			contentOffset : {
				height : 20,
				width : 20
			},
			dimensions : {
				image : {height : 250, width : 250},
				page : {height : 250, width : 250},
				inline : {height : 250, width : 250},
				media : {height : 250, width : 250},
				external : {height : 250, width : 250},
				titleHeight : 25
			},
			classNames : {	
				standard : 'lightwindow',
				action : 'lightwindow_action'
			},
			fileTypes : {
				page : ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php4', 'php3', 'php', 'php5', 'phtml', 'rhtml', 'shtml', 'txt', 'vbs', 'rb'],
				media : ['aif', 'aiff', 'asf', 'avi', 'divx', 'm1v', 'm2a', 'm2v', 'm3u', 'mid', 'midi', 'mov', 'moov', 'movie', 'mp2', 'mp3', 'mpa', 'mpa', 'mpe', 'mpeg', 'mpg', 'mpg', 'mpga', 'pps', 'qt', 'rm', 'ram', 'swf', 'viv', 'vivo', 'wav'],
				image : ['bmp', 'gif', 'jpg', 'png', 'tiff']
			},
			mimeTypes : {
				avi : 'video/avi',
				aif : 'audio/aiff',
				aiff : 'audio/aiff',
				gif : 'image/gif',
				bmp : 'image/bmp',
				jpeg : 'image/jpeg',
				m1v : 'video/mpeg',
				m2a : 'audio/mpeg',
				m2v : 'video/mpeg',
				m3u : 'audio/x-mpequrl',
				mid : 'audio/x-midi',
				midi : 'audio/x-midi',
				mjpg : 'video/x-motion-jpeg',
				moov : 'video/quicktime',
				mov : 'video/quicktime',
				movie : 'video/x-sgi-movie',
				mp2 : 'audio/mpeg',
				mp3 : 'audio/mpeg3',
				mpa : 'audio/mpeg',
				mpa : 'video/mpeg',
				mpe : 'video/mpeg',
				mpeg : 'video/mpeg',
				mpg : 'audio/mpeg',
				mpg : 'video/mpeg',
				mpga : 'audio/mpeg',
				pdf : 'application/pdf',
				png : 'image/png',
				pps : 'application/mspowerpoint',
				qt : 'video/quicktime',
				ram : 'audio/x-pn-realaudio-plugin',
				rm : 'application/vnd.rn-realmedia',
				swf	: 'application/x-shockwave-flash',
				tiff : 'image/tiff',
				viv : 'video/vivo',
				vivo : 'video/vivo',
				wav : 'audio/wav',
				wmv : 'application/x-mplayer2'			
			},	
			classids : {
				mov : 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
				swf : 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
				wmv : 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6'
			},
			codebases : {
				mov : 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
				swf : 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
				wmv : 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715'
			},	
			viewportPadding : 10,
			EOLASFix : 'swf,wmv,fla,flv',
			overlay : {
				opacity : 0.7,
				image : '/static_images/lightwindow/black.png',
				presetImage : '/static_images/lightwindow/black-70.png'
			},
			skin : 	{
				main : 	'<div id="lightwindow_container" >'+
							'<div id="lightwindow_title_bar" >'+
								'<div id="lightwindow_title_bar_inner" >'+
									'<span id="lightwindow_title_bar_title"></span>'+
									'<a id="lightwindow_title_bar_close_link" >close</a>'+
								'</div>'+
							'</div>'+
							'<div id="lightwindow_stage" >'+
								'<div id="lightwindow_contents" >'+
								'</div>'+
								'<div id="lightwindow_navigation" >'+
									'<a href="#" id="lightwindow_previous" >'+
										'<span id="lightwindow_previous_title"></span>'+
									'</a>'+
									'<a href="#" id="lightwindow_next" >'+
										'<span id="lightwindow_next_title"></span>'+
									'</a>'+
									'<iframe name="lightwindow_navigation_shim" id="lightwindow_navigation_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
								'</div>'+								
								'<div id="lightwindow_galleries">'+
									'<div id="lightwindow_galleries_tab_container" >'+
										'<a href="#" id="lightwindow_galleries_tab" >'+
											'<span id="lightwindow_galleries_tab_span" class="up" >Galleries</span>'+
										'</a>'+
									'</div>'+
									'<div id="lightwindow_galleries_list" >'+
									'</div>'+
								'</div>'+
							'</div>'+
							'<div id="lightwindow_data_slide" >'+
								'<div id="lightwindow_data_slide_inner" >'+
									'<div id="lightwindow_data_details" >'+
										'<div id="lightwindow_data_gallery_container" >'+
											'<span id="lightwindow_data_gallery_current"></span>'+
											' of '+
											'<span id="lightwindow_data_gallery_total"></span>'+
										'</div>'+
										'<div id="lightwindow_data_author_container" >'+
											'by <span id="lightwindow_data_author"></span>'+
										'</div>'+
									'</div>'+
									'<div id="lightwindow_data_caption" >'+
									'</div>'+
								'</div>'+
							'</div>'+
						'</div>',	
				loading : 	'<div id="lightwindow_loading" >'+
								'<img src="/static_images/lightwindow/ajax-loading.gif" alt="loading" />'+
								'<span>Loading or <a href="javascript: myLightWindow.deactivate();">Cancel</a></span>'+
								'<iframe name="lightwindow_loading_shim" id="lightwindow_loading_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
							'</div>',
				iframe : 	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
							'<html xmlns="http://www.w3.org/1999/xhtml">'+
								'<body>'+
									'{body_replace}'+
								'</body>'+
							'</html>',
				gallery : {
					top :		'<div class="lightwindow_galleries_list">'+
									'<h1>{gallery_title_replace}</h1>'+
									'<ul>',
					middle : 			'<li>'+
											'{gallery_link_replace}'+
										'</li>',
					bottom : 		'</ul>'+
								'</div>'
				}
			},
			formMethod : 'get',
			hideFlash : false,
			hideGalleryTab : false,
			showTitleBar : true,
			animationHandler : false,
			navigationHandler : false,
			transitionHandler : false,
			finalAnimationHandler : false,
			formHandler : false,
			galleryAnimationHandler : false,
			showGalleryCount : true
		}, options || {});
		this.duration = ((11-this.options.resizeSpeed)*0.15);
		this._setupLinks();
		this._getScroll();
		this._getPageDimensions();
		this._browserDimensions();
		this._addLightWindowMarkup(false);
		this._setupDimensions(); 
		this.buildGalleryList();
	},
	//
	//	Activate the lightwindow.
	//
	activate : function(e, link){		
		// Clear out the window Contents
		this._clearWindowContents(true);
			
		// Add back in out loading panel
		this._addLoadingWindowMarkup();

		// Setup the element properties
		this._setupWindowElements(link);
		
		// Setup everything
		this._getScroll();
		this._browserDimensions();
		this._setupDimensions();
		this._toggleTroubleElements('hidden', false);
		this._displayLightWindow('block', 'hidden');
		this._setStatus(true);
		this._monitorKeyboard(true);
		this._prepareIE(true);
		this._loadWindow();
	},
	//
	//	Turn off the window
	//
	deactivate : function(){
		// The window is not active
		this.windowActive = false;
		
		// There is no longer a gallery active
		this.activeGallery = false;
		if (!this.options.hideGalleryTab) {
			this._handleGalleryAnimation(false);
		}
		
		// Kill the animation
		this.animating = false;
		
		// Clear our element
		this.element = null;
		
		// hide the window.
		this._displayLightWindow('none', 'visible');
		
		// Clear out the window Contents
		this._clearWindowContents(false);
		
		// Stop all animation
		var queue = Effect.Queues.get('lightwindowAnimation').each(function(e){e.cancel();});
		
		// Undo the setup
		this._prepareIE(false);
		this._setupDimensions();
		this._toggleTroubleElements('visible', false);	
		this._monitorKeyboard(false);	
	},
	//
	//  Initialize specific window
	//
	createWindow : function(element, attributes) {
		this._processLink($(element));
	},
	//
	//  Open a Window from a hash of attributes
	//
	activateWindow : function(options) {
		this.element = Object.extend({
			href : null,
			title : null,
			author : null,
			caption : null,
			rel : null,
			top : null,
			left : null,
			type : null,
			showImages : null,
			height : null,
			width : null,
			loadingAnimation : null,
			iframeEmbed : null,
			form : null
		}, options || {});
		
		// Set the window type
		this.contentToFetch = this.element.href;
		this.windowType = this.element.type ? this.element.type : this._fileType(this.element.href);	
		
		// Clear out the window Contents
		this._clearWindowContents(true);
			
		// Add back in out loading panel
		this._addLoadingWindowMarkup();
		
		// Setup everything
		this._getScroll();
		this._browserDimensions();
		this._setupDimensions();
		this._toggleTroubleElements('hidden', false);
		this._displayLightWindow('block', 'hidden');
		this._setStatus(true);
		this._monitorKeyboard(true);
		this._prepareIE(true);
		this._loadWindow();
	},
	//
	//  Fire off our Form handler
	//
	submitForm : function(e) {
		if (this.options.formHandler) {
			this.options.formHandler(e);
		} else {
			this._defaultFormHandler(e);
		}
	},
	//
	//	Reload the window with another location
	//
	openWindow : function(element) {
		var element = $(element);

		// The window is active
		this.windowActive = true;
		
		// Clear out the window Contents
		this._clearWindowContents(true);
		
		// Add back in out loading panel
		this._addLoadingWindowMarkup();
		
		// Setup the element properties
		this._setupWindowElements(element);

		this._setStatus(true);
		this._handleTransition();
	},
	//
	//  Navigate the window
	//
	navigateWindow : function(direction) {
		this._handleNavigation(false);
		if (direction == 'previous') {
			this.openWindow(this.navigationObservers.previous);
		} else if (direction == 'next'){ 
			this.openWindow(this.navigationObservers.next);
		}
	},
	//
	//  Build the Gallery List and Load it
	//
	buildGalleryList : function() {
		var output = '';
		var galleryLink;
		for (i in this.galleries) {
			if (typeof this.galleries[i] == 'object') {
				output += (this.options.skin.gallery.top).replace('{gallery_title_replace}', unescape(i));
				for (j in this.galleries[i]) {
					if (typeof this.galleries[i][j] == 'object') {						
						galleryLink = '<a href="#" id="lightwindow_gallery_'+i+'_'+j+'" >'+unescape(j)+'</a>';
						output += (this.options.skin.gallery.middle).replace('{gallery_link_replace}', galleryLink);
					}
				}
				output += this.options.skin.gallery.bottom;
			}
		}
		new Insertion.Top('lightwindow_galleries_list', output);
		
		// Attach Events
		for (i in this.galleries) {
			if (typeof this.galleries[i] == 'object') {
				for (j in this.galleries[i]) {
					if (typeof this.galleries[i][j] == 'object') {
						Event.observe($('lightwindow_gallery_'+i+'_'+j), 'click', this.openWindow.bind(this, this.galleries[i][j][0]), false);
						$('lightwindow_gallery_'+i+'_'+j).onclick = function() {return false;};	
					}
				}
			}
		}
	},
	// 
	//  Set Links Up
	//
	_setupLinks : function() {
		var links = $$('.'+this.options.classNames.standard);
		links.each(function(link) {
			this._processLink(link);
		}.bind(this));	
	},
	//
	//  Process a Link
	//
	_processLink : function(link) {
		if ((this._fileType(link.getAttribute('href')) == 'image' || this._fileType(link.getAttribute('href')) == 'media')) {
			if (gallery = this._getGalleryInfo(link.rel)) {
				if (!this.galleries[gallery[0]]) {
					this.galleries[gallery[0]] = new Array();
				}
				if (!this.galleries[gallery[0]][gallery[1]]) {
					this.galleries[gallery[0]][gallery[1]] = new Array();
				}
				this.galleries[gallery[0]][gallery[1]].push(link);
			}
		}
		
		// Take care of our inline content
		var url = link.getAttribute('href');
		if (url.indexOf('?') > -1) {
			url = url.substring(0, url.indexOf('?'));
		}
		
		var container = url.substring(url.indexOf('#')+1);
		if($(container)) {
			$(container).setStyle({
				display : 'none'
			});
		}
		
		Event.observe(link, 'click', this.activate.bindAsEventListener(this, link), false);
		link.onclick = function() {return false;};		
	},
	//
	//	Setup our actions
	//
	_setupActions : function() {
		var links = $$('#lightwindow_container .'+this.options.classNames.action);
		links.each(function(link) {
			Event.observe(link, 'click', this[link.getAttribute('rel')].bindAsEventListener(this, link), false);
			link.onclick = function() {return false;};
		}.bind(this));
	},
	//
	//	Add the markup to the page.
	//
	_addLightWindowMarkup : function(rebuild) {
		var overlay = Element.extend(document.createElement('div'));
		overlay.setAttribute('id', 'lightwindow_overlay');		
		// FF Mac has a problem with putting Flash above a layer without a 100% opacity background, so we need to use a pre-made
		if (Prototype.Browser.Gecko) {
			overlay.setStyle({
				backgroundImage: 'url('+this.options.overlay.presetImage+')',
				backgroundRepeat: 'repeat',
				height: this.pageDimensions.height+'px'
			});			
		} else {
			overlay.setStyle({
				opacity: this.options.overlay.opacity,
				backgroundImage: 'url('+this.options.overlay.image+')',
				backgroundRepeat: 'repeat',
				height: this.pageDimensions.height+'px'
			});
		}
		
		var lw = document.createElement('div');
		lw.setAttribute('id', 'lightwindow');
		lw.innerHTML = this.options.skin.main;
		
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(overlay);
		body.appendChild(lw);	
				
		if ($('lightwindow_title_bar_close_link')) {
			Event.observe('lightwindow_title_bar_close_link', 'click', this.deactivate.bindAsEventListener(this));
			$('lightwindow_title_bar_close_link').onclick = function() {return false;};
		}
			
		Event.observe($('lightwindow_previous'), 'click', this.navigateWindow.bind(this, 'previous'), false);
		$('lightwindow_previous').onclick = function() {return false;};		
		Event.observe($('lightwindow_next'), 'click', this.navigateWindow.bind(this, 'next'), false);
		$('lightwindow_next').onclick = function() {return false;};

		if (!this.options.hideGalleryTab) {
			Event.observe($('lightwindow_galleries_tab'), 'click', this._handleGalleryAnimation.bind(this, true), false);
			$('lightwindow_galleries_tab').onclick = function() {return false;};
		}
		
		// Because we use position absolute, kill the scroll Wheel on animations
		if (Prototype.Browser.IE) {
			Event.observe(document, 'mousewheel', this._stopScrolling.bindAsEventListener(this), false);
		} else {
			Event.observe(window, 'DOMMouseScroll', this._stopScrolling.bindAsEventListener(this), false);
		}
				
		Event.observe(overlay, 'click', this.deactivate.bindAsEventListener(this), false);
		overlay.onclick = function() {return false;};
	},
	//
	//  Add loading window markup
	//
	_addLoadingWindowMarkup : function() {
		$('lightwindow_contents').innerHTML += this.options.skin.loading;
	},
	//
	//  Setup the window elements
	//
	_setupWindowElements : function(link) {
		this.element = link;
		this.element.title = null ? '' : link.getAttribute('title');
		this.element.author = null ? '' : link.getAttribute('author');
		this.element.caption = null ? '' : link.getAttribute('caption');
		this.element.rel = null ? '' : link.getAttribute('rel');
		this.element.params = null ? '' : link.getAttribute('params');

		// Set the window type
		this.contentToFetch = this.element.href;
		this.windowType = this._getParameter('lightwindow_type') ? this._getParameter('lightwindow_type') : this._fileType(this.contentToFetch);	
	},
	//
	//  Clear the window contents out
	//
	_clearWindowContents : function(contents) {
		// If there is an iframe, its got to go
		if ($('lightwindow_iframe')) {
			Element.remove($('lightwindow_iframe'));
		}

		// Stop playing an object if its still around
		if ($('lightwindow_media_primary')) {
			try {
				$('lightwindow_media_primary').Stop();
			} catch(e) {}
			Element.remove($('lightwindow_media_primary'));
		}

		// Stop playing an object if its still around		
		if ($('lightwindow_media_secondary')) {
			try {
				$('lightwindow_media_secondary').Stop();
			} catch(e) {}
			Element.remove($('lightwindow_media_secondary'));
		}
		
		this.activeGallery = false;
		this._handleNavigation(this.activeGallery);
		
		if (contents) {
			// Empty the contents
			$('lightwindow_contents').innerHTML = '';
			
			// Reset the scroll bars
			$('lightwindow_contents').setStyle({
				overflow: 'hidden'
			});		
			
			if (!this.windowActive) {
				$('lightwindow_data_slide_inner').setStyle({
					display: 'none'
				});

				$('lightwindow_title_bar_title').innerHTML = '';
			}

			// Because of browser differences and to maintain flexible captions we need to reset this height at close
			$('lightwindow_data_slide').setStyle({
				height: 'auto'
			});
		}
		
		this.resizeTo.height = null;
		this.resizeTo.width = null;
	},
	//
	//	Set the status of our animation to keep things from getting clunky
	//
	_setStatus : function(status) {
		this.animating = status;
		if (status) {
			Element.show('lightwindow_loading');
		}
		if (!(/MSIE 6./i.test(navigator.userAgent))) {
			this._fixedWindow(status);
		}
	},
	//
	//  Make this window Fixed
	//
	_fixedWindow : function(status) {
		if (status) {
			if (this.windowActive) {
				this._getScroll();
				$('lightwindow').setStyle({
					position: 'absolute',
					top: parseFloat($('lightwindow').getStyle('top'))+this.pagePosition.y+'px',
					left: parseFloat($('lightwindow').getStyle('left'))+this.pagePosition.x+'px'
				});		
			} else {
				$('lightwindow').setStyle({
					position: 'absolute'
				});						
			}
		} else {
			if (this.windowActive) {
				this._getScroll();
				$('lightwindow').setStyle({
					position: 'fixed',
					top: parseFloat($('lightwindow').getStyle('top'))-this.pagePosition.y+'px',
					left: parseFloat($('lightwindow').getStyle('left'))-this.pagePosition.x+'px'
				});		
			} else {
				if ($('lightwindow_iframe')) {
					// Ideally here we would set a 50% value for top and left, but Safari rears it ugly head again and we need to do it by pixels
					this._browserDimensions();
				}
				$('lightwindow').setStyle({
					position: 'fixed',
					top: (parseFloat(this._getParameter('lightwindow_top')) ? parseFloat(this._getParameter('lightwindow_top'))+'px' : this.dimensions.viewport.height/2+'px'),
					left: (parseFloat(this._getParameter('lightwindow_left')) ? parseFloat(this._getParameter('lightwindow_left'))+'px' : this.dimensions.viewport.width/2+'px')
				});
			}
		}
	},
	//
	//	Prepare the window for IE.
	//
	_prepareIE : function(setup) {
		if (Prototype.Browser.IE) {
			var height, overflowX, overflowY;
			if (setup) { 
				var height = '100%';
			} else {
				var height = 'auto';
			}
			var body = document.getElementsByTagName('body')[0];
			var html = document.getElementsByTagName('html')[0];
			html.style.height = body.style.height = height;
		}
	},
	_stopScrolling : function(e) {
		if (this.animating) {
			if (e.preventDefault) {
				e.preventDefault();
			}
			e.returnValue = false;		
		}
	},
	//
	//	Get the scroll for the page.
	//
	_getScroll : function(){
      	if(typeof(window.pageYOffset) == 'number') {
        	this.pagePosition.x = window.pageXOffset;
        	this.pagePosition.y = window.pageYOffset;
      	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
	       	this.pagePosition.x = document.body.scrollLeft;
        	this.pagePosition.y = document.body.scrollTop;
		} else if(document.documentElement) {
        	this.pagePosition.x = document.documentElement.scrollLeft;
        	this.pagePosition.y = document.documentElement.scrollTop;
      	}
	},
	//
	//	Reset the scroll.
	//
	_setScroll : function(x, y) {
		document.documentElement.scrollLeft = x; 
		document.documentElement.scrollTop = y; 
	},
	//
	//	Hide Selects from the page because of IE.
	//     We could use iframe shims instead here but why add all the extra markup for one browser when this is much easier and cleaner
	//
	_toggleTroubleElements : function(visibility, content){
		
		if (content) {
			var selects = $('lightwindow_contents').getElementsByTagName('select');
		} else {
			var selects = document.getElementsByTagName('select');
		}
		
		for(var i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
		
		if (!content) {
			if (this.options.hideFlash){
				var objects = document.getElementsByTagName('object');
				for (i = 0; i != objects.length; i++) {
					objects[i].style.visibility = visibility;
				}
				var embeds = document.getElementsByTagName('embed');
				for (i = 0; i != embeds.length; i++) {
					embeds[i].style.visibility = visibility;
				}
			}
			var iframes = document.getElementsByTagName('iframe');
			for (i = 0; i != iframes.length; i++) {
				iframes[i].style.visibility = visibility;
			}
		}
	},
	// 
	//  Get the actual page size
	//
	_getPageDimensions : function() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {	
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	

		if(yScroll < windowHeight){
			this.pageDimensions.height = windowHeight;
		} else { 
			this.pageDimensions.height = yScroll;
		}

		if(xScroll < windowWidth){	
			this.pageDimensions.width = windowWidth;
		} else {
			this.pageDimensions.width = xScroll;
		}
	},
	//
	//	Display the lightWindow.
	//
	_displayLightWindow : function(display, visibility) {
		$('lightwindow_overlay').style.display = $('lightwindow').style.display = $('lightwindow_container').style.display = display;	
		$('lightwindow_overlay').style.visibility = $('lightwindow').style.visibility = $('lightwindow_container').style.visibility = visibility;
	},
	//
	//	Setup Dimensions of lightwindow.

	//
	_setupDimensions : function() {

		var originalHeight, originalWidth;
		switch (this.windowType) {
			case 'page' :
				originalHeight = this.options.dimensions.page.height;
				originalWidth = this.options.dimensions.page.width;
				break;

			case 'image' :
				originalHeight = this.options.dimensions.image.height;
				originalWidth = this.options.dimensions.image.width;
				break;
				
			case 'media' :
				originalHeight = this.options.dimensions.media.height;
				originalWidth = this.options.dimensions.media.width;
				break;
			
			case 'external' : 
				originalHeight = this.options.dimensions.external.height;
				originalWidth = this.options.dimensions.external.width;
				break;
				
			case 'inline' :
				originalHeight = this.options.dimensions.inline.height;
				originalWidth = this.options.dimensions.inline.width;
				break;
				
			default :
				originalHeight = this.options.dimensions.page.height;
				originalWidth = this.options.dimensions.page.width;
				break;
				
		}

		var offsetHeight = this._getParameter('lightwindow_top') ? parseFloat(this._getParameter('lightwindow_top'))+this.pagePosition.y : this.dimensions.viewport.height/2+this.pagePosition.y;
		var offsetWidth = this._getParameter('lightwindow_left') ? parseFloat(this._getParameter('lightwindow_left'))+this.pagePosition.x : this.dimensions.viewport.width/2+this.pagePosition.x;
		
		// So if a theme has say shadowed edges, they should be consistant and take care of in the contentOffset
		$('lightwindow').setStyle({
			top: offsetHeight+'px',
			left: offsetWidth+'px'
		});
		
		$('lightwindow_container').setStyle({
			height: originalHeight+'px',
			width: originalWidth+'px',
			left: -(originalWidth/2)+'px',
			top: -(originalHeight/2)+'px'
		});

		$('lightwindow_contents').setStyle({
			height: originalHeight+'px',
			width: originalWidth+'px'
		});
	},
	//
	//	Get the type of file.
	//
	_fileType : function(url) {
		var image = new RegExp("[^\.]\.("+this.options.fileTypes.image.join('|')+")\s*$", "i");
		if (image.test(url)) return 'image';
		if (url.indexOf('#') > -1 && (document.domain == this._getDomain(url))) return 'inline';		
		if (url.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));
		var type = 'unknown';
		var page = new RegExp("[^\.]\.("+this.options.fileTypes.page.join('|')+")\s*$", "i");
		var media = new RegExp("[^\.]\.("+this.options.fileTypes.media.join('|')+")\s*$", "i");
		if (document.domain != this._getDomain(url)) type = 'external';
	  	if (media.test(url)) type = 'media';
		if (type == 'external' || type == 'media') return type;
	  	if (page.test(url) || url.substr((url.length-1), url.length) == '/') type = 'page';
		return type;
	},
	//
	//  Get file Extension
	//
	_fileExtension : function(url) {
		if (url.indexOf('?') > -1) {
			url = url.substring(0, url.indexOf('?'));
		}
		var extenstion = '';
		for (var x = (url.length-1); x > -1; x--) {
			if (url.charAt(x) == '.') {
				return extenstion;
			}
			extenstion = url.charAt(x)+extenstion;
		}
	},
	//
	//	Monitor the keyboard while this lightwindow is up
	//
	_monitorKeyboard : function(status) {
		if (status) document.onkeydown = this._eventKeypress.bind(this); 
		else document.onkeydown = '';
	},
	//
	//  Perform keyboard actions
	//
	_eventKeypress : function(e) {
		if (e == null) {
			var keycode = event.keyCode;
		} else {
			var keycode = e.which;
		}
		
		switch (keycode) { 
			case 27: 
				this.deactivate(); 
				break;
			
			case 13:
				return;
				
			default:
				break;
		}
	
		// Gotta stop those quick fingers
		if (this.animating) {
			return false;
		}
		
		switch (String.fromCharCode(keycode).toLowerCase()) {
			case 'p':
				if (this.navigationObservers.previous) {
					this.navigateWindow('previous');
				}
				break;
				
			case 'n':
				if (this.navigationObservers.next) {
					this.navigateWindow('next');
				}
				break;
				
			default:
				break;
		}
	},
	//
	//	Get Gallery Information
	//
	_getGalleryInfo : function(rel) {
		if (!rel) return false;
		if (rel.indexOf('[') > -1) {
			return new Array(escape(rel.substring(0, rel.indexOf('['))), escape(rel.substring(rel.indexOf('[')+1, rel.indexOf(']'))));
		} else {
			return false;
		}
	},
	//
	//	Get the domain from a string.
	//
	_getDomain : function(url) {    
        var leadSlashes = url.indexOf('//');
        var domainStart = leadSlashes+2;
        var withoutResource = url.substring(domainStart, url.length);
        var nextSlash = withoutResource.indexOf('/');
        var domain = withoutResource.substring(0, nextSlash);
		if (domain.indexOf(':') > -1){
			var portColon = domain.indexOf(':');
			domain = domain.substring(0, portColon);
       	}
		return domain;
    },
	//
	//	Get the value from the params attribute string.
	//
	_getParameter : function(parameter, parameters) {
		if (!this.element) return false;
		if (parameter == 'lightwindow_top' && this.element.top) {
			return unescape(this.element.top);
		} else if (parameter == 'lightwindow_left' && this.element.left) {
			return unescape(this.element.left);
		} else if (parameter == 'lightwindow_type' && this.element.type) {
			return unescape(this.element.type);
		} else if (parameter == 'lightwindow_show_images' && this.element.showImages) {
			return unescape(this.element.showImages);
		} else if (parameter == 'lightwindow_height' && this.element.height) {
			return unescape(this.element.height);
		} else if (parameter == 'lightwindow_width' && this.element.width) {
			return unescape(this.element.width);
		} else if (parameter == 'lightwindow_loading_animation' && this.element.loadingAnimation) {
			return unescape(this.element.loadingAnimation);
		} else if (parameter == 'lightwindow_iframe_embed' && this.element.iframeEmbed) {
			return unescape(this.element.iframeEmbed);
		} else if (parameter == 'lightwindow_form' && this.element.form) {
			return unescape(this.element.form);
		} else {
			if (!parameters) {
				if (this.element.params) parameters = this.element.params;
				else return;
			}
			var value;
			var parameterArray = parameters.split(',');
			var compareString = parameter+'=';
			var compareLength = compareString.length;
			for (var i = 0; i < parameterArray.length; i++) {
				if (parameterArray[i].substr(0, compareLength) == compareString) {
					var currentParameter = parameterArray[i].split('=');
					value = currentParameter[1];
					break;
				}
			}
			if (!value) return false;
			else return unescape(value);
		}
	},
	//
	//  Get the Browser Viewport Dimensions
	//
	_browserDimensions : function() {
		if (Prototype.Browser.IE) {
            this.dimensions.viewport.height = document.documentElement.clientHeight;
            this.dimensions.viewport.width = document.documentElement.clientWidth;   
        } else {
            this.dimensions.viewport.height = window.innerHeight;
            this.dimensions.viewport.width = document.width || document.body.offsetWidth;
        }
	},
	//
	//  Get the scrollbar offset, I don't like this method but there is really no other way I can find.
	//
	_getScrollerWidth : function() {
	    var scrollDiv = Element.extend(document.createElement('div'));
		scrollDiv.setAttribute('id', 'lightwindow_scroll_div');
		scrollDiv.setStyle({
			position: 'absolute',
			top: '-10000px',
			left: '-10000px',
			width: '100px',
			height: '100px',
			overflow: 'hidden'
		});



	    var contentDiv = Element.extend(document.createElement('div'));
		contentDiv.setAttribute('id', 'lightwindow_content_scroll_div');
		contentDiv.setStyle({
			width: '100%',
			height: '200px'
		});

	    scrollDiv.appendChild(contentDiv);

		var body = document.getElementsByTagName('body')[0];
		body.appendChild(scrollDiv);

	    var noScroll = $('lightwindow_content_scroll_div').offsetWidth;
	    scrollDiv.style.overflow = 'auto';
    	var withScroll = $('lightwindow_content_scroll_div').offsetWidth;

	   	Element.remove($('lightwindow_scroll_div'));

	    this.scrollbarOffset = noScroll-withScroll;
	},
	

	//
	//  Add a param to an object dynamically created
	//
	_addParamToObject : function(name, value, object, id) {
		var param = document.createElement('param');
		param.setAttribute('value', value);
		param.setAttribute('name', name);
		if (id) {
			param.setAttribute('id', id);
		}
		object.appendChild(param);
		return object;
	},
	//
	//  Get the outer HTML of an object CROSS BROWSER
	//
	_outerHTML : function(object) {
 		if (Prototype.Browser.IE) {
			return object.outerHTML;
		} else {
			var clone = object.cloneNode(true);
			var cloneDiv = document.createElement('div');
			cloneDiv.appendChild(clone);
			return cloneDiv.innerHTML;
		}
	},
	//
	//  Convert an object to markup
	//
	_convertToMarkup : function(object, closeTag) {
		var markup = this._outerHTML(object).replace('</'+closeTag+'>', '');
		if (Prototype.Browser.IE) {
			for (var i = 0; i < object.childNodes.length; i++){
				markup += this._outerHTML(object.childNodes[i]);
			}
			markup += '</'+closeTag+'>';
		}
		return markup;
	},
	//
	//  Depending what type of browser it is we have to append the object differently... DAMN YOU IE!!
	//
	_appendObject : function(object, closeTag, appendTo) {
		if (Prototype.Browser.IE) {
			appendTo.innerHTML += this._convertToMarkup(object, closeTag);
			
			// Fix the Eolas activate thing but only for specified media, for example doing this to a quicktime film breaks it.
			if (this.options.EOLASFix.indexOf(this._fileType(this.element.href)) > -1) {
				var objectElements = document.getElementsByTagName('object');
				for (var i = 0; i < objectElements.length; i++) {
					if (objectElements[i].getAttribute("data")) objectElements[i].removeAttribute('data');
					objectElements[i].outerHTML = objectElements[i].outerHTML;
					objectElements[i].style.visibility = "visible";
				}
			}
		} else {
			appendTo.appendChild(object);	
		}	
	},
	//
	//  Add in iframe
	//
	_appendIframe : function(scroll) {
		var iframe = document.createElement('iframe');
		iframe.setAttribute('id', 'lightwindow_iframe');
		iframe.setAttribute('name', 'lightwindow_iframe');
		iframe.setAttribute('src', 'about:blank');
		iframe.setAttribute('height', '100%');
		iframe.setAttribute('width', '100%');
		iframe.setAttribute('frameborder', '0');
		iframe.setAttribute('marginwidth', '0');
		iframe.setAttribute('marginheight', '0');
		iframe.setAttribute('scrolling', scroll);	
		
		this._appendObject(iframe, 'iframe', $('lightwindow_contents'));
	},
	//
	//  Write Content to the iframe using the skin
	//
	_writeToIframe : function(content) {
		var template = this.options.skin.iframe;
		template = template.replace('{body_replace}', content); 
		if ($('lightwindow_iframe').contentWindow){
			$('lightwindow_iframe').contentWindow.document.open();
			$('lightwindow_iframe').contentWindow.document.write(template);
			$('lightwindow_iframe').contentWindow.document.close();
		} else {
			$('lightwindow_iframe').contentDocument.open();
			$('lightwindow_iframe').contentDocument.write(template);
			$('lightwindow_iframe').contentDocument.close();
		}
	},
	//
	//  Load the window Information
	//  
	_loadWindow : function() {
		switch (this.windowType) {
			case 'image' :

				var current = 0;
				var images = [];
				this.checkImage = [];
				this.resizeTo.height = this.resizeTo.width = 0;
				this.imageCount = this._getParameter('lightwindow_show_images') ? parseInt(this._getParameter('lightwindow_show_images')) : 1;

				// If there is a gallery get it
				if (gallery = this._getGalleryInfo(this.element.rel)) {	
					for (current = 0; current < this.galleries[gallery[0]][gallery[1]].length; current++) {
						if (this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href) > -1) {
							break;
						}
					}
					if (this.galleries[gallery[0]][gallery[1]][current-this.imageCount]) {
						this.navigationObservers.previous = this.galleries[gallery[0]][gallery[1]][current-this.imageCount];
					} else {
						this.navigationObservers.previous = false;
					}
					if (this.galleries[gallery[0]][gallery[1]][current+this.imageCount]) {
						this.navigationObservers.next = this.galleries[gallery[0]][gallery[1]][current+this.imageCount];
					} else {
						this.navigationObservers.next = false;
					}
					
					this.activeGallery = true;
				} else {
					this.navigationObservers.previous = false;
					this.navigationObservers.next = false;					

					this.activeGallery = false;
				}
				
				for (var i = current; i < (current+this.imageCount); i++) {
		
					if (gallery && this.galleries[gallery[0]][gallery[1]][i]) {
						this.contentToFetch = this.galleries[gallery[0]][gallery[1]][i].href;
						
						this.galleryLocation = {current: (i+1)/this.imageCount, total: (this.galleries[gallery[0]][gallery[1]].length)/this.imageCount};
											
						if (!this.galleries[gallery[0]][gallery[1]][i+this.imageCount]) {
							$('lightwindow_next').setStyle({
								display: 'none'
							});
						} else {
							$('lightwindow_next').setStyle({
								display: 'block'
							});
							$('lightwindow_next_title').innerHTML = this.galleries[gallery[0]][gallery[1]][i+this.imageCount].title;
						}
						
						if (!this.galleries[gallery[0]][gallery[1]][i-this.imageCount]) {
							$('lightwindow_previous').setStyle({
								display: 'none'
							});
						} else {
							$('lightwindow_previous').setStyle({
								display: 'block'
							});
							$('lightwindow_previous_title').innerHTML = this.galleries[gallery[0]][gallery[1]][i-this.imageCount].title;
						}
					}

					images[i] = document.createElement('img');
					images[i].setAttribute('id', 'lightwindow_image_'+i);
					images[i].setAttribute('border', '0');
					images[i].setAttribute('src', this.contentToFetch);
					$('lightwindow_contents').appendChild(images[i]);

					// We have to do this instead of .onload 
					this.checkImage[i] = new PeriodicalExecuter(function(i) {
						if (!(typeof $('lightwindow_image_'+i).naturalWidth != "undefined" && $('lightwindow_image_'+i).naturalWidth == 0)) {
	
							this.checkImage[i].stop();
	
							var imageHeight = $('lightwindow_image_'+i).getHeight();
							if (imageHeight > this.resizeTo.height) {
								this.resizeTo.height = imageHeight;
							}
							this.resizeTo.width += $('lightwindow_image_'+i).getWidth();
							this.imageCount--;
	
							$('lightwindow_image_'+i).setStyle({
								height: '100%'
							});
	
						 	if (this.imageCount == 0) {
								this._processWindow();
						 	}
						}
					
					}.bind(this, i), 1);			
				}


			break;
		
		case 'media' :			
		
			var current = 0;
			this.resizeTo.height = this.resizeTo.width = 0;

			// If there is a gallery get it
			if (gallery = this._getGalleryInfo(this.element.rel)) {	
				for (current = 0; current < this.galleries[gallery[0]][gallery[1]].length; current++) {
					if (this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href) > -1) {
						break;
					}
				}
				
				if (this.galleries[gallery[0]][gallery[1]][current-1]) {
					this.navigationObservers.previous = this.galleries[gallery[0]][gallery[1]][current-1];
				} else {
					this.navigationObservers.previous = false;
				}
				if (this.galleries[gallery[0]][gallery[1]][current+1]) {
					this.navigationObservers.next = this.galleries[gallery[0]][gallery[1]][current+1];
				} else {
					this.navigationObservers.next = false;
				}
		
				this.activeGallery = true;
			} else {
				this.navigationObservers.previous = false;
				this.navigationObservers.next = false;
				
				this.activeGallery = false;
			}
		

			if (gallery && this.galleries[gallery[0]][gallery[1]][current]) {
				this.contentToFetch = this.galleries[gallery[0]][gallery[1]][current].href;

				this.galleryLocation = {current: current+1, total: this.galleries[gallery[0]][gallery[1]].length};
				
				if (!this.galleries[gallery[0]][gallery[1]][current+1]) {
					$('lightwindow_next').setStyle({
						display: 'none'
					});
				} else {
					$('lightwindow_next').setStyle({
						display: 'block'
					});
					$('lightwindow_next_title').innerHTML = this.galleries[gallery[0]][gallery[1]][current+1].title;
				}
				
				if (!this.galleries[gallery[0]][gallery[1]][current-1]) {
					$('lightwindow_previous').setStyle({
						display: 'none'
					});
				} else {
					$('lightwindow_previous').setStyle({
						display: 'block'
					});
					$('lightwindow_previous_title').innerHTML = this.galleries[gallery[0]][gallery[1]][current-1].title;
				}
			}
			
			if (this._getParameter('lightwindow_iframe_embed')) {
				this.resizeTo.height = this.dimensions.viewport.height;
				this.resizeTo.width = this.dimensions.viewport.width;	
			} else {
				this.resizeTo.height = this._getParameter('lightwindow_height');
				this.resizeTo.width = this._getParameter('lightwindow_width');				
			}
			
			this._processWindow();
			
			break;

		case 'external' :		

			this._appendIframe('auto');

			this.resizeTo.height = this.dimensions.viewport.height;
			this.resizeTo.width = this.dimensions.viewport.width;
						
			this._processWindow();

			break;
				
		case 'page' :	
			
			var newAJAX = new Ajax.Request(
				this.contentToFetch, {
					method: 'get', 
					parameters: '', 
					onComplete: function(response) {
						$('lightwindow_contents').innerHTML += response.responseText;
						this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
						this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
						this._processWindow();
					}.bind(this)
				}
			);
			
			break;
			
		case 'inline' : 
		
			var content = this.contentToFetch;
			if (content.indexOf('?') > -1) {
				content = content.substring(0, content.indexOf('?'));
			}
			content = content.substring(content.indexOf('#')+1);
			
			new Insertion.Top($('lightwindow_contents'), $(content).innerHTML);
			
			this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
			this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
			
			this._toggleTroubleElements('hidden', true); 			
			this._processWindow();
			
			break;
			
		default : 
			throw("Page Type could not be determined, please amend this lightwindow URL "+this.contentToFetch);
			break;
		}
	},
	//
	//  Resize the Window to fit the viewport if necessary
	//
	_resizeWindowToFit : function() {
		if (this.resizeTo.height+this.dimensions.cruft.height > this.dimensions.viewport.height) {
			var heightRatio = this.resizeTo.height/this.resizeTo.width;
			this.resizeTo.height = this.dimensions.viewport.height-this.dimensions.cruft.height-(2*this.options.viewportPadding);
			// We only care about ratio's with this window type			
			if (this.windowType == 'image' || (this.windowType == 'media' && !this._getParameter('lightwindow_iframe_embed'))) {
				this.resizeTo.width = this.resizeTo.height/heightRatio;
				$('lightwindow_data_slide_inner').setStyle({
					width: this.resizeTo.width+'px'
				});			
			}
		} 
		if (this.resizeTo.width+this.dimensions.cruft.width > this.dimensions.viewport.width) {
			var widthRatio = this.resizeTo.width/this.resizeTo.height;
			this.resizeTo.width = this.dimensions.viewport.width-2*this.dimensions.cruft.width-(2*this.options.viewportPadding);
			// We only care about ratio's with this window type
			if (this.windowType == 'image' || (this.windowType == 'media' && !this._getParameter('lightwindow_iframe_embed'))) {
				this.resizeTo.height = this.resizeTo.width/widthRatio;
				$('lightwindow_data_slide_inner').setStyle({
					height: this.resizeTo.height+'px'
				});
			}
		}
			
	},
	//
	//  Set the Window to a preset size
	//
	_presetWindowSize : function() {
		if (this._getParameter('lightwindow_height')) {
			this.resizeTo.height = parseFloat(this._getParameter('lightwindow_height'));
		}
		if (this._getParameter('lightwindow_width')) {
			this.resizeTo.width = parseFloat(this._getParameter('lightwindow_width'));
		}
	},
	//
	//  Process the Window
	//
	_processWindow : function() {
		// Clean out our effects
		this.dimensions.dataEffects = [];

		// Set up the data-slide if we have caption information
		if (this.element.caption || this.element.author || (this.activeGallery && this.options.showGalleryCount)) {
			if (this.element.caption) {
				$('lightwindow_data_caption').innerHTML = this.element.caption;
				$('lightwindow_data_caption').setStyle({
					display: 'block'
				});
			} else {
				$('lightwindow_data_caption').setStyle({
					display: 'none'
				});				
			}
			if (this.element.author) {
				$('lightwindow_data_author').innerHTML = this.element.author;
				$('lightwindow_data_author_container').setStyle({
					display: 'block'
				});
			} else {
				$('lightwindow_data_author_container').setStyle({
					display: 'none'
				});				
			}
			if (this.activeGallery && this.options.showGalleryCount) {
				$('lightwindow_data_gallery_current').innerHTML = this.galleryLocation.current;
				$('lightwindow_data_gallery_total').innerHTML = this.galleryLocation.total;
				$('lightwindow_data_gallery_container').setStyle({
					display: 'block'
				});
			} else {
				$('lightwindow_data_gallery_container').setStyle({
					display: 'none'
				});				
			}

			$('lightwindow_data_slide_inner').setStyle({
				width: this.resizeTo.width+'px',
				height: 'auto',
				visibility: 'visible',
				display: 'block'
			});
			$('lightwindow_data_slide').setStyle({
				height: $('lightwindow_data_slide').getHeight()+'px',
				width: '1px',
				overflow: 'hidden',
				display: 'block'
			});
		} else {
			$('lightwindow_data_slide').setStyle({
				display: 'none',
				width: 'auto'
			});
			$('lightwindow_data_slide_inner').setStyle({
				display: 'none',
				visibility: 'hidden',
				width: this.resizeTo.width+'px',
				height: '0px'
			});
		}
				
		if (this.element.title != 'null') {		
			$('lightwindow_title_bar_title').innerHTML = this.element.title;
		} else {
			$('lightwindow_title_bar_title').innerHTML = '';
		}
		
		var originalContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
		// Position the window
    	$('lightwindow_container').setStyle({
			height: 'auto',
			// We need to set the width to a px not auto as opera has problems with it
			width: $('lightwindow_container').getWidth()+this.options.contentOffset.width-(this.windowActive ? this.options.contentOffset.width : 0)+'px'
		});
		var newContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
 		
		// We need to record the container dimension changes
		this.containerChange = {height: originalContainerDimensions.height-newContainerDimensions.height, width: originalContainerDimensions.width-newContainerDimensions.width};

		// Get out general dimensions
		this.dimensions.container = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
		this.dimensions.cruft = {height: this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.options.contentOffset.height, width: this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.options.contentOffset.width};
		
		// Set Sizes if we need too
		this._presetWindowSize();
		this._resizeWindowToFit(); // Even if the window is preset we still don't want it to go outside of the viewport

		if (!this.windowActive) {
			// Position the window
		   	$('lightwindow_container').setStyle({
				left: -(this.dimensions.container.width/2)+'px',
				top: -(this.dimensions.container.height/2)+'px'
			});
		}
	   	$('lightwindow_container').setStyle({
			height: this.dimensions.container.height+'px',
			width: this.dimensions.container.width+'px'
		});
		
		// We are ready, lets show this puppy off!
		this._displayLightWindow('block', 'visible');
		this._animateLightWindow();
	},
	//
	//  Fire off our animation handler
	//
	_animateLightWindow : function() {
		if (this.options.animationHandler) {
			this.options.animationHandler().bind(this);
		} else {
			this._defaultAnimationHandler();
		}
	},
	//
	//  Fire off our transition handler
	//
	_handleNavigation : function(display) {
		if (this.options.navigationHandler) {
			this.options.navigationHandler().bind(this, display);
		} else {
			this._defaultDisplayNavigation(display);
		}
	},
	//
	//  Fire off our transition handler
	//
	_handleTransition : function() {
		if (this.options.transitionHandler) {
			this.options.transitionHandler().bind(this);
		} else {
			this._defaultTransitionHandler();
		}
	},
	//
	//  Handle the finish of the window animation
	// 
	_handleFinalWindowAnimation : function(delay) {
		if (this.options.finalAnimationHandler) {
			this.options.finalAnimationHandler().bind(this, delay);
		} else {
			this._defaultfinalWindowAnimationHandler(delay);
		}		
	},
	//
	//  Handle the gallery Animation
	// 
	_handleGalleryAnimation : function(list) {
		if (this.options.galleryAnimationHandler) {
			this.options.galleryAnimationHandler().bind(this, list);
		} else {
			this._defaultGalleryAnimationHandler(list);
		}		
	},
	//
	//  Display the navigation 
	//
	_defaultDisplayNavigation : function(display) {
		if (display) {
			$('lightwindow_navigation').setStyle({
				display: 'block',
				height: $('lightwindow_contents').getHeight()+'px',
				width: '100%',
				marginTop: this.options.dimensions.titleHeight+'px'
			});			
		} else {
			$('lightwindow_navigation').setStyle({
				display: 'none',
				height: 'auto',
				width: 'auto'
			});			
		}
	},
	//
	//  This is the default animation handler for LightWindow
	//
	_defaultAnimationHandler : function() {	
		// Now that we have figures out the cruft lets make the caption go away and add its effects
		if (this.element.caption || this.element.author || (this.activeGallery && this.options.showGalleryCount)) {
			$('lightwindow_data_slide').setStyle({
				display: 'none',
				width: 'auto'
			});
			this.dimensions.dataEffects.push(
				new Effect.SlideDown('lightwindow_data_slide', {sync: true}),
				new Effect.Appear('lightwindow_data_slide', {sync: true, from: 0.0, to: 1.0})
			);
		}

		// Set up the Title if we have one
		$('lightwindow_title_bar_inner').setStyle({
			height: '0px',
			marginTop: this.options.dimensions.titleHeight+'px'
		});
		
		// We always want the title bar as well
		this.dimensions.dataEffects.push(
			new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: this.options.dimensions.titleHeight+'px', marginTop: '0px'}}),
		 	new Effect.Appear('lightwindow_title_bar_inner', {sync: true, from: 0.0, to: 1.0})
		);		
		
		if (!this.options.hideGalleryTab) {
			this._handleGalleryAnimation(false);
			if ($('lightwindow_galleries_tab_container').getHeight() == 0) {
				this.dimensions.dataEffects.push(
					new Effect.Morph('lightwindow_galleries_tab_container', {sync: true, style: {height: '20px', marginTop: '0px'}})
				);
				$('lightwindow_galleries').setStyle({
					width: '0px'
				});
			}
		}
		
		var resized = false;
		var ratio = this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.resizeTo.width+this.options.contentOffset.width;
		if (ratio != $('lightwindow_container').getWidth()) {
			new Effect.Parallel([
					new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.width/$('lightwindow_contents').getWidth()), {scaleFrom: 100*($('lightwindow_contents').getWidth()/($('lightwindow_contents').getWidth()+(this.options.contentOffset.width))), sync: true,  scaleY: false, scaleContent: false}),
					new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.width)), {sync: true, scaleY: false, scaleFromCenter: true, scaleContent: false})
				], {
					duration: this.duration, 
					delay: 0.25,
					queue: {position: 'end', scope: 'lightwindowAnimation'}
				}
			);		
		}
		
		ratio = this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.resizeTo.height+this.options.contentOffset.height;
		if (ratio != $('lightwindow_container').getHeight()) {
			new Effect.Parallel([
					new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.height/$('lightwindow_contents').getHeight()), {scaleFrom: 100*($('lightwindow_contents').getHeight()/($('lightwindow_contents').getHeight()+(this.options.contentOffset.height))), sync: true, scaleX: false, scaleContent: false}),
					new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.height)), {sync: true, scaleX: false, scaleFromCenter: true, scaleContent: false})
				], {
					duration: this.duration, 
					afterFinish: function() {				
						if (this.dimensions.dataEffects.length > 0) {
							if (!this.options.hideGalleryTab) {
								$('lightwindow_galleries').setStyle({
									width: this.resizeTo.width+'px'
								});
							}
							new Effect.Parallel(this.dimensions.dataEffects, {
									duration: this.duration,
									afterFinish: function() {
										this._finishWindow();
									}.bind(this),
									queue: {position: 'end', scope: 'lightwindowAnimation'} 
								}
							);
						}
					}.bind(this), 
					queue: {position: 'end', scope: 'lightwindowAnimation'} 
				}
			);
			resized = true;
		}
		
		// We need to do our data effect since there was no resizing
		if (!resized && this.dimensions.dataEffects.length > 0) {	
			new Effect.Parallel(this.dimensions.dataEffects, {
					duration: this.duration,
					beforeStart: function() {
						if (!this.options.hideGalleryTab) {
							$('lightwindow_galleries').setStyle({
								width: this.resizeTo.width+'px'
							});
						}
						if (this.containerChange.height != 0 || this.containerChange.width != 0) {
							new Effect.MoveBy('lightwindow_container', this.containerChange.height, this.containerChange.width, {transition: Effect.Transitions.sinoidal});
						}
					}.bind(this),			
					afterFinish: function() {
						this._finishWindow();
					}.bind(this),
					queue: {position: 'end', scope: 'lightwindowAnimation'} 
				}
			);
		}			
		
	},
	//
	//  Finish up Window Animation
	//
	_defaultfinalWindowAnimationHandler : function(delay) {
		if (this.windowType == 'media' || this._getParameter('lightwindow_loading_animation')) {	
			// Because of major flickering with the overlay we just hide it in this case
			Element.hide('lightwindow_loading');
			this._handleNavigation(this.activeGallery);
			this._setStatus(false);
		} else {
			Effect.Fade('lightwindow_loading', {
				duration: 0.75,
				delay: 1.0, 
				afterFinish: function() {
					// Just in case we need some scroll goodness (this also avoids the swiss cheese effect)
					if (this.windowType != 'image' && this.windowType != 'media' && this.windowType != 'external') {
						$('lightwindow_contents').setStyle({
							overflow: 'auto'
						});
					}
					this._handleNavigation(this.activeGallery);
					this._defaultGalleryAnimationHandler();
					this._setStatus(false);
				}.bind(this),
				queue: {position: 'end', scope: 'lightwindowAnimation'}
			});
		}
	},
	//
	//  Handle the gallery Animation
	//
	_defaultGalleryAnimationHandler : function(list) {
		if (this.activeGallery) {
			$('lightwindow_galleries').setStyle({
				display: 'block',
				marginBottom: $('lightwindow_data_slide').getHeight()+this.options.contentOffset.height/2+'px'
			});
			$('lightwindow_navigation').setStyle({
				height: $('lightwindow_contents').getHeight()-20+'px'
			});
		} else {
			$('lightwindow_galleries').setStyle({
				display: 'none'
			});	
			$('lightwindow_galleries_tab_container').setStyle({
				height: '0px',
				marginTop: '20px'
			});
			$('lightwindow_galleries_list').setStyle({
				height: '0px'
			});
			return false;
		}
		
		if (list) {
			if ($('lightwindow_galleries_list').getHeight() == 0) {
				var height = $('lightwindow_contents').getHeight()*0.80;
				$('lightwindow_galleries_tab_span').className = 'down';
			} else {
				var height = 0;
				$('lightwindow_galleries_tab_span').className = 'up';
			}

			new Effect.Morph('lightwindow_galleries_list', {
				duration: this.duration,
				transition: Effect.Transitions.sinoidal,
				style: {height: height+'px'},
				beforeStart: function() {
					$('lightwindow_galleries_list').setStyle({
						overflow: 'hidden'
					});					
				},
				afterFinish: function() {
					$('lightwindow_galleries_list').setStyle({
						overflow: 'auto'
					});
				},
				queue: {position: 'end', scope: 'lightwindowAnimation'}
			});	
		}
		
		
	},
	//
	//  Default Transition Handler
	//
	_defaultTransitionHandler : function() {
		// Clean out our effects
		this.dimensions.dataEffects = [];

		// Now that we have figures out the cruft lets make the caption go away and add its effects
		if ($('lightwindow_data_slide').getStyle('display') != 'none') {
			this.dimensions.dataEffects.push(
				new Effect.SlideUp('lightwindow_data_slide', {sync: true}),
				new Effect.Fade('lightwindow_data_slide', {sync: true, from: 1.0, to: 0.0})
			);
		}
		
		if (!this.options.hideGalleryTab) {
			if ($('lightwindow_galleries').getHeight() != 0 && !this.options.hideGalleryTab) {
				this.dimensions.dataEffects.push(
					new Effect.Morph('lightwindow_galleries_tab_container', {sync: true, style: {height: '0px', marginTop: '20px'}})
				);
			}
			
			if ($('lightwindow_galleries_list').getHeight() != 0) {
				$('lightwindow_galleries_tab_span').className = 'up';
				this.dimensions.dataEffects.push(
					new Effect.Morph('lightwindow_galleries_list', {
						sync: true, 
						style: {height: '0px'},
						transition: Effect.Transitions.sinoidal,
						beforeStart: function() {
							$('lightwindow_galleries_list').setStyle({
								overflow: 'hidden'
							});					
						},
						afterFinish: function() {
							$('lightwindow_galleries_list').setStyle({
								overflow: 'auto'
							});
						}
					})
				);
			}
		}
		
		// We always want the title bar as well
		this.dimensions.dataEffects.push(
			new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: '0px', marginTop: this.options.dimensions.titleHeight+'px'}}),
		 	new Effect.Fade('lightwindow_title_bar_inner', {sync: true, from: 1.0, to: 0.0})
		);

		new Effect.Parallel(this.dimensions.dataEffects, {
				duration: this.duration,
				afterFinish: function() {
					this._loadWindow();
				}.bind(this),
				queue: {position: 'end', scope: 'lightwindowAnimation'} 
			}
		);	
	},
	//
	//	Default Form handler for LightWindow
	//
	_defaultFormHandler : function(e) {
		var element = Event.element(e).parentNode;
		var parameterString = Form.serialize(this._getParameter('lightwindow_form', element.getAttribute('params')));
		if (this.options.formMethod == 'post') {
			var newAJAX = new Ajax.Request(element.href, { 
				method: 'post', 
				postBody: parameterString, 
				onComplete: this.openWindow.bind(this, element)
			});
		} else if (this.options.formMethod == 'get') {
			var newAJAX = new Ajax.Request(element.href, { 
				method: 'get', 
				parameters: parameterString, 
				onComplete: this.openWindow.bind(this, element)
			});
		}
	},
	// 
	//  Wrap everything up
	//
	_finishWindow : function() {
		if (this.windowType == 'external') {
			// We set the externals source here because it allows for a much smoother animation
			$('lightwindow_iframe').setAttribute('src', this.element.href);
			this._handleFinalWindowAnimation(1);	
		} else if (this.windowType == 'media') {

			var outerObject = document.createElement('object');
			outerObject.setAttribute('classid', this.options.classids[this._fileExtension(this.contentToFetch)]);
			outerObject.setAttribute('codebase', this.options.codebases[this._fileExtension(this.contentToFetch)]);
			outerObject.setAttribute('id', 'lightwindow_media_primary');
			outerObject.setAttribute('name', 'lightwindow_media_primary');
			outerObject.setAttribute('width', this.resizeTo.width);
			outerObject.setAttribute('height', this.resizeTo.height);
			outerObject = this._addParamToObject('movie', this.contentToFetch, outerObject);
			outerObject = this._addParamToObject('src', this.contentToFetch, outerObject);
			outerObject = this._addParamToObject('controller', 'true', outerObject);
			outerObject = this._addParamToObject('wmode', 'transparent', outerObject);
			outerObject = this._addParamToObject('cache', 'false', outerObject);
			outerObject = this._addParamToObject('quality', 'high', outerObject);

			if (!Prototype.Browser.IE) {
				var innerObject = document.createElement('object');
				innerObject.setAttribute('type', this.options.mimeTypes[this._fileExtension(this.contentToFetch)]);
				innerObject.setAttribute('data', this.contentToFetch);
				innerObject.setAttribute('id', 'lightwindow_media_secondary');
				innerObject.setAttribute('name', 'lightwindow_media_secondary');
				innerObject.setAttribute('width', this.resizeTo.width);
				innerObject.setAttribute('height', this.resizeTo.height);
				innerObject = this._addParamToObject('controller', 'true', innerObject);
				innerObject = this._addParamToObject('wmode', 'transparent', innerObject);
				innerObject = this._addParamToObject('cache', 'false', innerObject);
				innerObject = this._addParamToObject('quality', 'high', innerObject);
			
				outerObject.appendChild(innerObject);
			}	
			
			if (this._getParameter('lightwindow_iframe_embed')) {
				this._appendIframe('no');
				this._writeToIframe(this._convertToMarkup(outerObject, 'object'));
			} else {
				this._appendObject(outerObject, 'object', $('lightwindow_contents'));
			}

			this._handleFinalWindowAnimation(0);
		} else {
			this._handleFinalWindowAnimation(0);
		}

		// Initialize any actions
		this._setupActions();
	}
}

/*-----------------------------------------------------------------------------------------------*/

Event.observe(window, 'load', lightwindowInit, false);

//
//	Set up all of our links
//
var myLightWindow = null;
function lightwindowInit() {
	myLightWindow = new lightwindow();
}

/*-------------------------------------------------------------------------
 *    FieldHints version 1.1
 *    http://pauldowman.com/projects/fieldhints
 *
 *    Copyright 2007 Paul Dowman, http://pauldowman.com/
 *
 *    FieldHints is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    FieldHints is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *    
 *--------------------------------------------------------------------------
 *  
 *  This script requires the Prototype JavaScript library:
 *  http://prototypejs.org
 *
 *--------------------------------------------------------------------------*/


var FieldHints = {
    
    fieldWithHintClass: 'fieldWithHint',
    labelClass: 'hintText',

    initialize: function() {
        var labels = $$('label.hintText');
        var f = FieldHints.initializeField.bind(FieldHints);
        labels.each(f);
    },
    
    // Registers a blur handler and a focus handler for the field, and adds a
    // submit handler to a chain of submit handlers for the form.
    initializeField: function(label) {
        var fieldId = label.htmlFor;
        if (!fieldId) return;

        var field = $(fieldId);
        if (!field) return;
            
        if (!field.fieldHintsInitialized) {
            field.fieldHintsInitialized = true;
            var hint = label.innerHTML.strip();
            var form = field.form;
            
            this.addFocusHandler(field, hint);
            this.addBlurHandler(field, hint);
            
            var oldSubmitHandler;
            if (form.onsubmit) oldSubmitHandler = form.onsubmit.bind(form);
            field.form.onsubmit = this.hintSubmitHandler(hint, field, oldSubmitHandler);
            
            this.doBlur(field, hint);
        }
    },
    
    addFocusHandler: function(field, hint) {
      field.observe('focus', function(ev) {
        var el = Event.element(ev);
        if (el.value.strip() == hint) {
          el.value = '';
        }
        el.removeClassName(FieldHints.fieldWithHintClass);
      });
    },
    
    addBlurHandler: function(field, hint) {
      var obj = this;
      field.observe('blur', function(ev) {
        var el = Event.element(ev);
        obj.doBlur(el, hint)
      });
    },
    
    doBlur: function(el, hint) {
      if (el.value == '') el.value = hint;
      if (el.value == hint) el.addClassName(FieldHints.fieldWithHintClass);
    },
    
    // If the field never received focus then it will still have the hint text
    // in it. In that case it should be empty on submit, instead of submitting
    // the hint text, so register a submit handler for the form. There may
    // already be a submit handler on the form, so we need to keep a reference
    // to it and call it at the end.
    hintSubmitHandler: function(hint, field, oldSubmitHandler) {
        return function() {
            if (field.value == hint) {
                field.value = ''
                $(this).removeClassName(FieldHints.fieldWithHintClass);
            }
            if (oldSubmitHandler) {
                try {
                    var retval = oldSubmitHandler();
                } catch (error) {
                    return false;
                }
                return retval;
            } else {
                return true;
            }
        }
    }
    
}



var Cookie = {
  set: function(name, value, daysToExpire) {
    var expire = '';
    if(!daysToExpire) daysToExpire = 365;
    var d = new Date();
    d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
    expire = 'expires=' + d.toGMTString();
    var path = "path=/;"
    var cookieValue = escape(name) + '=' + escape(value || '') + '; ' + path + '; ' + expire + ';';
    return document.cookie = cookieValue;
  },

  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]+)'));
    return (cookie ? unescape(cookie[2]) : null);
  },

  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
  },

  eraseAll: function() {
    // Get cookie string and separate into individual cookie phrases:
    var cookieString = "" + document.cookie;
    var cookieArray = cookieString.split("; ");
 
    // Try to delete each cookie:
    for(var i = 0; i < cookieArray.length; ++ i)
    {
      var singleCookie = cookieArray[i].split("=");
      if(singleCookie.length != 2)
        continue;
      var name = unescape(singleCookie[0]);
      Cookie.erase(name);
    }
  },

  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  },

  exists: function(cookieName) {
    var cookieValue = Cookie.get(cookieName);
    if(!cookieValue) return false;
    return cookieValue.toString() != "";
  }
};


/* jPlex User Interface Framework
 *  (c) 2009 Loic Petit - Jean-Luc Dagon
 *
 *  jPlex is freely distributable under the terms of an MIT-style license.
 *  For details, see the jPlex web site: http://jplex.googlecode.com/
 *
 *--------------------------------------------------------------------------*/
var jPlex={version:"1.0",_dependancies:["prototype-1.6.0.3","scriptaculous"],_dependanciesFF2:["builder","effects","dragdrop","controls","slider","sound"],_classes:["jplex.common.Config","jplex.common.Locale","jplex.common.Component","jplex.xprototype.Core","jplex.xprototype.Date","jplex.xprototype.Element","jplex.xprototype.Event","jplex.xprototype.Object","jplex.xprototype.String","jplex.components.Calendar","jplex.components.MenuBar","jplex.components.MouseOverImage","jplex.components.Overlay","jplex.components.Tabs","jplex.components.Tooltip","jplex.components.Frame","jplex.components.frame.Dialog","jplex.components.frame.Modal","jplex.components.frame.FrameSet"],src:[],_loaded:[],load:function(fileName){if(jPlex._loaded[fileName]){return;}if(this.src[fileName]!=undefined){eval(jPlex.src[fileName]);return;}new Ajax.Request(this.path+fileName,{method:"get",asynchronous:false});jPlex._loaded[fileName]=true;},loadJS:function(A){document.write("<script type='text/javascript' src='"+A+"'><\/script>");},init:function(){var A=document.getElementsByTagName("script");for(var D=0;D<A.length;D++){var H=A[D];if(H.src&&H.src.match(/j[pP]lex\.js(\?.*)?$/)){var G=H.src.replace(/j[pP]lex\.js(\?.*)?$/,"");this.path=G;if(typeof Prototype!="undefined"){return;}var I=H.src.match(/\?.*load=([a-z,]*)/);var F=(I?I[1]:jPlex._dependancies);if(navigator.userAgent.indexOf("Firefox/2")){F=F.concat(jPlex._dependanciesFF2);}var E=G.split("/");E.length-=2;var C=E.join("/")+"/libs/";for(var B=0;B<F.length;B++){jPlex.loadJS(C+F[B]+".js");}}}},include:function(H,F){var D=H.split(".");var A=jPlex.get(H);if(A){if(!window[D[D.length-1]]&&!F&&D[1]!="xprototype"){window[D[D.length-1]]=A;}return A;}if(D[D.length-1]=="*"){$A(this._classes).each(function(I){if(I.startsWith(H.replace("*",""))){this.include(I,F);}},this);return null;}var G="";var C;for(C=0;C<D.length-1;C++){G+=D[C]+"/";}if(D[D.length-2]&&D[D.length-2]=="components"){G+=D[D.length-1].toLowerCase()+"/";}G+=D[D.length-1]+".js";jPlex.load(G);var B=jPlex.get(H);var E=D[D.length-1];if(!window[E]&&!F&&D[1]!="xprototype"){window[E]=B;}return B;},get:function(C){var B=window;var A=false;$A(C.split(".")).each(function(D,E){if(B){B=B[D];}else{A=true;throw $break;}});if(A){return null;}return B;},provide:function(G,F,E){var D,A;if(!E){D=F;}else{D=E;A=F;}var H;if(A){A=jPlex.include(A);H=Class.create(A,D);}else{H=Class.create(D);}var J=$A(G.split("."));var B=window;for(var C=0;C<J.length-1;C++){var I=J[C];if(!B[I]){B[I]={};}B=B[I];}B[J[J.length-1]]=H;},extend:function(A,B){Object.extend(this.get(A),B);},useSkin:function(B){var A=$(document.body);A.removeClassName(this._skin||"");A.addClassName(B);this._skin=B;}};jPlex.init();jPlex.src['jplex/common/_module.js']="";jPlex.src['jplex/common/Component.js']="jPlex.include(\"jplex.common.Config\");jPlex.include(\"jplex.common.Locale\");jPlex.include(\"jplex.xprototype.*\");jPlex.provide(\"jplex.common.Component\",{initialize:function(C,B){this.component=$(C);if(!this._definition||!this._definition.name||(!this._definition.defaultContainer&&!this.component)){throw\"DefinitionError: Mandatory definition or field not present (Component#initialize)\";}if(!Object.isElement(this.component)){if(typeof(C)!=\"string\"){throw\"WrongParameterType: The first parameters has to be a string in case of \"+\"a non-existing DOM element (Component#initialize)\";}this.createdComponent=true;this.component=new Element(this._definition.defaultContainer,{id:C});document.body.appendChild(this.component);}this.UID=\"jplex-\"+this._definition.name.toLowerCase()+\"-\";jplex.common.Component.subclasses.each(function(F){if(this instanceof F){this.UID=this.UID+F.prototype._instanceCount++;throw $break;}}.bind(this));this._definition.defaultConfig=this._definition.defaultConfig||{};this._definition.events=this._definition.events||{};B=B||{};B.events=B.events||{};var D=this._extension?this._extension.defaultConfig||{}:{};var A=Object.extendRecursive(Object.clone(this._definition.defaultConfig),D);A=Object.extend(A,B);A.events=null;var E=this._extension?this._extension.text||{}:{};Object.extendRecursive(this._definition.text,E);this._config=new jplex.common.Config(A);this._events=new Hash();$H(B.events).each(function(F){if(Object.isArray(F.value)){F.value.each(function(G){this.setEvent(F.key,G||Prototype.emptyFunction);},this);}else{this.setEvent(F.key,F.value||Prototype.emptyFunction);}},this);this.ID=this.component.getAttribute(\"id\");jplex.common.Component._list.set(this.ID,this);},cfg:function(A){return this._config.get(A);},setCfg:function(A,B){this._config.set(A,B);},setEvent:function(A,B){if(!this._events.get(A)){this._events.set(A,$A([]));}this.getEvent(A).push(B.bind(this));},getEvent:function(B){var A=this._events.get(B);return A?A:$A([]);},fireEvent:function(A,B){if(this.getEvent(A)){this.getEvent(A).invoke(\"call\",this,B);}},lang:function(C){var A=$H(this._definition.text);if(!A){return false;}var B=this.cfg(\"lang\");if(!B){B=jplex.common.Locale.lang;}return $H(A.get(B)).get(C);},locale:function(A,B){var D=this.cfg(\"lang\");if(!D){return jplex.common.Locale.current(A,B);}var C=jplex.common.Locale.get(A,D);if(!C){return undefined;}return C.get(B);},unregister:function(){jplex.common.Component._list.set(this.ID,undefined);if(this.createdComponent){this.component.remove();}},_instanceCount:0});jPlex.extend(\"jplex.common.Component\",{_list:$H()});$C=function(B){var A=null;if(typeof(B)==\"string\"){A=jplex.common.Component._list.get(B);}else{if(B instanceof jplex.common.Component){A=B;}}return A;};";jPlex.src['jplex/common/Config.js']="jPlex.provide(\"jplex.common.Config\",{initialize:function(A){this._oConfig=$H(A);},set:function(B,A){this._oConfig.set(B,A);},get:function(B){var A=this._oConfig.get(B);return A;},each:function(A){this._oConfig.each(A);}});";jPlex.src['jplex/common/Locale.js']="jPlex.provide(\"jplex.common.Locale\",{});jPlex.extend(\"jplex.common.Locale\",{lang:\"en\",get:function(B,C){var A=this._components.get(B);if(!A){return undefined;}if(!C){C=this.lang;}return $H(A.get(C));},current:function(B,C){var A=this.get(B);if(!A){return undefined;}return $H(A).get(C);},init:function(B,A){return this._components.set(B,$H(A));},_components:new Hash()});jplex.common.Locale.init(\"Date\",{fr:{DAYS_SHORT:$A([\"Di.\",\"Lu.\",\"Ma.\",\"Me.\",\"Je.\",\"Ve.\",\"Sa.\"]),DAYS:$A([\"Dimanche\",\"Lundi\",\"Mardi\",\"Mercredi\",\"Jeudi\",\"Vendredi\",\"Samedi\"]),MONTHS:$A([\"Janvier\",\"Février\",\"Mars\",\"Avril\",\"Mai\",\"Juin\",\"Juillet\",\"Août\",\"Septembre\",\"Octobre\",\"Novembre\",\"Décembre\"]),MONTHS_SHORT:$A([\"Jan.\",\"Fév.\",\"Mars\",\"Avr.\",\"Mai\",\"Juin\",\"Jui.\",\"Août\",\"Sep.\",\"Oct.\",\"Nov.\",\"Déc.\"]),FORMAT:\"d/m/Y\"},en:{DAYS_SHORT:$A([\"Su.\",\"Mo.\",\"Tu.\",\"We.\",\"Th.\",\"Fr.\",\"Sa.\"]),DAYS:$A([\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"]),MONTHS:$A([\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]),MONTHS_SHORT:$A([\"Jan.\",\"Feb.\",\"Mar.\",\"Apr.\",\"May\",\"June\",\"July\",\"Aug.\",\"Sep.\",\"Oct.\",\"Nov.\",\"Dec.\"]),FORMAT:\"m-d-Y\"},jp:{DAYS_SHORT:$A([\"\\u65E5\",\"\\u6708\",\"\\u706B\",\"\\u6C34\",\"\\u6728\",\"\\u91D1\",\"\\u571F\"]),DAYS:$A([\"\\u65E5\",\"\\u6708\",\"\\u706B\",\"\\u6C34\",\"\\u6728\",\"\\u91D1\",\"\\u571F\"]),MONTHS:$A([\"1\\u6708\",\"2\\u6708\",\"3\\u6708\",\"4\\u6708\",\"5\\u6708\",\"6\\u6708\",\"7\\u6708\",\"8\\u6708\",\"9\\u6708\",\"10\\u6708\",\"11\\u6708\",\"12\\u6708\"]),MONTHS_SHORT:$A([\"1\\u6708\",\"2\\u6708\",\"3\\u6708\",\"4\\u6708\",\"5\\u6708\",\"6\\u6708\",\"7\\u6708\",\"8\\u6708\",\"9\\u6708\",\"10\\u6708\",\"11\\u6708\",\"12\\u6708\"]),FORMAT:\"Y\\u5E74m\\u65E5\"}});";jPlex.src['jplex/components/_module.js']="";jPlex.src['jplex/components/calendar/Calendar.js']="jPlex.include(\"jplex.components.Tooltip\",false);jPlex.include(\"jplex.components.calendar.CalendarItem\",false);jPlex.include(\"jplex.components.Overlay\",false);jPlex.provide(\"jplex.components.Calendar\",\"jplex.common.Component\",{_definition:{name:\"Calendar\",defaultConfig:{date:new Date(),minDate:false,maxDate:false,dateFormat:\"d-m-Y\",titleFormat:\"{M} {Y}\",fade:0.3,textField:null,source:null,fastBrowse:true,zBase:11000,fastBrowseYearStart:(new Date()).getFullYear()-5,fastBrowseYearEnd:(new Date()).getFullYear()+5,fastBrowseYearStep:1},events:{onSelectEvent:Prototype.emptyFunction,onShowEvent:Prototype.emptyFunction,onHideEvent:Prototype.emptyFunction,onPositionChangeEvent:Prototype.emptyFunction},defaultContainer:\"div\",text:{fr:{CLOSE:\"Fermer\",SELECT_MONTH:\"Mois\",SELECT_YEAR:\"Année\",SELECT_END:\"Terminer\"},en:{CLOSE:\"Close\",SELECT_MONTH:\"Month\",SELECT_YEAR:\"Year\",SELECT_END:\"Finish\"},jp:{CLOSE:\"Close\",SELECT_MONTH:\"\\u65E5\",SELECT_YEAR:\"\\u5E74\",SELECT_END:\"Finish\"}}},initialize:function($super,E,D){$super(E,D);var B=this.cfg(\"date\");this._selectedItem=this._focusedItem={getDate:function(){return B;}};this._currentMonth=B;this._source=$(this.cfg(\"source\"));this._textField=$(this.cfg(\"textField\"));if(!this._textField&&this._source){this._textField=this._source;}this._initialRender();this.render();if(this._textField&&this._source){this.component.setStyle({position:\"absolute\",zIndex:this.cfg(\"zBase\")});if(Prototype.Browser.IE){this._textField.setAttribute(\"readOnly\",true);}else{this._textField.setAttribute(\"readonly\",true);}var A=(function(){if(this.component.visible()){return;}this.show();this._source.activate();}).bindAsEventListener(this);this._source.observe(\"focus\",A);this._source.observe(\"click\",A);document.observe(\"click\",function(G){G=Event.extend(window.event||G);var F=G.pointerX(),H=G.pointerY();if(!this._source.isWithin(F,H)&&!this.component.isWithin(F,H)&&!this._fastBrowseTooltip.component.isWithin(F,H)){this.hide();}}.bindAsEventListener(this));var C=function(){if(this.component.visible()){this._focusedItem.select(null,true);}else{this.show();}}.bind(this);this._source.bindKey(Event.Key.ENTER,C,{preventDefault:true});this._source.bindKey(Event.Key.SPACE,C,{preventDefault:true});this._source.bindKey(Event.Key.TAB,(function(){this.hide();}).bind(this));this._source.bindKey(Event.Key.TAB,(function(){this.hide();}).bind(this),{shift:true});this._source.bindKey(Event.Key.ESCAPE,function(){if(this.component.visible()){this.hide();}}.bind(this),{preventDefault:true});this._source.bindKey(Event.Key.PAGE_UP,this.previous.bind(this),{preventDefault:true});this._source.bindKey(Event.Key.PAGE_DOWN,this.next.bind(this),{preventDefault:true});this._source.bindKey(Event.Key.LEFT_ARROW,this.left.bind(this),{preventDefault:true});this._source.bindKey(Event.Key.RIGHT_ARROW,this.right.bind(this),{preventDefault:true});this._source.bindKey(Event.Key.UP_ARROW,this.up.bind(this),{preventDefault:true});this._source.bindKey(Event.Key.DOWN_ARROW,this.down.bind(this),{preventDefault:true});}},show:function(){this._fixPosition();if(this.cfg(\"fade\")==0){this.component.show();}else{new Effect.Appear(this.component,{duration:this.cfg(\"fade\")});}},hide:function(){this._fixPosition();if(this.cfg(\"fade\")==0){this.component.hide();}else{new Effect.Fade(this.component,{duration:this.cfg(\"fade\")});}},select:function(A){this.items[A].select();},render:function(){this.items=$A([]);var B=this._getTbody();B.removeChildren();var J=this._currentMonth.firstDayOfMonth(),G=this._currentMonth.lastDayOfMonth();this.__fdom=J;this.__ldom=G;var K=new Date(J.getFullYear(),J.getMonth(),J.getDate()-J.getDay(),0),F=new Date(G.getFullYear(),G.getMonth(),G.getDate()+6-G.getDay(),0);var I=K,A,D=0;while(F.compareTo(I)>=0){if(I.getDay()==0){A=new Element(\"tr\");this._getTbody().appendChild(A);}var E=new jplex.components.calendar.CalendarItem(this,I,D),C=E.getCell();var H=this._selectedItem.getDate().getTime()-I.getTime();if(H>=0&&H<86400000){E.select();E.focus();}this.items[D++]=E;A.appendChild(C);if(J.compareTo(I)>0||G.compareTo(I)<0){C.addClassName(\"outofmonth\");}I.setNextDay();}this._setTitle(this._currentMonth.getMonth(),this._currentMonth.getFullYear());if(this._fastBrowseOverlay&&this._fastBrowseOverlay.component.visible()){this._fastBrowseOverlay.component.clonePosition(this.component);}},next:function(){var B=this._currentMonth.getMonth()+1;var A=this._currentMonth.getFullYear();if(B>11){B=0;A++;}this.goTo(B,A);},previous:function(){var B=this._currentMonth.getMonth()-1;var A=this._currentMonth.getFullYear();if(B<0){B=11;A--;}this.goTo(B,A);},goTo:function(E,D){var F=this._focusedItem.getIndex();var C=this.__fdom.getDay();var A=new Date();if(!Object.isUndefined(E)){A.setMonth(E);}if(D){A.setYear(D);}this._currentMonth=A.firstDayOfMonth();this.render();var B=this.__fdom.getDay()+Math.min(this.__ldom.getDate()-1,F-C);this.items[B].focus();if(this._source){this._source.activate();}},left:function(){var A=Math.max(0,this._focusedItem.getIndex()-1);this.items[A].focus();},right:function(){var A=Math.min(this._focusedItem.getIndex()+1,this.items.length-1);this.items[A].focus();},up:function(){var A=Math.max(0,this._focusedItem.getIndex()-7);this.items[A].focus();},down:function(){var A=Math.min(this._focusedItem.getIndex()+7,this.items.length-1);this.items[A].focus();},setSelectedItem:function(A){this._selectedItem=A;if(this._textField&&this._textField.getAttribute(\"type\")!=\"button\"){this._textField.value=A.getDate().format(this.cfg(\"dateFormat\"));}},setFocusedItem:function(A){this._focusedItem=A;},getSelectedItem:function(){return this._selectedItem;},getFocusedItem:function(){return this._focusedItem;},getTextField:function(){return this._textField;},getFormattedValue:function(B){var A=B?B:this.cfg(\"dateFormat\");return this._selectedItem.getDate().format(A);},_initialRender:function(){this.component.addClassName(\"jplex-calendar\");if(this._source){this._source.addClassName(\"jplex-calendar\");this.component.setStyle({display:\"none\"});if(Prototype.Browser.IE6){if(this._source.getAttribute(\"type\")==\"button\"){this._source.addClassName(\"jplex-calendar-button\");}else{if(this._source.getAttribute(\"type\")==\"text\"){this._source.addClassName(\"jplex-calendar-text\");}}}}var E=new Element(\"div\").addClassName(\"top\"),G=new Element(\"span\",{id:this.UID+\"_TITLE\"}).addClassName(\"title\"),Q=new Element(\"span\").addClassName(\"previous\").update(\"&nbsp;&laquo;&nbsp\"),A=new Element(\"span\").addClassName(\"next\").update(\"&nbsp;&raquo;&nbsp\"),L=new Element(\"table\",{id:this.UID+\"_TABLE\"}).addClassName(\"calendar\"),F=new Element(\"tbody\").update(\"&nbsp;\"),O=new Element(\"thead\"),C=new Element(\"tr\"),K=new Element(\"div\",{id:this.UID+\"_CLOSE\"}).addClassName(\"close\").update(\"&nbsp;\"+this.lang(\"CLOSE\")+\"&nbsp;\");O.appendChild(C);L.appendChild(O);L.appendChild(F);E.appendChild(Q);E.appendChild(G);E.appendChild(A);this.component.appendChild(E);this.component.appendChild(L);if(this._textField&&this._source){this.component.appendChild(K);}this.component.IEFixCombobox();A.observe(\"click\",this.next.bindAsEventListener(this));Q.observe(\"click\",this.previous.bindAsEventListener(this));K.observe(\"click\",this.hide.bindAsEventListener(this));$A(this.locale(\"Date\",\"DAYS_SHORT\")).each(function(R){C.appendChild(new Element(\"th\").update(R));});if(this.cfg(\"fastBrowse\")){var N=new Element(\"select\");$A(this.locale(\"Date\",\"MONTHS\")).each(function(S,R){N.appendChild((new Element(\"option\",{value:R})).update(S));});var J=new Element(\"select\");$R(this.cfg(\"fastBrowseYearStart\"),this.cfg(\"fastBrowseYearEnd\")).each(function(R){J.appendChild((new Element(\"option\",{value:R})).update(R));});var M=new Element(\"input\",{value:this.lang(\"SELECT_END\"),type:\"button\"});M.addClassName(\"end\");this._fastBrowseTooltip=new jplex.components.Tooltip(this.UID+\"-fbtooltip\",{source:this._getTitle(),trigger:jplex.components.Tooltip.TRIGGER_CLICK,position:\"bottom-right\",positionRatio:0.35,zIndex:this.cfg(\"zBase\")+2});var B=this._fastBrowseTooltip.getBody();this._fastBrowseTooltip.component.addClassName(\"jplex-calendar-tooltip\");var D=new Element(\"div\").update(this.lang(\"SELECT_MONTH\")+\"<br/>\");D.appendChild(N);D.addClassName(\"select\");var P=new Element(\"div\").update(this.lang(\"SELECT_YEAR\")+\"<br/>\");P.appendChild(J);P.addClassName(\"select\");B.appendChildren(D,P,M);if(!Prototype.Browser.IE6){this._fastBrowseTooltip.setEvent(\"onShowEvent\",function(){if(!this._fastBrowseOverlay){this._fastBrowseOverlay=new jplex.components.Overlay(this.UID+\"-overlay\",{z:this.cfg(\"zBase\")+1,source:this.component,opacity:0.3,fade:0.5});this._fastBrowseOverlay.component.addClassName(\"jplex-calendar-overlay\");}this._fastBrowseOverlay.show();}.bind(this));this._fastBrowseTooltip.setEvent(\"onHideEvent\",function(){if(this._fastBrowseOverlay){this._fastBrowseOverlay.hide();}}.bind(this));}var H=function(R){R=Event.extend(window.event?window.event:R);R.cancelBubble=true;return false;};N.observe(\"click\",H);J.observe(\"click\",H);M.observe(\"click\",this._fastBrowseTooltip.hide.bind(this._fastBrowseTooltip));var I=function(){this.goTo(parseInt(N.value),parseInt(J.value));}.bind(this);N.observe(\"change\",I);J.observe(\"change\",I);N.value=this.cfg(\"date\").getMonth();J.value=this.cfg(\"date\").getFullYear();}this._fixPosition();},_getTbody:function(){return $(this.UID+\"_TABLE\").childNodes[1];},_getThead:function(){return $(this.UID+\"_TABLE\").childNodes[0];},_getTable:function(){return $(this.UID+\"_TABLE\");},_getTitle:function(){return $(this.UID+\"_TITLE\");},_setTitle:function(B,A){var C=this.cfg(\"titleFormat\").gsub(\"{M}\",this.locale(\"Date\",\"MONTHS\")[B]).gsub(\"{Y}\",A).gsub(\"{m}\",(B+1).toString());this._getTitle().update(\"&nbsp;\"+C+\"&nbsp;\");},_fixPosition:function(){if(!this._source){return;}var B=this._source.cumulativeOffset();var A={left:B.left,top:B.top+this._source.getHeight()};this.component.setStyle({left:A.left+\"px\",top:A.top+\"px\"});if(this._fastBrowseOverlay){this._fastBrowseOverlay.component.setStyle({left:A.left+\"px\",top:A.top+\"px\"});}this.fireEvent(\"onPositionChangeEvent\",{position:A,dimensions:this.component.getDimensions()});}});";jPlex.src['jplex/components/calendar/CalendarItem.js']="jPlex.provide(\"jplex.components.calendar.CalendarItem\",{initialize:function(B,C,A){this._calendar=B;this._date=new Date();this._date.setTime(C.getTime());this._index=A;this._cell=new Element(\"td\",{id:this._calendar.ID+\"_DAY_\"+A}).update(C.getDate().toString());if(Prototype.Browser.IE6){this._cell.observe(\"mouseover\",function(){this._cell.addClassName(\"ie6-hover\");}.bind(this));this._cell.observe(\"mouseout\",function(){this._cell.removeClassName(\"ie6-hover\");}.bind(this));}if(this.check()){this._cell.observe(\"click\",this.select.bindAsEventListener(this,true));}else{this._cell.addClassName(\"disabled\");}},select:function(B,A){if(!this.check()){return;}if(this._calendar.getSelectedItem()._unselect){this._calendar.getSelectedItem()._unselect();}if(!this._cell.hasClassName(\"selected\")){this._cell.addClassName(\"selected\");}this.focus();this._calendar.setSelectedItem(this);if(A&&this._calendar.getTextField()){this._calendar.hide();}this._calendar.fireEvent(\"onSelectEvent\",{date:this._date});},focus:function(){if(!this.check()){return;}if(this._calendar.getFocusedItem()._blur){this._calendar.getFocusedItem()._blur();}if(!this._cell.hasClassName(\"focused\")){this._cell.addClassName(\"focused\");}this._calendar.setFocusedItem(this);},check:function(){var A=this._calendar.cfg(\"minDate\"),B=this._calendar.cfg(\"maxDate\");return(!A||this._date.compareTo(A)>=-86400000)&&(!B||this._date.compareTo(B)<=0);},getCell:function(){return this._cell;},getIndex:function(){return this._index;},getDate:function(){return this._date;},_unselect:function(){this._cell.removeClassName(\"selected\");},_blur:function(){this._cell.removeClassName(\"focused\");}});";jPlex.src['jplex/components/frame/Dialog.js']="jPlex.provide(\"jplex.components.frame.Dialog\",\"jplex.components.Frame\",{_extension:{name:\"WindowDialog\",defaultConfig:{footer:true,center:true,draggable:true,okButton:true,cancelButton:true,okButtonLabel:\"\",cancelButtonLabel:\"\",otherButtons:[]},events:{onOkButtonClickEvent:Prototype.emptyFunction,onCancelButtonClickEvent:Prototype.emptyFunction},text:{fr:{OK:\"OK\",CANCEL:\"Annuler\"},en:{OK:\"OK\",CANCEL:\"Cancel\"}}},initialize:function($super,B,A){$super(B,A);this._addButtons();if($(this.sID+\"-closecross\")){$(this.sID+\"-closecross\").observe(\"click\",this._cancelButtonClick.bind(this));}},_addButtons:function(){var C=this.component.down(\"div.footer\");$A(this.cfg(\"otherButtons\")).each(function(F,E){var D=new Element(\"input\",{type:\"button\",id:this.sID+\"-bt\"+E,value:F.label});C.appendChild(D);D.observe(\"click\",F.click.bindAsEventListener(this));}.bind(this));if(this.cfg(\"okButton\")){var A=new Element(\"input\",{type:\"button\",id:this.sID+\"-ok\",value:this.cfg(\"okButtonLabel\")||true?this.lang(\"OK\"):this.cfg(\"okButtonLabel\")});C.appendChild(A);A.observe(\"click\",this._okButtonClick.bindAsEventListener(this));}if(this.cfg(\"cancelButton\")){var B=new Element(\"input\",{type:\"button\",id:this.sID+\"-cancel\",value:this.cfg(\"cancelButtonLabel\").blank()?this.lang(\"CANCEL\"):this.cfg(\"cancelButtonLabel\")});C.appendChild(B);B.observe(\"click\",this._cancelButtonClick.bindAsEventListener(this));}},_okButtonClick:function(){this.fireEvent(\"onOkButtonClickEvent\");},_cancelButtonClick:function(){this.fireEvent(\"onCancelButtonClickEvent\");this.hide();}});";jPlex.src['jplex/components/frame/Frame.js']="jPlex.include(\"jplex.components.Overlay\",true);jPlex.provide(\"jplex.components.Frame\",\"jplex.common.Component\",{_definition:{name:\"Frame\",defaultConfig:{header:true,footer:false,center:true,constrainToCenter:false,close:\"button\",draggable:false,title:\"\",ajax:null,ajaxParameters:{},modal:false,zBase:9998,overlayColor:\"#000000\",overlayOpacity:0.6,overlayFade:false,width:null,heigth:null,minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,overflow:\"auto\",constrainToViewport:true,top:null,left:null},events:{beforeRenderEvent:Prototype.emptyFunction,afterRenderEvent:Prototype.emptyFunction,onAjaxRequestCompleteEvent:Prototype.emptyFunction,onShowEvent:Prototype.emptyFunction,onHideEvent:Prototype.emptyFunction},defaultContainer:\"div\",text:{fr:{},en:{}}},initialize:function($super,B,A){$super(B,A);this._level=this.cfg(\"zBase\")+2*jplex.components.Frame.list.length+1;this.render();jplex.components.Frame.list.push(this);this._evtMakeCentered=this.makeCentered.bind(this);},render:function(){this.fireEvent(\"beforeRenderEvent\");this.component.addClassName(\"jplex-window\");if(this.cfg(\"header\")){this._addHeader(this.cfg(\"title\"));}this.setBody(this.component.textContent||\"\");this._body.setStyle({overflow:this.cfg(\"overflow\")});if(this.cfg(\"ajax\")){this.reload();}if(this.cfg(\"footer\")){this._addFooter();}if(this.cfg(\"close\")==jplex.components.Frame.CLOSE_BUTTON){if(!this._header){}this._addCloseButton();}if(this.cfg(\"modal\")){this._addOverlay();}if(this.cfg(\"draggable\")){if(this._header){this._drag=new Draggable(this.component,{handle:this._header,snap:this._constrainToViewport.bind(this)});}else{this._drag=new Draggable(this.component,{snap:this._constrainToViewport.bind(this)});}}this.component.setStyle({zIndex:this._level});this.fireEvent(\"afterRenderEvent\");},getZIndex:function(){return this._level;},setHeader:function(A){if(this._header){this._title.update(A);}else{this._addHeader(A);}return this._header;},setTitle:function(A){this.setHeader(A);},setBody:function(A){if(this._body){this.setLoading(true);this.makeCentered();var C=new Element(\"div\");C.update(A.stripScripts());var D=C.getElementsByTagName(\"img\");var B=$A([]);if(D.length>0){$A(D).each(function(H,G){var F=$(H);var E=F.src;B[G]=false;if(Prototype.Browser.Opera){F.src=\"\";}F.observe(\"load\",function(J,I,K){B[K]=true;I.show();if(B.all()){this._body.update(C.innerHTML);if(this._request){this._request.transport.responseText.evalScripts();this.fireEvent(\"onAjaxRequestCompleteEvent\",{result:A});}this.setLoading(false);}}.bindAsEventListener(this,F,G));if(Prototype.Browser.Opera){F.src=E;if(F.complete){F.removeEvents();}}},this);}else{this._body.update(C.innerHTML);if(this._request){this._request.transport.responseText.evalScripts();this.fireEvent(\"onAjaxRequestCompleteEvent\",{result:this._request.transport});}this.constrain();this.setLoading(false);}}else{this._addBody(A);}this.constrain();this.fireEvent(\"onContentChangeEvent\");return this._body;},setFooter:function(A){if(this._footer){this._footer.update(A);}else{this._addFooter(A);}return this._footer;},_addOverlay:function(){this._overlay=new jplex.components.Overlay(this.UID+\"-overlay\",{color:this.cfg(\"overlayColor\"),z:this._level-1,fade:this.cfg(\"overlayFade\"),opacity:this.cfg(\"overlayOpacity\")});this._overlay.component.observe(\"click\",function(A){if(this.cfg(\"close\")==jplex.components.Frame.CLOSE_CLICK_OUT){this.hide();}A.stop();}.bind(this));},_addCloseButton:function(){var A=new Element(\"a\",{id:this.ID+\"-closecross\"});A.addClassName(\"close\").update(\"&nbsp;\");A.observe(\"click\",this.hide.bind(this));(this._header||this._body).appendChild(A);},_addHeader:function(A){var B=new Element(\"div\");this._title=new Element(\"div\");B.appendChild(this._title.addClassName(\"title\").update(A||\"\"));B.addClassName(\"header\");this.component.insert({top:B});this._header=B;},_addBody:function(A){var B=new Element(\"div\");B.addClassName(\"body\");if(this._header){this._header.insert({after:B});}else{if(this._footer){this._footer.insert({before:B});}else{this.component.insert(B);}}this._body=B;this.setBody(A);},_addFooter:function(A){var B=new Element(\"div\");B.addClassName(\"footer\").update(A||\"\");this.component.insert({bottom:B});this._footer=B;},reload:function(){this.setLoading(true);this._request=new Ajax.Request(this.cfg(\"ajax\"),{parameters:this.cfg(\"ajaxParameters\"),evalJS:false,onSuccess:function(A){this.setBody(A.responseText);}.bind(this)});},show:function(){if(this.cfg(\"modal\")){this._overlay.show();}if(this.cfg(\"constrainToCenter\")){this.makeCentered();Event.observe(window,\"scroll\",this._evtMakeCentered);Event.observe(window,\"resize\",this._evtMakeCentered);}this.component.show();this.fireEvent(\"onShowEvent\");},hide:function(){if(this.cfg(\"modal\")){this._overlay.hide();}this.component.hide();Event.stopObserving(window,\"scroll\",this._evtMakeCentered);Event.stopObserving(window,\"resize\",this._evtMakeCentered);this.fireEvent(\"onHideEvent\");},makeCentered:function(B){var D=this.component.getDimensions();var C=document.viewport.getDimensions();var A=document.viewport.getScrollOffsets();this.component.setStyle({top:Math.max(0,C.height/2-D.height/2+A.top)+\"px\",left:Math.max(0,C.width/2-D.width/2+A.left)+\"px\"});if(!B&&this._evtMakeCentered){this._evtMakeCentered.delay(0.1,true);}},setLoading:function(B){var A=this.component.down(\"div.loading\");if(B){if(!A){A=new Element(\"div\").addClassName(\"loading\");A.setStyle({zIndex:this._level+1});A.setOpacity(0.7);this.component.appendChild(A);}A.show();}else{if(A){A.hide();}}this.constrain();},constrain:function(){this._constrainToSize();if(this.cfg(\"center\")&&this.cfg(\"constrainToCenter\")){this.makeCentered();}if(this.cfg(\"constrainToViewport\")){this._constrainToViewport();}},_constrainToViewport:function(A,G){if(!this.cfg(\"constrainToViewport\")){return[A,G];}if(typeof(A)==\"undefined\"||typeof(G)==\"undefined\"){var F=this.component.cumulativeOffset();A=F.left;G=F.top;}var D=document.viewport.getWidth(),E=document.viewport.getHeight(),B=this.component.getWidth(),C=this.component.getHeight();return[B>D?0:(A<D-B?(A>0?A:0):D-B),C>E?0:(G<E-C?(G>0?G:0):E-C)];},_constrainToSize:function(){if(Prototype.Browser.Opera){return;}var E=this._body;var D={body:this._body.getDimensions(),frame:this.component.getDimensions()};D.fixed={width:D.frame.width-D.body.width,height:D.frame.height-D.body.height};var A=null,C=null,F=null,B=null;if(this.cfg(\"minWidth\")){A=Math.max(0,this.cfg(\"minWidth\")-D.fixed.width);E.setStyle({minWidth:A+\"px\"});}if(this.cfg(\"minHeight\")){C=Math.max(0,this.cfg(\"minHeight\")-D.fixed.height);E.setStyle({minHeight:C+\"px\"});}if(this.cfg(\"maxWidth\")){F=Math.max(0,this.cfg(\"maxWidth\")-D.fixed.width);this.component.setStyle({maxWidth:F+\"px\"});}if(this.cfg(\"maxHeight\")){B=Math.max(this.cfg(\"maxHeight\")-D.fixed.height);E.setStyle({maxHeight:B+\"px\"});}if(Prototype.Browser.IElt8){if(this.cfg(\"minWidth\")&&this.cfg(\"minWidth\")>D.frame.width){E.setStyle({width:A+\"px\"});}if(this.cfg(\"minHeight\")&&this.cfg(\"minHeight\")>D.frame.height){E.setStyle({height:C+\"px\"});}if(this.cfg(\"maxWidth\")&&this.cfg(\"maxWidth\")<D.frame.width){this.component.setStyle({width:F+\"px\"});}if(this.cfg(\"maxHeight\")&&this.cfg(\"maxHeight\")<D.frame.height){E.setStyle({height:B+\"px\"});}}}});jPlex.extend(\"jplex.components.Frame\",{list:$A([]),CLOSE_BUTTON:\"button\",CLOSE_CLICK_OUT:\"clickout\",CLOSE_CUSTOM:\"custom\"});";jPlex.src['jplex/components/frame/FrameSet.js']="jPlex.include(\"jplex.components.Frame\",false);jPlex.provide(\"jplex.components.frame.FrameSet\",\"jplex.common.Component\",{_definition:{name:\"FrameSet\",defaultConfig:{overlay:false,overlayColor:\"#000000\",overlayOpacity:0.6},events:{onAddFrameEvent:Prototype.emptyFunction},defaultContainer:\"div\"},initialize:function($super,B,A){$super(B,A);this.windows=$A([]);if(this.cfg(\"overlay\")){this.overlay=new jplex.components.Overlay(this.sID+\"-overlay\",{z:0,color:this.cfg(\"overlayColor\"),opacity:this.cfg(\"overlayOpacity\")});this.overlay.show();}},add:function(C){var A=typeof(C)==\"string\"?new jplex.components.Frame(C,{draggable:true}):C;var B=this.windows.length;A.show();this.windows.push(A);A.toFront=this._winToFront.methodize();A._group=this;A._groupPosition=B;A.component.setStyle({zIndex:B});A.component.observe(\"click\",A.toFront.bindAsEventListener(A));this.fireEvent(\"onAddFrameEvent\",{frame:A});return A;},_winToFront:function(A){var C;for(var B=A._groupPosition+1;B<A._group.windows.length;B++){C=A._group.windows[B].component.getStyle(\"zIndex\");A._group.windows[B-1]=A._group.windows[B];A._group.windows[B-1]._groupPosition--;A._group.windows[B-1].component.setStyle({zIndex:Math.max(0,C-1)});}A._group.windows[A._group.windows.length-1]=A;if(C){A.component.setStyle({zIndex:C});}A._groupPosition=A._group.windows.length-1;}});";jPlex.src['jplex/components/frame/Modal.js']="jPlex.provide(\"jplex.components.frame.Modal\",\"jplex.components.Frame\",{_extension:{name:\"Modal\",defaultConfig:{header:false,modal:true,close:jplex.components.Frame.CLOSE_CLICK_OUT}},initialize:function($super,B,A){A.modal=true;$super(B,A);}});";jPlex.src['jplex/components/menubar/MenuBar.js']="jPlex.include(\"jplex.components.menubar.MenuBarItem\",false);jPlex.provide(\"jplex.components.MenuBar\",\"jplex.common.Component\",{_definition:{name:\"MenuBar\",defaultConfig:{data:[],source:0},events:{beforeRenderEvent:Prototype.emptyFunction,afterRenderEvent:Prototype.emptyFunction,onClickEvent:Prototype.emptyFunction,onItemAddEvent:Prototype.emptyFunction},defaultContainer:\"div\"},initialize:function($super,B,A){$super(B,A);this.render();this._items=$A([]);this._getData().each(function(C){this.addItem(C);}.bind(this));document.observe(\"click\",function(C){C=Event.extend(window.event?window.event:C);if(!$(Event.element(C)).up(\"li.item\")){this.setActive(false);this.hide();}this.fireEvent(\"onClickEvent\",{event:C});}.bind(this));if(Prototype.Browser.IE6){$$(\"div.jplex-menubar ul.with-icon > li.item-with-icon\",\"div.jplex-menubar ul.with-icon > li.item-without-icon\").each(function(C){$(C).setStyle({paddingLeft:\"26px\"});});}},render:function(){this.fireEvent(\"beforeRenderEvent\");this.component.addClassName(\"jplex-menubar\");this.me=new Element(\"ul\");this.component.appendChild(this.getHTMLElement());this.fireEvent(\"afterRenderEvent\");},hide:function(){this._items.each(function(A){A.getSubmenu().hide();});},addItem:function(C,E){var D=new jplex.components.menubar.MenuBarItem(this,C,0);if(E){this.getHTMLElement().insertBefore(D.getHTMLElement(),this._items[E].getHTMLElement());var B=$A([]);for(var A=0;A<this._items.length;A++){if(A==E){B.push(D);}B.push(this._items[A]);}this._items=B.compact();}else{this.getHTMLElement().appendChild(D.getHTMLElement());this._items.push(D);}this.fireEvent(\"onItemAddEvent\",{item:D});return this;},removeItem:function(A){this.getHTMLElement().removeChild(this.getItem(A).getMenu().getHTMLElement());delete this._items[A];this._items=this._items.compact();},getItem:function(A){return this._items[A].getSubmenu();},getHTMLElement:function(){return this.me;},getRootMenuBar:function(){return this;},isActive:function(){return this._activate;},setActive:function(A){this._activate=A;},getItems:function(){return this._items;},_getData:function(){var A;if(jplex.components.MenuBar.SOURCE_JS_ARRAY==this.cfg(\"source\")){A=this.cfg(\"data\");}else{if(jplex.components.MenuBar.SOURCE_AJAX_XML==this.cfg(\"source\")){}else{if(jplex.components.MenuBar.SOURCE_AJAX_JSON==this.cfg(\"source\")){}}}return $A(A);}});jPlex.extend(\"jplex.components.MenuBar\",{SOURCE_JS_ARRAY:0,SOURCE_AJAX_XML:1,SOURCE_AJAX_JSON:2});";jPlex.src['jplex/components/menubar/MenuBarItem.js']="jPlex.include(\"jplex.components.menubar.MenuBarSubmenu\",false);jPlex.provide(\"jplex.components.menubar.MenuBarItem\",{initialize:function(B,A,C){this._level=C;this._label=A.name;this._event=A.click?A.click.bind(this):Prototype.emptyFunction;this._shortcut=A.shortcut;this._icon=A.icon;this._link=A.link;this._menu=B;this.render(A.items);this.me.observe(\"mouseover\",this._onMouseOver.bindAsEventListener(this));this.me.observe(\"click\",this._onClick.bindAsEventListener(this));if(this._shortcut){document.bindKey(this._shortcut.key,this._event.wrap(function(D){this.getMenu().getRootMenuBar().setActive(false);return D();}).bind(this),{ctrl:this._shortcut.ctrl,preventDefault:true});}},render:function(A){this.me=new Element(\"li\").update(this._label);if(this._link){this.me.observe(\"click\",function(){window.location=this._link;}.bind(this));}this.me.addClassName(this._level==0?\"first\":\"item\");var B;if(this._shortcut){B=new Element(\"span\");B.update(this._shortcut.text).addClassName(\"shortcut\");this.me.appendChild(B);}if(this._icon){this.getMenu().getHTMLElement().addClassName(\"with-icon\");if(Prototype.Browser.IE6){this.me.removeClassName(\"item\");this.me.addClassName(\"item-with-icon\");}else{this.me.addClassName(\"icon\");}this.me.setStyle({backgroundImage:\"url('\"+this._icon+\"')\"});}else{if(Prototype.Browser.IE6){this.me.removeClassName(\"item\");this.me.addClassName(\"item-without-icon\");}else{this.me.addClassName(\"no-icon\");}}this._submenu=new jplex.components.menubar.MenuBarSubmenu(this,A,this._level);this.me.appendChild(this.getSubmenu().getHTMLElement());this.me.appendChild(this._submenu._shadow);if(!this.getSubmenu().isEmpty()&&this._level!=0){this._addSubmenuIndicator();}if(Prototype.Browser.IE6){var C=\"ie6-item-hover\";if(this._level==0){C=\"ie6-first-hover\";}this.me.observe(\"mouseover\",function(){this.me.addClassName(C);}.bind(this));this.me.observe(\"mouseout\",function(){if(this.me.hasClassName(C)){this.me.removeClassName(C);}}.bind(this));}},getSubmenu:function(){return this._submenu;},getHTMLElement:function(){return this.me;},getMenu:function(){return this._menu;},getDetails:function(){return{label:this._label||\"\",icon:this._icon||false,shortcut:this._shortcut||false,link:this._link||false,level:this._level,event:this._event||false};},_addSubmenuIndicator:function(){if(this._level!=0){var A=new Element(\"span\");this.me.appendChild(A.addClassName(\"parent\"));}},_onMouseOver:function(A){A=Event.extend(window.event?window.event:A);if(!this.getMenu().getRootMenuBar().isActive()){A.cancelBubble=true;return;}this.getSubmenu().show();this.getMenu().getItems().each(function(B){if(B!==this){B.getSubmenu().hide();}}.bind(this));},_onClick:function(A){A=Event.extend(window.event?window.event:A);this._event();if(this._level==0){if($(Event.element(A).up(\"li.item\"))){return false;}else{this.getMenu().getRootMenuBar().setActive(true);A.cancelBubble=true;this.getSubmenu().show();}}else{A.cancelBubble=true;this.getMenu().getRootMenuBar().setActive(false);if(this.getSubmenu().isEmpty()){this.getMenu().getRootMenuBar().hide();}}}});";jPlex.src['jplex/components/menubar/MenuBarSubmenu.js']="jPlex.provide(\"jplex.components.menubar.MenuBarSubmenu\",{initialize:function(A,B,D){this._level=D;this._parent=A;this._items=$A([]);this.render();if(B){for(var C=0;C<B.length;C++){if(!B[C]||!B[C].name){continue;}this.addItem(B[C]);}}},render:function(){this.me=$(new Element(\"ul\"));this._shadow=$(new Element(\"div\"));this._shadow.setStyle({background:\"#000000\",zIndex:2*this._level,position:\"absolute\"}).setOpacity(0.2);this.me.addClassName(\"submenu\").setStyle({display:\"none\",zIndex:2*this._level+1});},show:function(){if(!this.isEmpty()&&!this.me.visible()){this.me.show();this._shadow.show();this._fixPosition();}},hide:function(){if(!this.isEmpty()&&this.me.visible()){this._items.each(function(A){A.getSubmenu().hide();});this.me.hide();this._shadow.hide();}},getHTMLElement:function(){return this.me;},isEmpty:function(){return this._items.length==0;},addItem:function(C,D){var C=new jplex.components.menubar.MenuBarItem(this,C,this._level+1);if(D){this.me.insertBefore(C.getHTMLElement(),this._items[D].getHTMLElement());var B=$A([]);for(var A=0;A<this._items.length;A++){if(A==D){B.push(C);}B.push(this._items[A]);}this._items=B.compact();}else{this.me.appendChild(C.getHTMLElement());this._items.push(C);}C.getMenu().getParentItem()._addSubmenuIndicator();this.getRootMenuBar().fireEvent(\"onItemAddEvent\",{item:C});return this;},getItem:function(A){var B=this._items[A];if(B){return this._items[A].getSubmenu();}else{return false;}},removeItem:function(A){var B=this.getItem(A);if(B){this.me.removeChild(B.getParentItem().getHTMLElement());delete this._items[A];this._items=this._items.compact();return this;}else{return false;}},getParentItem:function(){return this._parent;},getRootMenuBar:function(){var A=this.getParentItem().getMenu();if(A._level==0){return A.getParentItem().getMenu();}else{return A.getRootMenuBar();}},getItems:function(){return this._items;},_fixPosition:function(){var A=this.getParentItem().getHTMLElement();var D=A.positionedOffset();var C,B;if(this._level==0){C=D.top+A.getHeight();B=D.left;}else{C=D.top;B=D.left+A.getWidth();}this.me.setStyle({top:C+\"px\",left:B+\"px\"});this._shadow.setStyle({top:C+\"px\",left:(B-2)+\"px\",width:(this.me.getWidth()+4)+\"px\",height:(this.me.getHeight()+2)+\"px\"});}});";jPlex.src['jplex/components/mouseoverimage/MouseOverImage.js']="jPlex.provide(\"jplex.components.MouseOverImage\",\"jplex.common.Component\",{_definition:{name:\"MouseOverImage\",defaultConfig:{position:\"top-right\",style:false,img:false,method:\"absolute\",padding:4},events:{onClickEvent:Prototype.emptyFunction},defaultContainer:\"div\"},initialize:function($super,C,B){$super(C,B);var D;if(this.cfg(\"img\")){D=new Element(\"div\");D.appendChild(new Element(\"img\",{border:0,src:this.cfg(\"img\")}));}else{if(this.cfg(\"style\")){D=new Element(\"span\").update(\" \");}else{throw {message:\"Mandatory argument not provided\"};}}this.eImg=D;if(this.cfg(\"style\")){D.addClassName(this.cfg(\"style\"));}D.hide();this.component.insert({top:D});this.position=this._getPositionFromCfg();this._bindEvents();if(this.cfg(\"method\")==\"float\"){if(this.position[1]!=\"left\"&&this.position[1]!=\"right\"){throw {message:\"Wrong position given considering method 'float'\"};}var A=this.cfg(\"padding\")+\"px\";this.eImg.setStyle({cssFloat:this.position[1],position:\"relative\",top:A});if(this.position[1]==\"left\"){this.eImg.setStyle({left:A});}else{this.eImg.setStyle({right:A});}}else{this.eImg.setStyle({position:\"absolute\"});this.setPosition();}return this;},setPosition:function(){if(this.cfg(\"method\")!=\"absolute\"){return;}var B=!this.component.visible();if(B){this.component.show();}var E=this.component.getDimensions();var C=this.eImg.getDimensions();var A=[];var D=this.cfg(\"padding\");if(this.position[0]==\"top\"){A[0]=D;}else{if(this.position[0]==\"bottom\"){A[0]=E.height-C.height-D;}else{if(this.position[0]==\"center\"){A[0]=(E.height-C.height)/2;}}}if(this.position[1]==\"left\"){A[1]=D;}else{if(this.position[1]==\"right\"){A[1]=E.width-C.width-D;}else{if(this.position[1]==\"center\"){A[1]=(E.width-C.width)/2;}}}this.eImg.clonePosition(this.component,{setWidth:false,setHeight:false,offsetTop:A[0],offsetLeft:A[1]});if(B){this.component.hide();}},_getPositionFromCfg:function(){var A=[\"center\",\"center\"];var B=this.cfg(\"position\").split(\"-\");if(B.length==2){A=B;}else{B=B[0];if(B==\"top\"||B==\"bottom\"){A[0]=B;}else{A[1]=B;}}return A;},_bindEvents:function(){var A=this.eImg;if(this.getEvent(\"onClickEvent\")!==Prototype.emptyFunction){A.setStyle({cursor:\"pointer\"});A.observe(\"click\",this.getEvent(\"onClickEvent\"));}this.component.observe(\"mouseover\",function(){this.eImg.show();this.setPosition();}.bind(this));this.component.observe(\"mouseout\",function(){this.eImg.hide();}.bind(this));}});";jPlex.src['jplex/components/overlay/Overlay.js']="jPlex.provide(\"jplex.components.Overlay\",\"jplex.common.Component\",{_definition:{name:\"Overlay\",defaultConfig:{opacity:0.75,fade:false,z:1,color:\"#000000\",source:document.body},events:{beforeRenderEvent:Prototype.emptyFunction,afterRenderEvent:Prototype.emptyFunction,onShowEvent:Prototype.emptyFunction,onHideEvent:Prototype.emptyFunction},defaultContainer:\"div\"},initialize:function($super,B,A){$super(B,A);this.render();},render:function(){this.fireEvent(\"beforeRenderEvent\");if(!$(this.cfg(\"source\"))||this.cfg(\"source\")==document.body){if(Prototype.Browser.IE6){this.component.setStyle({top:0,left:0,position:\"absolute\"});var A=function(){var E=document.viewport.getDimensions();var D=document.viewport.getScrollOffsets();this.component.setStyle({width:E.width+\"px\",height:E.height+\"px\",top:D.top+\"px\",left:D.left+\"px\"});}.bind(this);Event.observe(window,\"resize\",A);Event.observe(window,\"scroll\",A);this.setEvent(\"IEonShowEvent\",A);}else{this.component.setStyle({position:\"fixed\",top:0,left:0,width:\"100%\",height:\"100%\",zIndex:this.cfg(\"z\"),background:this.cfg(\"color\")});}}else{this.component.clonePosition(this.cfg(\"source\"));this.component.setStyle({position:\"absolute\",zIndex:this.cfg(\"z\")});if(Prototype.Browser.IE){var B=document.viewport.getScrollOffsets();var C=this.component.cumulativeOffset();this.component.setStyle({top:(C.top+B.top)+\"px\",left:(C.left+B.left)+\"px\"});}}this.component.setStyle({zIndex:this.cfg(\"z\"),background:this.cfg(\"color\"),display:\"none\"});this.component.setOpacity(this.cfg(\"opacity\"));this.fireEvent(\"afterRenderEvent\");},show:function(){if(!this.cfg(\"fade\")){this.component.show();}else{new Effect.Appear(this.component,{duration:this.cfg(\"fade\"),to:this.cfg(\"opacity\")});}this.fireEvent(\"IEonShowEvent\");this.fireEvent(\"onShowEvent\");},hide:function(){if(!this.cfg(\"fade\")){this.component.hide();}else{new Effect.Fade(this.component,{duration:this.cfg(\"fade\")});}this.fireEvent(\"onHideEvent\");}});";jPlex.src['jplex/components/tabs/Tabs.js']="jPlex.provide(\"jplex.components.Tabs\",\"jplex.common.Component\",{_definition:{name:\"Tabs\",defaultConfig:{data:null,style:\"jplex-tabs\",method:\"div\",ajaxDiv:false,ajaxMethod:\"get\",ajaxReload:false,activeTab:0,events:{onSwitchEvent:Prototype.emptyFunction}},defaultContainer:\"ul\"},cache:$A(),initialize:function($super,D,C){$super(D,C);if(this.cfg(\"method\")!=\"div\"&&!this.cfg(\"ajaxDiv\")){throw\"Mandatory parameter 'ajaxDiv' not provided\";}this.aDefinition=$A(this.cfg(\"data\"));if(!this.aDefinition){throw\"Mandatory parameter 'data' not provided\";}this.component.addClassName(this.cfg(\"style\"));var A=this.cfg(\"activeTab\");this.aDefinition.each(function(G,F){var E=new Element(\"li\").update(G.title);if(F==A){this.oldLi=E;E.addClassName(this.cfg(\"style\")+\"-active\");this.activeTab=G.content;}E.observe(\"click\",this.handler.curry(G.content,E).bind(this));this.component.appendChild(E);}.bind(this));if(this.cfg(\"method\")==\"div\"){this.initDivMethod(this.aDefinition,A);}else{this.initAjaxMethod(this.aDefinition,A);}var B=this.cfg(\"ajaxDiv\");if(B){this.ajaxDiv=B;}},initDivMethod:function(B,A){B.each(function(C){$(C.content).hide();});$(B[A].content).show();},initAjaxMethod:function(B,A){this.handleAjaxMethod(B[A].content,false);},handler:function(C,A){var B=this.activeTab;if(B==C){return;}this.oldLi.removeClassName(this.cfg(\"style\")+\"-active\");this.activeTab=C;if(this.cfg(\"method\")==\"div\"){this.handleDivMethod(C,B);}else{if(this.cfg(\"method\")==\"ajax\"){this.handleAjaxMethod(C,B);}}this.fireEvent(\"onSwitchEvent\",{oldContent:B,newContent:C});A.addClassName(this.cfg(\"style\")+\"-active\");this.oldLi=A;},handleDivMethod:function(B,A){$(B).show();$(A).hide();},handleAjaxMethod:function(C,B){var A;if(!this.cfg(\"ajaxReload\")&&B){this.cache[B]=$(this.ajaxDiv).innerHTML;if(this.cache[C]){A=this.cache[C];}}if(!A){new Ajax.Request(C,{method:this.cfg(\"ajaxMethod\"),onSuccess:function(D){$(this.ajaxDiv).innerHTML=D.responseText;}.bind(this)});}else{$(this.ajaxDiv).innerHTML=A;}},getActiveTab:function(){return this.activeTab;}});";jPlex.src['jplex/components/tooltip/Tooltip.js']="jPlex.provide(\"jplex.components.Tooltip\",\"jplex.common.Component\",{_definition:{name:\"Tooltip\",defaultConfig:{source:null,content:\"\",position:\"top-right\",shadowWidth:1,trigger:\"mouseover\",positionRatio:0.83,zIndex:99},events:{onShowEvent:Prototype.emptyFunction,onHideEvent:Prototype.emptyFunction},defaultContainer:\"div\"},initialize:function($super,B,A){$super(B,A);this.render();if(this.cfg(\"trigger\")==jplex.components.Tooltip.TRIGGER_MOUSEOVER){this._source.observe(\"mouseover\",this.show.bindAsEventListener(this));this.component.observe(\"mouseover\",this.show.bindAsEventListener(this));this._source.observe(\"mouseout\",this.hide.bindAsEventListener(this));this.component.observe(\"mouseout\",this.hide.bindAsEventListener(this));}else{if(this.cfg(\"trigger\")==jplex.components.Tooltip.TRIGGER_CLICK){this._source.observe(\"click\",this.show.bindAsEventListener(this));document.observe(\"click\",function(D){var C=D.pointerX(),E=D.pointerY();if(!this._source.isWithin(C,E)&&!this.component.isWithin(C,E)){this.hide();}}.bindAsEventListener(this));}}},render:function(){if(this.cfg(\"source\")){this._source=$(this.cfg(\"source\"));}if(!this._source){this._source=$(this.component.id+\"-source\");}if(!this._source){this._source=$(document.body);}this.component.addClassName(\"jplex-tooltip\").setStyle({zIndex:this.cfg(\"zIndex\")+1});this._pin=new Element(\"div\");this._body=new Element(\"div\");this._shadow=new Element(\"div\");this._body.addClassName(\"body\");var A=this.cfg(\"position\");this._pin.addClassName(\"bubble-pin\");if(\"top-right\"==A){this._pin.addClassName(\"bubble-pin-tr\");}if(\"top-left\"==A){this._pin.addClassName(\"bubble-pin-tl\");}if(\"bottom-right\"==A){this._pin.addClassName(\"bubble-pin-br\");}if(\"bottom-left\"==A){this._pin.addClassName(\"bubble-pin-bl\");}this.component.appendChildren(this._body,this._pin);this._shadow.addClassName(\"jplex-tooltip-shadow\").addClassName(\"jplex-tooltip\");this._shadow.setOpacity(0.3);this._shadow.setStyle({padding:0,zIndex:this.cfg(\"zIndex\")});document.body.appendChild(this._shadow);this._fixShadow();this._fixPin();this._source.addClassName(\"jplex-bubbler\");this.setContent(this.cfg(\"content\"));this.hide();},setContent:function(A){this._body.update(A);this._fixShadow();this._fixPin();},getBody:function(){return this._body;},getSource:function(){return this._source;},setPosition:function(B,A){this.component.setStyle({top:B+\"px\",left:A+\"px\"});this._fixShadow();this._fixPin();},show:function(){this.component.show();this._shadow.show();var D=this._source.cumulativeOffset();var A=this.cfg(\"position\"),C=D.left,B=D.top;if(\"top-right\"==A){B=B-this.component.getHeight()-15;C+=Math.floor(this._source.getWidth()*this.cfg(\"positionRatio\"))-10;}else{if(\"top-left\"==A){B=B-this.component.getHeight()-15;C=C-(5*this.component.getWidth())/6+this._source.getWidth()*(1-this.cfg(\"positionRatio\"))-5;}else{if(\"bottom-left\"==A){B=B+this._source.getHeight()+15;C=C-(5*this.component.getWidth())/6+this._source.getWidth()*(1-this.cfg(\"positionRatio\"))-5;}else{if(\"bottom-right\"==A){B=B+this._source.getHeight();C+=Math.floor(this._source.getWidth()*this.cfg(\"positionRatio\"));}}}}this.setPosition(B,C);this._fixShadow();this.fireEvent(\"onShowEvent\");},hide:function(){this.component.hide();this._shadow.hide();this.fireEvent(\"onHideEvent\");},_fixShadow:function(){var A=this.component.cumulativeOffset();this._shadow.setStyle({width:(this.component.getWidth())+\"px\",height:(this.component.getHeight())+\"px\",top:(A.top+this.cfg(\"shadowWidth\")-1)+\"px\",left:(A.left+this.cfg(\"shadowWidth\")-1)+\"px\"});},_fixPin:function(){var D=this.cfg(\"position\"),C=0,B=0,A=this.component.getWidth();if(\"top-right\"==D){C=this.component.getHeight()-2;B=A;}else{if(\"top-left\"==D){C=this.component.getHeight()-2;B=Math.floor(5*A/6);}else{if(\"bottom-right\"==D){C=-20;B=A;}else{if(\"bottom-left\"==D){C=-20;B=Math.floor(5*A/6);}}}}this._pin.setStyle({top:C+\"px\",width:B+\"px\"});}});jPlex.extend(\"jplex.components.Tooltip\",{TRIGGER_MOUSEOVER:\"mouseover\",TRIGGER_CLICK:\"click\",TRIGGER_CUSTOM:\"custom\"});";jPlex.src['jplex/xprototype/_module.js']="";jPlex.src['jplex/xprototype/Core.js']="Ajax.Base.defaultMethod=\"post\";Ajax.Base.prototype.initialize=Ajax.Base.prototype.initialize.wrap(function(B,A){if(!A.method){A.method=Ajax.Base.defaultMethod;}B(A);});Object.extend(Prototype.Browser,{IE6:Prototype.Browser.IE&&navigator.userAgent.indexOf(\"MSIE 6.0\")!=-1,IE7:Prototype.Browser.IE&&navigator.userAgent.indexOf(\"MSIE 7.0\")!=-1,IE8:Prototype.Browser.IE&&navigator.userAgent.indexOf(\"MSIE 8.0\")!=-1,IElt8:Prototype.Browser.IE6||Prototype.Browser.IE7});var console;Logger={error:function(A){if(console&&console.error){console.error(\"[%s] %s\",A.name,A.message);}},warning:function(A){if(console&&console.warning){console.warning(A);}},log:function(A){if(console&&console.log){console.log(A);}}};";jPlex.src['jplex/xprototype/Date.js']="Object.extend(Date,{YEAR_OFFSET:Prototype.Browser.IE||Prototype.Browser.Opera?0:1900});Object.extend(Date.prototype,{locale:function(A){return Locale.current(\"Date\",A);},getMonthLength:function(){return this.lastDayOfMonth().getDate();},isLeapYear:function(){var A=this.getYear()+Date.YEAR_OFFSET;return A%4==0&&(A%100!=0||A%400==0);},firstDayOfMonth:function(){return new Date(Date.YEAR_OFFSET+this.getYear(),this.getMonth(),1);},lastDayOfMonth:function(){return new Date(Date.YEAR_OFFSET+this.getYear(),this.getMonth()+1,0,0);},setNextDay:function(){this.setDate(this.getDate()+1);return this;},setPreviousDay:function(){this.setDate(this.getDate()-1);return this;},compareTo:function(A){return this.getTime()-A.getTime();},format:function(C){var E=this;var B=new String(C);B=B.gsub(/\\\\./,\"\");B=B.gsub(/[^dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZ]/,\"\");var D=$A(B.toArray()).uniq();var A={};D.each(function(H,F){switch(H){case\"d\":A.d=E.getDate().toString().lpad(2,\"0\");break;case\"D\":A.D=Locale.get(\"Date\",\"en\").get(\"DAYS\")[E.getDay()];break;case\"j\":A.j=E.getDate().toString();break;case\"l\":A.l=Locale.get(\"Date\",\"en\").get(\"DAYS_SHORT\")[E.getDay()];break;case\"N\":A.N=E.getDay()==0?7:E.getDay()+1;break;case\"S\":var G=E.getDate();switch(G){case 1:A.S=\"st\";break;case 2:A.S=\"nd\";break;case 3:A.S=\"rd\";break;default:A.S=\"th\";break;}break;case\"w\":A.w=E.getDay();break;case\"z\":var I=new Date(E.getFullYear(),0,1);A.z=Math.round((E.getTime()-I.getTime())/86400000+0.5,0);break;case\"W\":var I=new Date(E.getFullYear(),0,1);A.z=Math.round((E.getTime()-I.getTime())/86400000+I.getDay()/7,0);break;case\"F\":A.F=Locale.get(\"Date\",\"en\").get(\"MONTHS\")[E.getMonth()];break;case\"m\":A.m=(E.getMonth()+1).toString().lpad(2,\"0\");break;case\"M\":A.M=Locale.get(\"Date\",\"en\").get(\"MONTHS_SHORT\")[E.getMonth()];break;case\"n\":A.n=(E.getMonth()+1).toString();break;case\"t\":A.t=E.getMonthLength();break;case\"L\":A.L=E.isLeapYear()?\"1\":\"0\";break;case\"o\":throw\"Unsupported option (not yet implemented)\";break;case\"Y\":A.Y=E.getFullYear();break;case\"y\":A.y=E.getFullYear().toString().substring(2);break;case\"a\":A.a=E.getHours()<13&&E.getHours()>0?\"am\":\"pm\";break;case\"A\":A.A=E.getHours()<13&&E.getHours()>0?\"AM\":\"PM\";break;case\"B\":throw\"Unsupported option (not yet implemented)\";break;case\"g\":A.g=((11+E.getHours())%12+1).toString();break;case\"G\":A.G=E.getHours().toString();break;case\"h\":A.h=((11+E.getHours())%12+1).toString().lpad(2,\"0\");break;case\"H\":A.H=E.getHours().toString().lpad(2,\"0\");break;case\"i\":A.i=E.getMinutes().toString().lpad(2,\"0\");break;case\"s\":A.s=E.getSeconds().toString().lpad(2,\"0\");break;case\"u\":throw\"Unsupported option (not yet implemented)\";break;case\"e\":var H=E.toString();A.e=/GMT[+\\-0-9]+/.exec(H);break;case\"I\":case\"0\":case\"P\":case\"T\":case\"Z\":default:throw\"Unsupported option (not yet implemented)\";break;}});D.each(function(F){C=C.gsub(F,\"##\"+F+\"##\");});D.each(function(G,F){C=C.gsub(\"##\"+G+\"##\",A[G]);});return C;}});";jPlex.src['jplex/xprototype/Element.js']="Element.addMethods({appendChildren:function(A){$A(arguments).each(function(B){if(B==this){return;}if(Object.isArray(B)){$A(B).each(function(C){this.appendChild(C);}.bind(this));}else{this.appendChild(B);}}.bind(A));return A;},removeChildren:function(A){while(A.childNodes.length>0){A.removeChild(A.childNodes[0]);}return A;},isWithin:function(B,A,E){var C=B.cumulativeOffset();C=[A-C[0],E-C[1]];var D=B.getDimensions();return C[0]<D.width&&C[0]>=0&&C[1]<D.height&&C[1]>=0;},bindKey:function(E,D,F,C){E=$(E);if(!C){C={};}if(!E._keyHandlers){E._keyHandlers=$A([]);}var A={ctrl:false,shift:false,alt:false,preventDefault:false};C=Object.extend(A,C);var B=D;if(C){if(C.ctrl){B+=\"-ctrl\";}if(C.alt){B+=\"-alt\";}if(C.shift){B+=\"-shift\";}}if(E._keyHandlers[B]){throw {name:\"KeyEventOverride\",message:\"Key code '\"+D+\"' is already bound with modifiers \"+Object.toJSON(C)};}E._keyHandlers[B]=function(G){F();return C.preventDefault;};if(E._keyEvents){E.stopObserving(\"keydown\",E._keyEvents);}E._keyEvents=function(J,I){J=Event.extend(window.event?event:J);var G=J.keyCode;if(J.ctrlKey){G+=\"-ctrl\";}if(J.altKey){G+=\"-alt\";}if(J.shiftKey){G+=\"-shift\";}if(E._keyHandlers[G]){var H=E._keyHandlers[G](J);if(H){J.stop();}}}.bindAsEventListener(E,F);E.observe(\"keydown\",E._keyEvents);return E;},unbindKey:function(D,C,B){D=$(D);var A=C;if(B){if(B.ctrl){A+=\"-ctrl\";}if(B.alt){A+=\"-alt\";}if(B.shift){A+=\"-shift\";}}D._keyHandlers[A]=null;return D;},IEFixCombobox:function(A){if(Prototype.Browser.IE6){A=$(A);var C=A.getStyle(\"z-index\")||0;var B=new Element(\"iframe\");B.setStyle({position:\"absolute\",top:\"0px\",left:\"0px\",width:\"100%\",zIndex:C-1}).setOpacity(0);A.appendChild(B);}}});Object.extend(document,{bindKey:Element.Methods.bindKey.methodize(),unbindKey:Element.Methods.unbindKey.methodize()});if(Prototype.Browser.IElt8){Element.addMethods({getOffsetParent:Element.Methods.getOffsetParent.wrap(function(B,A){var C=B(A);if(C.tagName.toLowerCase()==\"html\"){C=$(document.body);}return C;})});}";jPlex.src['jplex/xprototype/Event.js']="Object.extend(Event,{Key:{BACKSPACE:8,TAB:9,ENTER:13,SPACE:32,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESCAPE:27,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,INSERT:45,DELETE:46,K_0:48,K_1:49,K_2:50,K_3:51,K_4:52,K_5:53,K_6:54,K_7:55,K_8:56,K_9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LEFT_WINDOW:91,RIGHT_WINDOW:92,SELECT:93,NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_SUBTRACT:109,NUMPAD_POINT:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUM_LOCK:144,SCROLL_LOCK:145,SEMI_COLON:186,EQUAL_SIGN:187,COMMA:188,DASH:189,PERIOD:190,SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACKSLASH:220,CLOSE_BRACKET:221,SINGLE_QUOTE:222},onElementReady:function(A,B){Event._readyStack.push({element:A,handler:B,tries:Event._ready_POLL_LIMIT});if(!Event._readyObserver){Event._readyObserver=new PeriodicalExecuter(Event._readyObserverHandler,Event._ready_POLL_INTERVAL);}},_ready_POLL_LIMIT:800,_ready_POLL_INTERVAL:0.05,_readyStack:$A(),_readyObserver:null,_readyObserverHandler:function(){Event._readyStack.each(function(C,B){if(!C){return;}var A=$(C.element);if(A){C.handler.bind(A)();Event._readyStack[B]=null;}else{C.tries--;if(C.tries==0){Event._readyStack[B]=null;}}});Event._readyStack=Event._readyStack.compact();if(Event._readyStack.length==0){Event._readyObserver.stop();delete Event._readyObserver;}}});";jPlex.src['jplex/xprototype/Object.js']="Object.extendRecursive=function(A,C){for(var B in C){if(typeof(C[B])==\"object\"&&typeof(A[B])==\"object\"){A[B]=Object.extendRecursive(A[B],C[B]);}else{A[B]=C[B];}}return A;};";jPlex.src['jplex/xprototype/String.js']="Object.extend(String.prototype,{lpad:function(A,C){var B=this;if(!A||A<=B.length){return this;}if(!C){C=\" \";}while(B.length<A){B=C+\"\"+B;}return B;},rpad:function(A,C){var B=this;if(!A||A<=B.length){return this;}if(!C){C=\" \";}while(B.length<A){B+=C+\"\";}return B;}});";jPlex.src['jplex/xprototype/Xml.js']="";