
/************************************************************************************
*************************************************************************************
*  Copyright 2004 (c) Aumediage S.P.R.L. All Rights Reserved.						*
*  This is a commercial software product, please visit								*
*  http://www.aumediage.net for more information. or send email to					*
*  aumediage@hotmail.com															*
*  See http://www.aumediage.net for Commercial License Agreement					*
*  All Copyright statements must always remain in place in all files at all times	*
*		***** PLEASE NOTE: THIS IS NOT FREE SCRIPT / SOFTWARE	*****				*
*				*****	IT MUST BE LICENSED FOR ALL USE	*****						*
*  HISTORY																			*
*	Name			Date				Action					Version				*
*	GdB				11/02/2004			Creation					1.00			*
*	GdB				13/02/2004			Init array change	2.00					*
*																					*
* TO DO : Fix div settings															*
*************************************************************************************
************************************************************************************/

/********************************************************
*********************************************************
*********************************************************
  GENERIC OBJECT CREATION
*********************************************************
********************************************************/
var IAMGMenuClass ={ID:0,Orientation:1,AllowChilds:2, MenuWidth:3,ItemWidth:4, Absolute:5, Top:6, Left:7, SubXOffset:8,SubYOffset:9,Style:10, AlignWithImage:11,  StayOnDelay:12,  DelayAppear:13, AryContent:14, AryTemp:15, TopMenu:16, SelectedCategory:17, VerticalSep:18, HorizontalSep:19, OpenedGroups:20, LastOpened:21, TimeOutID:22, Init:23, FindChilds:24, FindSubLevel:25, writeHtml:26, GetHorizontalHtml:27, GetVerticalHtml:28, GetItemHtml:29, GetRootWidth:30, GetItemStyle:31, MouseOver:32, MouseOut:33, HideGroup:34, ShowGroup:35, KillAll:36, GoTo:37, SetStatus:38, ShowWithDelay:39};
function AMGMenu(__sID, __aryContent, __vTopMenu, __iTop, __iLeft){
	this.Constructor			= AMGBaseObject;
	this.Constructor			(__sID, __aryContent);
	this.TopMenu				= __vTopMenu || 0;
	this.Top					= __iTop || 0;
	this.Left					= __iLeft || 0;
	this.Prefix					= 'AMGMenu_'+this.ID+'_';
	this.Orientation			= 'vertical';
	this.AllowChilds			= true;
	this.MenuWidth				= null;//200;
	this.ItemWidth				= null;//200;
	this.Absolute				= true;
	this.SubXOffset				= -5;
	this.SubYOffset				= 5;
	this.Style					= '_style1';
	this.AlignWithImage			= true;
	this.StayOnDelay			= 1500;
	this.DelayAppear			= 0;
	this.AryTemp				= new Array();
	this.SelectedCategory		= 0;
	this.SelectedIndex			;
	this.VerticalSep			= '<img src="/1.gif" border="0">';
	this.HorizontalSep			= '<img src="/1.gif" border="0">';
	this.OpenedGroups			= '';
	this.LastOpened				= '';
	this.TimeOutID				= '';
	this.Init						= AMGMenuInit;
	this.WriteHtml				= AMGMenuWriteHtml;
	this.FindChilds				= AMGMenuInitChildsItems;
	this.FindSubLevel			= AMGMenuFindSubLevel;
	this.GetHorizontalHtml	= AMGMenuGetHorizontalMenuHtml;
	this.GetVerticalHtml		= AMGMenuGetVerticalMenuHtml;
	this.GetItemHtml			= AMGMenuGetItemHtml;
	this.GetRootWidth		= AMGMenuGetRootWidth;
	this.GetItemStyle			= AMGMenuGetStyle;
	this.MouseOver			= AMGMenuOnMouseOver;
	this.MouseOut				= AMGMenuOnMouseOut;
	this.MoveTo					= AMGMenuMoveTo;
	this.HideGroup				= AMGMenuHideGroup;
	this.ShowGroup			= AMGMenuShowGroup;
	this.KillAll						= AMGMenuCloseAll;
	this.GoTo						= AMGMenuGoTo;
	this.SetStatus				= AMGMenuStatusMessage;
	this.ShowWithDelay		= AMGMenuShowWithDelay;
	this.SetParentPath		= AMGMenuSetParentPath;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuSetParentPath(__ID){
	var StopLoop	= false;
	if (__ID != 0){
		for (var i = 0; i< this.AryContent.length; i++){
			for (var j = 1; j< this.AryContent[i].length; j++){
				if (this.AryContent[i][j][1] == __ID ){
					this.AryContent[i][j][15] = true;
					this.SetParentPath(this.AryContent[i][0][1]);
					StopLoop = true;
					break;
				}
			}
			if (StopLoop)
				break;
		}
	}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuInit(){
try{
	if (this.AryContent.length > 0){
		this.TopInit					= this.Top;
		this.LeftInit					= this.Left;
		this.FindSubLevel			(this.TopMenu, '000');
		this.AryContent			= this.AryTemp;
		if (this.SelectedIndex != undefined && this.SelectedCategory)
			this.SetParentPath		(this.AryContent[this.SelectedIndex][0][1]);
		if (this.Orientation == 'vertical' || this.Orientation == 1)
			this.Orientation = 1;
		else{
			this.Orientation = 0;
		}
	}
}
catch(e){handleClientError(this.ID+'.Init()', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuWriteHtml(){
try{
	this.Init();
	var sBuffer = '';
	if (this.AryContent.length < 1)
		return
	if (this.Orientation == 1){
		//alert('fff')
		sBuffer += this.GetVerticalHtml(0, true);
	}
	else{
		//alert('ff')
		sBuffer += this.GetHorizontalHtml(0, true);
	}
	for (var i=1; i< this.AryContent.length ; i++){
			sBuffer += this.GetVerticalHtml(i, false);
	}
	this.WriteToDoc(sBuffer); 
}
catch(e){handleClientError('AMGMenuWriteHtml', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuInitChildsItems(__iNewIndex, __iThisMenuIndex, __sOrderPath){
try{
	for (var i=1; i< this.AryContent[__iThisMenuIndex].length;i++){
			this.AryTemp[__iNewIndex][i] = new Array();
			this.AryTemp[__iNewIndex][i][0] = __sOrderPath+'_00'+i;
			for (var k=0; k< this.AryContent[__iThisMenuIndex][i].length;k++){
				this.AryTemp[__iNewIndex][i][k+1] = this.AryContent[__iThisMenuIndex][i][k];
			}
			if (this.SelectedCategory && this.AryContent[__iThisMenuIndex][i][0] +'' == this.SelectedCategory+''){
				this.AryTemp[__iNewIndex][i][14]	= true;
				this.SelectedIndex							= __iNewIndex ;
			}
			if (this.AllowChilds)
				this.FindSubLevel(this.AryContent[__iThisMenuIndex][i][0] , __sOrderPath+'_00'+i);
	}
}
catch(e){handleClientError(this.ID+'.InitChildsItems()', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuFindSubLevel(__iThisSub, __sOrderPath){
try{
	var iTempLength;
	for (var i=0; i< this.AryContent.length;i++){
		if (this.AryContent[i][0][0]+'' == __iThisSub+''){
			iTempLength	= this.AryTemp.length;
			this.AryTemp[iTempLength] = new Array(new Array());
			this.AryTemp[iTempLength][0][0] = __sOrderPath;
			for (var k=0; k< this.AryContent[i][0].length;k++){
				this.AryTemp[iTempLength][0][k+1] = this.AryContent[i][0][k];
			}
			this.FindChilds(iTempLength, i, __sOrderPath);
			break;
		}
	}
}
catch(e){handleClientError(this.ID+'.InitSubLevels', e);}}

/*******************************************************
** ******************************************************
** ******************************************************
 RUN TIME FUNCTIONS
** ******************************************************
** *****************************************************/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuOnMouseOver(oThis, iCatID, sID, sPArentGroup, bHasChilds, bIsHor, bIsRoot, iThisMenuIndex, iThisIndex){
try{
	if (this.TimeOutID)
		clearTimeout(this.TimeOutID);
	if(document.getElementById(this.Prefix+'ItemTDIcon'+sID)){
		var oIconCont = document.getElementById(this.Prefix+'ItemTDIcon'+sID);
		oIconCont.className			= oIconCont.className.replace('Out', 'Over');
	}
	var oMainCont						= document.getElementById(this.Prefix+'ItemTDMain'+sID);
	oMainCont.className			= oMainCont.className.replace('Out', 'Over');
	if(document.getElementById(this.Prefix+'ItemTDArrow'+sID)){
		var oArrowCont = document.getElementById(this.Prefix+'ItemTDArrow'+sID);
		oArrowCont.className			= oArrowCont.className.replace('Out', 'Over');
	}
	//var oContainer						= document.getElementById(this.Prefix+'ItemTD'+sID);
	//oContainer.className			= oContainer.className.replace('Out', 'Over');
	//var oFontContainer				= document.getElementById(this.Prefix+'ItemFont'+sID);
	//oFontContainer.className	= oFontContainer.className.replace('Out', 'Over');
	if (this.LastOpened != sID){
		if (this.DelayAppear && this.DelayAppear > 0){
			this.TimeOutID = setTimeout(this.ID+'.ShowWithDelay(\'oThis\',  '+iCatID+', \''+sID+'\',  \''+sPArentGroup+'\', '+ bHasChilds+', '+ bIsHor+', '+ bIsRoot+', '+iThisMenuIndex+', '+iThisIndex+')',this.DelayAppear);
		}
		else{
			this.ShowWithDelay(oThis, iCatID, sID, sPArentGroup, bHasChilds, bIsHor, bIsRoot, iThisMenuIndex, iThisIndex);
		}
	}
	this.LastOpened = sID;
}
catch(e){handleClientError('OnMouseOver', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuOnMouseOut(oThis, iCatID, sID, sPArentGroup, bHasChilds, bIsHor, bIsRoot, iThisMenuIndex, iThisIndex){
try{
	this.TimeOutID						= setTimeout(this.ID+'.KillAll(1)',this.StayOnDelay);
	if(document.getElementById(this.Prefix+'ItemTDIcon'+sID)){
		var oIconCont = document.getElementById(this.Prefix+'ItemTDIcon'+sID);
		oIconCont.className			= oIconCont.className.replace('Over', 'Out');
	}
	var oMainCont						= document.getElementById(this.Prefix+'ItemTDMain'+sID);
	oMainCont.className			= oMainCont.className.replace('Over', 'Out');
	if(document.getElementById(this.Prefix+'ItemTDArrow'+sID)){
		var oArrowCont = document.getElementById(this.Prefix+'ItemTDArrow'+sID);
		oArrowCont.className			= oArrowCont.className.replace('Over', 'Out');
	}
	
	
	//var oContainer					= document.getElementById(this.Prefix+'ItemTD'+sID);
	//oContainer.className			= oContainer.className.replace('Over', 'Out');
	//var oFontContainer				= document.getElementById(this.Prefix+'ItemFont'+sID);
	//oFontContainer.className	= oFontContainer.className.replace('Over', 'Out');
}
catch(e){handleClientError('menuOnMouseOut', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuShowWithDelay(oThis, iCatID, sID, sPArentGroup, bHasChilds, bIsHor, bIsRoot, iThisMenuIndex, iThisIndex){
try{
	if (bHasChilds )
		this.ShowGroup(oThis, iCatID, sID, sPArentGroup, bHasChilds, bIsHor, bIsRoot, iThisMenuIndex, iThisIndex);
	if (this.OpenedGroups){
		var aryOpenedMenus = this.OpenedGroups.split('~~');
		for (var i = 0; i< aryOpenedMenus.length; i++){
			var sFakeID = '@'+sID;
			if (aryOpenedMenus[i] && sFakeID.indexOf(aryOpenedMenus[i]) == -1 ){
				this.HideGroup(aryOpenedMenus[i]);
				this.OpenedGroups	= replaceAll(this.OpenedGroups, aryOpenedMenus[i]+'~~', '', true);
			}
		}
	}
}
catch(e){handleClientError('menuShowWithDelay', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuHideGroup(sID){
try{
	hide(this.Prefix+'Group'+sID.replace('@', ''));
	this.OpenedGroups = replaceAll(this.OpenedGroups, sID+'~~', '', true);
}
catch(e){handleClientError('menuHideGroup', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuShowGroup(oThis, iCatID, sID, sPArentGroup, bHasChilds, bIsHor, bIsRoot, iThisMenuIndex, iThisIndex){
try{
		this.MoveTo(sPArentGroup, this.Prefix+'ItemTD'+sID, this.Prefix+'Group'+sID, bIsHor, bIsRoot, this.SubXOffset, this.SubYOffset);
		show(this.Prefix+'Group'+sID);
		if (this.OpenedGroups.indexOf('@'+ sID+'~~') == -1){
			this.OpenedGroups += '@'+ sID+'~~';
		}
		/*if (!bIsRoot){Future Scrolling facilities
			var sChildItem = this.ID+'menuGroup'+sID;
			var iTop				= getObjTop(sChildItem);
			var iHeight			= getObjHeight(sChildItem);
			var iWinHeight		= getWindowInnerHeight();
				var oO = getObject(sChildItem, true)
			alert(iHeight+'\n'+oO.height + '\n' + iWinHeight+'\n'+iTop)
			if (iWinHeight < (iTop + iHeight)){
				setObjHeight(sChildItem, (iWinHeight - iTop)+'px');
				oO.overflow = 'scroll';
			}
			else{
				setObjHeight(sChildItem, '');
				oO.overflow = 'visible';
			}
			alert(oO.height)
		}*/
}
catch(e){handleClientError('menuShowGroup', e);}}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuMoveTo(sParentGroup, sThisItem, sChildItem, bIsHor, bIsRoot, iOffsetLeft, iOffsetTop){
try{
	var iWinWidth		= getWindowInnerWidth();
	var iWinHeight		= getWindowInnerHeight();
	var iTop;
	var iLeft;
	//var iThisLeft		= getObjLeft(sParentGroup) + getObjLeft(sThisItem);
	var iThisLeft		= getObjWindowOffsetLeft(sParentGroup) + getObjLeft(sThisItem);
	var iThisWidth		= getObjWidth(sParentGroup);
	var iSubWidth		= getObjWidth(sChildItem);
	
	var iRight			= ( bIsHor ) ? iThisLeft + iSubWidth : iThisLeft + iThisWidth + iSubWidth + iOffsetLeft;
	if (!bIsRoot  &&  iRight > iWinWidth && (iThisLeft - (iSubWidth + iOffsetLeft)) >= 0)
		iLeft					= iThisLeft - (iSubWidth + iOffsetLeft);
	else if( bIsHor ) 
		iLeft					= iThisLeft;
	else{
		iLeft					= iThisLeft + iThisWidth + iOffsetLeft;
	}
	//var iThisTop			= getObjTop(sParentGroup) + getObjTop(sThisItem);
	var iThisTop			= getObjWindowOffsetTop(sParentGroup) + getObjTop(sThisItem);
	var iThisHeight		= getObjHeight(sThisItem);
	var iSubHeight		= getObjHeight(sChildItem);
	var iBottom			= ( bIsHor ) ? iThisTop + iThisHeight +iSubHeight : iThisTop + iSubHeight + iOffsetTop;
	if (iBottom > iWinHeight && (iThisTop - (iSubHeight + iOffsetTop)) >= 0)
		iTop					= iThisTop - (iSubHeight + iOffsetTop);
	else if(bIsRoot && bIsHor) 
		iTop					= iThisTop + iThisHeight;
	else{
		iTop					= iThisTop + iOffsetTop;
	}
	moveTo(sChildItem, iLeft, iTop);
}
catch(e){
	handleClientError('AMGMenuMoveTo', e);}}

/***************************************************/
function AMGMenuCloseAll(){
try{
	if (this.OpenedGroups){
		var aryOpenedMenus = this.OpenedGroups.split('~~');
		for (var i = 0; i< aryOpenedMenus.length; i++)
			if (aryOpenedMenus[i] )
				this.HideGroup(aryOpenedMenus[i]);
	}
	this.LastOpened = null;
}
catch(e){handleClientError('AMGMenuCloseAll', e);}}
/*******************************************************
** ******************************************************
** ******************************************************
 ACCESS FUNCTION
** ******************************************************
** *****************************************************/
function AMGMenuGoTo(sUrl, sFrame){
	GoToPage(sUrl, sFrame);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuStatusMessage(sMessage){
	//alert(sMessage)
	setWindowStatus(sMessage);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuGetHorizontalMenuHtml(iThisIndex, bIsRoot){
try{
	var sBuffer = '';
	var iHeight = '';
	var sThisStyle = this.GetItemStyle(iThisIndex, 0) ;
	if (this.AryContent[iThisIndex][0][3])
		iHeight = ' height="'+this.AryContent[iThisIndex][0][3]+'"';
	sBuffer += '<div id="'+this.Prefix+'">';
	sBuffer += '<div id="'+this.Prefix+'Group'+this.AryContent[iThisIndex][0][0]+'" style="';
	if (this.Absolute)
		sBuffer += 'position:absolute;top:'+this.Top+'px;left:'+this.Left+'px;z-index:500;">';
	//sBuffer += '<div id="'+this.Prefix+'Group'+this.AryContent[iThisIndex][0][0]+'" style="';
	//if (this.Absolute || !bIsRoot){
	//	sBuffer += 'position:absolute;';
	//	sBuffer += 'top:'+this.Top+sPx+';';
	//	sBuffer += 'left:'+this.Left+sPx+';';
	//	sBuffer += 'z-index:500;';
	//}
	if (bIsRoot){
		sBuffer += 'width:'+this.GetRootWidth()+';';
		sThisMenuWidth = ' width="100%"';
	}
	else{
		sThisMenuWidth = '';
	}
	sBuffer += 'visibility:';
	sBuffer += (bIsRoot)?sVisible:sHidden;
	sBuffer += ';background-color:transparent;height:22px;" class="menuContainer'+sThisStyle+'">';
	sBuffer += '<table cellpadding="0" cellspacing="0" border="0" bordercolor="pink" '+iHeight+' class="menuTableBorder'+sThisStyle+'">';
	sBuffer += '<tr>';
	for (var i=1; i< this.AryContent[iThisIndex].length ; i++){
		sBuffer += this.GetItemHtml(iThisIndex, i, true, this.Prefix+'Group'+this.AryContent[iThisIndex][0][0], bIsRoot);
		if ( i< this.AryContent[iThisIndex].length-1){
			sBuffer += '<td class="AMGMenuTableHorSep'+sThisStyle+'" valign="middle">' + this.HorizontalSep;
			sBuffer += '</td>';
		}
	}
	sBuffer += '</tr>';
	sBuffer += '</table>';
	sBuffer += '</div>';
	sBuffer += '</div>';
	return sBuffer;
}
catch(e){handleClientError('AMGMenuGetHorizontalMenuHtml', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuGetVerticalMenuHtml(iThisIndex, bIsRoot){
try{
	var sBuffer		= '';
	var sThisMenuWidth;
	var sThisStyle	= this.GetItemStyle(iThisIndex, 0) ;
	var iHeight		= '';
	if (this.AryContent[iThisIndex][0][3])
		iHeight			= ' height="'+this.AryContent[iThisIndex][0][3]+'"';
	sBuffer += '<div id="'+this.Prefix+'">';
	sBuffer += '<div id="'+this.Prefix+'Group'+this.AryContent[iThisIndex][0][0]+'" style="';
	if (this.Absolute || !bIsRoot){
		sBuffer += 'position:absolute;';
		sBuffer += 'top:'+this.Top+sPx+';';
		sBuffer += 'left:'+this.Left+sPx+';';
		sBuffer += 'z-index:500;';
	}
	if (bIsRoot){
		sBuffer += 'width:'+this.GetRootWidth()+';';
		sThisMenuWidth = '100%';
	}
	else{
		sThisMenuWidth = this.AryContent[iThisIndex][0][2];
	}
	sBuffer		+= 'visibility:';
	sBuffer		+= (bIsRoot)?sVisible+';':sHidden+';';
	sBuffer		+= (sThisMenuWidth)? ' width:'+sThisMenuWidth+'px;':'';
	sBuffer		+= 'background-color:transparent;" class="AMGMenuContainer'+sThisStyle+'">';
	sBuffer		+= '<table cellpadding="0" cellspacing="0" border="0" width="'+sThisMenuWidth+'"' + ' class="AMGMenuTableBorder'+sThisStyle+'">';
	for (var i=1; i< this.AryContent[iThisIndex].length ; i++){
		sBuffer += '<tr>';
		sBuffer += this.GetItemHtml(iThisIndex, i, false, this.Prefix+'Group'+this.AryContent[iThisIndex][0][0], bIsRoot);
		sBuffer += '</tr>';
		if (  i< this.AryContent[iThisIndex].length-1){
			sBuffer += '<tr class="AMGMenuTableVerSep'+sThisStyle+'">';
			sBuffer += '<td>' + this.VerticalSep;
			sBuffer += '</td>';
			sBuffer += '</tr>';
		}
	}
	sBuffer		+= '</table>';
	sBuffer	+= '</div>';
	sBuffer	+= '</div>';
	return sBuffer;
}
catch(e){handleClientError('AMGMenuGetVerticalMenuHtml', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuGetRootWidth(){
try{
	if (this.MenuWidth)
		return this.MenuWidth;
	else if (this.ItemWidth)
		return this.ItemWidth;
	else{
		return 150;
	}
}
catch(e){handleClientError('menuGetRootWidth', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuGetStyle(iThisMenuIndex, iThisIndex){
try{
	var sRetValue = this.Style;
	var iPos = (iThisIndex == 0) ? 4 : 8;
	if (this.AryContent[iThisMenuIndex][iThisIndex][iPos]){
		sRetValue =  this.AryContent[iThisMenuIndex][iThisIndex][iPos];
	}
	else if (iThisIndex != 0 && this.AryContent[iThisMenuIndex][0][4]){
		sRetValue =  this.AryContent[iThisMenuIndex][0][4];
	}
	else 	if ( iThisMenuIndex > 0){
		var bFound = false;
		for (var i = 0; i< this.AryContent.length; i++){
			for (var j = 1; j< this.AryContent[i].length; j++){
				if (this.AryContent[i][j][0] == this.AryContent[iThisMenuIndex][0][0] ){
					bFound = true;
					break;
				}
			}
			if (bFound)break;
		}
		if (bFound)
			sRetValue =  this.GetItemStyle(i, j);
	}
	return sRetValue;
}
catch(e){handleClientError('menuGetStyle', e);}}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function AMGMenuGetItemHtml(iThisMenuIndex, iThisIndex, bIsHor, sThisMenuGroup, bIsRoot){
try{
	var sBuffer			= '';
	var iHeight			= '';
	var sClassType	= '';
	//if (this.AryContent[iThisMenuIndex][iThisIndex][1] == this.SelectedCategory)
	if (this.AryContent[iThisMenuIndex][iThisIndex][14] )
		sClassType = 'Sel';
	else if(this.AryContent[iThisMenuIndex][iThisIndex][15]){
		sClassType = 'Parent';
	}
	var sThisStyle		= this.GetItemStyle(iThisMenuIndex, iThisIndex) ;
	var sThisStatusMessage = this.AryContent[iThisMenuIndex][iThisIndex][6] || this.AryContent[iThisMenuIndex][iThisIndex][3];
	if (this.AryContent[iThisMenuIndex][0][3])
		iHeight				= ' height="'+this.AryContent[iThisMenuIndex][0][3]+'"';
	var bHasChilds	= (this.AllowChilds)?this.AryContent[iThisMenuIndex][iThisIndex][7]:false;
	var sCursor			= (this.AryContent[iThisMenuIndex][iThisIndex][4])?'cursor:pointer;cursor:hand':'cursor:default';
	var sArguments	= 'this, '+ this.AryContent[iThisMenuIndex][iThisIndex][1] +', \''+this.AryContent[iThisMenuIndex][iThisIndex][0]+'\', \''+sThisMenuGroup+'\', '+ bHasChilds + ', ' +bIsHor+', '+bIsRoot + ' , ' + iThisMenuIndex + ', ' + iThisIndex;
	var sMouseOver	= ' onMouseOver="'+this.ID+'.MouseOver('+sArguments+');'+this.ID+'.SetStatus(\''+EscapeString(sThisStatusMessage)+'\');';
	var sMouseOut	= ' onMouseOut="'+this.ID+'.MouseOut('+sArguments+');'+this.ID+'.SetStatus(\'\');';
	var sMouseClick	= ' onClick="'+this.ID+'.GoTo(\''+this.AryContent[iThisMenuIndex][iThisIndex][4]+'\');';
	sMouseOver	+= 'event.cancelBubble=true;"';
	sMouseOut	+= 'event.cancelBubble=true;"';
	sMouseClick += 'event.cancelBubble=true;"';
	sBuffer = '<td  style="'+sCursor+';" class="AMGMenuColorOut'+sClassType+sThisStyle+'" valign="top" id="'+this.Prefix+'ItemTD'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'"'+sMouseOver + sMouseOut + sMouseClick+'>';
	
	//sBuffer +='<div id="'+this.ID+'menuItem'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'">';
	sBuffer +='<div id="'+this.Prefix+'Item'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'">';
	sBuffer += '<table cellpadding="0" cellspacing="0" WIDTH="100%" border="0" '+iHeight+' style="'+sCursor+';">';
	sBuffer += '<tr>';
	var bHasImage = false;
		for (var i = 1; i< this.AryContent[iThisMenuIndex].length;i++){
			if ( this.AryContent[iThisMenuIndex][i][2]){
				bHasImage = true;
				break;
			}
		}
	if (this.AryContent[iThisMenuIndex][iThisIndex][2] || (bHasImage && !bIsHor && this.AlignWithImage)){
		sBuffer += '<td valign="middle" align="center" width="26" class="AMGMenuColorIconOut'+sClassType+sThisStyle+'" id="'+this.Prefix+'ItemTDIcon'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'"';
		sBuffer += sMouseOver + sMouseOut + sMouseClick;
		sBuffer += ' style="'+sCursor+';">';
		sBuffer += (this.AryContent[iThisMenuIndex][iThisIndex][2])?'<img src="'+this.AryContent[iThisMenuIndex][iThisIndex][2]+'" hspace="3" border="0">' : '<img src="/1.gif" border="0" width="16" hspace="3">';
		sBuffer += '</td>';
	}
	sBuffer += '<td valign="middle" width="100%" id="'+this.Prefix+'ItemTDMain'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'"';
	if (bIsHor)
		sBuffer += ' nowrap';
	sBuffer += sMouseOver + sMouseOut + sMouseClick;
	sBuffer += ' style="'+sCursor+';" class="AMGMenuColorMainOut'+sClassType+sThisStyle+'">';
	//<span id="'+this.Prefix+'ItemFont'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'" class="menuFontOut'+sClassType+sThisStyle+'" style="'+sCursor+';">&nbsp;';
	sBuffer +=this.AryContent[iThisMenuIndex][iThisIndex][3];
	//sBuffer += '</span>';
	sBuffer += '</td>';
	sBuffer += '<td width="14" class="AMGMenuColorArrowOut'+sClassType+sThisStyle+'" id="'+this.Prefix+'ItemTDArrow'+this.AryContent[iThisMenuIndex][iThisIndex][0]+'"';
	sBuffer += sMouseOver + sMouseOut + sMouseClick;
	sBuffer += ' align="center" valign="middle">';
	if (bHasChilds){
		if (bIsHor)
			sBuffer += '<img src="/pix/menu/mArrowDown.gif" border="0" >';
		else{
			sBuffer += '<img src="/pix/menu/mArrowRight.gif" border="0">';
		}
	}
	sBuffer += '</td>';
	sBuffer += '</tr>';
	sBuffer += '</table></div></td>';
	return sBuffer;
}
catch(e){handleClientError('menuGetItemHtml', e);}}
