/*************		BEGIN PRELOAD OF BACKGROUND IMAGES 	*************/
function doPreload()
{
   var the_images = new Array('images/search/1.jpg','images/search/2.jpg','images/search/3.jpg','images/search/4.jpg','images/search/5.jpg','images/search/6.jpg','images/search/7.jpg','images/search/8.jpg','images/search/9.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 	*************/
/*R12: WBDP-906: Modified to post the new images */
function changeback(){
	var images = new Array(9);
	images[0] = 'images/search/1.jpg';
	images[1] = 'images/search/2.jpg';
	images[2] = 'images/search/3.jpg';
	images[3] = 'images/search/4.jpg';
	images[4] = 'images/search/5.jpg';
	images[5] = 'images/search/6.jpg';
	images[6] = 'images/search/7.jpg';
	images[7] = 'images/search/8.jpg';
	images[8] = 'images/search/9.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();
}
/*************		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
	//commented for BUG -217 (wba)
	//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
	//added to fix Script error on MyR in advanced same as BUG - 217,set the image width to 117px 
	//thefloatingcontainer.style.width = "117px";
	//Fix for ends
	if(thefloatingcontainer!=null){
		//WBDP-1424: Sluglines spilling out of box. Determine the width of the image. If (image width+12 pixel) is less than 100, keep the minimum width as 100. Else keep it as it is.
		if((theimagebyid.width + 12)<100){
			thefloatingcontainer.style.width = 100 + "px";
		} else {	
			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 	*************/

/*************		BEGIN FUNCTION TO EXPAND THE FOOTER DROP DOWN 	*************/
function setDivPosition(which){
	var divToPos = document.getElementById(which);
	divToPos.style.display = 'block';
}
function hideRollOverDiv(which){
	var divToHide = document.getElementById(which);
	divToHide.style.display = 'none';
}
/*************		END FUNCTION TO EXPAND THE FOOTER DROP DOWN 	*************/

/*************		BEGIN FUNCTION TO EXPAND AND COLAPSE DIVS 	*************/
function showhidediv(which,oClass){
	var oDiv = document.getElementById(which);
	var oClass = document.getElementById(oClass);
	
	if(oDiv.style.display != 'block'){
		oDiv.style.display = 'block';
		oClass.className = 'wb-index-heading-h3-minus';
	} else {
		oDiv.style.display = 'none';
		oClass.className = 'wb-index-heading-h3-plus';
	}
}
/*************		END FUNCTION TO EXPAND AND COLAPSE DIVS 	*************/


/*************		BEGIN FUNCTION TO EXPAND THE MAIN CONTAINER IF THE IMAGE IS LARGER THAN IT NEEDS TO BE 	*************/
function changeLayout(theMainImage){
	var thecontainer = document.getElementById('container'); // THIS IS THE MAIN CONTAINER THAT WE WILL NEED TO RESIZE
	var thetwocolumnbody = document.getElementById('two-column-body'); // THIS IS THE CONTAINER AROUND THE CONTENT OF THE PAGE
	var thebodycontainer = document.getElementById('two-column-body-container'); // THIS IS THE CONTAINER AROUND RIGHT SIDE CONTENT
	var themainimagebyid = document.getElementById(theMainImage); // THIS IS THE IMAGE
	
	//HERE WE ARE MAKING SURE THAT THIS FUNCTION WILL NOT MAKE THIS PAGE SMALLER THAN THE REST OF THE SITE
	//IF THIS FUNCTION DOES MAKE IT SMALLER, THEN DON'T DO ANYTHING
	if((themainimagebyid.width + 246) < 949){
		//do nothing
	} else {
		thetwocolumnbody.style.border = "1px solid #1c438a"; //SETTING A BORDER AROUND THE CONTAINER TO MATCH THE REST OF THE SITE
		thebodycontainer.style.borderLeft = "1px solid #1c438a"; //SETTING A LEFT SIDE BORDER TO SEPERATE THE LEFT AND RIGHT SIDES
		
		if(navigator.appName != "Microsoft Internet Explorer"){ //IF THEY ARE NOT IN IE, LETS DO THIS
			thetwocolumnbody.style.background = "none"; //REMOVE THE BACKGROUND OF THE CONTAINER
			thebodycontainer.style.marginLeft = "0px"; //GIVE THE CONTAINER A 0 MARGIN LEFT
			thebodycontainer.style.width = (themainimagebyid.width + 20) + "px"; //LETS CHANGE THE WIDTH OF THE RIGHT SIDE CONTENT CONTAINER
			thecontainer.style.width = (themainimagebyid.width + 244) + "px"; //LETS CHANGE THE WIDTH OF THE MAIN CONTAINER
		} else {
			//IF THE USER IS USING IE, LETS DO THE FOLLOWING
			thetwocolumnbody.style.background = "#ffffff"; //SET A WHITE BACKGROUND ON THE MAIN CONTENT
			thebodycontainer.style.marginLeft = "-1px"; //GIVE THE RIGHT SIDE A NEGATIVE MARGIN SO THAT IT WILL COVER ENY EXTRA LINES
			thebodycontainer.style.width = (themainimagebyid.width + 20) + "px"; //LETS CHANGE THE WIDTH OF THE RIGHT SIDE CONTENT CONTAINER
			thecontainer.style.width = (themainimagebyid.width + 243) + "px"; //LETS CHANGE THE WIDTH OF THE MAIN CONTAINER
		}
	}
}
/*************		END FUNCTION TO EXPAND THE MAIN CONTAINER IF THE IMAGE IS LARGER THAN IT NEEDS TO BE 	*************/

