function f_c_menuItem( action, description, status){
	this.action			= action;
	this.description	= description;
	this.status			= status;
}

function f_c_menu( srcMenuArray, hstWindow){
	this.hstWindow		= hstWindow;
	this.srcMenuArray	= srcMenuArray;
	this.subMenusSrc	= [];
	this.subMenus		= [];
	this.menuItems		= [];
	this.menuWindows	= [];
	this.initString	= null;
	this.init();
}

f_c_menu.prototype.init = function(){
   for(var i=0; i<this.srcMenuArray.length; i++){
      this.menuItems[i] = new f_c_menuItem(null, this.srcMenuArray[i].valueOf(), true);
		this.subMenus[i]  = new f_c_subMenu( this.srcMenuArray[i].subMenu, i, this);
   }
   //alert(this.srcMenuArray.length)
//<!--
   this.initString = top.MENU_CSS + top.MENU_ENGINE +
   '<script>\n'+
   '//<!-' + '-\n' +
   'function down(){top.f_repaint();\n'+
   'if(top.windowRegister[self.name].parentWindow.isMaximized) return;\n'+
   'top.o_winManager.focusManager("focus",top.windowRegister[self.name].parentWindow.parentWindow)};\n'+
   'onload=function(){\n'+
   '	baseMenu=top.windowRegister[self.name].parentWindow.menu;\n'+
	'	if(top.windowRegister[self.name].parentWindow.subType != top.TOOLBAR_MODIFIER)\n'+
   '		document.body.style.borderBottomWidth=0;\n'+
   '	top.windowRegister[self.name].parentWindow.creation_manager();\n'+
   '}\n'+
   '//-' + '->\n'+
   '</script>\n'+
   '<body onmousedown="down();event.preventDefault()" class=menuWin_body style="border-style:solid;border-color:#4F4365;border-width:0px;border-bottom-width:1px;margin:0" scroll=no onselectstart="return false;">\n'+
   '<div id=lyrMenu style="position:absolute;left:2;top:1;">\n'+
   '<table height=20 cellspacing=0 cellpadding=0 onmousedown="event.cancelBubble = true">\n'+
   '<tr>\n';
   for(var i=0; i<this.menuItems.length; i++){
      if(this.srcMenuArray[i].subMenu.length == 0)
         this.initString += '<td id=menu' + i + ' class=butMenuNormal onmouseover="f_over_from_menu(this)" onmouseout="f_out_from_menu(this)" onmousedown="f_process_click(this)">' + this.menuItems[i].description + '</td>\n'
      else
         this.initString += '<td id=menu' + i + ' class=butMenuNormal  onmouseover="f_over_from_menu(this)" onmouseout="f_out_from_menu(this)" onmousedown="f_process_click(this)">' + this.menuItems[i].description + '</td>\n'
   }
   this.initString  += '</tr></table></div></body>'

   //alert(this.initString)
//-->
}

f_c_menu.prototype.selObj			= null;
f_c_menu.prototype.f_addItem		= function(){}
f_c_menu.prototype.f_removeItem	= function(){}
f_c_menu.prototype.f_fixPosition = function(){
	//alert(this.hstWindow.htmlFrameObj["menu0"].offsetLeft)
   f_c_menu.prototype.selObj = this;
	if( this.menuWindows[0].htmlLayerObj && this.hstWindow.htmlFrameObj.document.getElementById("menu0") && this.hstWindow.htmlLayerObj ){
	   for( var i=0; i<this.srcMenuArray.length; i++){
	      this.menuWindows[i].htmlLayerObj.style.left = parseInt(this.hstWindow.htmlFrameObj.document.getElementById("menu" + i).offsetLeft) + parseInt( this.hstWindow.htmlLayerObj.style.left) + 2;
	      this.menuWindows[i].htmlLayerObj.style.top  = parseInt(this.hstWindow.htmlFrameObj.document.getElementById("menu" + i).offsetTop) + parseInt(this.hstWindow.htmlLayerObj.style.top) + 22;
	   }
	}
}

function f_c_subMenu( srcMenuArray, index, parentMenu){
   this.index        = index;
   this.srcMenuArray = srcMenuArray;
   this.parentMenu   = parentMenu;
   this.subMenus     = [];
   this.menuItems    = [];
   this.initString   = null;
   this.init();
}

f_c_subMenu.prototype.init = function(){
   for( var i=0; i<this.srcMenuArray.length; i++){
      this.menuItems[i] = new f_c_menuItem( this.srcMenuArray[i][1], this.srcMenuArray[i][0], this.srcMenuArray[i][2]);
   }
//<!--
   this.initString = top.MENU_CSS +
   '<script>\n' +
   'function f_repaint(){top.windowRegister[self.name].hide()}\n' +
   'function f_over(cellObj){cellObj.className="butSubMenuDown"} \n'+
   'function f_out(cellObj){cellObj.className="butSubMenuUp"} \n'+
   'function init(){\n';

   if(this.parentMenu)
   	this.initString += '  baseMenu = top.windowRegister[self.name].parentWindow.menu\n';
		
   this.initString += '  baseIndex = ' + this.index + ';\n'+
   '  top.windowRegister[self.name].parentWindow.creation_manager();\n'+
   '  top.windowRegister[self.name].resizeTo(document.getElementById("menu_table").offsetWidth, document.getElementById("menu_table").offsetHeight);\n'+
   '}\n'+
	'</script>\n'+
   '<body onmousedown=event.preventDefault() style="overflow:hidden;padding:0;margin:0" scroll=no onload="init()" onclick="top.f_repaint()">\n'+
   '<table id=menu_table width=100% border=0 cellpadding=0 cellspacing=0>\n';
   for(var i=0; i<this.menuItems.length; i++)
	   if(this.menuItems[i].description == "separator")
	      this.initString += '<tr><td valign=middle nowrap id=row' + i + ' class=butSubMenuUp height=8 style="padding-right:4px;height:8px;padding-top:0px;padding-bottom:0px"><div style="top:-2;width:100%;height:1px;border-top-style:solid;border-top-color:#706CA6;border-top-width:1px;background-color:#FFFFFF"><img src=images/spacer.gif width=1 height=1></div></td></tr>\n'
	   else
	      this.initString += '<tr><td valign=middle nowrap id=row' + i + ' class=butSubMenuUp style="padding-right:20px" onmouseover="f_over(this)" onmouseout="f_out(this)" onclick="' + this.menuItems[i].action + '"><img src=' + top.IMAGE_BLANK.src + ' width=16 height=16 align=middle>' + this.menuItems[i].description + '</td></tr>\n'
   
   this.initString += '</table></body>';
   //alert(this.initString)
//-->
}

f_c_subMenu.prototype.f_addItem 	= function(){}
f_c_subMenu.prototype.f_removeItem = function(){}

f_c_subMenu.prototype.f_replace = function( m){
   var tempString1 = "";

   this.srcMenuArray = m
   if(m.length == 0){
      this.parentMenu.hstWindow.htmlFrameObj.document.getElementById("menu" + this.index).style.display = 'none';
      this.parentMenu.f_fixPosition();
      return;
   }
   else
      this.parentMenu.hstWindow.htmlFrameObj.document.getElementById("menu" + this.index).style.display = 'table-cell';
   this.parentMenu.f_fixPosition();

// place here the logic for hiding and showing the menu that doesnt have submenus ...   
   
   this.menuItems = [];
   for(var i=0; i<this.srcMenuArray.length; i++){
      this.menuItems[i] = new f_c_menuItem(this.srcMenuArray[i][1], this.srcMenuArray[i][0], this.srcMenuArray[i][2]);
   }

   tempString1 = '<table id=menu_table width=100% border=0 cellpadding=0 cellspacing=0>\n';
   for(var i=0; i<this.menuItems.length; i++)
	   if(this.menuItems[i].description == "separator")
	      tempString1 += '<tr><td valign=middle nowrap id=row' + i + ' class=butSubMenuUp height=8 style="padding-right:4px;height:8px;padding-top:0px;padding-bottom:0px"><div style="top:-2;width:100%;height:1px;border-top-style:solid;border-top-color:#706CA6;border-top-width:1px;background-color:#FFFFFF"><img src=images/spacer.gif width=1 height=1></div></td></tr>\n'
	   else
	      tempString1 += '<tr><td valign=middle nowrap id=row' + i + ' class=butSubMenuUp style="padding-right:20px" onmouseover="f_over(this)" onmouseout="f_out(this)" onclick="' + this.menuItems[i].action + '"><img src=' + top.IMAGE_BLANK.src + ' width=16 height=16 align=middle>' + this.menuItems[i].description + '</td></tr>\n'
   
   tempString1 += '</table>';

   this.parentMenu.menuWindows[this.index].htmlFrameObj.document.body.innerHTML = tempString1;
   this.parentMenu.menuWindows[this.index].resizeTo(this.parentMenu.menuWindows[this.index].htmlFrameObj.document.getElementById("menu_table").scrollWidth, this.parentMenu.menuWindows[this.index].htmlFrameObj.document.getElementById("menu_table").scrollHeight);
}
