// global variables

var tid		= "";  // timer ID
var currentPage	= "";  // current page name, same as menu gifs name prefix
var delay	= 250;  // delay before reverting to highlighting current page's menu item
var NS=(navigator.appName=='Netscape');  // is this netscape?


// Create all menu bar images

if (document.images) {
  home1 = new Image();
  home1.src = "/images/menu/home1.gif";
  products1 = new Image();
  products1.src = "/images/menu/products1.gif";
  demo1 = new Image();
  demo1.src = "/images/menu/demo1.gif";
  orderNow1 = new Image();
  orderNow1.src = "/images/menu/orderNow1.gif";
  clients1 = new Image();
  clients1.src = "/images/menu/clients1.gif";
  aboutUs1 = new Image();
  aboutUs1.src = "/images/menu/aboutUs1.gif";
  contact1 = new Image();
  contact1.src = "/images/menu/contact1.gif";

  home2 = new Image();
  home2.src = "/images/menu/home2.gif";
  products2 = new Image();
  products2.src = "/images/menu/products2.gif";
  demo2 = new Image();
  demo2.src = "/images/menu/demo2.gif";
  orderNow2 = new Image();
  orderNow2.src = "/images/menu/orderNow2.gif";
  clients2 = new Image();
  clients2.src = "/images/menu/clients2.gif";
  aboutUs2 = new Image();
  aboutUs2.src = "/images/menu/aboutUs2.gif";
  contact2 = new Image();
  contact2.src = "/images/menu/contact2.gif";
}


// functions to change menu bar images

// shows highlighted menu item
function showImage2(imageName) {
  if (document.images) {
    if (document.images[imageName]) {
      document.images[imageName].src = eval(imageName+"2.src");
    } 
    else {
      if (document.layers) { 
        for (i=0; i<document.layers.length; i++) {
          if (document.layers[i].document.images[imageName]) {
            document.layers[i].document.images[imageName].src = eval(imageName+"2.src");
            break;
          }
        }
      }
    }
  }
} 

// shows normal menu item
function showImage1(imageName) {
  if (document.images) {
    if (document.images[imageName]) {
      document.images[imageName].src = eval(imageName+"1.src");
    } 
    else {
      if (document.layers) { 
        for (i=0; i<document.layers.length; i++) {
          if (document.layers[i].document.images[imageName]) {
            document.layers[i].document.images[imageName].src = eval(imageName+"1.src");
            break;
          }
        }
      }
    }
  }
} 


// called when mouse enters menu item
function enterMI(name) {
  clearTimeout(tid);
  showImage1('home');
  showImage1('products');
  showImage1('demo');
  showImage1('orderNow');
  showImage1('clients');
  showImage1('aboutUs');
  showImage1('contact');
  showImage2(name);
}

// called when mouse leaves menu item
function leaveMI() {
  tid = setTimeout("enterMI('"+currentPage+"')", delay);
}


// called by onload function of each separate page
function setCurrentPage(name) {
  currentPage = name;
  enterMI(name);
}
