var i;
var contentDivVisible = 1;

window.addEvent('domready', function() {
	
	$('img1').set('opacity', 0);
	if (JSRunSlider == 1) {
		$('contentDivSlider').set('opacity', 0); 
		i = setTimeout("doPageAnim()", 500);
		}
	else {
		if (1 != JSPageTo) { 
			$('contentDivSlider').set('opacity', 0.8); 
			$('contentDivSlider').setStyle('left', 0);
			}
		else
			{
			$('contentDivSlider').set('opacity', 0); 
			$('contentDivSlider').setStyle('left', -440);			
			}
		doImageFade();
		}
	
	if (1 != JSPageTo) { 
		$('contentReveal').set('opacity', 0);
		$('img1').addEvent('click', function(e) { e.stop(); slideAndHide(); });	
		$('contentReveal').addEvent('click', function(e) { e.stop(); slideAndHide(); });
		}
		
});

function doPageAnim() {
	clearTimeout(i);
	doImageFade();
	if (1 != JSPageTo) { i = setTimeout("doContentSlide()", 750); }
	}
	

function slideAndHide() {
	var cd = new Fx.Morph('contentDivSlider', {duration: 800, transition: Fx.Transitions.Sine.easeOut});
	cd.addEvent('onComplete', function(e) { if (contentDivVisible == 0) {	$('contentReveal').fade('in'); } });
	var startLeft = -400;
	var endLeft = 0;
	var startOpacity = 0;
	var endOpacity = 0.80;
	
	if (contentDivVisible == 1) {		// slide left and fade out
		startLeft = 0;				endLeft = -400;
		startOpacity = 0.80;		endOpacity = 0;	
		contentDivVisible = 0;
		}
	else {									// slide right and fade in (use default settings)
		contentDivVisible = 1;
		$('contentReveal').fade('out');
		}	
		
	// run the animation
	cd.start({'left': [startLeft, endLeft], 'opacity': [startOpacity, endOpacity] });

	}
	
function doContentSlide() {
	clearTimeout(i);
	var cd = new Fx.Morph('contentDivSlider', {duration: 800, transition: Fx.Transitions.Sine.easeOut});
	cd.start({'left': [-400, 0], 'opacity': [0, 0.80]});
	}
	
function doImageFade() {
	$('img1').fade('in');
	$('img2').fade('out');
	}

