var BorderWidth=1;				// Border width
var BorderBtwnElmnts=1;			// Border between elements 1 or 0
var FontFamily="arial,comic sans ms,technical"	// Font family menu items
var FontSize=9;				// Font size menu items
var FontBold=0;				// Bold menu items 1 or 0
var FontItalic=0;				// Italic menu items 1 or 0
var ChildOverlap=.2;				// horizontal overlap child/ parent
var ChildVerticalOverlap=.2;			// vertical overlap child/ parent
var StartTop=0;				// Menu offset x coordinate
var StartLeft=0;				// Menu offset y coordinate
var MenuTextCentered='left';			// Item text position 'left', 'center' or 'right'
var MenuCentered='left';			// Menu horizontal position 'left', 'center' or 'right'
var MenuVerticalCentered='top';		// Menu vertical position 'top', 'middle','bottom' or static
var VerCorrect=0;				// Multiple frames y correction
var HorCorrect=0;				// Multiple frames x correction
var LeftPaddng=3;				// Left padding
var TopPaddng=2;				// Top padding
var MenuFramesVertical=1;			// Frames in cols or rows 1 or 0
var DissapearDelay=500;			// delay before menu folds in
var TakeOverBgColor=1;			// Menu frame takes over background color subitem frame
var FirstLineFrame='self';			// Frame where first level appears
var SecLineFrame='self';			// Frame where sub levels appear
var DocTargetFrame='self';			// Frame where target documents appear
var TargetLoc='menu_placeholder';				// span id for relative positioning
var HideTop=0;				// Hide first level when loading new document 1 or 0
var MenuWrap=1;				// enables/ disables menu wrap 1 or 0
var RightToLeft=0;				// enables/ disables right to left unfold 1 or 0
var UnfoldsOnClick=0;			// Level 1 unfolds onclick/ onmouseover
var WebMasterCheck=0;			// menu tree checking on or off 1 or 0
var ShowArrow=1;				// Uses arrow gifs when 1
var KeepHilite=1;				// Keep selected path highligthed
var Arrws=['/modules/htp.tsite/blocks/sectionmenu/immagini/tri.gif',3,6,'/modules/htp.tsite/blocks/sectionmenu/immagini/tridown.gif',6,3,'/modules/htp.tsite/blocks/sectionmenu/immagini/trileft.gif',3,6];	// Arrow source, width and height
var LowBgColor='white';
var LowSubBgColor='white';
var HighBgColor='black';
var HighSubBgColor='black';
var FontLowColor='black';
var FontSubLowColor='black';
var FontHighColor='white';
var FontSubHighColor='white';
var BorderColor='black';
var BorderSubColor='black';
var FirstLineHorizontal=1;

var nfontXWidth = 5; 		// Larghezza del carattere
var nMinCellWidth = 40; 	// Larghezza min. cella primo livello
var nMaxCellWidth = 100; 	// Larghezza max. cella primo livello
var nCellHeight = 20; 		// Altezza cella primo livello
var nMinSubCellWidth = 100; // Larghezza min. cella sottolivelli
var nMaxSubCellWidth = 300; // Larghezza max. cella sottolivelli
var nSubCellHeight = 20; 	// Altezza cella sottolivelli

var submenutable = new Array(); // memoria associativa con le lunghezze min. per ogni submenu

function readStyleParams()
{
	var menuStyle = getStyle("menu");
	var subMenuStyle = getStyle("submenu");
	var menuStyleRoll = getStyle("rollovermenu");
	var subMenuStyleRoll = getStyle("rolloversubmenu");

	if(menuStyle.direction) FirstLineHorizontal = (menuStyle.direction == 'ltr') ? 0 : 1;

	if(menuStyle.fontWeight && (menuStyle.fontWeight == "bold")) FontBold = 1;

	if(menuStyle.backgroundColor) LowBgColor = menuStyle.backgroundColor;
	if(menuStyleRoll.backgroundColor) HighBgColor = menuStyleRoll.backgroundColor;
	if(subMenuStyle.backgroundColor) LowSubBgColor = subMenuStyle.backgroundColor;
	if(subMenuStyleRoll.backgroundColor) HighSubBgColor = subMenuStyleRoll.backgroundColor;

	if(menuStyle.color) FontLowColor = menuStyle.color;
	if(subMenuStyle.color) FontSubLowColor = subMenuStyle.color;
	if(menuStyleRoll.color) FontHighColor=menuStyleRoll.color;
	if(subMenuStyleRoll.color) FontSubHighColor=subMenuStyleRoll.color;

	// Il metodo borderColor in Mozilla restituisce i 4 colori del bordo
	if(menuStyle.borderLeftColor) BorderColor = menuStyle.borderLeftColor;
	if(subMenuStyle.borderLeftColor) BorderSubColor = subMenuStyle.borderLeftColor;

	if(menuStyle.textAlign) MenuCentered = menuStyle.textAlign;
	if(menuStyle.verticalAlign) MenuVerticalCentered = menuStyle.verticalAlign;

	if(menuStyle.fontSize) nfontXWidth = parseInt(menuStyle.fontSize);
	if(menuStyle.paddingLeft) nMinCellWidth = parseInt(menuStyle.paddingLeft);
	if(menuStyle.paddingRight) nMaxCellWidth = parseInt(menuStyle.paddingRight);
	if(menuStyle.height) nCellHeight = parseInt(menuStyle.height);
	if(subMenuStyle.paddingLeft) nMinSubCellWidth = parseInt(subMenuStyle.paddingLeft);
	if(subMenuStyle.paddingRight) nMaxSubCellWidth = parseInt(subMenuStyle.paddingRight);
	if(subMenuStyle.height) nSubCellHeight = parseInt(subMenuStyle.height);
}

function calcDim(nLen, nMax, nMin)
{
	var dim = (nLen * nfontXWidth) / 10 + 6;
	
  if(dim > nMax)
		dim = nMax;
	else if(dim < nMin)
		dim = nMin;

	return Math.round(dim);	
}

function calcWidth(nLen)
{
  return calcDim(nLen, nMaxCellWidth, nMinCellWidth);
}

function calcSubWidth(nLen, sSubId)
{
	var nMin = submenutable[sSubId];

	if(nMin && nMin > nLen)
		nLen = nMin;

  var nDim = calcDim(nLen, nMaxSubCellWidth, nMinSubCellWidth);

	return nDim;
}

