/*************		BEGIN PRELOAD OF BACKGROUND IMAGES 	*************/
function doPreload()
{
   var the_images = new Array('images/search/search-dunes.jpg','images/search/search-historical.jpg','images/search/search-iwo-jima.jpg','images/search/search-nebula.jpg','images/search/search-penguins.jpg','images/search/search-pyramids.jpg','images/search/search-the-arts.jpg','images/search/search-tiger.jpg','images/search/search-volcano.jpg','images/search/search-windmill.jpg');
   preloadImages(the_images);
}

function preloadImages(the_images_array) {

   for(var loop = 0; loop < the_images_array.length; loop++)
   {
 	var an_image = new Image();
	an_image.src = the_images_array[loop];
   }
}
/*************		END PRELOAD OF BACKGROUND IMAGES	*************/


/*************		BEGIN FUNCTION TO CHANGE THE BACKGROUND IMAGE ON THE HOME PAGE 	*************/
function changeback(){
	var images = new Array(10);
	images[0] = 'images/search/search-dunes.jpg';
	images[1] = 'images/search/search-historical.jpg';
	images[2] = 'images/search/search-iwo-jima.jpg';
	images[3] = 'images/search/search-nebula.jpg';
	images[4] = 'images/search/search-penguins.jpg';
	images[5] = 'images/search/search-pyramids.jpg';
	images[6] = 'images/search/search-the-arts.jpg';
	images[7] = 'images/search/search-tiger.jpg';
	images[8] = 'images/search/search-volcano.jpg';
	images[9] = 'images/search/search-windmill.jpg';
	
	var objDiv = document.getElementById("home-center-top");
	
	
	var i = Math.floor(Math.random() * images.length);
	objDiv.style.backgroundImage = 'url(' + images[i] + ')';
	setTimeout('changeback()',3000);
}
/*************		END FUNCTION TO CHANGE THE BACKGROUND IMAGE ON THE HOME PAGE 	*************/


/*************		BEGIN FUNCTION TO SET FOCUS ON A PARTICULAR INPUT FIELD 	*************/
function setFocusOfElement(which){
	var theInputField = document.getElementById(which);
	theInputField.focus();
}

function setFocusElement(username,library) {
	var theUserName = document.getElementById(username);
	var theLibrary = document.getElementById(library);

	//alert(document.loginForm.auth.value);
	var authValue = document.loginForm.auth.value;
	if(authValue == 'UidPassword') 
	theUserName.focus();
	else
	theLibrary.focus();

}
/*************		END FUNCTION TO SET FOCUS ON A PARTICULAR INPUT FIELD 	*************/

/*************		BEGIN FUNCTION TO HIDE AWAY AN ERROR MESSAGE AFTER 5 SECONDS 	*************/
/*** USE THIS CODE TO REMOVE THE ERROR MESSAGE
hideawayerrorbox('error-classes');		-- THIS NEEDS TO BE PLACED IN THE ONLOAD EVENT WHEN THE ERROR MESSAGE APPEARS
hideawayerrorbox						-- THIS IS THE NAME OF THE FUNCTION
error-classes							-- THIS IS THE NAME OF THE DIV THAT IS TO HIDE AFTER 5 SECONDS
***/
var theerrordiv;
function hideawayerrorbox(which){
	theerrordiv = document.getElementById(which);
	setTimeout('hideerror()',5000);
}
function hideerror(){
	theerrordiv.style.display = 'none';
}
/*************		END FUNCTION TO HIDE AWAY AN ERROR MESSAGE AFTER 5 SECONDS 	*************/


/*************		BEGIN FUNCTION TO DETERMINE THE WIDTH OF THE FLOATING IMAGES SO THAT THE TEXT WILL WRAP 	*************/
function determineFloatWidth(theimage,thecontainer){
	var theimagebyid = document.getElementById(theimage); // THIS IS THE IMAGE THAT WE NEED TO DETERMINE THE SIZE FOR
	var thefloatingcontainer = document.getElementById(thecontainer); // THIS IS THE FLOATING CONTAINER
	thefloatingcontainer.style.width = (theimagebyid.width + 12) + "px"; // THIS SETS THE WIDTH OF THE CONTAINER TO THE WIDTH OF THE IMAGE PLUS 12px FOR THE PADDING ON BOTH THE LEFT AND RIGHT SIDE
}
/*************		END FUNCTION TO DETERMINE THE WIDTH OF THE FLOATING IMAGES SO THAT THE TEXT WILL WRAP 	*************/
