addOnload(rolloverInit);
addOnload(initForm);

function addOnload(newFunction) {
	var oldOnload = window.onload;
	
	if (typeof oldOnload == "function") {
		window.onload = function() {
			if (oldOnload) {
				oldOnload();
			}
			newFunction();
		}
	}
	else {
		window.onload = newFunction;
	} 
}


//drop down menu stuff
window.onunload = function() {};

function initForm() {
	document.getElementById("newLocation").selectedIndex = 0;
	document.getElementById("newLocation").onchange = jumpPage;
}

function jumpPage() {
	var newLoc = document.getElementById("newLocation");
	var newPage = newLoc.options[newLoc.selectedIndex].value;

	if (newPage != "") {
		window.location = newPage;
	}
}

//button over stuff

function rolloverInit() {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].parentNode.tagName == "A") {
			setupRollover(document.images[i]);
		}
	}
}

function setupRollover(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;

	thisImage.overImage = new Image();
	thisImage.overImage.src = thisImage.id + "over.gif";
	thisImage.onmouseover = rollOver;	
}

function rollOver() {
	this.src = this.overImage.src;
}

function rollOut() {
	this.src = this.outImage.src;
}

function rollClick() {
	this.src = this.clickImage.src;
}


/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://www.scholastic.com/harrypotter/books/stone/">Harry Potter and the Sorcerer\'\s Stone</a>'
menu1[1]='<a href="http://www.scholastic.com/harrypotter/books/chamber/">Harry Potter and the Chamber of Secrets</a>'
menu1[2]='<a href="http://www.scholastic.com/harrypotter/books/prisoner/">Harry Potter and the Prisoner of Azkaban</a>'
menu1[3]='<a href="http://www.scholastic.com/harrypotter/books/goblet/">Harry Potter and the Goblet of Fire</a>'
menu1[4]='<a href="http://www.scholastic.com/harrypotter/books/phoenix/">Harry Potter and the Order of the Phoenix</a>'
menu1[5]='<a href="http://www.scholastic.com/harrypotter/books/prince/">Harry Potter and the Half-Blood Prince</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="http://www.alagaesia.com/eragon.htm"> Eragon </a>'
menu2[1]='<a href="http://www.alagaesia.com/eldest.htm"> Eldest </a>'

var menu3=new Array()
menu3[0]='<a href="http://lotr.ugo.com/books/fellowship_of_the_ring/">The Fellowship of the Ring </a>'
menu3[1]='<a href="http://lotr.ugo.com/books/two_towers/">The Two Towers </a>'
menu3[2]='<a href="http://lotr.ugo.com/books/return_of_the_king/">The Return of the King </a>'
menu3[3]='<a href="http://lotr.ugo.com/books/hobbit/"> The Hobbit </a>'

var menu4=new Array()
menu4[0]='<a href="http://incredibooks.com/2006/02/24/the-lion-the-witch-and-the-wardrobe/"> The Lion, The Witch, and The Wardrobe </a>'
menu4[1]='<a href="http://incredibooks.com/2006/02/23/prince-caspian/">Prince Caspian: The Return to Narnia </a>'
menu4[2]='<a href="http://incredibooks.com/2006/02/23/the-voyage-of-the-dawn-treader/"> The Voyage of the Dawn Treader </a>'
menu4[3]='<a href="http://incredibooks.com/2006/02/24/the-silver-chair/">The Silver Chair </a>'
menu4[4]='<a href="http://incredibooks.com/2006/02/24/the-silver-chair/">The Horse and His Boy </a>'
menu4[5]='<a href="http://incredibooks.com/2006/02/24/the-magicians-nephew/">The Magician\'\s Nephew </a>'
menu4[6]='<a href="http://incredibooks.com/2006/02/23/the-last-battle/">The Last Battle </a>'

var menu5=new Array()
menu5[0]='<a href="http://blackholly.com/tithe.html"> Tithe: A Modern Faerie Tale </a>'
menu5[1]='<a href="http://blackholly.com/valiant.html">Valiant</a>'
menu5[2]='<a href="http://blackholly.com/ironside.html">Ironside</a>'

var menu6=new Array()
menu6[0]='<a href="http://www.eoincolfer.com/books/artemisfowl/artemisfowl.html"> Artemis Fowl</a>'
menu6[1]='<a href="http://www.eoincolfer.com/books/artemisfowl/artemisfowlarcticincident.html">Artemis Fowl: The Arctic Incident </a>'
menu6[2]='<a href="http://www.eoincolfer.com/books/artemisfowl/artemisfowleternitycode.html"> Artemis Fowl: The Eternity Code </a>'
menu6[3]='<a href="http://www.eoincolfer.com/books/artemisfowl/artemisfowlopaldeception.html"> Artemis Fowl: The Opal Deception </a>'
menu6[4]='<a href="http://www.eoincolfer.com/books/artemisfowl/artemisfowllostcolony.html"> Artemis Fowl and the Lost Colony </a>'

var menu7=new Array()
menu7[0]='<a href="http://www.philip-pullman.com/pages/content/index.asp?PageID=41">Part One: Northern Lights</a>'
menu7[1]='<a href="http://www.philip-pullman.com/pages/content/index.asp?PageID=42">Part Two: The Subtle Knife </a>'
menu7[2]='<a href="http://www.philip-pullman.com/pages/content/index.asp?PageID=43">Part Three: The Amber Spyglass </a>'

		
var menuwidth='165px' //default menu width
var menubgcolor='white'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

