// object oriented menus


//First object is the menuBar, which is the container for the menus and submenus

function menuBar(cc, tt) {



	this.content = cc;    // is an array with the menuitems
	this.type = tt;       // can be VERTICAL or HORIZONTAL. NOT in use yet

	// display menu
	// write the main div which contains the menuitems
	document.write("<div class=\"menu\">");
	for(i = 0; i < this.content.length; i++) {
		document.write(this.content[i].writeItem(tt));
	};
	document.write("</div>");
		

// making these functions public
	
	
	this.addItem = function(menuitem,index){
	// add menuitem at index ( no index means last ), index = 0 means as first
	this.content.splice(index,0,index); // text if index starts with 0
	
	}
	this.deleteItem = function(index) {
	// delete item at index ( no index means last ), index = 0 means first;
	this.content.splice(index,1); // text if index starts with 0
	}

};


// Second object is the menuItem, which is a normal menu entry or an container for submenus



function menuItem(nn, cc, tt, ss) {



	this.name = nn;		// name of the link
	this.link = cc;		// can be an array with submenus or an url
	this.tooltip = tt;	// tooltiptext and or image, Not in use yet
	this.tooltipsize = ss;  // size op tooltip label
	this.frame_id = "textframe"; // frame  where text will placed

	
// making these functions public
	this.getName = function() {
		return this.name;
	};
	this.getLink = function() {
		return this.link;
	};
	this.changeFunction = function(ff_id,ff) {
		ff_id = ff;
	};

	
	this.writeItem = function(tt) {
	if (tt == "HORIZONTAL") {
		divbody = "<span class=\"menuitem\">";
	} else {
		divbody = "<div class=\"menuitem\">";
	}
	divbody += "<a class=\"menuitem\" HREF = \"javascript:void(0);\"";
	if ( this.tooltip != null ) {
		if (this.tooltipsize) {
		divbody += "onmouseover=\"this.T_WIDTH=" + this.tooltipsize + ";return escape(\'" + this.tooltip + "\');\"";
		} else {
		divbody += "onmouseover=\"return escape(\'" + this.tooltip + "\');\"";
		}
	}
	divbody += "onClick=\"" + this.frame_id + ".src=\'" + this.link + "\'; return false;\"";  
	divbody +=  ">";
	divbody += this.name;
	divbody += "</a>";
	if (tt == "HORIZONTAL") {
		divbody += "</span>";
	} else {
		divbody += "</div>";
	}
	return (divbody);
	
	}
};


function submenuItem(nn,cc,tt,ss,ll) {
	
	this.name = nn;			// name of the link
	this.link = cc;			// can be an array with submenus or an url
	this.tooltip = tt;		// tooltiptext and or image, Not in use yet
	this.tooltipsize = ss;  	// size op tooltip label
	this.menulist = ll;		// list with submenus
	this.frame_id = "textframe"; 	// frame  where text will placed



	this.writeItem = function(tt) {

		if (tt == "HORIZONTAL") {
			divbody = "<span class=\"submenuitem\">";
		} else {
			divbody = "<div class=\"submenuitem\">";
		}
		divbody += "<a class=\"submenuitem\" HREF = \"javascript:void(0);\"";
		divbody += "onMouseOver=\"this.displayItems();return false;\"";  
		divbody +=  ">";
		divbody += this.name;
		divbody += "</a>";
		divbody += "</a>";
	if (tt == "HORIZONTAL") {
		divbody += "</span>";
	} else {
		divbody += "</div>";
	}
	alert(divbody);
	return (divbody);
	}

	this.displayItems = function() {
		document.write("<div class=\"menu\">");
		for(i = 0; i < this.menulist.length; i++) {
			document.write(this.menulist[i].writeItem(tt));
			//alert(this.ll.writeItem());
			};
		document.write("</div>");	
		}



    }

