// JavaScript Document
addLoadEvent(preloadEverything);
function preloadEverything()
{
	if (IE)
	{
		document.getElementById("Exhibit_img").style.top = "140px";
	}
	
	MM_preloadImages('images/leaf.png');
	MM_preloadImages('images/doctors_place.png');
	MM_preloadImages('images/grandma_sophie.png');
	MM_preloadImages('images/DaysofKnights.gif');
	MM_preloadImages('images/ColorCanyon.gif');
	MM_preloadImages('images/Village.gif');
	MM_preloadImages('images/MappingUtah.gif');
	MM_preloadImages('images/music_room.png');
	MM_preloadImages('images/american_map.png');
	MM_preloadImages('images/oval_office.png');
	MM_preloadImages('images/school_house.png');
	MM_preloadImages('images/russian_book.png');
	MM_preloadImages('images/art_garden.png');
	MM_preloadImages('images/theater.png');
	MM_preloadImages('images/image_soon_to_come.png');
}


//change the display of the page rule depending on their browser
function fixPageRule()
{
	if (IE)
	{
		document.getElementById("page_rule").style.top = "330px";
	}
	else if (FireFox)
	{
		document.getElementById("page_rule").style.top = "230px";
	}
}

//when they click a link for an exhibit, hide the original text, and replace it with the exhibit's description, also change the image
function changeExhibit(exhibit)
{
	document.getElementById("Intro").style.display = "none";
	var exhibit_desc = "";
	var image_src = "image_soon_to_come.png";
	var fs = "17px";
	var flipped = false;
	
	switch(exhibit)
	{
		case "the_treehouse":
			exhibit_desc = "<b>The Treehouse</b><br />Climb up the spiral staircase in the trunk to the Treehouse deck where activities and dress-ups await. Also be sure to slide down the Slickrock Slide.";
			image_src = "treehouse.png";
			flipped = true;
			break;
		case "the_baby_place":
			exhibit_desc = "<b>The Baby Place</b><br />Be a doctor who cares for the babies in our mini-hospital.";
			image_src = "doctors_place.png";
			break;
		case "grandma_sophie":
			exhibit_desc = "<b>Grandma Sophie's House</b><br />Listen to Grandma Sophie tell a story and play house in her kitchen. Plant vegtables in her garden or buy flowers at the market.";
			image_src = "grandma_sophie.png";
			flipped = true;
			break;
		case "days_of_the_knights":
			exhibit_desc = "<b>Days of the Knights</b><br />Sit in a throne, play chess, try to pull the sword from the stone, learn about heraldry and more.";
			image_src = "DaysofKnights.gif";
			break;
		case "music_room":
			exhibit_desc = "<b>Music Room</b><br />Play a marimba, shake a rattle or pound on a drum. Make a rhythm band with your family.";
			image_src = "music_room.png";
			break;
		case "one_world_villiage":
			exhibit_desc = "<b>One World Villiage</b><br />Jump into stories and activities from China, Germany, England and Mexico.";
			image_src = "Village.gif";
			break;
		case "great_american_map":
			exhibit_desc = "<b>Great American Map</b><br />Discover interesting things about each state of our country.";
			image_src = "american_map.png";
			break;
		case "oval_office":
			exhibit_desc = "<b>Oval Office</b><br />Sit at a replica of the President's desk and test your knowledge of the men who have served as President.";
			image_src = "oval_office.png";
			break;
		case "dinosaur_discovery":
			exhibit_desc = "<b> and Color Canyon</b><br />Do a fossil rubbing, create your own dinosaur, or complete a bone puzzle.";
			image_src = "ColorCanyon.gif";
			break;
		case "the_one_room_school":
			exhibit_desc = "<b>The One Room School</b><br />Be the teacher or the student. Do a \"reading\" and practice your \"figures\" on a slate.";
			image_src = "school_house.png";
			flipped = true;
			break;
		case "mapping_utah":
			exhibit_desc = "<b>Mapping Utah</b><br />Test your knowledge of our \"Pretty Great\" State.";
			image_src = "MappingUtah.gif";
			break;
		case "millennium_tales":
			exhibit_desc = "<b>Millennium Tales</b><br />Step into the giant \"pop-up\" activity books featuring folk tales from around the world.";
			image_src = "russian_book.png";
			break;
		case "native_peoples_area":
			exhibit_desc = "<b>Native Peoples Area</b><br />Find out about the first residents of Utah. Try weaving at our loom or assembling a \"pot shard\" puzzle.";
			break;
		case "the_art_garden":
			exhibit_desc = "<b>The Art Garden</b><br />This is the place to learn various techniques and make fun, book-based art projects.";
			image_src = "art_garden.png";
			break;
		case "castle_theater":
			exhibit_desc = "<b>Castle Theater</b><br />Open only for scheduled performances and other announced storytimes and programs, the Castle Theater is where stories come to life.";
			image_src = "theater.png";
			break;
		case "jump_to_japan":
			exhibit_desc = "<b>Jump to Japan</b><br />Experience a once-in-a-lifetime traveling exhibit featuring storytelling traditions of Japan. Treehouse is the final tour stop on for this amazing exhibit which has been on display in museums throughout the country. Children will explore traditional komishibi to manga and anim&eacute;. <a href='Jump_To_Japan/J2Japan.pdf' target='_blank'>Click here to learn more.</a>";
			fs = "14px";
			image_src = "catbus.png";
			break;
		default:
			exhibit_desc = exhibit;
			image_src = 'image_soon_to_come.png';
	}
	document.getElementById("Exhibit_img").src = "images/spacer.gif";
	document.getElementById("Exhibit").style.fontSize = fs;
	document.getElementById("Exhibit").innerHTML = exhibit_desc;
	var h = "144";
	var w = "216";
	if (flipped)
	{
		document.getElementById("Exhibit_img").height = w;
		document.getElementById("Exhibit_img").width = h;
	}
	else
	{
		document.getElementById("Exhibit_img").height = h;
		document.getElementById("Exhibit_img").width = w;
	}
	document.getElementById("Exhibit_img").src = "images/" + image_src;
	document.getElementById("Exhibit_img").alt = exhibit;
	document.getElementById("Exhibit_img").title = exhibit;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

