/******************************************************************
 *
 *     Date: 1999-11-17
 *     File: [/scripts]/cfMenu.js
 *   Author: Lage Ohlund
 *  Library: C-ForWard (R) JavaScript API Library
 *
 *  Copyright (C) 1999 by Muskö Net (www.musko.net)
 *
 *  This script can NOT been used freely.
 *  =============================================================
 *  Date     Ver      Sign        Description
 *  -------------------------------------------------------------
 *  991117   1.0      McLage      Start of project
 ******************************************************************/

//--Define Library Version and Load Flag
var cfDEBUG        = false;
var cfMENU_VERSION = "cfMenu v1.0";
var cfMENU_LOADED  = false;

//--Define global variables
var g_IE  = 0;  //(document.all)? 1 : 0;
var g_NS  = 0;  //(document.layers)? 1 : 0;
var g_DOM = 0;  //(document.getElementById)? 1 : 0;

//--Check Client Browser
if (parseInt(navigator.appVersion) >= 4) {
  g_DOM = (document.getElementById)? 1 : 0;
  if (navigator.appName == "Netscape") {
    g_NS = (document.layers)? 1 : 0;
  } else {
    g_IE  = (document.all)? 1 : 0;
  }
}

//--Define event handlers
if(g_IE || g_DOM) {
  eval("document.onclick = cfMouseClickHandler");
} else {
  document.onmouseup = cfMouseUpHandler;
  document.captureEvents(Event.MOUSEUP);
}

/******************************************************************
 *  cfMenu Functions
 ******************************************************************/

//--Define Global cfMenu variables
var g_cfMenu = "";

//--Handle cfMenu navigation
function cfMenu(MenuId, bShow) {
  if (cfMENU_LOADED) {
    if (bShow) {
      if (g_cfMenu) {
        cfMenu(g_cfMenu, false);
      }
      if (g_NS) {
        if (!document.layers[MenuId]) { return; }
        document.layers[MenuId].visibility = "show";
      } else if (g_DOM) {
        if (!document.getElementById(MenuId)) {return; }
        document.getElementById(MenuId).style.visibility = "visible";
      } else {
        if (!document.all[MenuId]) {return; }
        document.all[MenuId].style.visibility = "visible";
      }
      g_cfMenu = MenuId;
    } else {
      if (g_NS) {
        if (!document.layers[MenuId]) {return; }
        document.layers[MenuId].visibility = "hide";
      } else if (g_DOM) {
        if (!document.getElementById(MenuId)) {return; }
        document.getElementById(MenuId).style.visibility = "hidden";
      } else {
        if (!document.all[MenuId]) {return; }
        document.all[MenuId].style.visibility = "hidden";
      }
    }
  }
}

/******************************************************************
 *  MouseHandler Help Functions
 ******************************************************************/

//--Handle event mouseUp
function cfMouseUpHandler() {
	eval("cfMouseClickHandler()")	
}

//--Handle event mouseClick
function cfMouseClickHandler() {
  if (g_cfMenu) {
    cfMenu(g_cfMenu, false);
  }
}

/******************************************************************
 *  Window Help Functions
 ******************************************************************/

//--Set window size
function cfSetWindow(obj, width, height) {
  obj.style.left = Math.max(((document.all ? document.body.clientWidth : window.innerWidth)-width)/2, 0) + "px";
  obj.style.top = Math.max(((document.all ? document.body.clientHeight : window.innerHeight)-height)/2, 0) + "px";
  obj.style.width = Math.min((document.all ? document.body.clientWidth : window.innerWidth), width) + "px";
  obj.style.height = Math.min((document.all ? document.body.clientHeight : window.innerHeight), height) + "px";
}

/******************************************************************
 *  Initialize Library
 ******************************************************************/

/**************************************
 *
 *  Purpose:
 *    Init C-ForWard (R) Library
 *
 */

function cfInitMenu() {
//--Set Library Load Flag
  cfMENU_LOADED = true;
  if (cfDEBUG == true) { self.status = "Loading: " + cfMENU_VERSION; }
}

//--Initialize the library
cfInitMenu();

/******************************************************************
 *  EndOfFile
 ******************************************************************/
 