function opacity(id, opacStart, opacEnd, millisec)
{
 var speed = Math.round(millisec / 100);
 var timer = 0;
 if(opacStart > opacEnd)
 {
  for(i = opacStart; i >= opacEnd; i--)
  {
   setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
   timer++;
  }
 }
 else if(opacStart < opacEnd)
 {
  for(i = opacStart; i <= opacEnd; i++)
  {
   setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
   timer++;
  }
 }
}

function shiftOpacity(id, millisec)
{
 if(document.getElementById(id).style.opacity == 0)
 {
  opacity(id, 0, 100, millisec);
 }
 else
 {
  opacity(id, 100, 0, millisec);
 }
}

function currentOpac(id, opacEnd, millisec)
{
 var currentOpac = 100;
 if(document.getElementById(id).style.opacity < 100)
 {
  currentOpac = document.getElementById(id).style.opacity * 100;
 }
 opacity(id, currentOpac, opacEnd, millisec)
}

function changeImage(direction, change)
{
 if(Browser == "Gecko")
 {
  if(direction == "down")
  { 
   document.getElementById("blenddiv").style.backgroundImage = "url(" + image + less + filetype + ")";
   document.getElementById("blendimage").src = image + less + filetype;
  }
  else
  { 
   document.getElementById("blenddiv").style.backgroundImage = "url(" + image + more + filetype + ")";
   document.getElementById("blendimage").src = image + more + filetype;
  }
  less=change-1;
  more=change+1;
  if(less < 1) less=1;
  if(more > last) more=last;
 }
 else
 {
  if(direction == "down")
  {
   blendimage('blenddiv','blendimage', prev, less, 600);
  }
  else
  {
   blendimage('blenddiv','blendimage', next, more, 600);
  }
 }
}

function fadeImage(background, foreground, current, next)
{
 if(Browser == "Gecko" || Browser == "Safari")
 {
  document.getElementById(foreground).src = current;
  document.getElementById(background).style.backgroundImage = "url(" + document.getElementById(foreground).src + ")";
 }
 else { blendimage(background, foreground, current, next, 200); }
}

function blendimage(divid, imageid, imagefile, change, millisec)
{
 var speed = Math.round(millisec / 100);
 var timer = 0;
 document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
 changeOpac(0, imageid);
 document.getElementById(imageid).src = imagefile;
 for(i = 0; i <= 100; i++)
 {
  setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
  timer++;
 }
 less=change-1;
 more=change+1;
 if(less < 1) less=1;
 if(more > last) more=last;
 prev=image + less + filetype;
 next=image + more + filetype;
}

function changeOpac(opacity, id)
{
 var object = document.getElementById(id).style;
 object.opacity = (opacity / 101);
 object.MozOpacity = (opacity / 101);
 object.KhtmlOpacity = (opacity / 101);
 object.filter = "alpha(opacity=" + opacity + ")";
}

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;
}

function BrowserDetect()
{
 var ua = navigator.userAgent.toLowerCase();
 if(ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1) Browser="Gecko";
 if(ua.indexOf('applewebkit') != -1) Browser="AppleWebKit";
 if(ua.indexOf('konqueror') != -1) Browser="Konqueror"; 
 if(ua.indexOf('safari') != - 1) Browser="Safari";
 if(ua.indexOf('omniweb') != - 1) Browser="Omniweb";
 if(ua.indexOf('opera') != -1) Browser="Opera";
 if(ua.indexOf('icab') != -1) Browser="Icab"; 
 if(ua.indexOf('aol') != -1) Browser="Aol"; 
 if(ua.indexOf('msie') != -1) Browser="IE"; 
 if(Browser == 'Gecko' && ua.indexOf('gecko/') + 14 == ua.length) Browser="Mozilla";
 if(ua.indexOf('firebird/') != -1) Browser="Firebird";
}

function centerLayout()
{
 if (navigator.appName == 'Netscape')
 {
  var bodyWidth = self.innerWidth;
  var bodyHeight = self.innerHeight;
  var offsetLeft = ((bodyWidth - layoutWidth)/2);
  var offsetTop = ((bodyHeight - layoutHeight)/2);
  if (offsetLeft > 0) document.getElementById("maindiv").style.left = offsetLeft;
  if (offsetTop > 0) document.getElementById("maindiv").style.top = offsetTop;
 }
 else
 {
  var bodyWidth = document.body.offsetWidth;
  var bodyHeight = document.body.offsetHeight;
  var offsetLeft = ((bodyWidth - layoutWidth)/2);
  var offsetTop = ((bodyHeight - layoutHeight)/2);
  if (offsetLeft > 0) document.all.tags('DIV')['maindiv'].style.left=offsetLeft;
  if (offsetTop > 0) document.all.tags('DIV')['maindiv'].style.top=offsetTop;
 }
}