/* this code loops through image gallery and sorts out the element nodes from the text nodes, 
it then alerts an attribute value from those nodes

window.onload = function(){ //lets the window load before the code
	
var myArray=document.getElementById("imageGallery").childNodes;

for(var i in myArray){
if(myArray[i].nodeType==1);{ //finding all child nodes that are type 1 only
alert(myArray[i].firstChild.getAttribute("href"));	
}
}

}
*/


window.onload = function(){
var myLinks= document.getElementById("imageGallery").getElementsByTagName("a");

showOrHide("lions");
setUpNav();
//alert(myLinks.length)
for(i in myLinks){ //finds all links in image gallery
myLinks[i].onclick=function(){ 
	var myUrl=this.href;      
	var myTitle=this.getAttribute("title");
	document.getElementById("placeholder").src=myUrl;
	document.getElementById("description").firstChild.nodeValue=myTitle;
	return false; //tells the browser not to take default action
	}
}

}


function showOrHide(divToShow){
	var divName=divToShow.toLowerCase();
	var main=document.getElementById("main");
	var divs=main.getElementsByTagName("div");
	for(var i=0; i<divs.length; i++){
	divs[i].className="hide";
	}
	document.getElementById(divName).className="show";
}

function setUpNav(){
var nav=document.getElementById("nav");
var links=nav.getElementsByTagName("a");
for(var i=0; i<links.length; i++){
links[i].onclick=function(){
var name=this.firstChild.nodeValue;
showOrHide(name);
	};
	}
}


