/*
Lightbox Slideshow
Author: Paul Sayre
Date: 2007-01-22

Creates a Lightbox-like slideshow with an array as input.

To create, follow this syntax:
<script>
	var lsi = [];
	lsi[lsi.length] = {full: 'images/3f44f68c1132ea03.jpg', thumb: 'images/3f44f68c1132ea03_t.jpg', caption: 'Mt. Rainier'};
	lsi[lsi.length] = {full: 'images/8c435b46019ae88f.jpg', thumb: 'images/8c435b46019ae88f_t.jpg', caption: 'Prairy'};
	lsi[lsi.length] = {full: 'images/315e770c4ba54f19.jpg', thumb: 'images/315e770c4ba54f19_t.jpg', caption: 'Pine Cones'};
	lsi['close'] = 'images/closelabel.gif';	// or false if no button
	lsi['prev'] = 'images/prevlabel.gif';	// or false if no button
	lsi['next'] = 'images/nextlabel.gif';	// or false if no button
	
	// All these are optional. If not set, it uses defaults.
	var options = {duration: .5, top: 100, width: 800, first: 0, opacity: .8};
	
	// Needs to be varible ls
	var ls = new LightboxSlideshow(lsi, options);
</script>
*/

var effectDuration;
function LightboxFlash( options) {
	
	// Defaults
	var overlayOpacity = .8;
	effectDuration = 1;
	var width = 1024;
	var height = 600;
	var top = 50;
	
	// Options
	if(options) {
		if(Object.isNumber(options.width)) width = options.width;
		if(Object.isNumber(options.height)) height = options.height;
		if(Object.isNumber(options.top)) top = options.top;
		if(Object.isNumber(options.duration)) effectDuration = options.duration;
		if(Object.isNumber(options.opacity)) overlayOpacity = options.opacity;
	}
	
	// Setup Overlay
	document.writeln('<div id="overlayFlash" onclick="lf.stop()">&nbsp;</div>');
	$('overlayFlash').hide();
	var vpsize = document.viewport.getDimensions();
	var docsize = $$('body')[0].getDimensions();
	var newsize = {
		height: vpsize.height > docsize.height ? vpsize.height : docsize.height,
		width: vpsize.width > docsize.width ? vpsize.width : docsize.width
	};
	//alert(height);
	$('overlayFlash').setStyle({
		height: (newsize.height)+'px',
		width: (newsize.width)+'px',
		opacity: overlayOpacity
	});
	
	// Setup Lightbox
	document.writeln('<div id="lightboxFlash">');
	// Cache Images
	/*for(var i=0; i<imgs.length; i++) {
		document.writeln('	<img id="lightboxImage'+i+'" src="'+imgs[i].full+'" style="display:none;" />');
	}*/
	document.writeln('	<div id="lightboxFlashContainer">');

	document.writeln('		<div id="lightboxFlashClose">');
	document.writeln('			<img src="'+btnClose+'" onclick="lf.stop()" /></a>');
	document.writeln('		</div>');
	
	document.writeln('		<div id="flashBox">');
	document.writeln('			<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="980" height="551" id="ION_Final" align="middle">');
	document.writeln('				<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('				<param name="allowFullScreen" value="false" />');
	document.writeln('				<param name="movie" value="flash/ION_Final.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed id="ION_Final" src="flash/ION_Final.swf" quality="high" bgcolor="#ffffff" width="980" height="551" name="ION_Final" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('			</object>');
	document.writeln('		</div>');

	document.writeln('	</div>');
	document.writeln('</div>');
	
	$('lightboxFlash').hide();	
	$('lightboxFlash').setStyle({
		left: (vpsize.width-width)/2+'px',
		top: top+'px',
		width: width+'px'
	});
	
}

LightboxFlash.prototype = {
	start: function() {
		if (document.all)
		{
			document.getElementById('ION_Final').Rewind();
		}
		new Effect.Appear('lightboxFlash', {duration: effectDuration, beforeStart: function() {
			$('overlayFlash').show();
			Effect.ScrollTo('header');
		}});
		if (document.all)
		{
			document.getElementById('ION_Final').Play();
		}
	},
	stop: function() {
		if (document.all)
		{
			document.getElementById('ION_Final').StopPlay();
		}
		new Effect.Fade('lightboxFlash', {duration: effectDuration, afterFinish: function() {
			$('overlayFlash').hide();
			
		}});
	}
};

	