SubMenuCnt=6;
Timeout=null;
OnMenu=null;
Menus=new Array();

function SubMenuItem(stitle,slink,starget,sspecial) {
	this.stitle=stitle;
	this.slink=slink;
	this.starget=starget;
	this.sspecial=sspecial;
}

function SubMenu(n,x,y) {
	this.n=n;
	this.name="sub"+n;
	this.x=x;
	this.y=y;
	this.items=new Array();
}

function AddItem(obj,stitle,slink,starget,sspecial) { obj.items[obj.items.length]=new SubMenuItem(stitle,slink,starget,sspecial); }

function DrawSubMenu(obj) {
	n=Menus.length;
	if (obj.items.length>0) {
		Menus[n]=true;
		if (isIE5 || isN6 || isIE4) { document.write('<div id="'+obj.name+'" style="position:absolute; left:'+obj.x+'px; top:'+obj.y+'px; visibility:hidden" onmouseover="SubMenuOn('+obj.n+')" onmouseout="SubMenuOff('+obj.n+')">'); }
		if (isNN4) {
			document.write('<layer id="'+obj.name+'" left="'+obj.x+'" top="'+obj.y+'" visibility="hidden" onmouseover="SubMenuOn('+obj.n+')" onmouseout="SubMenuOff('+obj.n+')">');
			document.write('<ilayer id="'+obj.name+'cont" left="0" top="0">');
		}
	
		document.write('	<table cellspacing="1" cellpadding="0" border="0" bgcolor="#FFFFFF"><tr><td>');
		document.write('	<table cellspacing="0" cellpadding="5" border="0" bgcolor="#046236"><tr><td>');
		document.write('	<table cellspacing="0" cellpadding="2" border="0" width="150">');
		for (x=0; x<obj.items.length; x++) {
			if (obj.items[x].sspecial) {
				document.write('	<tr>');
				document.write('		<td height="5" class="popup_inactive"><hr size="1" width="100%"></td>');
				document.write('	</tr>');
			}
			else {
				document.write('	<tr>');
				document.write('		<td class="menu" height="5"><a href="'+obj.items[x].slink+'" target="'+obj.items[x].starget+'" class="popup">'+obj.items[x].stitle+'</a></td>');
				document.write('	</tr>');
			}
		}	
		document.write('	</table></td></tr></table>');
		document.write('	</td></tr></table>');
	
		if (isIE5 || isN6 || isIE4) { document.write('</div>') }
		if (isNN4) {
			document.write('</ilayer>');
			document.write('</layer>');
		}
	}
	else { Menus[n]=false; }
}

function Show(n) {
	Obj=LayerObj("sub"+n);
	Obj.visibility="visible";
}
function Hide(n) {
	if (OnMenu!=n || OnMenu==null) {
		Obj=LayerObj("sub"+n);
		Obj.visibility="hidden";
	}
}
function TryToHide(n) { clearTimeout(Timeout); Timeout=setTimeout("Hide("+n+")",250); }
function HideAllExcept(n) { for (x=1; x<=SubMenuCnt; x++) { if (x!=n && Menus[x-1]) { Hide(x); } } }

function MenuOn(n) { 
	if (Loaded) { 
		HideAllExcept(n);
		if (Menus[n-1]) {
			OnMenu=n;
			clearTimeout(Timeout);
			Show(n);
		}
	}
}
function MenuOff(n) { 
	if (Loaded && Menus[n-1]) {
		OnMenu=null;
		TryToHide(n);
	}
}

function SubMenuOn(n) { clearTimeout(Timeout); Show(n); }
function SubMenuOff(n) { TryToHide(n); }


