function switch_photo(image_id,last)
{
 image=document.getElementById(image_id).src;
 image_location=image.split("/image");
 image_name=image_location[1].split(".");
 current=parseInt(image_name[0])+1;
 filetype=image_name[1];
 if(current > last) current=1;
 imagesrc=image_location[0] + "/image" + current + "." + filetype;
 document.getElementById(image_id).src=imagesrc;
}

function initMaps()
{
 if (document.getElementById)
 {
  var mapIds = initMaps.arguments;
  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++)
   {
    area = areas[j];
    area.onmousedown = imgSwap;
    area.onmouseout = imgSwap;
    area.onmouseover = imgSwap;
    area.onmouseup = imgSwap;
   }
  }
 }
}

function imgSwap(evt)
{
 evt = (evt) ? evt : event;
 var elem = (evt.target) ? evt.target : evt.srcElement;
 var imgClass = elem.parentNode.name;
 var coords = elem.coords.split(",");
 if(coords.length == 3)
 {
  var x1 = parseInt(coords[0]) - parseInt(coords[2]);
  var x2 = parseInt(coords[0]) + parseInt(coords[2]);
  var y1 = parseInt(coords[1]) - parseInt(coords[2]);
  var y2 = parseInt(coords[1]) + parseInt(coords[2]);
  var clipVal = "rect(" + y1 + "px " + x2 + "px " + y2 + "px " + x1 + "px)";
 }
 else
 {
  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";
    break;
  case "mouseout" :
    document.getElementById(imgClass + "Over").style.visibility = "hidden";
    document.getElementById(imgClass + "Down").style.visibility = "hidden";
    break;
  case "mouseover" :
    imgStyle = document.getElementById(imgClass + "Over").style;
    imgStyle.clip = clipVal;
    imgStyle.visibility = "visible";
    break;
  case "mouseup" :
    document.getElementById(imgClass + "Down").style.visibility = "hidden";
    if (elem.click)
    {
     elem.click();
    }
    break;
 }
 evt.cancelBubble = true;
 return false;
}