var Toolbar='<DIV ID="Toolbar"  class="mToolbar" NOWRAP><table style="margin-left: 100px;" border=0><tr><!-- TB_ITEMS --></tr></table><div id="tray" TRAYENABLE><!-- TRAY --></div><!-- TB_SUBITEMS --></DIV>'
var currentMenu=null
var currentSubMenu=null
var currentItem=null
var focusTimer=null
var root=''
   
var ie=(document.all)?true:false; 
var mac=(navigator.platform.indexOf("Mac") != -1)? true:false;
var opera=(navigator.userAgent.indexOf("Opera")>0)

function drawToolbar() {
	document.write(Toolbar);
}

function addMenu(id,caption, split) {
	var tmpTag='<!-- TB_ITEMS -->'
	Toolbar=Toolbar.replace(tmpTag,'<TD id="IT_'+id+'" class="mItem" NOWRAP ALIGN="left"><p class="mItemLink" onmouseover="doAction(\''+id+'\');setFocus10(\''+id+'\')" onClick="doAction(\''+id+'\');setFocus10(\''+id+'\')" onmouseout="setFocus(\''+id+'\')">&nbsp;'+caption+'&nbsp;</p></td><td width="5px" class="mItem">'+ split +' </td>'+tmpTag)
	var tmpTag='<!-- TB_SUBITEMS -->'
	Toolbar=Toolbar.replace(tmpTag,'<DIV id="TBS_'+id+'" class="mSub1Menu" ALIGN="left" onmouseover="setFocus10(\''+id+'\')" onmouseout="setFocus(\''+id+'\')" NOWRAP ALIGN="left"><!-- TBS_'+id+' --></div>'+tmpTag)
}
function addMenuItem(p,id,caption,turl,hint) {
	var tmpTag='<!-- TBS_'+p+' -->'
	Toolbar=Toolbar.replace(tmpTag,'<DIV id="TBSI_'+id+'" class="mSub1ItemLink" onmouseover="showSelect(\''+p+'\',\''+id+'\',\''+hint+'\')" onmouseup="location=root+\''+turl+'\'" NOWRAP ALIGN="left">'+caption+'</div>'+tmpTag)
}
function addSubMenuItem(p,id,caption,turl,hint) {
	var tmpTag='<!-- TBS_'+p+' -->'
	Toolbar=Toolbar.replace(tmpTag,'<DIV id="TBSI_'+id+'" class="mSub1ItemLink" onmouseover="showSelect(\''+p+'\',\''+id+'\',\''+hint+'\')" onmouseup="location=root+\''+turl+'\'" NOWRAP ALIGN="left">'+caption+'</div>'+tmpTag)
}
function addSubMenu(p,caption) {
	var tmpTag='<!-- TB_SUBITEMS -->'
	Toolbar=Toolbar.replace(tmpTag,'<DIV id="TBSUB_'+p+'" class="mSub1Menu" onmouseover="setFocus10(\''+p+'\')" onmouseout="setFocus(\''+p+'\');setFocus(\''+p+'\')" NOWRAP><!-- TBS_'+p+' --></div>'+tmpTag)
	var tmpTag='<!-- TBS_'+p+' -->'
	Toolbar=Toolbar.replace(tmpTag,'<DIV id="TBSI_'+p+'" class="mSub1MenuCaption" onmouseover="showSelect(\''+p+'\',\''+p+'\',\''+caption+'\')" NOWRAP>'+caption+'</div>'+tmpTag)
}

function addTray(c) {
	var tmpTag='<!-- TRAY -->'
	Toolbar=Toolbar.replace(tmpTag,c+tmpTag)
	Toolbar=Toolbar.replace('TRAYENABLE','class="mTray"')
}

function setFocus10(id) {
	//disableServerList();
	if (focusTimer) clearTimeout(focusTimer)
	focusTimer=setTimeout('doHide("'+id+'")',10000)
}
function setFocus(id) {
	//disableServerList();
	if (focusTimer) clearTimeout(focusTimer)
	focusTimer=setTimeout('doHide("'+id+'")',200)
}
function doHide(id) {
	//enableServerList();
	var o=document.getElementById('TBS_'+id)
	if (!o) var o=document.getElementById('TBSUB_'+id)
	o.style.display="none"

	var o=document.getElementById('IT_'+id)
	if (o) o.className='mItem'
	
	if (currentItem) {
		document.getElementById('TBSI_'+currentItem).className="mSub1ItemLink"
		currentItem=''
	}
	if (currentSubMenu) {
		document.getElementById('TBSUB_'+currentSubMenu).style.display="none"
		document.getElementById('TBSI_'+currentSubMenu).className="mSub1ItemLink"
		currentSubMenu='';
	}
	status=''
	currentMenu=''
}
function doSubHide(id) {
	if (currentSubMenu) {
		document.getElementById('TBSUB_'+currentSubMenu).style.display="none"
		currentSubMenu='';
		document.getElementById('TBSI_'+id).className="mSub1ItemLink"
	}
}
function showSelect(p,id,hint) {

	if (currentItem) {
		if (currentItem != p) {
			document.getElementById('TBSI_'+currentItem).className="mSub1ItemLink"
		}
	}
	document.getElementById('TBSI_'+id).className="mSub1ItemSelect"
	currentItem=id
	if (hint!='undefined') status=hint
	else status=''

	var o=document.getElementById('Toolbar')
	y=o.offsetTop+o.offsetHeight-4

	// check for showing SubMenu and hide it	
	if (currentSubMenu) {
		if (currentSubMenu != p) {
			doSubHide(currentSubMenu);
			currentSubMenu = "";
		}
	}
	// check for SubMenu and display it	
	var o=document.getElementById('TBSUB_'+id)
	if (o) {
		y=document.getElementById('TBSI_'+id).offsetTop+document.getElementById('TBSI_'+id).offsetParent.offsetTop
		x=document.getElementById('TBSI_'+id).offsetLeft+document.getElementById('TBSI_'+id).offsetParent.offsetLeft+document.getElementById('TBSI_'+id).offsetParent.offsetWidth-15
	
		o.style.display='block'	
		o.style.left=x
		o.style.top=y
	
		currentSubMenu=id
	}
}
function doAction(id) {
	var o=document.getElementById('Toolbar')
	y=o.offsetTop+o.offsetHeight-4
	
	if (currentMenu) {
		document.getElementById('IT_'+currentMenu).className='mItem'
		document.getElementById('TBS_'+currentMenu).style.display='none'
		if (currentSubMenu) {
			document.getElementById('TBSUB_'+currentSubMenu).style.display='none'
		}
	}

	var o=document.getElementById('IT_'+id)
	x=o.offsetLeft+o.offsetParent.offsetLeft;
	o.className='mItemSelect'
	
	o=document.getElementById('TBS_'+id)
	o.style.display='block'	
	o.style.left=x
	//o.style.top=y
	
	currentMenu=id
}



