// ***********************************************************************
//
// homepage.js
//
// Copyright 2008 Optodesign, inc.
//
// Javascript routines for the Administration > Manage Projects form
//
// nextslide 	-- switches the slide on the homepage
// initcontrols	-- Initializes the javascript controls after the page has loaded.
//

var debug	= false;

if ( debug ) {
	alert( "In homepage.js" );
}

	// Constants

var MAXIMAGES	= 8;
var DELAY		= 10000;		// Number of seconds until next slide

	// Globals

var curimage	= 0;
var images		= new Array();

	//
	// Functions
	//


//
// nextslide -- switches the slide on the homepage
//
function nextslide() {
	var debug	= false;

	if ( debug ) {
		alert( "In nextside" );
	}

		// Bump the image

	curimage++;
	if ( curimage > ( images.length - 1 )) {
		curimage	= 0;
		if ( debug ) {
			alert( "images[ curimage ][ 2 ] = [" + images[ curimage ][ 2 ] + "]" );
		}

	}

		// Swap the image and title

	document.getElementById( "curslide" ).src		= images[ curimage ][ 0 ];
	document.getElementById( "title" ).style.color	= "";
	document.getElementById( "title" ).style.color	= images[ curimage ][ 2 ];
	document.getElementById( "title" ).innerHTML	= images[ curimage ][ 1 ];

		// Reset the time out

	setTimeout( "nextslide()", DELAY );

	if ( debug ) {
		alert( "Done nextslide" );
	}

}


//
// initcontrols -- Initializes the javascript controls after the page has loaded.
// This routine should be called by the initpage routine in main.js.  Use it
// by setting jscommand at the end of the page.
//
function initcontrols() {
	var debug	= false;

	if ( debug ) {
		alert( "In initcontrols" );
	}


	if ( debug ) {
		alert( "images.length = [" + images.length + "]" );
	}

	if ( images.length > 0 ) {
		curimage	= images.length;
		nextslide();
		document.getElementById( "curslide" ).style.visibility	= "visible";
	}

	if ( debug ) {
		alert( "Done initcontrols" );
	}
}



	// Trace end of load

if ( debug ) {
	alert( "Done homepage.js" );
}