// when nav links are clicked,
// load the image onto the current page

/*window.onload tells the browser not to load the javascript functions 
below until the html document is fully loaded*/

window.onload=init;

function init()
{
	// get access to nav
	var nav = document.getElementById('nav');
	
	// get access to all anchor tags inside of nav
	var links = nav.getElementsByTagName('A');
	
	// loop through links array, attach event listener to each link
	for(var i=0; i<links.length;i++)
	{
		links[i].onclick=showPic;	
	}
}

//create the event handler used by nav links
function showPic(evt)
{
	var myEvent= window.event || evt;
	var target;
	
	if(window.event)
	{
		target= window.event.srcElement;
	}
	else 
	{
		target= evt.target;
	}
	
	var title= target.getAttribute('title');
	var source= target.getAttribute('href');
	
	// change the picture
	var pic=document.getElementById('placeholder');
	pic.setAttribute('src',source);
	
	//change the text
	var text= document.getElementById('description');
	text.firstChild.nodeValue=title;
	
	//prevent the default behavior of the link
	return false;
}

