//----------------------------------------------------------------------
// L O C A L . J S
// Copyright © 2003 Tom Ogden
// CREATED: 2003-07-21
// DESCRIPTION: Functions for this web site only. 
//----------------------------------------------------------------------
// GLOBALS
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// FUNCTION: testL
// INPUT: 
// OUTPUT: alert string
// DESCRIPTION: Test this library for globally crippling syntax errors.
// CREATED: 2003-07-21
//----------------------------------------------------------------------
function testL() {
	alert("Library 'local' is active.");
}

//----------------------------------------------------------------------
// FUNCTION: docInit
// INPUT: 
// OUTPUT: 
// DESCRIPTION: Do checks and initializations for a page.
// CREATED: 2003-07-21
// 2005-12-13: Adjust for browser time differences
//----------------------------------------------------------------------
function docInit ( ) {
	var rotateInterval = 1000;
	if ( navigator.userAgent.indexOf ( "Firefox" ) != -1 ) {
		rotateInterval = 3000;
	} else if ( navigator.userAgent.indexOf ( "MSIE" ) != -1 ) {
		rotateInterval = 1000;
	} else if ( navigator.userAgent.indexOf ( "Netscape" ) != -1 ) {
		rotateInterval = 1000;
	}
	
	if ( window.location.pathname == "/" || window.location.pathname == "/index.php" ) {
		rotateImagesRand ( rotateInterval );
	}

	// Check for Cookies Allowed
	//if ( !cookiesEnabled ( ) ) {
	//	alert ( "Your browser is not responding to cookies.\rYou must allow cookies to properly use this site." );
	//}
	
	// LASTLY: Select first element.
	//if ( document.forms.length > 0 ) document.forms[0].elements[0].select ( );
}

//----------------------------------------------------------------------
// FUNCTION: glowLights
// INPUT: rating, firstImage, imageON, imageOFF, myInput
// OUTPUT: 
// DESCRIPTION: Change rollovers to match given integer, but don't set value.
// CREATED: 2004-04-12
//----------------------------------------------------------------------
function glowLights ( rating, firstImage, imageON, imageOFF, myInput ) {
	var maxRating 	= 6;
	var beginIndex = 0;

	//-- FIND INDEX of FIRST in SERIES
	for ( var i = 0; i < document.images.length; i++ ){
		if ( firstImage == document.images[i] ) beginIndex = i;
	}

	if ( myInput.value == 0 ) {	
		//-- WIPE IMAGES CLEAN
		for ( var i = 0; i < maxRating; i++ ) {
			setImage ( document.images[i+beginIndex], imageOFF );
		}
		//-- SET IMAGES AS INDICATED
		for ( var i = 0; i < rating; i++ ) {
			setImage ( document.images[i+beginIndex], imageON );
		}
	}
}

//----------------------------------------------------------------------
// FUNCTION: setLights
// INPUT: firstImage, imageON, imageOFF, myInput
// OUTPUT: 
// DESCRIPTION: Change rollovers to match rating value.
// CREATED: 2004-04-12
//----------------------------------------------------------------------
function setLights ( firstImage, imageON, imageOFF, myInput ) {
	var maxRating 	= 6;
	var beginIndex = 0;

	//-- FIND INDEX of FIRST in SERIES
	for ( var i = 0; i < document.images.length; i++ ){
		if ( firstImage == document.images[i] ) beginIndex = i;
	}

	//-- WIPE IMAGES CLEAN
	for ( var i = 0; i < maxRating; i++ ) {
		setImage ( document.images[i+beginIndex], imageOFF );
	}
	//-- SET IMAGES AS INDICATED
	for ( var i = 0; i < myInput.value; i++ ) {
		setImage ( document.images[i+beginIndex], imageON );
	}
}
