/**********************************************************************************
 The following panel rollover code is adapted from Danny Goodman's 
 "Recipe for Super-Efficient Image Rollovers"
   Home Page: fttp://www.dannyg.com
  JavaScript: http://www.oreillynet.com/pub/a/javascript/2003/07/01/bonusrecipe.html
 **********************************************************************************/

function initPanels() {
  if (document.getElementById) {
    var mapIds = initPanels.arguments;			// pass string IDs of containing map elements
    var i, j, area, areas;
    for (i = 0; i < mapIds.length; i++) {
      areas = document.getElementById(mapIds[i]).getElementsByTagName("area");  
      for (j = 0; j < areas.length; j++) {	// loop thru img elements
        area = areas[j];
        area.onmousedown = panelsSwap;			// set event handlers
        area.onmouseout = panelsSwap;
        area.onmouseover = panelsSwap;
        area.onmouseup = panelsSwap;
      }
    }
  }
}


// image swapping event handling
function panelsSwap(evt) {
  evt = (evt) ? evt : event;
  var elem = (evt.target) ? evt.target : evt.srcElement;
  var imgClass = elem.parentNode.name;   // "fourpart" or "ninepart"
  var coords = elem.coords.split(",");
  var clipVal = "rect(" + coords[1] + "px " +
              coords[2] + "px " +
              coords[3] + "px " +
              coords[0] + "px)";
  var imgStyle;
  
  switch (evt.type) {
    case "mousedown" :
      imgStyle = document.getElementById(imgClass + "Down").style;
      imgStyle.clip = clipVal;
      imgStyle.visibility = "visible";
      document.getElementById(imgClass + "Over").style.visibility = "hidden";
      break;
    case "mouseout" :
      document.getElementById(imgClass + "Down").style.visibility = "hidden";
      document.getElementById(imgClass + "Over").style.visibility = "hidden";
      document.getElementById(imgClass + "Faded").style.visibility = "hidden";
      break;
    case "mouseover" :
      document.getElementById(imgClass + "Faded").style.visibility = "visible";
      imgStyle = document.getElementById(imgClass + "Over").style;
      imgStyle.clip = clipVal;
      imgStyle.visibility = "visible";
      break
    case "mouseup" :
     document.getElementById(imgClass + "Down").style.visibility = "hidden";
     document.getElementById(imgClass + "Faded").style.visibility = "visible";
       // guarantee click in IE
      if (elem.click) {
        elem.click();
      }
      break;
  }
  evt.cancelBubble = true;
  return false;
}