/******************************************************************************
* Define the Menu object. *
******************************************************************************/
function MTMenu() {
this.items = new Array();
this.MTMAddItem = MTMAddItem;
}
function MTMAddItem(item) {
this.items[this.items.length] = item;
}
/******************************************************************************
* Define the icon list, addIcon function and MTMIcon item. *
******************************************************************************/
function IconList() {
this.items = new Array();
this.addIcon = addIcon;
}
function addIcon(item) {
this.items[this.items.length] = item;
}
/******************************************************************************
* The MTMBrowser object. A custom "user agent" that'll define the browser *
* seen from the menu's point of view. *
******************************************************************************/
/******************************************************************************
* Global variables. Not to be altered unless you know what you're doing. *
* User-configurable options are at the end of this document. *
******************************************************************************/
var MTMLoaded = false;
var MTMLevel;
var MTMBar = new Array();
var MTMIndices = new Array();
var MTMUA = new MTMBrowser();
var MTMClickedItem = false;
var MTMExpansion = false;
var MTMNumber = 1;
var MTMTrackedItem = false;
var MTMTrack = false;
var MTMFrameNames;
var MTMFirstRun = true;
var MTMCurrentTime = 0; // for checking timeout.
var MTMUpdating = false;
var MTMWinSize, MTMyval, MTMxval;
var MTMOutputString = "";
var MTMCookieString = "";
var MTMCookieCharNum = 0; // cookieString.charAt()-number
/******************************************************************************
* Code that picks up frame names of frames in the parent frameset. *
******************************************************************************/
function MTMgetFrames() {
if(MTMUA.MTMable) {
MTMFrameNames = new Array();
for(i = 0; i < parent.frames.length; i++) {
MTMFrameNames[i] = parent.frames[i].name;
}
}
}
/******************************************************************************
* Functions to draw the menu. *
******************************************************************************/
function MTMListItems(menu) {
var i, isLast;
for (i = 0; i < menu.items.length; i++) {
MTMIndices[MTMLevel] = i;
isLast = (i == menu.items.length -1);
MTMDisplayItem(menu.items[i], isLast);
// These are from Netscape's Client-Side JavaScript Guide.
// setCookie() is altered to make it easier to set expiry.
function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset)
// set index of end of cookie value
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
}
function setCookie(name, value, daysExpire) {
if(daysExpire) {
var expires = new Date();
expires.setTime(expires.getTime() + 1000*60*60*24*daysExpire);
}
document.cookie = name + "=" + escape(value) + (daysExpire == null ? "" : (";expires=" + expires.toGMTString())) + ";path=/";
}