/* events.js */

<!-- begin script

// global variables
var lastAlbumId = "";
var text_desc = new Array( "main_text", "help_text" );

// Permalinks option
function flashPutHref( href )
{
    location.href = href;
}

// swf finder
function thisMovie( movieName )
{
	if ( navigator.appName.indexOf( "Microsoft" ) != -1 )
	{
		return window[movieName];
	}
	else
	{
	    return document[movieName];
	}
}

// add event listeners
function onSlideShowProReady()
{
    var ssp = document.getElementById( "ssp" );
    ssp.addEventListener( "albumData", "onAlbumData" );
    ssp.addEventListener( "galleryClosing", "onGalleryClosing" );
    ssp.addEventListener( "galleryOpening", "onGalleryOpening" );
    ssp.addEventListener( "imageClick", "onImageClick" );
}

// hide a div
function hideDiv( div_str )
{
	var div = document.getElementById( div_str );
	if ( div != null )
	{ // hide main text div
		div.style.display = "none";
	}
}

// hide all description divs
function hideAllDivs()
{
	for ( ii = 0; ii < text_desc.length; ii++ )
	{
		hideDiv( text_desc[ii] );
	}
}

// album data change
function onAlbumData( o )
{
	var show_div = document.getElementById( o.data.id );
	if ( show_div != null )
	{ // show album description
		hideAllDivs();
		show_div.style.display = "block";
		// remember this album
		lastAlbumId = o.data.id;
		if ( !text_desc.contains( lastAlbumId ))
		{ // add this album ID to hide list
			text_desc.push( lastAlbumId );
		}
	}
	show_div = document.getElementById( "help_text" );
	if ( show_div != null )
	{ // show album help
		show_div.style.display = "block";
	}
}

// gallery is opening - hide album info & show gallery help text
function onGalleryOpening( o )
{
	hideAllDivs();	// hide all desc divs
	var main = document.getElementById( "main_text" );
	if ( main != null )
	{ // show main text div
		main.style.display = "block";
	}
}

// gallery is closing (top gallery button) - show last album text
function onGalleryClosing( o )
{
	if ( lastAlbumId.length )
	{ // set album text
		hideAllDivs();	// hide all desc divs
		var show_div = document.getElementById( lastAlbumId );
		if ( show_div != null )
		{ // show last album
			show_div.style.display = "block";
		}
		show_div = document.getElementById( "help_text" );
		if ( show_div != null )
		{ // show gallery help
			show_div.style.display = "block";
		}
	}
}

// mouse click on album image - display gallery
function onImageClick( o )
{
	thisMovie("ssp").toggleGallery();
}

// end script -->

