/*************		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);
	
	var textArray = 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';
	
	textArray[0] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 1</a>';
	textArray[1] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 2</a>';
	textArray[2] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 3</a>';
	textArray[3] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 4</a>';
	textArray[4] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 5</a>';
	textArray[5] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 6</a>';
	textArray[6] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 7</a>';
	textArray[7] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 8</a>';
	textArray[8] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 9</a>';
	textArray[9] = '<a href =\'javascript:void(0)\'>Wind power was first used to generate electric power in Denmark in the 1890\'s. Text 0</a>';
	
	
	var objDiv = document.getElementById("home-center-top");
	
	var i = Math.floor(Math.random() * images.length);
	objDiv.style.backgroundImage = 'url(' + images[i] + ')';
	objDiv.innerHTML = textArray[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
	//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 BUG - 217 Script error on MyR,set the image width to 117px 
	thefloatingcontainer.style.width = "117px";
	//Fix for 217 ends
}
/*************		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 	*************/





/*****************************			BEGIN DISPLAY DIV 		*************************************************/

function displayDiv(x){
	var y = "topic" + x;
	var imgId = "image" + x
	var z = document.getElementById(y)
	var imgDisp = document.getElementById(imgId)
	
	if(z.style.display == "none"){
		z.style.display = "";
		imgDisp.style.display = "";
		}else{
		z.style.display = "none";
		imgDisp.style.display = "none";
		}
	
}

/********** ENH-98: BEGIN FUNCTION TO EXPAND-COLLAPSE THE FEATURE LINKS OF HOW TO DO RESEARCH *********/
function showhide(which,oClass){
	var oType = document.getElementById(oClass);
	var oSub = document.getElementById(which);
	if(oSub.style.display == 'block'){
		oType.src="/wbdiscover/discover/html/howtoresearch/images/document-content-plus.gif"
		oSub.style.display = 'none';
	}
	else{
		oType.src="/wbdiscover/discover/html/howtoresearch/images/document-content-minus.gif";
		oSub.style.display = 'block';	
	}	
}
function onPageLoad()
{
	var str = document.location.search;
	var displayImage = "/wbdiscover/discover/html/howtoresearch/images/document-content-minus.gif"
	if(str.indexOf('plan_your_research') != -1){
		document.getElementById('img2').src = displayImage;
		document.getElementById('sl_2').style.display = 'block';
	}
	else if(str.indexOf('conduct_your_research') != -1){
		document.getElementById('img3').src = displayImage;
		document.getElementById('sl_3').style.display = 'block';
	}
	else if(str.indexOf('evaluate_your_sources') != -1){
		document.getElementById('img4').src = displayImage;
		document.getElementById('sl_4').style.display = 'block';
	}
	else if(str.indexOf('compile_and_organize') != -1){
		document.getElementById('img5').src = displayImage;
		document.getElementById('sl_5').style.display = 'block';
	}
	else if(str.indexOf('present_your_information') != -1){
		document.getElementById('img6').src = displayImage;
		document.getElementById('sl_6').style.display = 'block';
	}
}

function onEduResearchPageLoad(){
	var str = document.location.search;
	var displayImage = "/wbdiscover/discover/html/howtoresearch/images/document-content-minus.gif"
	if(str.indexOf('?need_to_know') != -1){
		document.getElementById('img1').src = displayImage;
		document.getElementById('sl_1').style.display = 'block';
	}
	else if(str.indexOf('?teaching') != -1){
		document.getElementById('img2').src = displayImage;
		document.getElementById('sl_2').style.display = 'block';
	}
	else if(str.indexOf('?assess_learning') != -1){
		document.getElementById('img3').src = displayImage;
		document.getElementById('sl_3').style.display = 'block';
	}
}
/********** ENH-98: END FUNCTION TO EXPAND-COLLAPSE THE FEATURE LINKS OF HOW TO DO RESEARCH *********/