function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

// Functions for image map navigation
function overMap(node) {
	/* Changes the image map to highlight the
	 * current restaurant. The Area's alt tag is
	 * manipulated and becomes the path for 
	 * the highlighted image */
	var pic = node.alt.replace("'s","").toLowerCase();
	document.getElementById("restArt").src="images/"+pic+".gif";
} // end overMap


function exitMap() {
	/* Returns the base image of the map. 
	 * The Body's ID is manipulated to 
	 * become the pathe to the base image. */
	var pic = document.getElementsByTagName("body")[0].id;
	document.getElementById("restArt").src="images/"+pic+".gif";
} // end exitMap




/// preload images
var aArt = ["navhover.gif", "angelo.gif", "dean.gif", "nick.gif", "patsy.gif"];
var aImages=[];
for(var i=0;i<aArt.length;i++){
	aImages[i] = new Image();
	aImages[i].src = "images/"+aArt[i];
} // end for loop