var homeFadeDuration = 500;
var homeSlideShow = null;

function homeInitSlideShow() {
	homeSlideShow = new gallery( $('home-slideshow'), {
		timed: true,
		delay: 2500,
		fadeDuration: 700,
		showArrows: false,
		showCarousel: false,
		embedLinks: false,
		useHistoryManager: false,
		useThumbGenerator: false,
		showInfopane: true,
		slideInfoZoneSlide: false,
		titleSelector: "span",
		slideInfoZoneOpacity: 0
	} );
}

function homeGallery() {
	if(window.location.hash != '') {
		$('content-wrapper').style.height = 'auto';
		$('content-wrapper').style.overflow = 'visible';
		$('home-content').style.display = 'none';
		$('content').style.display = 'block';
		//$('home-content').dispose();
		$('content').set( 'morph', { duration: 10, onComplete: function() { 
			pausePolling = false;
			contentDispatch(); 
		} } );
		$('content').morph( { 'opacity': [1, 1] } );
		return;
	}
	
	homeInitSlideShow();
	
	$('home-slideshow').style.visibility = 'visible';
	$('home-slideshow').style.display = 'block';
}

function homeShowSite(action) {
	if ( action == undefined ) action = function() { };
	if ( homeSlideShow != null ) homeSlideShow.clearTimer();
	
	$('home-content').set('morph', { duration: homeFadeDuration, transition: Fx.Transitions.linear, 
		onComplete: function() {
			$('content-wrapper').style.height = 'auto';
			$('content-wrapper').style.overflow = 'visible';
			$('home-content').style.display = 'none';
			//$('home-content').dispose();
			
			$('content').set( 'morph', { duration: homeFadeDuration, transition: Fx.Transitions.linear,
				onComplete: function() {
					if(currentIdx >= 0) updateHash($$('.togglers')[currentIdx].getElements('a')[0]);
					action.run();
					pausePolling = false;
				}
			} );
			$('content').style.display = 'block';
			$('logo').style.display = 'block';
			$('content').morph( { 'opacity': [0, 1] } );
		} 
	} );
	$('home-content').morph( { opacity: [1, 0] } );
	
	//homeSlideShow.prepareTimer();
}

function homeHideSite(action) {
	if ( action == undefined ) action = function() { };
	homeSlideShow.flushGallery();
	
	$('content').set( 'morph', { duration: homeFadeDuration, transition: Fx.Transitions.linear,
		onComplete: function() {
			$('content-wrapper').style.height = 'auto';
			$('content-wrapper').style.overflow = 'visible';
			$('content').style.display = 'none';
			
			$('home-content').set('morph', { duration: homeFadeDuration, transition: Fx.Transitions.linear,			
				onComplete: function() {
					homeInitSlideShow();
					action.run();
					pausePolling = false;
				}
			} );
			$('home-content').style.display = 'block';
			$('home-content').morph( { 'opacity': [0, 1] } );
		} 
	} );
	$('content').morph( { opacity: [1, 0] } );
	
	//homeSlideShow.prepareTimer();
}

function goHome() { window.location.href="/"; }