function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// ------------------------------------------------------------------------------------------------

IE = window.navigator.appName.indexOf("Explorer") != -1 ? true : false;
Menu = [];
ActiveMenu = null;
MenuDelay = 1000;

// MenuObj.state = 0 (off), 1 (on but inactive), 2 (on and active)

function RegisterMenu(obj,onScript,offScript) {
 if (typeof(obj) != "object") obj = document.getElementById(obj);
 if (!obj) return false;
 if (obj.menuNumber) return obj.menuNumber;
 obj.menuNumber = Menu.length;
 obj.state = 0;
 obj.fate = null;
 obj.onshow = typeof(onScript) == "function" ? onScript : (onScript ? eval("obj.onshow = function() {\n " + onScript + "\n}") : null);
 obj.onhide = typeof(offScript) == "function" ? offScript : (offScript ? eval("obj.onhide = function() {\n " + offScript + "\n}") : null);
 Menu[Menu.length] = obj;
 return obj.menuNumber;
}

function UseMenu(m,s,x,y) {
 m = parseInt(m);
 if (!Menu[m]) return false;
 if (s) {
  if (Menu[m].state) {
   Menu[m].state = 2;
   clearTimeout(Menu[m].fate);
   return true;
   }
  if (Menu[m].onshow) Menu[m].onshow();
  x = parseInt(x);
  y = parseInt(y);
  if (isNaN(x) || isNaN(y)) {
   x = 0;
   y = 0;
   }
  if (ActiveMenu) UseMenu(ActiveMenu.menuNumber,false);
  Menu[m].style.left = x + "px";
  Menu[m].style.top = y + "px";
  Menu[m].state = 2;
  ActiveMenu = Menu[m];
  Menu[m].style.visibility = "visible";
  } else {
  clearTimeout(Menu[m].fate);
  Menu[m].state = 0;
  ActiveMenu = null;
  Menu[m].style.visibility = "hidden";
  if (Menu[m].onhide) Menu[m].onhide();
  }
 return true;
}

function CheckMenu(m,s) {
 m = parseInt(m);
 if (!Menu[m]) return false;
 if (s) {
  Menu[m].state = 2;
  clearTimeout(Menu[m].fate);
  } else {
  Menu[m].state = 1;
  Menu[m].fate = setTimeout("if (Menu[" + m + "].state == 1) UseMenu(" + m + ",false);",MenuDelay);
  }
 return true;
}

// ------------------------------------------------------------------------------------------------

function doAutoexec() {
 var e,a = document.getElementById("Autoexec"); if (a) eval(a.value);
 for (e = 0; e < Autoexec.length; e++) eval(Autoexec[e]);
}

function JSS(data,reaction) {
 var c,msg = "";
 if (reaction) {
  data += "";
  for (c = 0; c < data.length; c++) msg += "&#" + data.charCodeAt(c) + ";";
  return escape(msg);
  } else {
  document.write(unescape(data));
  }
}