<?php
	$xt = new Xtempl();
	if(array_key_exists("custom1",$params) && $params["custom1"]=="horizontal")
	{
		$xt->assign("horizontal_typemenu",true);//horizontal type menu
		$xt->assign("tophorizontal_item",true);//top item for horizontal menu
		$xt->assign("simplehorizontal_item",true);//simple item for horizontal menu
		$horiz=true;
	}	
	else{
		$xt->assign("vertical_typemenu",true);//vertical type menu
		$xt->assign("topvertical_item",true);//top item for vertical menu
		$xt->assign("simplevertical_item",true);//simple item for vertical menu
		$horiz=false;
	}
		
	// create menu nodes arr
	$menuNodes = array();
##foreach @BUILDER.MenuNodes as @menu##
	$menuNode = array();
	$menuNode["name"] = "##@menu.name s##";
	$menuNode["nameType"] = "##@menu.nameType##";
	$menuNode["id"] = "##@menu.id##";
	$menuNode["parent"] = "##@menu.parent##";
	$menuNode["style"] = "##@menu.style s##";
	$menuNode["href"] = "##@menu.href##";
	$menuNode["table"] = "##@menu.table s##";
	$menuNode["type"] = "##@menu.type##";
	$menuNode["linkType"] = "##@menu.linkType##";
	$menuNode["pageType"] = "##@menu.pageType##";
	$menuNode["openType"] = "##@menu.openType##";					 

	// set title		
	##if @menu.name && @menu.nameType=="CustomID"##
		$menuNode["title"] = ##custom @menu.name##;
	##elseif @menu.name##
		$menuNode["title"] = "##@menu.name s##";
	##elseif @menu.PageType=="WebReports"##
		$menuNode["title"] = ##message WEBREPORTS_SHORT##;
	##else##
		$menuNode["title"] = ##caption @menu.table##;
	##endif##				
			
	$menuNodes[] = $menuNode;	
##endfor##		
	
	// need to predefine vars
	$nullParent = NULL;
	$rootInfoArr = array("id"=>0, "href"=>"");
	// create treeMenu instance
	$menuRoot = new MenuItem($rootInfoArr, $menuNodes, $nullParent);
	// call xtempl assign, set session params
	$menuRoot->setMenuSession();
	$menuRoot->assignMenuAttrsToTempl($xt);
	$menuRoot->setCurrMenuElem($xt);
	$menuRoot->clearMenuSession();
	
	$xt->assign("mainmenu_block",true);
	$mainmenu=array();
//	Javascript code for menu on page
	$menumessages = "window.TEXT_EXPAND_ALL = '".jsreplace(##message EXPAND_ALL##)."';\r\n";
	$menumessages.= "window.TEXT_COLLAPSE_ALL = '".jsreplace(##message COLLAPSE_ALL##)."';\r\n";
	$mainmenu["end"]='
	<script type="text/javascript" language="javascript" src="include/jquery.dropshadow.js"></script>
	<script type="text/javascript" language="javascript" src="include/cookies.js"></script>
	<script>'.$menumessages.
	'	flag = 0;menu1 = null;ul = null;';
	if($horiz)
	{
		//	Horizontal menu
		$mainmenu["end"].='if($("div.Gmenu").length)
				Gmenu();';
	}	
	else
	{
	##if @BUILDER.InlineMenu##
		//	Vertical menu variant 2
		$mainmenu["end"].='if($("div.Vmenu2").length)
		{
			Vmenu2();
			openMenuItemsOnLoad();
		}
		';
	##else##
		//	Vertical menu variant 1
		$mainmenu["end"].='if($("div.Vmenu1").length)
			Vmenu1();
		';
	##endif##
	}
	$mainmenu["end"].='</script>';
	$xt->assignbyref("mainmenu_block",$mainmenu);
	$xt->assign("mainmenustyle_block",true);
	$xt->assign("mainmenuiestyle_block",true);
	if(isset($params["quickjump"]))
		$xt->display("mainmenu_quickjump.htm");
	elseif(array_key_exists("custom1",$params) && $params["custom1"]=="horizontal")
		$xt->display("mainmenu_horiz.htm");
	else
		$xt->display("mainmenu.htm");
	//for add ao delete &nbsp; 
?>
