
var isIE        = false;
var isNS4       = false; 
var isNS6plus   = false;
var isNS7plus   = false;
var isSafari    = false;
var agt         = navigator.userAgent.toLowerCase();


isNS4           = (document.layers) ? true : false;
isIE            = (document.all) ? true : false;
isMac           = (agt.indexOf("mac") != -1); 
isSafari        = (agt.indexOf("safari") != -1);
isNS6plus       = (!document.all && document.getElementById) ? true : false;

var lastLayer = "";
var to = "";		

function wait( _method ) {
  to = setTimeout( _method ,0); 
}
function cancelTO() {
  if (to != "" && to != null) {
    clearTimeout( to );
  }
}
function showMenu( _which ) {
  lastLayer = _which;
  if (isIE) {
    document.all( _which ).style.visibility = "visible";
  }
  else if (isNS6plus || isNS7plus || isSafari) {
    document.getElementById( _which ).style.visibility = "visible";
  }
}
function hideMenu( _which ) {
  if (isIE) {
    document.all( _which ).style.visibility = "hidden";
  }
  else if (isNS6plus || isNS7plus || isSafari) {
    document.getElementById( _which ).style.visibility = "hidden";
  }
}
function hideLast() { 
  if (lastLayer) {
    if (isIE) {
      document.all( lastLayer ).style.visibility = "hidden";
    }
    else if (isNS6plus || isNS7plus || isSafari) {
      document.getElementById( lastLayer ).style.visibility = "hidden";
    }
  }
  
}



var isMacIE=0;
if (navigator.userAgent.indexOf('Mac') > -1) isMacIE=1;

function ImageSwap() {
  this.imagesDefault = new Object();
  this.imagesOn = new Object();
  this.imagesDown = new Object();
}

ImageSwap.prototype.add = 
function (arg_path,arg_names) {
  
  if(!document.images) return;

  //preload images
  for (var i=0; i<arg_names.length;i++) {
    var name = arg_names[i];

    if (this.imagesDefault[name]) {
      alert("ImageSwap Error!\nThere is already a image with this name: " + name);
    }
    this.imagesDefault[name] = new Image();
    this.imagesDefault[name].src = arg_path + "/" + name + ".gif";
    this.imagesOn[name] = new Image();
    this.imagesOn[name].src = arg_path + "/" + name + ".on.gif";
    this.imagesDown[name] = new Image();
    this.imagesDown[name].src = arg_path + "/" + name + ".down.gif";

  }
}

ImageSwap.prototype.addMouseOver = 
function (arg_path,arg_names) {
  
  if(!document.images) return;


  for (var i=0; i<arg_names.length;i++) {
    var name = arg_names[i];

    if (this.imagesDefault[name]) {

      alert("ImageSwap Error!\nThere is already a image with this name: " + name);
    }
    this.imagesDefault[name] = new Image();
    this.imagesDefault[name].src = arg_path + "/" + name + ".gif";
    this.imagesOn[name] = new Image();
    this.imagesOn[name].src = arg_path + "/" + name + ".on.gif";
  }
}

ImageSwap.prototype.addMouseDown = 
function (arg_path,arg_names) {
  
  if(!document.images) return;

  //preload images
  for (var i=0; i<arg_names.length;i++) {
    var name = arg_names[i];

    if (this.imagesDefault[name]) {

      alert("ImageSwap Error!\nThere is already a image with this name: " + name);
    }
    this.imagesDefault[name] = new Image();
    this.imagesDefault[name].src = arg_path + "/" + name + ".gif";
    this.imagesDown[name] = new Image();
    this.imagesDown[name].src = arg_path + "/" + name + ".down.gif";
  }
}

ImageSwap.prototype.over = 
function (which) {
  if(document.images){
    if (document.images[which]) {
      document.images[which].src = this.imagesOn[which].src; 
    } else if (document.getElementsByName && !isMacIE) {
      document.getElementsByName(which)[0].src = this.imagesOn[which].src;
    }
  }
}

ImageSwap.prototype.out = 
function (which) {
  if(document.images){
    if (document.images[which]) {
      document.images[which].src = this.imagesDefault[which].src;
    } else if (document.getElementsByName && !isMacIE) {
      document.getElementsByName(which)[0].src = this.imagesDefault[which].src;
    }
  }
}

ImageSwap.prototype.down = 
function (which) {
  if(document.images){
    if (document.images[which]) {
      document.images[which].src = this.imagesDown[which].src;
    } else if (document.getElementsByName && !isMacIE) {
      document.getElementsByName(which)[0].src = this.imagesDown[which].src;
    }

  }  
}


var imageswap = new ImageSwap();


function openPopup(loc, name, width, height) {
    popup = window.open(loc, name, 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,' +
		         'menubar=no,width='+ width +',height='+ height +',dependent=yes');
    if (popup) popup.focus();
}

function openPopupNoResize(loc, name, width, height) {
    popup = window.open(loc, name, 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,' +
		         'menubar=no,width='+ width +',height='+ height +',dependent=yes');
    if (popup) popup.focus();
}











