/* 

	mapb_menu



	Copyright Miquel Angel Pintanel 2000-2002

	Last Update 10/Mar/2002

	Version 0.8

		

	http://perso.wanadoo.es/mapintanel/mapbdhtml/index.html      mapbdhtml@wanadoo.es

	

	This script and his components are free, but must be

	maintained this text and the copyright to use it.

	

	Version 0.2 Added autoHide feature

	Version 0.3 Fixed bug in stylesheet

	Version 0.4 Added compatibility NS6



    Version 0.6 Support frames (first public release)

      Update 0.6.1 Fixed a bug

      Update 0.6.2 Previous fixed a bug makes a new bug



    Version 0.7 Added You are here feature

      Update 0.7.1 First level Items can be links now and can change color as other levels

      Update 0.7.2 Fixed a bug of last update now works fine in horizontal

      Update 0.7.3 Fixed bug in internal links

      Update 0.7.4 Fixed bug in frames and added frames sample

      Update 0.7.5 Minor bugs fixed



    Version 0.8 Added background images. Menu can do pop-up. Colors and backgrounds only

                defined in menu definition, no duplicated in CSS. Changed behaviour of links,

                now like other elements

      Update 0.8.1 Fixed bug in pop-up

      Update 0.8.2 Cursor change on links, fixed empty cells, fixed YouAreHere bug in first level items, decoration and weight in links returns



      Update 0.8.3 New approach to change cursor on links. Added 'onclick' mXtra.

      Update 0.8.4 Another new approach to change cursor on links. Arranged freeze in Netscape 4.7

      Update 0.8.5 Menus can open to left or right

 */



var NN = (document.layers ? true : false);

var hideName = (NN ? 'hide' : 'hidden');

var showName = (NN ? 'show' : 'visible');

var open_sm = new Array ();

var to_load = new Array ();

var imgs_url = new Array ();

var imgs_loaded = new Array ();

var autoHide_pass = 1;



var autoHide_on = false;

var autoHide_var = null;

var autoHide_activate = false;

var autoHide_seconds = 3;

var idYouarehere = '';

var tempX;

var tempY;

var sagepath='';



function Menu (idMenu,m_left,m_top) {



	// PREFS

	this.m_left  = m_left; // Left position

	this.m_top  = m_top; // Top position



	this.m_vertical  = false; // If true menu is vertical

	this.sm_width  = 150; // Width of submenu items

	this.sm_height  = 25; // Height of submenu items



	this.sm_border = 0;

	this.h_offset  = -3; // Horizontal offset in relation to previous menu



	this.v_offset  = 3; // Vertical offset in relation to previous menu 

	this.l_m_color  = '#3333AA'; // If sm_border > 0 border color of initial menu

	this.l_sm_color  = '#999999'; //'#CCFFFF'; // If sm_border > 0 border color of submenus

	this.m_color  = '#FFFFFF'; //'#666666';  //'#3333AA';  // Color of initial menu

	this.m_a_color  = '#FFFFFF'; //'#669999'; //this.m_color;

	this.m_txt_color  = '#000000';

	this.m_txt_a_color  = '#000000';//this.m_txt_color;

	this.m_txt_weight = 900;

	this.m_txt_link_weight = 900;

	this.m_txt_decoration = 'none';

	this.m_txt_link_decoration = 'none';	

	this.sm_color  = '#000000'; //'#666666'; // Item color of submenus

	this.sm_a_color  = '#FFFFCC'; //'#669999'; //'#669999'; // Item color when mouseOver

	this.txt_color  = '#FFFFFF';  // Color of initial menu

	this.txt_a_color  = '#000000'; // Item color of submenus

	this.txt_i_color  = 'gray'; // Item color of inactive items

	this.txt_weight = 700;

	this.txt_link_weight = 700;

	this.txt_decoration = 'none';

	this.txt_link_decoration = 'underline';

	this.default_cursor ='default';

	this.link_cursor = 'hand';



	this.m_dec = ''; // Right decoration of menu



	this.sm_sep = (NN)? '----------' : '<HR width="90%">'; // Separator Image

	this.sm_arrow = '<img src="' + sagepath + '/images/arrow_white.gif" border="0" hspace="3" align="right">'; // Arrow image

	this.sm_left_arrow = '<img src="' + sagepath + '/images/mini_left.gif" border="0" hspace="3" align="right">'; // Left arrow image

	this.sm_current = '<img src="' + sagepath + '/images/v.gif" border="0" hspace="3" align="right">'; // Current Image

	this.menu_back_st = (NN)?'NNmenuBackSt':'menuBackSt';               // Style variables of font

	this.submenu_back_st = (NN)?'NNsubmenuBackSt':'submenuBackSt';         //     and another preferences in

	this.menu_st = 'menuSt';                        //     mapb_menu_style.css

	this.submenu_st = 'submenuSt';                  //

	this.submenu_st_inactive = 'submenuStInactive'; //

	this.zIndx = 10;

	this.iconYouarehere = '<img src="http://www.sageinst.com/images/iconYouarehere.gif" width="20" height="20" border="0" alt="The page you are viewing now" title="The page you are viewing now">';

	this.iconYouarenothere = '<img src="http://www.sageinst.com/images/iconYouarenothere.gif" width="20" height="20" border="0" alt="You are here!">';

	this.activeYouarehere = false;



	this.sm_direction = 'right';



	

	this.frameMenu = 'noFrames';

	this.frameSubMenu = 'noFrames';

	frameMenu = this.frameMenu;

	

	//private variables



	this.idMenu = idMenu;

	this.lev = 0;

	this.pre_sm = this.idMenu + 'm';

	this.pre_td = 'td';

	this.suf_sm_a = this.idMenu + 'a';

	this.pre_l = this.idMenu + 'l';

	this.num_sm = -1;

	this.sm = new Array ();

	this.sm[0] = new Array();

	this.c_a = new Array ();

	this.c_a[this.lev] = [0,0,0,false,0,'',0];

	this.c_l = new Array ();

	this.c_l[this.lev] = [this.m_left,this.m_top];

	this.mn = new Array();

	this.idYouarehere = idYouarehere;

	this.nextChangeDir = false;

	

	//Functions

	this.addItem = addItem;



	this.doMenu = doMenu;

	this.genL = genL;

	this.endL = endL;

	this.hideL = hideL;

	this.showL = showL;



	this.refL = refL;

	this.hideMenus = hideMenus;

	this.onOut_sm = onOut_sm;

	this.onOver_sm = onOver_sm;



	this.youAreHere = youAreHere



	this.openHere = openHere;

	this.open_l = open_l;

	

	return this;

}



function genL(sName, sLeft, sTop, sWdh, sHgt, sVis,sColor,copy,handlers) {

	if (NN) {

		tWidth = (!sWdh)? '' : ' WIDTH="' + sWdh + '"';



		tHeight = (!sHgt)? '' : ' HEIGHT="' + sHgt + '"';

		tHandlers = (!handlers)? '' : handlers;

		var s = '<LAYER NAME="' + sName + '" LEFT="' + sLeft;

		s += '" TOP="' + sTop + '"';

		s += tWidth;

		s += tHeight;



		s += ' VISIBILITY="' + sVis + '"';

		s += ' z-Index="' + (++this.zIndx) + '" ';

		if (typeof (sColor) == 'number'){

		    s += ' background="' + to_load[sColor] + '"';

		} else {

		    s +=' bgcolor="' + sColor + '"';

		}

		s += tHandlers + '>\n' + copy;



		return s;

	} else {

		tWidth = (!sWdh)? '' : ' width:' + sWdh + 'px;';



		tHeight = (!sHgt)? '' : ' height:' + sHgt + 'px;';

		tHandlers = (!handlers)? '' : handlers;

		var s = '<DIV ID="' + sName + '" STYLE="position:absolute; overflow:clip;';

		s += ' left:' + sLeft + 'px;';

		s += ' top:' + sTop + 'px;';

		s += tWidth;

		s += tHeight;

		s += ' visibility:' + sVis + '; z-Index:' + (++this.zIndx) + '; background:';

		s += (typeof (sColor) == 'number'? imgs_url[sColor] : sColor);

		s += '"' + tHandlers + '>\n' + copy;

		return s;

	}

}



function endL (){

	if (NN){

		return '</LAYER>\n';

	}



	else{

		return '</DIV>\n';



	}

}



function hideL(name,alayer,theFrame) {

    if (NN){refL(name,alayer,theFrame).visibility = hideName} else {refL(name,alayer,theFrame).style.visibility = hideName}

}



function showL(name,alayer,theFrame) {

    if (NN){refL(name,alayer,theFrame).visibility = showName} else {refL(name,alayer,theFrame).style.visibility = showName}



}



function refL(aLayer,aLayout,theFrame) {

    theDoc = (theFrame == 'noFrames')? document : top.frames[theFrame].document;

    if (document.getElementById) {

	    return theDoc.getElementById(aLayer);

    } else if (document.layers){

	    if (aLayout != ''){

		    return theDoc.layers[aLayout].document.layers[aLayer]

	    } else {

		    return theDoc.layers[aLayer]

	    }

    } else if (document.all){

	    return eval('theDoc.all.' + aLayer);

    }

}



function searchL (searchedL) {

    var isMatch = false;

    for (i = 0;i < open_sm.length;i++){

	if (open_sm[i][0] == searchedL){

	    isMatch = true;

	    break

	}



    }

    theMatch = (isMatch)? i : -1;

    return theMatch

}



/*

Example of

mXtras: {'url':'a.html','target':'atarget','background':'acolororimg','backgroundA':'otherColororImg',

	'txtcolor':'acolor','txtacolor':'yetanotherColor','theWidth': number,'theHeight':number,



	'winOptions':'status=yes,toolbar=yes,resizable=yes,location=yes,scrollbars=auto','onclick':anAction,

         'nextOpenDir':'left or right'}

*/



function addItem (mText,mXtras,isLast) {

    var suf = '',idLayout,theText,theDecor,is_active;

    var clickAction = '';

    var prevWidth = 0;

    var prevDiff = 0;

    mXtras = (typeof (mXtras) == 'string')? {'url':mXtras}: mXtras;



    theColor = mXtras['Mnbackground'] || mXtras['background'] || this.sm_color;

    theaColor = mXtras['MnAbackground'] || mXtras['backgroundA'] || this.sm_a_color;

    txtcolor = mXtras['Mntxtcolor'] || mXtras['txtcolor'] || this.txt_color;

    txtAcolor =  mXtras['Mntxtacolor'] || mXtras['txtacolor'] || this.txt_a_color;

    theWidth = mXtras['theWidth'] || this.sm_width;

    theHeight = mXtras['theHeight'] || this.sm_height;

    winOpts = mXtras['winOptions'] || '';

    theDir = mXtras['nextOpenDir'] || '';

    for (i=0;i <= this.lev; i++){

	suf += '_';

	suf += this.c_a[i][0];



    }

    if (this.c_a[this.lev][0] == 0){



	this.num_sm++;

	this.sm[this.num_sm] = new Array ();

	this.c_a[this.lev][4] = this.num_sm;

	if ((this.sm_direction == 'left' && !this.nextChangeDir) || (this.nextChangeDir && this.sm_direction != 'left')){

	    this.c_l[this.lev][0] -= ((this.lev > 1 && !this.m_vertical) || (this.lev > 0 && this.m_vertical))? theWidth : 0;



	    this.nextChangeDir = false

	} else if (this.sm_direction == 'left' && this.nextChangeDir){

	    this.nextChangeDir = false

	}

	this.mn[this.c_a[this.lev][4]] = new Array(this.c_l[this.lev][0],this.c_l[this.lev][1]);

	this.c_a[this.lev][5] = suf;

    }

    if (mXtras['url'] == ''){

	this.c_a[this.lev][6] = theWidth;

	    var s = '';

	    prevWidth = theWidth;

	    clickAction = mXtras['onclick'] || '';

	    if (this.lev == 0) {

		idLayer = this.pre_l + suf;

		idLayout = this.c_a[this.lev][5];

		theClass = this.menu_st;



		theText = mText;

		theDecor = this.m_dec;



		is_active = true;

		theColor = mXtras['Mnbackground'] || mXtras['background'] || this.m_color;

		theaColor = mXtras['MnAbackground'] || mXtras['backgroundA'] || this.m_a_color;

		txtcolor = mXtras['Mntxtcolor'] || mXtras['txtcolor'] || this.m_txt_color;

		txtAcolor = mXtras['Mntxtacolor'] || mXtras['txtacolor'] || this.m_txt_a_color

	    } else {

		idLayer = this.pre_l + suf;

		idLayout = this.c_a[this.lev][5];

		theClass = this.submenu_st;

		theText = mText;

		theDecor = (this.sm_direction == 'left')? this.sm_left_arrow : this.sm_arrow;

		is_active = true;

	    }

	    if (theColor.indexOf ('url') > -1){

		offImg = new addToLoad (theColor);

		theColor = offImg.indx

	    }

	    if (theaColor.indexOf ('url') > -1){

		activeImg = new addToLoad (theaColor);

		theaColor = activeImg.indx

	    }

	    this.sm[this.c_a[this.lev][4]][this.c_a[this.lev][0]] = new Array (suf,idLayer,idLayout,theClass,theText,

									       theDecor,is_active,this.c_a[this.lev][1],

									       this.c_a[this.lev][2],

									       [theColor,theaColor,txtcolor,txtAcolor,

									       theWidth,theHeight],mXtras['url'],mText,null,

									       clickAction,prevWidth,prevDiff);



	    if (isLast){

		if (this.m_vertical || this.lev > 0){

		    this.mn[this.c_a[this.lev][4]][3] = this.c_a[this.lev][2] + theHeight;

		    this.mn[this.c_a[this.lev][4]][2] = theWidth;

		} else {



		    this.mn[this.c_a[this.lev][4]][3] = theHeight;

		    this.mn[this.c_a[this.lev][4]][2] = this.c_a[this.lev][1] + theWidth;		    

		}



		this.c_a[this.lev][3] = true;

	    } else {

		this.c_a[this.lev][3] = false;

	    }

	    this.lev++;

	    if (this.lev == 1 && !this.m_vertical){



		if (this.frameMenu == 'noFrames'){

		    this.c_l[this.lev] = new Array(this.c_l[this.lev-1][0]+this.c_a[this.lev-1][1],this.c_l[this.lev-1][1] + theHeight);

		    this.c_a[this.lev] = new Array(0,0,0,false,this.num_sm,'',0);

		} else {

		    this.c_l[this.lev] = new Array(this.c_l[this.lev-1][0]+this.c_a[this.lev-1][1],this.c_l[this.lev-1][1]);

		    this.c_a[this.lev] = new Array(0,0,0,false,this.num_sm,'',0);

		}

	    } else if (this.lev == 1 && this.m_vertical){

		if (this.frameMenu == 'noFrames'){



		    toSum = (this.sm_direction == 'left')? 0 : theWidth;

		    this.c_l[this.lev] = new Array(this.c_l[this.lev-1][0]+toSum,this.c_l[this.lev-1][1]+this.c_a[this.lev-1][2]);

		    this.c_a[this.lev] = new Array(0,0,0,false,this.num_sm,null,0);

		} else {

		    this.c_l[this.lev] = new Array(this.c_l[this.lev-1][0],this.c_l[this.lev-1][1]+this.c_a[this.lev-1][2]);

		    this.c_a[this.lev] = new Array(0,0,0,false,this.num_sm,'',0);



		}

	    } else {

		if (this.sm_direction == 'left'){

		    this.c_l[this.lev] = new Array(this.c_l[this.lev-1][0]-this.h_offset,this.c_l[this.lev-1][1]+this.c_a[this.lev-1][2] + this.v_offset);

		    this.c_a[this.lev] = new Array(0,0,0,false,this.num_sm,'',0);

		} else {

		    this.c_l[this.lev] = new Array(this.c_l[this.lev-1][0]+theWidth+this.h_offset,this.c_l[this.lev-1][1]+this.c_a[this.lev-1][2] + this.v_offset);

		    this.c_a[this.lev] = new Array(0,0,0,false,this.num_sm,'',0);

		}

	    }

	    if (this.sm_direction == 'left' &&  theDir == 'right'){

		this.c_l[this.lev][0] = this.c_l[this.lev-1][0] + theWidth;

		this.nextChangeDir = true

	    } else if (this.sm_direction == 'right' &&  theDir == 'left'){

		this.c_l[this.lev][0] = this.c_l[this.lev-1][0];

		this.nextChangeDir = true

	    }

	    if ((this.lev - 1) == 0){

		    if (this.m_vertical){

			this.c_a[this.lev-1][2] += theHeight;

			this.c_a[this.lev-1][1] = 0

		    } else {

			this.c_a[this.lev-1][1] += theWidth;



			this.c_a[this.lev-1][2] = 0;

		    }

	    } else {

		this.c_a[this.lev-1][2] += theHeight;

		this.c_a[this.lev-1][1] = 0

	    }



    } else {

	    var s;

	    if (this.lev == 0){

		theClass = this.menu_st;

		is_active = true;

		theDecor = '';

		theColor = mXtras['Mnbackground'] || mXtras['background'] || this.m_color;

		theaColor = mXtras['MnAbackground'] || mXtras['backgroundA'] || this.m_a_color;



		txtcolor = mXtras['Mntxtcolor'] || mXtras['txtcolor'] || this.m_txt_color;



		txtAcolor = mXtras['Mntxtacolor'] || mXtras['txtacolor'] || this.m_txt_a_color;

	    } else {

		theClass = this.submenu_st;

		is_active = true;

		theDecor = '';

	    }

	    if (mText == '-') {



		idLayout = this.c_a[this.lev][5];

		theText = this.sm_sep;

		is_active = false;

		theDecor = '';

	    } else {

		    idLayer = '';

		    idLayout = this.c_a[this.lev][5];

		    if (mXtras['url'] == 'v'){

			theDecor = this.sm_current;



		    } else if (mXtras['url'] == 'x'){

			theClass = this.submenu_st_inactive;

			theColor  = this.txt_i_color;

			theaColor  = this.txt_i_color;

			is_active = false;

		    } else if (mXtras['url'] == 'a'){

			clickAction = mXtras['onclick'];

		    } else {

			theTarget = (mXtras['target'])? mXtras['target'] : '' ;



			preAct = (this.frameMenu == 'noFrames')? '': 'top.';

			if (theTarget.indexOf ('parent') > -1 && theTarget.length <= 7){



			    clickAction = 'parent.location.href = \'' + mXtras['url'] + '\''

			} else if (theTarget.indexOf ('top') > -1 && theTarget.length <= 4){

			    clickAction = 'top.location.href = \'' + mXtras['url'] + '\''

			} else if (theTarget == '') {

			    clickAction = 'window.location.href = \'' + mXtras['url'] + '\''

			} else if (theTarget.indexOf ('blank') > -1 && theTarget.length <= 6){

			    postNW = String(Math.random ());

			    postNWin = (postNW.length > 1)? postNW.substr (2) : postNW;

			    clickAction = preAct + 'mapb_openBrWindow (\'' + mXtras['url'] + '\',\'mapbNewWin' + postNWin + '\',\'' + winOpts +'\')'

			} else if (parent.frames[theTarget]){



			    clickAction = 'parent.frames[\''+ theTarget +'\'].location.href = \'' + mXtras['url'] + '\''

			} else {

			    clickAction = preAct + 'mapb_openBrWindow (\'' + mXtras['url'] + '\',\''+ theTarget +'\',\''+ winOpts +'\')'

			}

		    }

		    theText = mText;

	    }

	    if (theColor.indexOf ('url') > -1){

		smoffImg = new addToLoad (theColor);

		theColor = smoffImg.indx

	    }

	    if (theaColor.indexOf ('url') > -1){

		smactiveImg = new addToLoad (theaColor);



		theaColor = smactiveImg.indx

	    }

	    this.sm[this.c_a[this.lev][4]][this.c_a[this.lev][0]] = new Array (suf,idLayer,idLayout,theClass,

									       theText,theDecor,is_active,

									       this.c_a[this.lev][1],this.c_a[this.lev][2],



									       [theColor,theaColor,txtcolor,txtAcolor,

									       theWidth,theHeight],mXtras['url'],mText,null,

									       clickAction,prevWidth,prevDiff);

	    this.c_a[this.lev][2] += theHeight;

	    if (this.lev == 0){

		if (!this.m_vertical){

		    this.c_a[this.lev][2] = 0;

		    this.c_a[this.lev][1] = this.c_a[this.lev][1] + theWidth;

		}

	    }

	    this.c_a[this.lev][0]++;

	    if (isLast){

		    this.c_a[this.lev][0] = 0;

		    this.c_a[this.lev][3] = true;



		    if (!this.m_vertical && this.lev == 0){



			this.mn[this.c_a[this.lev][4]][2] = this.c_a[this.lev][1];



			this.mn[this.c_a[this.lev][4]][3] = theHeight;

		    } else {

			this.mn[this.c_a[this.lev][4]][2] = theWidth;

			this.mn[this.c_a[this.lev][4]][3] = this.c_a[this.lev][2];

		    }

		    if (this.lev > 0){

			this.lev--;

		    }

		    if (this.lev >= 0){

			this.c_a[this.lev][0]++;

		    }

		    while (this.c_a[this.lev][3] == true){

			    this.c_a[this.lev][0] = 0;

			    this.lev--;

			    if (this.lev >= 0){



				    this.c_a[this.lev][0]++;

				    }



			    if (this.lev <= 0){

				    break;

			    }

		    }

	    } else {

		this.c_a[this.lev][3] = false;

	    }

    }

}



function doMenu (theWindow){

    var theL = '';

    for (i=0;i < this.sm.length;i++){

	var m;

	if (i == 0){

	    if (!this.m_vertical){

		    theClass = this.menu_back_st;

		    h = ' class="' + theClass + '"';



		    m = '<table border="0" cellpadding="0" cellspacing="0" width="'+ this.mn[i][2] +'" height="' + this.mn[i][3] + '">\n';



		    m += '<tr><td>\n';

	    } else {

		    theClass = this.menu_back_st;



		    h = ' class="' + theClass + '"';

		    m = '<table border="0" cellpadding="0" cellspacing="0" width="' + this.mn[i][2] + '" height="' + this.mn[i][3] + '">';

		    m += '<tr><td>\n';

	    }

	    theL += this.genL (this.pre_l + this.sm[i][0][0],this.mn[i][0],this.mn[i][1],false,false,showName,this.l_m_color,m,h);

	} else {

	    h = ' class="' + this.submenu_back_st + '"';

	    m = '<table border="0" cellpadding="0" cellspacing="0" width="'+ this.mn[i][2] +'" height="' + this.mn[i][3] + '">';

	    m += '<tr><td>';

	    theL += this.genL (this.pre_l + this.sm[i][0][0],this.mn[i][0],this.mn[i][1],false,false,hideName,this.l_sm_color,m,h);

	}

	for (j=0;j < this.sm[i].length;j++){

	    f = (this.sm[i][j][3] == this.menu_st)? this.frameMenu : this.frameSubMenu;

	    txtWeight = (this.sm[i][j][3] == this.menu_st)? this.m_txt_weight : this.txt_weight;

	    txtDec = (this.sm[i][j][3] == this.menu_st)? this.m_txt_decoration : this.txt_decoration;

	    t = (this.frameMenu == 'noFrames')? '': 'parent.';

	    visibleText = this.sm[i][j][4];

	    decoration = this.sm[i][j][5];

	    acType = (NN)? 'onFocus':  'onclick';

	    actOnClick = (this.sm[i][j][13] > '')? ' ' + acType + '="' + this.sm[i][j][13] + '"' : '';



	    if (theWindow == this.frameSubMenu){

		if(top.frames[this.frameSubMenu].location.href.indexOf(this.sm[i][j][10]) > -1 && this.sm[i][j][10].indexOf('#') == -1 && this.sm[i][j][10].length > 1){

		    visibleText = this.sm[i][j][11];

		    decoration = this.iconYouarehere;

		    this.Iamhere = this.sm[i][j][2];

		    this.idYouarehere = this.sm[i][j][2];

		    actOnClick = '';

		}

	    } else {

		if(location.href.indexOf(this.sm[i][j][10]) > -1 && this.sm[i][j][10].indexOf('#') == -1 && this.sm[i][j][10].length > 1){

		    visibleText = this.sm[i][j][11];

		    decoration = this.iconYouarehere;

		    this.Iamhere = this.sm[i][j][2];

		    this.idYouarehere = this.sm[i][j][2];

		    actOnClick = '';

		}

	    }

	    xTras ='';

	    for (lm in this.sm[i][j][9]){

		xTras += (typeof(this.sm[i][j][9][lm]) == 'string'? ',\'' + this.sm[i][j][9][lm] + '\'' : ',' + this.sm[i][j][9][lm]);

	    }

	    hasLink = (actOnClick.length > 1)? 1 : 0;



	    cursorST = (actOnClick.length > 1)? this.link_cursor : this.default_cursor;

	    tdStyle = ' style="color: '+ this.sm[i][j][9][2] +';font-weight:'+ txtWeight +';text-decoration:'+ txtDec + '"';

	    h = ' onMouseOver="' + t + this.idMenu + '.onOver_sm(\''+ this.sm[i][j][3] + '\',' + hasLink + ',\'' + this.pre_sm + this.sm[i][j][0] +'\',\'';

	    h += this.sm[i][j][1] + '\',\'' + this.pre_l + this.sm[i][j][2] + '\',' + this.sm[i][j][6] + ',\''+ f + '\'';

	    h += xTras + ')"';



	    h += actOnClick;		

	    h += ' onMouseOut="' + t + this.idMenu + '.onOut_sm(\''+ this.sm[i][j][3] + '\','+ hasLink +',\'' + this.pre_sm + this.sm[i][j][0] + '\',\'' + this.pre_l + this.sm[i][j][2] + '\',' + this.sm[i][j][6] + ',\''+ f + '\'';

	    h += xTras + ')"';

	    m = '<table border="0" cellspacing="0" cellpadding="3">\n';

	    m += '<tr>';

	    theAlign = (this.sm_direction == 'left')? 'right': 'left' ;



	    if (NN){



		longTD = '<td class="' + this.sm[i][j][3] + '" width="' + this.sm[i][j][9][4] + '" height="' + this.sm[i][j][9][5] + '"' + ' align="' + theAlign + '"'

		longTD += ' id="' + this.pre_td + this.pre_sm + this.sm[i][j][0] + '"';

		longTD += ' name="' + this.pre_td + this.pre_sm + this.sm[i][j][0] + '"><font color="'+ this.sm[i][j][9][2] +'">' + visibleText + '</font></td>\n';



		shortTD = (decoration > '')?'<td align="right" class="' + this.sm[i][j][3] + '"><font color="'+ this.sm[i][j][9][2] +'">' + decoration + '</font></td>\n':'';

	    } else {

		longTD = '<td class="' + this.sm[i][j][3] + '" width="' + this.sm[i][j][9][4] + '" height="' + this.sm[i][j][9][5] + '"' + ' align="' + theAlign + '"'

		longTD += ' style="cursor: '+ cursorST +'"';

		longTD += '><span';

		longTD += ' id="' + this.pre_td + this.pre_sm + this.sm[i][j][0] + '"';

		longTD += ' name="' + this.pre_td + this.pre_sm + this.sm[i][j][0] + '"';



		longTD += tdStyle;

		longTD += '>' + visibleText + '</span></td>\n';

		shortTD = (decoration > '')? '<td class="' + this.sm[i][j][3] + '"' + tdStyle + '>' + decoration + '</td>\n':'';



	    }

	    m += (this.sm_direction == 'left')? shortTD + longTD : longTD + shortTD;

	    m += '</tr></table>\n';	    

	    layerName = this.pre_sm + this.sm[i][j][0];



	    theL += this.genL (layerName,this.sm[i][j][7],this.sm[i][j][8],this.sm[i][j][9][4],this.sm[i][j][9][5],'inherit',this.sm[i][j][9][0],m,h);

	    theL += endL();

	}

	theL += '</td></tr>\n';

	theL += '</table>\n';

	theL += endL() + '\n';

	if (this.frameMenu == 'noFrames'){

		document.writeln(theL);

	} else {

	    if (this.sm[i][0][3] == this.menu_st && theWindow == this.frameMenu){

		top.frames[this.frameMenu].document.writeln(theL);

	    } else if (this.sm[i][0][3] == this.submenu_st && theWindow == this.frameSubMenu){

		top.frames[this.frameSubMenu].document.writeln(theL);

	    }

	}



	theL = '';

    }

}



function hideMenus () {

	for (var i = 0;i < open_sm.length;i++){

	    if (open_sm[i][1] != 'noFrames'){

		if (document.all){

		    refL(open_sm[i][0],'',open_sm[i][1]).style.pixelTop = open_sm[i][2];

		    refL(open_sm[i][0],'',open_sm[i][1]).style.pixelLeft = open_sm[i][3]

		} else if (NN){



		    refL(open_sm[i][0],'',open_sm[i][1]).top = open_sm[i][2];

		    refL(open_sm[i][0],'',open_sm[i][1]).left = open_sm[i][3]

		}

	    }

	    hideL(open_sm[i][0],'',open_sm[i][1]);



	}

	clearInterval (autoHide_var);

	autoHide_on = false;

}



function onOver_sm (classLment,isaURL,what_sm,what_l,parentL,sm_active,theFrame,smColor,smaColor,txtcolor,txtAcolor) {

    if (sm_active){

	if (NN){



	    if (typeof (smaColor) == 'number'){

		refL(what_sm,parentL,theFrame).background.src = to_load[smaColor];

	    } else {

		refL(what_sm,parentL,theFrame).bgColor = (smaColor > '')? smaColor : this.sm_a_color;

	    }

	} else {

	    if (typeof (smaColor) == 'number'){

		refL(what_sm,'',theFrame).style.background = imgs_url[smaColor];

	    } else {

		refL(what_sm,'',theFrame).style.background = (smaColor > '')? smaColor : this.sm_a_color;



	    }

	    refL(this.pre_td + what_sm,'',theFrame).style.color =  (txtAcolor > '')? txtAcolor : this.txt_a_color;

	    if (isaURL > 0){

		refL(this.pre_td + what_sm,'',theFrame).style.fontWeight = (classLment == this.menu_st)? this.m_txt_link_weight : this.txt_link_weight;

		refL(this.pre_td + what_sm,'',theFrame).style.textDecoration = (classLment == this.menu_st)? this.m_txt_link_decoration :  this.txt_link_decoration;

	    }

	}

    }

    this.open_l (what_sm,what_l);

}



function onOut_sm (classLment,isaURL,what_sm,what_l,sm_active,theFrame,smColor,smaColor,txtcolor,txtAcolor){

    if (sm_active){

	if (NN){

	    if (typeof (smColor) == 'number'){



		refL(what_sm,what_l,theFrame).background.src = to_load[smColor];

	    } else {

		refL(what_sm,what_l,theFrame).background.src = null;

		refL(what_sm,what_l,theFrame).bgColor = (smColor > '')? smColor : this.sm_color;

	    }

	} else {

	    if (typeof (smColor) == 'number'){

		refL(what_sm,'',theFrame).style.background = imgs_url[smColor];

	    } else {

		refL(what_sm,'',theFrame).style.background = (smColor > '')? smColor : this.sm_color;



	    }

	    refL(this.pre_td + what_sm,'',theFrame).style.color = (txtcolor > '')? txtcolor : this.txt_color;

	    if (isaURL > 0){

		refL(this.pre_td + what_sm,'',theFrame).style.fontWeight = (classLment == this.menu_st)? this.m_txt_weight : this.txt_weight;

		refL(this.pre_td + what_sm,'',theFrame).style.textDecoration = (classLment == this.menu_st)? this.m_txt_decoration : this.txt_decoration;

	    }

	}

    }



}



function open_l (what_sm,what_l){

    if (autoHide_activate){

	if (!autoHide_on){

	    autoHide_on = true;

	    autoHide_var = setInterval ("autoHide ()",1000);

	} else {

	    autoHide_pass = 1;

	}

    }

    if (what_l != ''){

	var initialY,initialX;

	if (this.frameMenu != 'noFrames'){

	    if (document.all){

		tempY = eval(this.frameSubMenu + '.document.body.scrollTop');

		tempX = eval(this.frameSubMenu + '.document.body.scrollLeft');

		thePos = searchL (what_l+'_0');



		if (thePos > -1){

		    initialY = open_sm[thePos][2];

		    initialX = open_sm[thePos][3]

		} else {



		    initialY = refL(what_l+'_0','',this.frameSubMenu).style.pixelTop;

		    initialX = refL(what_l+'_0','',this.frameSubMenu).style.pixelLeft;

		}

		refL(what_l+'_0','',this.frameSubMenu).style.pixelTop = initialY + tempY;

		refL(what_l+'_0','',this.frameSubMenu).style.pixelLeft = initialX + tempX

	    } else if (NN || document.getElementById){

		tempY = eval(this.frameSubMenu + '.pageYOffset');



		tempX = eval(this.frameSubMenu + '.pageXOffset');

		thePos = searchL (what_l+'_0');

		if (thePos > -1){



		    initialY = open_sm[thePos][2];

		    initialX = open_sm[thePos][3]

		} else {

		    initialY = (NN)? refL(what_l+'_0','',this.frameSubMenu).top : parseInt(refL(what_l+'_0','',this.frameSubMenu).style.top);

		    initialX = (NN)? refL(what_l+'_0','',this.frameSubMenu).left : parseInt(refL(what_l+'_0','',this.frameSubMenu).style.left);

		}

		if (NN){



		    refL(what_l+'_0','',this.frameSubMenu).top = initialY + tempY;



		    refL(what_l+'_0','',this.frameSubMenu).left = initialX + tempX;

		} else {



		    refL(what_l+'_0','',this.frameSubMenu).style.top = (initialY + tempY) + 'px';



		    refL(what_l+'_0','',this.frameSubMenu).style.left = (initialX + tempX) + 'px';



		}



	    }



	}



	showL (what_l+'_0','',this.frameSubMenu);



	theLength = open_sm.length;



	open_sm[theLength] = new Array (what_l+'_0',this.frameSubMenu,initialY,initialX)



    }



    var tempA = new Array ();



    for (this.i = 0;this.i < open_sm.length;this.i++){



	    if (open_sm[this.i][0].length > what_sm.length && open_sm[this.i][0].indexOf(this.pre_l + what_sm.substr(this.pre_sm.length)) == -1){



		hideL (open_sm[this.i][0],'',this.frameSubMenu);



		if (this.frameMenu != 'noFrames'){



		    if (document.all){



			refL(open_sm[this.i][0],'',this.frameSubMenu).style.pixelTop = open_sm[this.i][2];



			refL(open_sm[this.i][0],'',this.frameSubMenu).style.pixelLeft = open_sm[this.i][3]



		    } else if (NN){



			refL(open_sm[this.i][0],'',this.frameSubMenu).top = open_sm[this.i][2];



			refL(open_sm[this.i][0],'',this.frameSubMenu).left = open_sm[this.i][3]



		    } else if ( document.getElementById){



			refL(open_sm[this.i][0],'',this.frameSubMenu).style.top = open_sm[this.i][2] + 'px';



			refL(open_sm[this.i][0],'',this.frameSubMenu).style.left = open_sm[this.i][3] + 'px'



		    }



		}



	    } else {



		tempA[tempA.length] = open_sm[this.i];



	    }



    }



    open_sm = tempA;



}











function autoHide () {



	if (autoHide_pass > autoHide_seconds) {



	    hideMenus ();



	} else {



	    autoHide_pass++;



	}



}







function youAreHere (myname,my_left, my_top, my_width, my_height,theText,my_color){



	if(this.frameSubMenu == 'noFrames'){



	    if (this.idYouarehere == ''){



		my_aText = '<table border="0" cellspacing="0" width="' + my_width + '"><tr><td align="right">';



		my_aText += this.iconYouarenothere;



		my_aText += '</td><td align="left"><span style="color: gray; font-size: 11px;font-family: sans-serif; cursor: default">'+ theText +'</span></td></tr></table>';



		aText = genL(myname,my_left,my_top,my_width,my_height,showName,my_color,my_aText);



		aText +=  endL();



	    } else {



		my_aText = '<table border="0" cellspacing="0" width="' + my_width + '"><tr><td align="right">';



		my_aText += this.iconYouarehere;



		my_aText += '</td><td align="left"><span style="font-size: 11px;font-family: sans-serif; cursor: default">'+ theText +'</span></td></tr></table>';



		aHand = ' onMouseOver="' + this.idMenu + '.openHere ()"';



		aText = genL(myname,my_left,my_top,my_width,my_height,showName,my_color,my_aText,aHand);



		aText +=  endL();



	    }



	    document.writeln (aText)



	} else {



	    if (this.idYouarehere == ''){



		my_aText = '<table border="0" cellspacing="0" width="' + my_width + '"><tr><td align="right">';



		my_aText += this.iconYouarenothere;



		my_aText += '</td><td align="left"><span  style="color: gray; font-size: 11px;font-family: sans-serif; cursor: default">'+ theText +'</span></td></tr></table>';



		aText = genL(myname,my_left,my_top,my_width,my_height,showName,my_color,my_aText);



		aText +=  endL();



	    } else {



		my_aText = '<table border="0" cellspacing="0" width="' + my_width + '"><tr><td align="right">';



		my_aText += this.iconYouarehere;



		my_aText += '</td><td align="left"><span style="font-size: 11px;font-family: sans-serif; cursor: default">'+ theText +'</span></td></tr></table>';



		aHand = ' onMouseOver="parent.' + this.idMenu + '.openHere ()"';



		aText = genL(myname,my_left,my_top,my_width,my_height,showName,my_color,my_aText,aHand);



		aText +=  endL();



	    }



	    top.frames[this.frameSubMenu].document.writeln (aText)



	}



}







function openHere (){



    if (this.idYouarehere.length > 2){



	hideMenus ();



	aLength = this.idYouarehere.length - 2;



	sinceOpen = this.pre_sm + this.idYouarehere;



	for (u = 2; u <= aLength; u += 2){



	    whatOpen = this.pre_l + this.idYouarehere.substr(0,u);



	    this.open_l (sinceOpen,whatOpen);



	}



    }



}







function addToLoad (searchedString) {



    startStr = searchedString.indexOf ('(') + 1;



    endStr = searchedString.length - startStr - 1;



    extractURL = searchedString.substr(startStr,endStr);



    i = 0;



    isMatch = false;



    if (to_load.length > 0){



	for (i = 0;i < to_load.length;i++){



	    if (to_load[i] == extractURL){



		isMatch = true;



		break



	    }



	}



	if (!isMatch){



	    oldLength = to_load.length;



	    to_load[to_load.length] = extractURL;



	    imgs_url[imgs_url.length] = searchedString;



	    addNewImg (oldLength)



	}



	this.indx = i;



    } else {



	to_load[0] = extractURL;



	imgs_url[0] = searchedString;



	addNewImg (0);



	this.indx = 0; 



    }



    return this



}







function addNewImg (anum){



	aLay = genL('preloadLay' + anum,0,0,20,20,hideName,anum,'<p>&nbsp;</p>');



	aLay +=  endL();



	document.writeln (aLay)



}







function mapb_openBrWindow (theURL,winName,features) {



    var finestra;



    if (features > ''){



	finestra = window.open('',winName,features);



    } else {



	finestra = window.open('',winName,'status=yes,toolbar=yes,resizable=yes,location=yes,scrollbars=auto');



    }



    finestra.document.title = 'Loading...';



    finestra.location.href = theURL;



}







function findPosY(obj)



{



	var curtop = 0;



	if (document.getElementById || document.all)



	{



		while (obj.offsetParent)



		{



			curtop += obj.offsetTop



			obj = obj.offsetParent;



		}



	}



	else if (document.layers)



		curtop += obj.y;



	return curtop;



}




