/****************************************************************************************/
/*  Copyright (C) 2004 Erik Boon (Tectavia)			                        */
/*                                                                                      */
/*  This program IS NOT free software; you may not use, redistribute or modify          */
/*  without the permission of the author.  						*/
/****************************************************************************************/


window.aClasses = new Array();
var bw=new bw_check();
if (bw.ie) {
   for (y=0;y < document.styleSheets.length; y++ ) {
       for ( i = 0; i < document.styleSheets[y].rules.length; i++ ) {
	   sClass = document.styleSheets[y].rules[i].selectorText;
	   eval('window.aClasses["'+sClass+'"] = "1";');
       }
   }
} else {
   for (y=0;y < document.styleSheets.length; y++ ) {
       for ( i = 0; i < document.styleSheets[y].cssRules.length; i++ ) {
	   sClass = document.styleSheets[y].cssRules[i].selectorText;
	   eval('window.aClasses["'+sClass+'"] = "1";');
       }
   }  
}


function bw_check(){
var is_major=parseInt(navigator.appVersion);
this.nver=is_major;
this.ver=navigator.appVersion;
this.agent=navigator.userAgent;
this.dom=document.getElementById?1:0;
this.opera=window.opera?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1&&this.dom&&!this.opera)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1&&this.dom&&!this.opera)?1:0;
this.ie7=(this.ver.indexOf("MSIE 7")>-1&&this.dom&&!this.opera)?1:0;
this.ie8=(this.ver.indexOf("MSIE 8")>-1&&this.dom&&!this.opera)?1:0;
this.ie9=(this.ver.indexOf("MSIE 9")>-1&&this.dom&&!this.opera)?1:0;
this.ie4=(document.all&&!this.dom&&!this.opera)?1:0;
this.ie=this.ie4||this.ie5||this.ie6||this.ie7||this.ie8||this.ie9;
this.mac=this.agent.indexOf("Mac")>-1;
this.ns6=(this.dom&&parseInt(this.ver)>=5)?1:0;
this.ie3=(this.ver.indexOf("MSIE")&&(is_major<4));
this.hotjava=(this.agent.toLowerCase().indexOf('hotjava')!=-1)?1:0;
this.ns4=(document.layers&&!this.dom&&!this.hotjava)?1:0;
this.bw=(this.ie8||this.ie7||this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera);
this.ver3=(this.hotjava||this.ie3);
this.opera7=((this.agent.toLowerCase().indexOf('opera 7')>-1) || (this.agent.toLowerCase().indexOf('opera/7')>-1));
this.operaOld=this.opera&&!this.opera7;
return this;
};


function TCmLC() {
	this.init = function() {
		this.curPos = new mouseCoords(false);
		if(this.isIE()) document.onmousemove = window.TCmL.eTrackCoords;
		else {
			window.captureEvents(Event.MOUSEMOVE);
			window.onmousemove = window.TCmL.eTrackCoords;
		}
	}
	this.isIE = function() {
		return navigator.appName.indexOf('Microsoft') >= 0;
	}
	this.getLeft = function(obj) {
		return (obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft + this.getLeft(obj.offsetParent));
	}
	this.getTop = function(obj) {
		return (obj.offsetParent==null ? obj.offsetTop : obj.offsetTop + this.getTop(obj.offsetParent));
	}
	this.in_array = function(needle, haystack) {
		for(var i in haystack) {
			if(haystack[i] == needle) return true;
		}
		return false;
	}

	this.getElementByClassName = function(that, name) {
		for(var i=0; i<that.childNodes.length; ++i) {
			if(that.childNodes[i].className == name) return that.childNodes[i];
			else {
				var f = this.getElementByClassName(that.childNodes[i], name);
				if(f) return f;
			}
		}
		return false;
	}

	this.copyObjectByVal = function(obj, recursive) {
		var ret = new Object;
		for(var i in obj) {
	        if (recursive && typeof obj[i] == 'object') {
	            ret[i] = window.TCmL.copyObjectByVal(obj[i], recursive);
	        }
	        else ret[i] = obj[i];
		}
	}

	this.eTrackCoords = function(e) {
		window.TCmL.curPos.x = (window.TCmL.isIE()) ? event.clientX : e.pageX;
		window.TCmL.curPos.y = (window.TCmL.isIE()) ? event.clientY : e.pageY;
		if(window.TCmL.curPos.display) self.status = window.TCmL.curPos.x + ' x ' + window.TCmL.curPos.y;
	}

	function mouseCoords(display) {
		this.x = this.y = 0;
		this.display = display;
	
		this.isOver = function(that) {
			if(typeof(that) == 'undefined') return;
			if(that.style.visibilty == 'hidden' || that.style.visibilty == 'hide') return;
			var left = window.TCmL.getLeft(that);
			var top = window.TCmL.getTop(that);
			if(window.TCmL.isIE()) {
				left -= document.body.scrollLeft;
				top -= document.body.scrollTop;
			}
			var right = left + that.offsetWidth;			
			var bot = top + that.offsetHeight;
			return (this.x > left) && (this.x < right) && (this.y > top) && (this.y < bot);
		}
	}
}
function TCmO(x, y) {
	this.x = x;
	this.y = y;
}

window.TCmL = new TCmLC(); window.TCmL.init();
window.TCmCnt = window.JSMenuItemCounter = 0;

function JSMenu(menutype, regClass, ovrClass, parent) {
	if(!menutype) menutype = 'v';
	this.menutype = (menutype.substr(0,1).toLowerCase() == 'h') ? 'horizontal' : 'vertical';
//	this.menustyle = menustyle;
        this.bw=new bw_check();
	this.regclass = regClass;
	this.ovrclass = ovrClass;
	this.sepclass ='';
	this.sepPx =0;
	this.barclass ='';
	this.timeout = 1000;
	this.offset = new TCmO(0, 0);
	this.scrictpositioning = false;
	this.width = 0;
	this.height = 0;
	this.align = 'right';
	this.valign = 'top';
	this.parent = parent;
	this.isRoot = (parent) ? false : true;
	this.menudiv = false;
	this.lib = window.TCmL;
	this.initflag = false;
	this.menuid = ++window.TCmCnt;
	this.menuitemids = 0;
	this.menuitems = new Array();
	this.triggers = new Array();
	this.triggerswap = new Array();
	this.triggercount = 0;
	this.sepChar = "|";
	this.timer;
	this.alignopts = new Array('top', 'bottom', 'left', 'right');
	this.visible = false;	

	if(this.parent) {
		this.align = parent.align;
		this.valign = parent.valign;
		this.timeout = parent.timeout;
		this.offset = parent.offset;
		this.scrictpositioning = parent.scrictpositioning;
	} 

	this.init = function() {
		if(!window.JSMenus) window.JSMenus = new Array();
		window.JSMenus[this.menuid] = this;

		for(var i=0; i<this.menuitems.length; ++i) {
			if(this.menuitems[i].childmenu) this.menuitems[i].childmenu.init();
		}

		this.initflag = true;
	}

	this.write = function() {
		document.write(this.writemenutable());
		document.write(this.writemenudivs());
	}
	this.writemenutable = function() {

		var tablestylestr = tdstylestr = tdstylestr2 = '';
		//var dohorz = (this.isRoot && this.menutype == 'horizontal');
		var dohorz = (this.menutype == 'horizontal');
		var rootmenu = this.getRootMenu();
		var buf = '';
		buf += '<table cellspacing="0" cellpadding="0"><tr><td class="'+this.barclass+'"><table cellspacing="0" cellpadding="0">';
	
		if(dohorz) buf += '<tr>';

		var menuref = "window.JSMenus["+this.menuid+"]";
/* arrowCode
		var arrowalign = (this.menustyle.arrowAlign) ? this.menustyle.arrowAlign : this.align;

		if(arrowalign != 'left' && arrowalign != 'right') arrowalign = this.align;
*/

		for(var i=0; i<this.menuitems.length; ++i) {
			var menuitemref = menuref + ".menuitems["+i+"]";
			var showmenujs = hidemenujs = elemId = '';
			var arrowcode = '';
			var pxBetween = (this.pxBetween)? this.pxBetween : 0; 

			if(this.menuitems[i].childmenu) {
				showmenujs += 'window.JSMenus['+this.menuitems[i].childmenu.menuid+'].showMenu(this,'+this.menuitems[i].menuitemid+');';
				showmenujs += 'window.JSMenuItems['+this.menuitems[i].menuitemid+'].parent.mouseOver(this, \''+this.menuid+'\','+this.menuitems[i].menuitemid+');';		
			}
			else {
				showmenujs += 'window.JSMenuItems['+this.menuitems[i].menuitemid+'].parent.doHideAllMenus();';
				showmenujs += 'window.JSMenuItems['+this.menuitems[i].menuitemid+'].parent.mouseOver(this, \''+this.menuid+'\','+this.menuitems[i].menuitemid+');';
				hidemenujs += 'window.JSMenuItems['+this.menuitems[i].menuitemid+'].parent.mouseOut(this, \''+this.menuid+'\','+this.menuitems[i].menuitemid+');';

			}
			hidemenujs += 'window.JSMenus['+rootmenu.menuid+'].hideMenu('+this.menuitems[i].menuitemid+','+this.menuid+');'
			elemId = 'm'+this.menuitems[i].menuitemid;

/* arrowCode
			if(this.menuitems[i].childmenu && this.menustyle.arrowImage) {
				arrowcode = '<img src="'+this.menustyle.arrowImage+'" style="margin:0px; border:none;" alt="">';
			}
*/

			var tdstyle = this.getTDStyleString(this.menuitems[i].menuitemid);
			tdstyle += tdstylestr;
			
			var tdSepBuf = '';
			if (this.sepclass) {
				if(dohorz) {
					tdSepBuf = '<td width='+this.seppx+' class="'+this.sepclass+'">';
//					tdSepBuf += '<img src="images/pic11.gif">';
                    if (this.sepChar.length == 0) {
					   tdSepBuf += "|";
					} else {
					   tdSepBuf += this.sepChar;
					}
				    tdSepBuf += '</td>';
				} else {
				    if (this.seppx != 0) {
					   tdSepBuf = '<tr><td height='+this.seppx+' class="'+this.sepclass+'">';
					   tdSepBuf += '<img src="images/pic11.gif">';
				       tdSepBuf += '</td></tr>';
					}
				}
			} 

			if(!dohorz) buf += '<tr>';
			var sClsH = '';
			var sClsD = '';			
			if (window.aClasses["."+this.menuitems[i].regclass+"H"]) {
			   sClsH = this.menuitems[i].regclass+"H";
			} else {
			   sClsH = this.regclass+"H";
			}
			if (window.aClasses["."+this.menuitems[i].regclass+"D"]) {
			   sClsD = this.menuitems[i].regclass+"D";
			} else {
			   sClsD = this.regclass+"D";
			}			
			buf += '<td style="'+tdstyle+'" class="'+sClsH+'" id="'+elemId+'H" ';
			buf += 'onmouseover="window.status=\''+this.menuitems[i].alttext+'\';'+showmenujs+'" ';
			buf += 'onmouseout="window.status=\'\';'+hidemenujs+'" ';
			buf += 'onclick="'+menuitemref+'.click();" nowrap>';

			buf += '<table width="100%" cellspacing="0" style="padding:0px;margin:0px;border:none;background:none;"><tr>';
			if(arrowcode != '' && arrowalign == 'left') buf += '<td align="left" style="padding-right:'+this.menustyle.horizontalPadding+';">'+arrowcode+'</td>';
			buf += '<td width="100%" style="white-space: nowrap" id="'+elemId+'D" class="'+sClsD+'">'+this.menuitems[i].title+'</td>';
/* arrowCode0
			if(arrowcode != '' && arrowalign == 'right') buf += '<td align="right" style="padding-left:'+this.menustyle.horizontalPadding+';">'+arrowcode+'</td>';
*/
			buf += '</tr></table>';

			buf += '</td>';
			if(dohorz && i != this.menuitems.length-1 && pxBetween != 0 ) buf += '<td><img src="images/pic11.gif" width='+pxBetween+'></td>';
			if(dohorz) {
			  if(i != this.menuitems.length-1) {
			    buf += tdSepBuf;			   
			    if(pxBetween != 0) buf += '<td><img src="images/pic11.gif" width='+pxBetween+'></td>';
			  }
			}
			if(!dohorz) buf += '</tr>';
			if(!dohorz && i != this.menuitems.length-1 && pxBetween != 0) buf += '<tr style="padding:0px;margin:0px;border:none;background:none;"><td><img src="images/pic11.gif" width='+pxBetween+'></td></tr>';
			if(!dohorz) {
				if(i != this.menuitems.length-1) {
				  buf += tdSepBuf;
				  if(pxBetween != 0) buf += '<tr style="padding:0px;margin:0px;border:none;background:none;"><td><img src="images/pic11.gif" width='+pxBetween+'></td></tr>';
				}
			}
		}

		if(dohorz) buf += '</tr>';
		buf += '</table></td></tr></table>';
		//alert(buf);

		return buf;
	}
	this.writemenudivs = function() {
		var buf = '';
		for(var i=0; i<this.menuitems.length; ++i) {
			if(this.menuitems[i].childmenu) {
			   if (this.ns6) {
			   	var stylestr = 'visibility:hide;position:absolute;z-index:9999;';
			   } else {
				var stylestr = 'visibility:hidden;position:absolute;z-index:9999;';
			   }
				if(this.width) stylestr += 'width:'+this.width+';';

				buf += '<div id="jsmenudiv'+this.menuitems[i].childmenu.menuid+'" style="'+stylestr+'">';
				buf += this.menuitems[i].childmenu.writemenutable();
				buf += '</div>';

				buf += this.menuitems[i].childmenu.writemenudivs();
			}
		}

		return buf;
	}

	this.addItem = function (title, href, target, alttext, height, width, regClass, ovrClass) { 
		var a = arguments;
		var key = this.menuitems.length;
		height = (!a[4]) ? this.height : height;
		width = (!a[5]) ? this.width : width;
		regClass = (!a[6]) ? this.regclass : regClass;
		ovrClass = (!a[7]) ? this.ovrclass : ovrClass;
		this.menuitems[key] = new JSMenuMenuItem(title, href, target, alttext, this, height, width, regClass, ovrClass);
		this.menuitems[key].init();
		return this.menuitems[key];
	}
	
	this.addMenu = function(title, href, target, alttext, height, width, regClass, ovrClass, regmClass, ovrmClass, sepClass, sepPx, barClass, pxB, ox, oy, orientation, valign, align, sepChar) {

		var key = this.menuitems.length;
		var a = arguments;
		var height = (!a[4]) ? this.height : height;
		var width =  (!a[5]) ? this.width : width;
	    var regClass = (!a[6]) ? this.regclass : regClass;
		var ovrClass = (!a[7]) ? this.ovrclass : ovrClass;
	    var regmClass = (!a[8]) ? this.regclass : regmClass;
		var ovrmClass = (!a[9]) ? this.ovrclass : ovrmClass;
		var sepClass = (!a[10]) ? this.sepclass : sepClass;
		var sepPx = (!a[11]) ? this.seppx : sepPx;
		var barClass = (!a[12]) ? this.barclass : barClass;
		var orientation = (a[16] == 'null') ? this.menutype : orientation;
		var valign = (a[17] == 'null') ? this.valign : valign;
		var align = (a[18] == 'null') ? this.align : align;
		var sepChar = (a[19] == 'null') ? this.sepChar : sepChar;

		this.menuitems[key] = new JSMenuMenuItem(title, href, target, alttext, this, height, width, regClass, ovrClass);
		this.menuitems[key].childmenu = new JSMenu(this.menutype, regmClass, ovrmClass, this);
		this.menuitems[key].childmenu.menutype = orientation;
		this.menuitems[key].childmenu.sepclass = sepClass;
		this.menuitems[key].childmenu.seppx = sepPx;
		this.menuitems[key].childmenu.barclass = barClass;
		this.menuitems[key].childmenu.pxBetween = pxB;
		this.menuitems[key].childmenu.width = width;
		this.menuitems[key].childmenu.height = height;
		this.menuitems[key].childmenu.valign = valign;
		this.menuitems[key].childmenu.align = align;
		this.menuitems[key].childmenu.sepChar = sepChar;
		if(a[14]) this.menuitems[key].childmenu.x = ox;
		if(a[15]) this.menuitems[key].childmenu.y = oy;
		this.menuitems[key].init();
		return this.menuitems[key].childmenu;
	}

	this.getMenuDiv = function() {
		return document.getElementById('jsmenudiv'+this.menuid);
	}
	this.getRootMenu = function() {
		var that = this;
		while(that.parent) that = that.parent;
		return that;
	}

	this.showMenu = function(that, itemId) {
		if(!this.initflag) return;
		clearTimeout(this.timer);

		this.parent.doHideAllMenus();

		var thismenudiv = this.getMenuDiv();

		var rootmenu = this.getRootMenu();
		if(!that.id) that.id = 'menutrigger_' + this.menuid + '_' + ++rootmenu.triggercount;
		this.triggers[this.menuid] = that;

		this.mouseOver(that,null,itemId);

		var thisoffsetx = this.offset.x;
		var thisoffsety = this.offset.y;
		if (window.JSMenuItems[this.menuitemids].childmenu.x) thisoffsetx = window.JSMenuItems[this.menuitemids].childmenu.x
		if (window.JSMenuItems[this.menuitemids].childmenu.y) thisoffsety = window.JSMenuItems[this.menuitemids].childmenu.y
		var sValign = window.JSMenuItems[this.menuitemids].childmenu.valign;
		var sAlign = window.JSMenuItems[this.menuitemids].childmenu.align;
		var posleft = postop = 0;
		var thisdivheight = thismenudiv.offsetHeight;
		var thisdivwidth = thismenudiv.offsetWidth;
		//alert (that.id + " - " + thisdivheight + " - " + thisdivwidth + " - " + this.menutype + " - " + sValign + " - " + sAlign );

//		if(this.parent.isRoot && this.menutype == 'horizontal') {
		if(this.menutype == 'horizontal') {
		    switch (sValign){
		     case 'top':
			   postop = this.lib.getTop(that) - thisdivheight;
			   break;
		     case 'bottom':
			   postop = this.lib.getTop(that) + that.offsetHeight + thisoffsety;
			   break;
			 default:
			   postop = this.lib.getTop(that);		
		    }
		    switch (sAlign){
		     case 'left':
			   posleft = this.lib.getLeft(that) - thisdivwidth - thisoffsetx;
			   break;
		     case 'right':
			   posleft = this.lib.getLeft(that) + that.offsetWidth + thisoffsetx;
			   break;
		     default:
			   posleft = this.lib.getLeft(that) + thisoffsetx;
		    }
		} else {		
		    switch (sAlign){
		     case 'left':
			   posleft = this.lib.getLeft(that) - thisdivwidth - thisoffsetx;
			   break;
		     case 'right':
			   posleft = this.lib.getLeft(that) + that.offsetWidth + thisoffsetx;
			   break;
		     default:
			   posleft = this.lib.getLeft(that) + thisoffsetx;
		    }
		    switch (sValign){
		     case 'top':
			   postop = this.lib.getTop(that) - thisdivheight;
			   break;
		     case 'bottom':
			   postop = this.lib.getTop(that) + that.offsetHeight + thisoffsety;
			   break;
			 default:
			   postop = this.lib.getTop(that) + that.offsetHeight;
		    }
			/*
			if(sAlign == 'left') {
				posleft = this.lib.getLeft(that) - thisdivwidth - thisoffsetx;
			} else { // right
				posleft = this.lib.getLeft(that) + that.offsetWidth + thisoffsetx;
			}
			if(sValign == 'top') {
				postop = this.lib.getTop(that) - thisdivheight;
			} else { // bottom
				postop = this.lib.getTop(that) + that.offsetHeight;
			}
			*/
		}

		// try to keep the menu on the screen
		if(!this.scrictpositioning) {
			var divbot = postop + thisdivheight;
			var screenbot = document.body.clientHeight + document.body.scrollTop;
			var screentop = screenbot - document.body.clientHeight;

			if(divbot > screenbot) {
				if(this.menutype == 'horizontal' && this.parent.isRoot) postop = this.lib.getTop(that) - thisdivheight;
				else postop = screenbot - thisdivheight - 1;
			}
			else if(postop < screentop) {
				if(this.menutype == 'horizontal' && this.parent.isRoot) postop = this.lib.getTop(that) + that.offsetHeight;
				else postop = screentop;
			}
	
			var divright = posleft + thisdivwidth;
			var screenright = document.body.clientWidth + document.body.scrollLeft;
			var screenleft = screenright - document.body.clientWidth;

			if(divright > screenright) {
				if(this.menutype == 'horizontal' && this.parent.isRoot) posleft = screenright - thisdivwidth - 1;
				else posleft = this.lib.getLeft(that) - thisdivwidth;
 			}
			else if(posleft < screenleft) {
				if(this.menutype == 'horizontal' && this.parent.isRoot) posleft = screenleft + 1;
				else posleft = this.lib.getLeft(that) + that.offsetWidth;
			}
		}

		// position & display
		thismenudiv.style.top = postop;
		thismenudiv.style.left = posleft;
		if (this.ns6) {
		  thismenudiv.style.visibility = 'show';
		} else {
		  thismenudiv.style.visibility = 'visible';
		}
		this.visible = true;
	}

	this.mouseOver = function(that, menuid, itemId) {
		var style = false;
		if(menuid) style = window.JSMenus[menuid].menustyle;
		else if(this.menustyle) style = this.menustyle;
		else if(this.parent) style = this.parent.menustyle;
		
		if (itemId) {this.menuitemids = itemId;}		
		sId = that.id.substr(0,that.id.length-1);
		oObjH = document.getElementById(sId+'H');
		oObjD = document.getElementById(sId+'D');
		if (!window.JSMenuItems[itemId].AHclass) {
		   window.JSMenuItems[itemId].Hclass = oObjH.className;
		   if (window.aClasses["."+window.JSMenuItems[itemId].ovrclass+"AH"]) {
		      window.JSMenuItems[itemId].AHclass = window.JSMenuItems[itemId].ovrclass+"AH";
		   } else {
		      if (window.JSMenuItems[itemId].parent) {
			      window.JSMenuItems[itemId].AHclass = window.JSMenuItems[itemId].parent.ovrclass+"H";
			  } else {
			      sRc = oObjH.className.substr(0,oObjH.className.length-1);
		          window.JSMenuItems[itemId].AHclass = sRc+"AH";
			  }
		   }
		}		
		oObjH.className = window.JSMenuItems[itemId].AHclass;
		
		if (!window.JSMenuItems[itemId].Dclass) {
		   window.JSMenuItems[itemId].Dclass = oObjD.className;
		   //if (window.aClasses["."+window.JSMenuItems[itemId].ovrclass+"AD"]) {
		      //window.JSMenuItems[itemId].ADclass = window.JSMenuItems[itemId].ovrclass+"AD";
		   if (window.aClasses["."+window.JSMenuItems[itemId].ovrclass+"D"]) {
		      window.JSMenuItems[itemId].ADclass = window.JSMenuItems[itemId].ovrclass+"D";
		   } else {	   	
		      if (window.JSMenuItems[itemId].parent) {
			      window.JSMenuItems[itemId].ADclass = window.JSMenuItems[itemId].parent.ovrclass+"D";
			  } else {
			      sRc = oObjD.className.substr(0,oObjD.className.length-1);
		          window.JSMenuItems[itemId].ADclass = this.ovrClass+"AD";
			  }
		   }
		}
		oObjD.className = window.JSMenuItems[itemId].ADclass;		
	
		return;

	}

	this.mouseOut = function(that, menuid, itemId) {
		var style = false;
		if(menuid) style = window.JSMenus[menuid].menustyle;		
		else if(this.parent) style = this.parent.menustyle;
		
		if (that) {
		   newthat = that.id.substr(0,that.id.length-1);
		   itemId = parseInt(newthat.substr(1,newthat.length));			
		   sId = that.id.substr(0,that.id.length-1);
		   oObjH = document.getElementById(sId+'H');
		   oObjD = document.getElementById(sId+'D');
		   oObjH.className = window.JSMenuItems[itemId].Hclass;
		   oObjD.className = window.JSMenuItems[itemId].Dclass;
		}

		return;

	}

	this.hideMenu = function(p1,p2) {
		if(!this.initflag) return;
		var rootmenu = this;		
		clearTimeout(rootmenu.timer);
		if (p1) {
	            rootmenu.timer = setTimeout("window.JSMenus["+rootmenu.menuid+"].mouseOut(null,null,"+p1+");window.JSMenus["+rootmenu.menuid+"].startDoHideMenu("+p1+");", rootmenu.timeout);
		} else {
		  rootmenu.timer = setTimeout("window.JSMenus["+rootmenu.menuid+"].startDoHideMenu();", rootmenu.timeout);
		}
	}
	this.startDoHideMenu = function(p1) {
		this.doHideAllMenus(p1);
	}
	this.doHideMenu = function(p1) {
		if (this.ns6) {
		  this.getMenuDiv().style.visibility = 'hide';
		} else {
		  this.getMenuDiv().style.visibility = 'hidden';
		}
		if(this.triggers[this.menuid]) this.mouseOut(this.triggers[this.menuid],this.menuid,null);		
		this.visible = false;
	}

	this.doHideAllMenus = function(p1) {
		var rootmenu = this.getRootMenu();
		clearTimeout(rootmenu.timer);
		for(var i=0; i<this.menuitems.length; ++i) {
			if(this.menuitems[i].childmenu) {
				this.menuitems[i].childmenu.doHideAllMenus(p1);
				this.menuitems[i].childmenu.doHideMenu(p1);
			}
		}
	}

	this.cat = function(key, val) {
		if(!val) return '';
		var buf = '';
		buf += key + ':' +val+ ';';
		return buf;
	}

	this.getFontStyleString = function(itemId) {
		this.init();
		var buf = '';

		this.fontStyleString = buf;
		return this.fontStyleString;
	}



	this.getTDStyleString = function(itemId) {
		this.init();
		var buf = '';
		buf += this.cat('height',window.JSMenuItems[itemId].height);
		buf += this.cat('width',window.JSMenuItems[itemId].width);
     		this.styleString = buf;
		return this.styleString;
	}

 function JSMenuMenuItem(title, href, target, alttext, parent, height, width, regClass, ovrClass) { 	

		this.title = title;
		this.href = href;
		this.target = target;
		this.alttext = alttext;
		this.childmenu = false;
		this.parent = parent;
		this.height = height;
		this.width = width;
		this.regclass = regClass;
		this.ovrclass = ovrClass;
		this.menuitemid = ++window.JSMenuItemCounter;

		this.init = function() {
			if(!window.JSMenuItems) window.JSMenuItems = new Array();
			window.JSMenuItems[this.menuitemid] = this;

			if(!this.target) this.target = '_self';

			if(!this.href) this.href = '';
			var re = new RegExp("'", 'gi') ;
			this.alttext = (this.alttext) ? this.alttext : this.href;
			this.alttext = this.alttext.replace(re, '');

			if(!window.JSMenuWindowCount) window.JSMenuWindowCount = 0;
		}

		this.click = function() {
			if(!this.href) return;
			switch(this.target) {
				case '_script':
				    eval(this.href);
					break;				
				case '_self':
					document.location = this.href;
					break;
				case '_top':
					top.location = this.href;
					break;
				case '_blank':
					window.open(this.href, 'jswindow' + ++window.JSMenuWindowCount, 'resizable=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes');
					break;
				case '_window':
					eval(this.href);
					break;
				default:
					if(typeof(window.frames[this.target]) != 'undefined') {
						window.frames[this.target].location = this.href;
					}
			}

		}
	}
}
