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

var effectDuration;
	
function LightboxPress( options) {
	
	// Defaults
	var overlayOpacity = .8;
	effectDuration = 1;
	var width = 700;
	var height = 340;
	var top = 50;
	var flashId = 1;
	
	// 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="overlayPress" onclick="lfPress.stop()">&nbsp;</div>');
	$('overlayPress').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);
	$('overlayPress').setStyle({
		height: (newsize.height)+'px',
		width: (newsize.width)+'px',
		opacity: overlayOpacity
	});
	
	// Setup Lightbox
	document.writeln('<div id="lightboxPress">');
	// 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="lightboxPressContainer">');

	document.writeln('		<div id="lightboxPressClose">');
	document.writeln('			<a href="javascript: void(null)" onclick="lfPress.stop()">close</a>');
	document.writeln('		</div>');
	
	document.writeln('<input type="hidden" id="press-item-type" />');
	document.writeln('<input type="hidden" id="press-item-filename" />');
	
	document.writeln('		<div id="PressBox">');
	document.writeln('			<div id="player"></div>');
	document.writeln('		</div>');

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

LightboxPress.prototype = {
	start: function(elem) {	
		$('lightboxPress').setStyle({
			top: ($(elem).cumulativeScrollOffset()['top']+50)+'px'
		});
			
		new Effect.Appear('lightboxPress', {duration: effectDuration, beforeStart: function() {
			$('overlayPress').show();
			//Effect.ScrollTo('header');
		}});
			
	},
	stop: function() {
		
		//kill the object
		$('player').innerHTML = '';
		new Effect.Fade('lightboxPress', {duration: effectDuration, afterFinish: function() {
			$('overlayPress').hide();
		}});
	}
};

