// Fields
var o_mtag = 'odhm_';
var o_odhm = null;
var o_show = false;
var ie = document.all;
var ns6 = (document.getElementById && !document.all);
// TheGamingLib
if(typeof TheGamingLib=="undefined"){
var TheGamingLib={};
};
//
// TheGamingLib.DHTMLMenu
// Methods
TheGamingLib.DHTMLMenu={
enableDHTMLMenu:function(){
TheGamingLib.DHTMLMenu.Enable=true;
},
Menu:function(){
this.params = new Object();
this.variables = new Object();
},
createMenu:function(mId,mX,mY){
if(typeof mX=='undefined') mX = 0;
if(typeof mY=='undefined') mY = 0;
var menu = new TheGamingLib.DHTMLMenu.Menu();
menu.addParam('id',mId);
menu.addParam('type','dynamic');
menu.addParam('selectable','false');
menu.addParam('x',mX);
menu.addParam('y',mY);
return TheGamingLib.DHTMLMenu.setMenu(menu);
},
createStaticMenu:function(mId,itemId,itemX,itemY){
var menu = new TheGamingLib.DHTMLMenu.Menu();
menu.addParam('id',mId);
menu.addParam('type','static');
menu.addParam('selectable','false');
menu.addParam('item',itemId);
menu.addParam('x',itemX);
menu.addParam('y',itemY);
return TheGamingLib.DHTMLMenu.setMenu(menu);
},
setMenu:function(oDHTMLMenu){
if(TheGamingLib.DHTMLMenu.Enable == true){
TheGamingLib.DHTMLMenu.Menus[TheGamingLib.DHTMLMenu.Count] = oDHTMLMenu;
TheGamingLib.DHTMLMenu.Count += 1;
return (TheGamingLib.DHTMLMenu.Count - 1);
}
return -1;
},
getMenu:function(id){
if((TheGamingLib.DHTMLMenu.Enable == true) && (id > -1) && (id < TheGamingLib.DHTMLMenu.Count)){
return TheGamingLib.DHTMLMenu.Menus[id];
}
return null;
},
showMenu:function(id){
if(TheGamingLib.DHTMLMenu.Enable == true){
o_odhm = null;
var mnid = (o_mtag+id);
var menu;
var mnme;
for(var i=0;i<TheGamingLib.DHTMLMenu.Count;i++){
menu = TheGamingLib.DHTMLMenu.Menus[i];
mnme=(o_mtag+menu.getParam('id'));
if(mnme == mnid){
o_show = true;
o_odhm = menu;
}
if(mnme){
glib_hidedhtmlmenu(document.getElementById(mnme), menu.getParam('selectable'));
}
}
}
}
}
// prototype
var ODHM = TheGamingLib.DHTMLMenu.Menu.prototype;
ODHM.addParam = function(name, value) {this.params[name] = value;}
ODHM.getParam = function(name) {return this.params[name];}
ODHM.getParams = function() {return this.params;}
ODHM.addVariable = function(name, value) {this.variables[name] = value;}
ODHM.getVariable = function(name) {return this.variables[name];}
ODHM.getVariables = function() {return this.variables;}
ODHM.showMe = function(){glib_dhtmlmenushow(this.getParam('id'));return true;}
ODHM.hideMe = function(){glib_hidedhtmlmenu(document.getElementById((o_mtag+this.getParam('id'))),'false');return true;}
// Fields
TheGamingLib.DHTMLMenu.Enable=new Boolean(false);
TheGamingLib.DHTMLMenu.Count=new Number();
TheGamingLib.DHTMLMenu.Menus=new Array();
TheGamingLib.DHTMLMenu.MenuObjects=new Array();
// Function
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function getAbsPos(elt,which){
var pos = 0;
while(elt != null){
pos += elt["offset" + which];
elt = elt.offsetParent;
}
return pos;
}
function glib_dhtmlmenushow(id, obj, sep){
if(typeof obj == 'undefined') obj = null;
if(typeof sep == 'undefined') sep = ";";
if(obj != null){
TheGamingLib.DHTMLMenu.MenuObjects = obj.split(sep);
}else{
TheGamingLib.DHTMLMenu.MenuObjects = new Array();
}
TheGamingLib.DHTMLMenu.showMenu(id);
}
function glib_hidedhtmlmenu(menu, selectable){
if(menu){
if(ns6||ie){
if(selectable != 'true'){
menu.style.display="none";
menu.style.visibility="hidden";
menu.style.left="-1000px";
menu.style.backgroundColor='';
menu.style.width='';
}
}
}
}
function positionmenu(e){
if(o_odhm != null){
if(o_show == true){
var mbox = document.getElementById(o_mtag+o_odhm.getParam('id'));
if(o_odhm.getParam('type') == 'static'){
//position of the menu
var elt = document.getElementById(o_odhm.getParam('item'));
var posX=(elt.x)? elt.x : getAbsPos(elt,"Left");
var posY=(elt.y)? elt.y : getAbsPos(elt,"Top");
mbox.style.left=(posX+10+o_odhm.getParam('x'))+"px";
mbox.style.top=(posY+20+o_odhm.getParam('y'))+"px";
}else{
var curX=(ns6)? e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)? e.pageY : event.clientY+ietruebody().scrollTop;
//position of the menu where the mouse is positioned
mbox.style.left=((curX+10)+o_odhm.getParam('x'))+"px";
mbox.style.top=((curY+20)+o_odhm.getParam('y'))+"px";
}
mbox.style.display="block";
mbox.style.visibility="visible";
o_show = false;
}else{
glib_dhtmlmenushow(o_odhm);
o_odhm = null;
}
}
};
// Document
document.onclick=positionmenu;
