
// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03
//	by Lokesh Dhakar - http://www.huddletogether.com
//	4/9/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.org), Thomas Fuchs(mir.aculo.us), and others.
//
//	Lightbox v2.03a
//	by Dynamicdrive.com- http://www.dynamicdrive.com
//	Nov 29th, 2007
//	Added ability for the caption ("title" attr of link) to be optionally hyperlinked, by throwing in a "rev" attr containing the desired link
// -----------------------------------------------------------------------------------
/*

	Table of Contents
	-----------------
	Configuration
	Global Variables

	Extending Built-in Objects	
	- Object.extend(Element)
	- Array.prototype.removeDuplicates()
	- Array.prototype.empty()

	Lightbox Class Declaration
	- initialize()
	- start()
	- changeImage()
	- resizeImageContainer()
	- showImage()
	- updateDetails()
	- updateNav()
	- enableKeyboardNav()
	- disableKeyboardNav()
	- keyboardAction()
	- preloadNeighborImages()
	- end()
	
	Miscellaneous Functions
	- getPageScroll()
	- getPageSize()
	- getKey()
	- listenKey()
	- showSelectBoxes()
	- hideSelectBoxes()
	- showFlash()
	- hideFlash()
	- pause()
	- initLightbox()
	
	Function Calls
	- addLoadEvent(initLightbox)
	
*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/loading.gif";		
var fileBottomNavCloseImage = "http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/closelabel.gif";

var animate = true;	// toggles resizing animations
var resizeSpeed = 7;	// controls the speed of the image resizing animations (1=slowest and 10=fastest)

var borderSize = 0;	//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

//
//	Global Variables
//
var imageArray = new Array;
var activeImage;

if(animate == true){
	overlayDuration = 0.2;	// shadow fade in/out duration
	if(resizeSpeed > 10){ resizeSpeed = 10;}
	if(resizeSpeed < 1){ resizeSpeed = 1;}
	resizeDuration = (11 - resizeSpeed) * 0.15;
} else { 
	overlayDuration = 0;
	resizeDuration = 0;
}

// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
		element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
		element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
		element.style.top = t +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//	- array.removeDuplicates()
//	- array.empty()
//
Array.prototype.removeDuplicates = function () {
    for(i = 0; i < this.length; i++){
        for(j = this.length-1; j>i; j--){        
            if(this[i][0] == this[j][0]){
                this.splice(j,1);
            }
        }
    }
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------

//
//	Lightbox Class Declaration
//	- initialize()
//	- start()
//	- changeImage()
//	- resizeImageContainer()
//	- showImage()
//	- updateDetails()
//	- updateNav()
//	- enableKeyboardNav()
//	- disableKeyboardNav()
//	- keyboardNavAction()
//	- preloadNeighborImages()
//	- end()
//
//	Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var Lightbox = Class.create();

Lightbox.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Loops through anchor tags looking for 
	// 'lightbox' references and applies onclick events to appropriate links. The 2nd section of
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		var areas = document.getElementsByTagName('area');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		// loop through all area tags
		// todo: combine anchor & area tag loops
		for (var i=0; i< areas.length; i++){
			var area = areas[i];
			
			var relAttribute = String(area.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				area.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		// The rest of this code inserts html at the bottom of the page that looks similar to this:
		//
		//	<div id="overlay"></div>
		//	<div id="lightbox">
		//		<div id="outerImageContainer">
		//			<div id="SponsorContainer">
		//				<img id="SponsorImage">
		//				<embed id="SponsorImage">
		//			</div>
		//			<div id="imageContainer">
		//				<img id="lightboxImage">
		//				<div style="" id="hoverNav">
		//					<a href="#" id="prevLink"></a>
		//					<a href="#" id="nextLink"></a>
		//				</div>
		//				<div id="loading">
		//					<a href="#" id="loadingLink">
		//						<img src="images/loading.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//		<div id="imageDataContainer">
		//			<div id="imageData">
		//				<div id="imageDetails">
		//					<span id="caption"></span>
		//					<span id="numberDisplay"></span>
		//				</div>
		//				<div id="bottomNav">
		//					<a href="#" id="bottomNavClose">
		//						<img src="images/close.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//	</div>


		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.onclick = function() { myLightbox.end(); }
		objBody.appendChild(objOverlay);
				
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
			if (!e) var e = window.event;
			var clickObj = Event.element(e).id;
			if ( clickObj == 'lightbox') {
				myLightbox.end();
			}
		};
		objBody.appendChild(objLightbox);
		
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		// When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.
		// If animations are turned off, it will be hidden as to prevent a flicker of a
		// white 250 by 250 box.
		if(animate){
			Element.setWidth('outerImageContainer', 250);
			Element.setHeight('outerImageContainer', 250);			
		} else {
			Element.setWidth('outerImageContainer', 1);
			Element.setHeight('outerImageContainer', 1);			
		}

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);
	
		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objImageContainer.appendChild(objLoading);
		
		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objImageDataContainer.className = 'clearfix';
		objLightbox.appendChild(objImageDataContainer);

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);
		
		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);
	
		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
	
		var objBottomNavCloseImage = document.createElement("img");
		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);

//	start sponsor div
		var objSponsorContainer = document.createElement("div");
		objSponsorContainer.setAttribute('id','SponsorContainer');
		objSponsorContainer.className = 'clearfix';
		objLightbox.appendChild(objSponsorContainer);

		if (navigator.appVersion.indexOf("MSIE")==-1){
			//alert("running the flash code");

			// non-IE browsers get flash sponsors

			var objSponsorImage1 = document.createElement("img");
			objSponsorImage1.setAttribute('id','SponsorImage1');
			objSponsorImage1.setAttribute('align','middle');

			if (document.title.search("1988") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-1988.png');
			} else if (document.title.search("1990") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-1990.png');
			} else if (document.title.search("1992") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-1992.png');
			} else if (document.title.search("1994") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-1994.png');
			} else if (document.title.search("1996") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-1996.png');
			} else if (document.title.search("1998") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-1998.png');
			} else if (document.title.search("2000") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2000.png');
			} else if (document.title.search("2002") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2002.png');
			} else if (document.title.search("2004") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2004.png');
			} else if (document.title.search("2006") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2006.png');
			} else if (document.title.search("2007") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2007.png');
			} else if (document.title.search("2008") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2008.png');
			} else {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo-2009.png');
			}
			//objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP-Logo---outer-glow.png');
			objSponsorContainer.appendChild(objSponsorImage1);
			objSponsorContainer.style.zIndex = 1;
			
			var objLineBreakElement1 = document.createElement("br");
			objSponsorContainer.appendChild(objLineBreakElement1);
			
			
			var objSponsorFlashObject = document.createElement("object");
			objSponsorFlashObject.setAttribute('classid','clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
			objSponsorFlashObject.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0');
			objSponsorContainer.appendChild(objSponsorFlashObject);

			var objSponsorFlashParam1 = document.createElement("param");
			objSponsorFlashParam1.setAttribute('movie','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP_sponsors_final.swf');
			objSponsorFlashObject.appendChild(objSponsorFlashParam1);

			var objSponsorFlashParam2 = document.createElement("param");
			objSponsorFlashParam2.setAttribute('quality','transparent');
			objSponsorFlashObject.appendChild(objSponsorFlashParam2);

			var objSponsorFlashEmbed = document.createElement("embed");
			objSponsorFlashEmbed.setAttribute('id','SponsorImage2');
			objSponsorFlashEmbed.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/MP_sponsors_final.swf');
			objSponsorFlashEmbed.setAttribute('quality','high');
			objSponsorFlashEmbed.setAttribute('wmode','transparent');
			objSponsorFlashEmbed.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer');
			objSponsorFlashEmbed.setAttribute('type','application/x-shockwave-flash');
			objSponsorFlashObject.appendChild(objSponsorFlashEmbed);
			
		} else {
			//alert("running the image code");

			// no flash sponsors for IE
			var objSponsorImage1 = document.createElement("img");
			objSponsorImage1.setAttribute('id','SponsorImage1');
			objSponsorImage1.setAttribute('align','middle');

			if (document.title.search("1988") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-1988.png');
			} else if (document.title.search("1990") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-1990.png');
			} else if (document.title.search("1992") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-1992.png');
			} else if (document.title.search("1994") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-1994.png');
			} else if (document.title.search("1996") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-1996.png');
			} else if (document.title.search("1998") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-1998.png');
			} else if (document.title.search("2000") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2000.png');
			} else if (document.title.search("2002") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2002.png');
			} else if (document.title.search("2004") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2004.png');
			} else if (document.title.search("2006") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2006.png');
			} else if (document.title.search("2007") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2007.png');
			} else if (document.title.search("2008") > 0) {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2008.png');
			} else {
				objSponsorImage1.setAttribute('src','http://www.moranprizes.com.au/ContentFiles/MoranPrizes/Images/DMNPP-Sponsors-2009.png');
			}
			objSponsorContainer.style.zIndex = -1;
			objSponsorContainer.appendChild(objSponsorImage1);
			
		} 

//	end sponsor div

	},
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {

		function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
			var ddimageTitle=anchor.getAttribute('title')
			var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
			return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>' : ddimageTitle
		};

		hideSelectBoxes();
		//hideFlash();
		if (document.getElementById("divFlash")) {
			document.getElementById("divFlash").style.visibility = "hidden";
		}

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		maxImageHeight = arrayPageSize[3];
		Element.setHeight('overlay', arrayPageSize[1]);
		
		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: 0.8 });

		imageArray = [];
		imageNum = 0;

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');

		// if image is NOT part of a set..
		if((imageLink.getAttribute('rel') == 'lightbox')){
			// add single image to imageArray
			imageArray.push(new Array(imageLink.getAttribute('href'), getImageTitle(imageLink)));			
		} else {
		// if image is part of a set..

			// loop through anchors, find other images in set, and add them to imageArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('href'), getImageTitle(anchor)));
				}
			}
			imageArray.removeDuplicates();
			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
		}

		// calculate top offset for the lightbox and display 
		var arrayPageScroll = getPageScroll();
		//var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxTop = arrayPageScroll[1]; // + 10;

		Element.setTop('lightbox', lightboxTop);
		Element.show('lightbox');
		
		this.changeImage(imageNum);
	},

	//
	//	changeImage()
	//	Hide most elements and preload image in preparation for resizing image container.
	//
	changeImage: function(imageNum) {	
		
		activeImage = imageNum;	// update global var

		// hide elements during transition
		if(animate){ Element.show('loading');}
		Element.hide('lightboxImage');
		Element.hide('hoverNav');
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('imageDataContainer');
//		Element.hide('SponsorImage1');
//		Element.hide('SponsorImage2');
		Element.hide('numberDisplay');
		
		imgPreloader = new Image();
		
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

	//
	//	resizeImageContainer()
	//
	resizeImageContainer: function( imgWidth, imgHeight) {

		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();

		//alert("window = " + arrayPageSize[2] + "x" + arrayPageSize[3]);
		maxImageHeight = (arrayPageSize[3] - 38);
		maxImageWidth = (arrayPageSize[2] - 30);
		
		//alert("imgHeight = " + imgHeight + "\nmaxImageHeight = " + maxImageHeight + "\nRatio = " + (imgHeight / maxImageHeight));
		//alert("imgWidth = " + imgWidth + "\nmaxImageWidth = " + maxImageWidth + "\nRatio = " + (imgWidth / maxImageWidth));
		if((imgHeight / maxImageHeight) > (imgWidth / maxImageWidth)) {
			// resize using height as the constrainer
			//alert("forcing height to " + maxImageHeight + " (original is " + imgHeight + ").");
			imgWidth = (imgWidth / imgHeight) * maxImageHeight;
			imgHeight = maxImageHeight;
		} else {
			// resize using width as the constrainer
			//alert("forcing width to " + maxImageWidth + " (original is " + imgWidth + ").");
			imgHeight = (imgHeight / imgWidth) * maxImageWidth;
			imgWidth = maxImageWidth;
		}

//		if((imgWidth > maxImageWidth) && (imgHeight > maxImageHeight)){
//			// both exceed max, find which exceeds by more and use that to fit
//			if((imgHeight / maxImageHeight) > (imgWidth / maxImageWidth)) {
//				// resize using height as the constrainer
//				//alert("Height and Width both exceed max. \nHeight ratio is " + (imgHeight / maxImageHeight) + "\nWidth ratio is " + (imgWidth / maxImageWidth) + ".\nGoing with Height.");
//				imgWidth = (imgWidth / imgHeight) * maxImageHeight;
//				imgHeight = maxImageHeight;
//			} else {
//				// resize using width as the constrainer
//				//alert("Height and Width both exceed max. \nHeight ratio is " + (imgHeight / maxImageHeight) + "\nWidth ratio is " + (imgWidth / maxImageWidth) + ".\nGoing with Width.");
//				imgHeight = (imgHeight / imgWidth) * maxImageWidth;
//				imgWidth = maxImageWidth;
//			}
//		} else if (imgWidth > maxImageWidth) {
//			// resize by width
//			//alert("Width exceeds max(" + maxImageWidth + "). Old resolution = " + imgWidth + "x" + imgHeight);
//			imgHeight = (imgHeight / imgWidth) * maxImageWidth;
//			imgWidth = maxImageWidth;
//			//alert("new = " + imgWidth + "x" + imgHeight);
//		} else if (imgHeight > maxImageHeight) {
//			// resize by height
//			//alert("Height exceeds max(" + maxImageHeight + "). Old resolution = " + imgWidth + "x" + imgHeight + ".");
//			imgWidth = (imgWidth / imgHeight) * maxImageHeight;
//			imgHeight = maxImageHeight;
//			//alert("new image = " + imgWidth + "x" + imgHeight);
//		} else {
//			//no resizing required
//			//alert("Height and Width are OK.");
//		}
		
		Element.setHeight('lightboxImage', imgHeight);
		Element.setWidth('lightboxImage', imgWidth);

		// get curren width and height
		this.widthCurrent = Element.getWidth('outerImageContainer');
		this.heightCurrent = Element.getHeight('outerImageContainer');

		var widthNew = (imgWidth + (borderSize * 2));
		var heightNew = (imgHeight + (borderSize * 2));
		
		// scalars based on change from old to new
		this.xScale = (widthNew / this.widthCurrent) * 100;
		this.yScale = (heightNew / this.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = this.widthCurrent - widthNew;
		hDiff = this.heightCurrent - heightNew;

		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);
		Element.setWidth('imageDataContainer', widthNew);

		this.showImage();
	},
	
	//
	//	showImage()
	//	Display image and begin preloading neighbors.
	//
	showImage: function(){
		Element.hide('loading');
		new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
		this.preloadNeighborImages();
	},

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//

	updateDetails: function() {
	
		Element.show('caption');
		Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
		
		// if image is part of set display 'Image x of x' 
		//if(imageArray.length > 1){
		//	Element.show('numberDisplay');
		//	Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
		//}
		var pageid = gup('id');
            if(pageid == "112"){
              Element.show('numberDisplay');
		  Element.setInnerHTML( 'numberDisplay', "");
            } else {
              Element.show('numberDisplay');
		  Element.setInnerHTML( 'numberDisplay', "Doug Moran National Portrait Prize");
            }


		new Effect.Parallel(
			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
			{ duration: resizeDuration, afterFinish: function() {
				// update overlay size and update nav
				var arrayPageSize = getPageSize();
				Element.setHeight('overlay', arrayPageSize[1]);
				myLightbox.updateNav();
				}
			} 
		);

		//showFlash();
		//Element.show('SponsorImage1');
		//new Effect.Parallel(
		//	[ new Effect.SlideDown( 'SponsorImage1', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
		//	  new Effect.Appear('SponsorImage1', { sync: true, duration: resizeDuration }) ], 
		//	{ duration: resizeDuration, afterFinish: function() {}
		//	} 
		//);
		//Element.show('SponsorImage2');
		//new Effect.Parallel(
		//	[ new Effect.SlideDown( 'SponsorImage2', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
		//	  new Effect.Appear('SponsorImage2', { sync: true, duration: resizeDuration }) ], 
		//	{ duration: resizeDuration, afterFinish: function() {}
		//	} 
		//);

	},

	//
	//	updateNav()
	//	Display appropriate previous and next hover navigation.
	//
	updateNav: function() {

		Element.show('hoverNav');		
		// if not first image in set, display prev image button
		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		// if not last image in set, display next image button
		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		this.enableKeyboardNav();
	},

	//
	//	enableKeyboardNav()
	//
	enableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	//
	//	disableKeyboardNav()
	//
	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	//
	//	keyboardAction()
	//
	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
			escapeKey = 27;
		} else { // mozilla
			keycode = e.keyCode;
			escapeKey = e.DOM_VK_ESCAPE;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
			myLightbox.end();
		} else if((key == 'p') || (keycode == 37)){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}

	},

	//
	//	preloadNeighborImages()
	//	Preload previous and next images.
	//
	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	//
	//	end()
	//
	end: function() {
		this.disableKeyboardNav();
		Element.hide('lightbox');
		new Effect.Fade('overlay', { duration: overlayDuration});
		showSelectBoxes();
		//showFlash();
		var pageid = gup('id');
            if (pageid == 12){
              document.getElementById("divFlash").style.visibility = "visible";
            }
		
	}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	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){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	
// ---------------------------------------------------

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i != flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embeds");
	for (i = 0; i != flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i != flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embeds");
	for (i = 0; i != flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}


// ---------------------------------------------------

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Help from Ran Bar-On [ran2103@gmail.com]
//

function pause(ms){
	var date = new Date();
	curDate = null;
	do{var curDate = new Date();}
	while( curDate - date < ms);
}
/*
function pause(numberMillis) {
	var curently = new Date().getTime() + sender;
	while (new Date().getTime();	
}
*/
// ---------------------------------------------------

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function initLightbox() { myLightbox = new Lightbox(); }
Event.observe(window, 'load', initLightbox, false);


/* 
 * flowplayer.js 3.2.3. The Flowplayer API
 * 
 * Copyright 2009 Flowplayer Oy
 * 
 * This file is part of Flowplayer.
 * 
 * Flowplayer 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 3 of the License, or
 * (at your option) any later version.
 * 
 * Flowplayer 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 Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Date: 2010-08-10 10:12:09 +0000 (Tue, 10 Aug 2010)
 * Revision: 539 
 */
(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,F,t){var w=this,v=null,C=false,u,s,E=[],y={},x={},D,r,p,B,o,z;i(w,{id:function(){return D},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!C)},getParent:function(){return q},hide:function(G){if(G){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=z+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(I){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var G=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(F.version)){q.innerHTML=""}flashembed(q,F,{config:t});if(I){I.cached=true;j(x,"onLoad",I)}};var H=0;m(a,function(){this.unload(function(J){if(++H==a.length){G()}})})}return w},unload:function(I){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(I){I(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(I){I(false)}return w}C=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(G){}var H=function(){v=null;q.innerHTML=u;C=false;if(I){I(true)}};setTimeout(H,50)}else{if(I){I(false)}}return w},getClip:function(G){if(G===undefined){G=B}return E[G]},getCommonClip:function(){return s},getPlaylist:function(){return E},getPlugin:function(G){var I=y[G];if(!I&&w.isLoaded()){var H=w._api().fp_getPlugin(G);if(H){I=new l(G,H,w);y[G]=I}}return I},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(G){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(G){return G?k(t):t},getFlashParams:function(){return F},loadPlugin:function(J,I,L,K){if(typeof L=="function"){K=L;L={}}var H=K?e():"_";w._api().fp_loadPlugin(J,I,L,H);var G={};G[H]=K;var M=new l(J,null,w,G);y[J]=M;return M},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(H,G){var I=function(){if(H!==undefined){w._api().fp_play(H,G)}else{w._api().fp_play()}};if(w.isLoaded()){I()}else{if(C){setTimeout(function(){w.play(H,G)},50)}else{w.load(function(){I()})}}return w},getVersion:function(){var H="flowplayer.js 3.2.3";if(w.isLoaded()){var G=v.fp_getVersion();G.push(H);return G}return H},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(G){w.setPlaylist([G]);return w},getIndex:function(){return p}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var G="on"+this;if(G.indexOf("*")!=-1){G=G.slice(0,G.length-1);var H="onBefore"+G.slice(2);w[H]=function(I){j(x,H,I);return w}}w[G]=function(I){j(x,G,I);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var G=this;w[G]=function(I,H){if(!w.isLoaded()){return w}var J=null;if(I!==undefined&&H!==undefined){J=v["fp_"+G](I,H)}else{J=(I===undefined)?v["fp_"+G]():v["fp_"+G](I)}return J==="undefined"||J===undefined?w:J}});w._fireEvent=function(P){if(typeof P=="string"){P=[P]}var Q=P[0],N=P[1],L=P[2],K=P[3],J=0;if(t.debug){g(P)}if(!w.isLoaded()&&Q=="onLoad"&&N=="player"){v=v||c(r);o=v.clientHeight;m(E,function(){this._fireEvent("onLoad")});m(y,function(R,S){S._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(Q=="onLoad"&&N!="player"){return}if(Q=="onError"){if(typeof N=="string"||(typeof N=="number"&&typeof L=="number")){N=L;L=K}}if(Q=="onContextMenu"){m(t.contextMenu[N],function(R,S){S.call(w)});return}if(Q=="onPluginEvent"||Q=="onBeforePluginEvent"){var G=N.name||N;var H=y[G];if(H){H._fireEvent("onUpdate",N);return H._fireEvent(L,P.slice(3))}return}if(Q=="onPlaylistReplace"){E=[];var M=0;m(N,function(){E.push(new h(this,M++,w))})}if(Q=="onClipAdd"){if(N.isInStream){return}N=new h(N,L,w);E.splice(L,0,N);for(J=L+1;J<E.length;J++){E[J].index++}}var O=true;if(typeof N=="number"&&N<E.length){B=N;var I=E[N];if(I){O=I._fireEvent(Q,L,K)}if(!I||O!==false){O=s._fireEvent(Q,L,K,I)}}m(x[Q],function(){O=this.call(w,N,L);if(this.cached){x[Q].splice(J,1)}if(O===false){return false}J++});return O};function A(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}z=parseInt(q.style.height,10)||q.clientHeight;D=q.id||"fp"+e();r=F.id||D+"_api";F.id=r;t.playerId=D;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var H=0;m(t.playlist,function(){var J=this;if(typeof J=="object"&&J.length){J={url:""+J}}m(t.clip,function(K,L){if(L!==undefined&&J[K]===undefined&&typeof L!="function"){J[K]=L}});t.playlist[H]=J;J=new h(J,H,w);E.push(J);H++});m(t,function(J,K){if(typeof K=="function"){if(s[J]){s[J](K)}else{j(x,J,K)}delete t[J]}});m(t.plugins,function(J,K){if(K){y[J]=new l(J,K,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function I(J){if(/iPad|iPhone/.test(navigator.userAgent)&&!/.flv$/i.test(E[0].url)&&w.ipad===undefined){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(J)}function G(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",I,false)}else{if(q.attachEvent){q.attachEvent("onclick",I)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}setTimeout(G,0)}if(typeof q=="string"){flashembed.domReady(function(){var G=c(q);if(!G){throw"Flowplayer cannot access element: "+q}else{q=G;A()}})}else{A()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(n){try{var l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=l&&l.GetVariable("$version")}catch(m){}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.3"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();
