function menuItem(text, link, smnu){
	this.text = text;
	this.link = link;
	this.submnu = smnu;
}

function menuTrigger(name, text){
	this.name = name;
	this.text = text;
}

function menu(){
	var itemArray = new Array();
	var args = menu.arguments;
	
	this.name = args[0];
	this.trigger = args[1];
	for(i=2; i<args.length; i++){
		itemArray[i-2] = args[i];
	}
	
	this.menuItems = itemArray;
	this.write = writeMenu;
	this.position = positionMenu;
}
			
function writeMenu(mname){
try {
	var mnu_El;
	var myElement;
	
	mnu_El = document.getElementById('cal');

	for(i=0; i<mname.menuItems.length; i++){
		myElement = document.createElement('a');
		myElement.setAttribute('href', mname.menuItems[i].link);
		myElement.setAttribute('id', "itm" + mname.menuItems[i].submnu);
		myElement.setAttribute('name', "link2");
		myElement.setAttribute('class', "tab");
		myElement.setAttribute('target', "tabIframe2");

		myElement.appendChild(document.createTextNode(mname.menuItems[i].text));
		mnu_El.appendChild(myElement);
	}
	} catch(e){
	alert("Error in writeMenu: " + e.message);
	}
}

function writeSubMenu(mname,num){
try {
	var mnu_El;
	var myElement;
	
	mnu_El = document.getElementById('cal');
	myElement = document.createElement('a');
	myElement.setAttribute('class', "tab");
	myElement.setAttribute('href', mnu_Arr[num].url);
	myElement.setAttribute('id', "itm" + mnu_Arr[num].id);
	myElement.setAttribute('name', "link2");
	myElement.setAttribute('target', "tabIframe2");
	myElement.setAttribute('style', "background-color: #ddf;");

	myElement.appendChild(document.createTextNode(mnu_Arr[num].name));
	mnu_El.appendChild(myElement);
//alert("Mnu: " + myElement.getAttribute('class'));
	} catch(e){
	alert("Error in writeMenu: " + e.message);
	}
}

function positionMenu(top,left,width){
	this.top = top;
	this.left = left;
	this.width = width;
}

var mnuSelected = '';

function showMenu(menu){
	hideMenu(mnuSelected);
	document.getElementById(menu).style.visibility = 'visible';
	mnuSelected = menu;
}

function showSubMenu(menu){
try {	
	document.getElementById(menu).style.visibility = 'visible';
	mnuSelected = menu;
	} catch(e){
	alert("Error in showSubMenu: " + e.message + " menu: " + menu);
	}		
}

function hideMenu(menu){
	if(mnuSelected!='')
		document.getElementById(menu).style.visibility = 'hidden';
}