// id, father, name, brands, nav

// first of all.. some common sense vars used by these class
var nFam=0; // total number of families
var rootId="root";
var root = new branch("root","", "root","","",true);	// sets the root of the tree
var tree= new Array (); // an array containing all the branch objects
var waitLayer=""; // layer name for "waiting" message
var oldRouge = new Array();

// -- Browser Detection --
var domLib_userAgent = navigator.userAgent.toLowerCase();
var domLib_isMac = navigator.appVersion.indexOf('Mac') != -1;
var domLib_isWin = domLib_userAgent.indexOf('windows') != -1;
// NOTE: could use window.opera for detecting Opera
var domLib_isOpera = domLib_userAgent.indexOf('opera') != -1;
var domLib_isOpera7up = domLib_userAgent.match(/opera.(7|8)/i);
var domLib_isSafari = domLib_userAgent.indexOf('safari') != -1;
var domLib_isKonq = domLib_userAgent.indexOf('konqueror') != -1;
// Both konqueror and safari use the khtml rendering engine
var domLib_isKHTML = (domLib_isKonq || domLib_isSafari || domLib_userAgent.indexOf('khtml') != -1);
var domLib_isIE = (!domLib_isKHTML && !domLib_isOpera && (domLib_userAgent.indexOf('msie 5') != -1 || domLib_userAgent.indexOf('msie 6') != -1 || domLib_userAgent.indexOf('msie 7') != -1));
var domLib_isIE5up = domLib_isIE;
var domLib_isIE50 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.0') != -1);
var domLib_isIE55 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.5') != -1);
var domLib_isIE5 = (domLib_isIE50 || domLib_isIE55);
// safari and konq may use string "khtml, like gecko", so check for destinctive /
var domLib_isGecko = domLib_userAgent.indexOf('gecko/') != -1;
var domLib_isMacIE = (domLib_isIE && domLib_isMac);
var domLib_isIE55up = domLib_isIE5up && !domLib_isIE50 && !domLib_isMacIE;
var domLib_isIE6up = domLib_isIE55up && !domLib_isIE55;

// NAV are 3 flags used by JS to show feature links
// Discovery->  Contents about this family are available
// Assistant->  This family can use the Assistant
// List->		There are products of this family, so you can show a list of pruducts
function htmlize(str)
{
        //str = str.replace(/\&/g,"&amp;");
        str = str.replace(/\</g,"&lt;");
        str = str.replace(/\>/g,"&gt;");
        str = str.replace(/\"/g,"&quot;");
        str = str.replace(/\n/g,"<br/>\n");
        return str;
}

function branch(id,idParent,name,brands,nav,havechildren)
{
	nFam = nFam+1;
	this.id=id;
	this.idParent=idParent||0;
	this.hasChildren=havechildren; // true if this leaf got childs
	this.haveLoadedChildrens=false;	// true if all the children have been already loaded'
	this.name=htmlize(name); // htmlize this variable!!! _to_be_changed_ SE 20040129
	this.brands=brands;

	this.childrens=new Array();
	// three flags use to determine wich of the three flags should B used
	this.discovery = (nav.indexOf("D")>=0);
	this.assistant = (nav.indexOf("A")>=0);
	this.list = (nav.indexOf("L")>=0);

	// Data Used to Control The vis. of the layers
	this.status=false;		// true if currently shown
	this.layerId="";		// ID of the layer showing the contents for the leaf
}

// this functions recalls a.js script,dynamically built upon the php+mysql engine that returns a list of brands to be added to the tree
function loadLeaf(fatherID)
	{
	MM_setTextOfLayer('waitLayer','',"loading childrens of branch:"+fatherID)
	MM_showHideLayers('waitLayer','','show')
	var script= document.createElement("SCRIPT");
	script.src="data"+fatherID+".js";
	script.id="branch"+fatherID
	script.name="branch"+fatherID
	document.getElementById('body').appendChild(script);
	MM_setTextOfLayer('waitLayer','',"loaded childrens of branch:"+fatherID)
	MM_showHideLayers('waitLayer','','hide')
	}

// got from previous version of macroIE.js: populate the three, by inserting all the branches in an Array.
function f(father, name, id, brands, nav, havechildren)
{
	if (father != "" && nav != "")
	{
		tree["f"+id] = new branch(id, father, name, brands,nav,havechildren);
		if ( (father != rootId) || (father=="") )
		{
			father = "f"+father;
			if (typeof(tree[father]) == "undefined")
			{
                alert("error adding " + id + " to " + father);
			}
			tree[father].childrens[tree[father].childrens.length] = tree["f"+id];
			tree[father].hasChildren=true;
			tree[father].haveLoadedChildrens=true;
		} else
		{
			root.childrens[root.childrens.length] = tree["f"+id];
			root.hasChildren=true;
			root.haveLoadedChildrens=true;
			//alert(root.childrens[root.childrens.length-1] + " added " + id + " to "+father+ " as "+tree["f"+id]);
		}
	}
}


// this function shows all the families in a two-row-table with collapsed view mode
function showDyn()
{
	var texte="";
	var debut="";
	var level=1;
	var nbRow = root.childrens.length/2;

	nbRow = Math.ceil(nbRow);
    if ((typeof(pid) == 'undefined') || (pid == "voltimum"))
    {
        for(i = 0; i < nbRow; i++)
        {
            var fam1 = root.childrens[i];
            var fam2 = root.childrens[i+nbRow];
            var fam2id ="";
            if (fam2!=null) {fam2id=fam2.id}

            var ligne="<tr>";

            ligne = ligne + '<td width="278" class="vltMacro1" id="f'+fam1.id+'">'+link(fam1,level)+'</td>';
            ligne = ligne + '<td width="278" class="vltMacro1" id="f'+fam2id+'">'+link(fam2,level)+'</td>';
            ligne = ligne+'</tr>';
            texte = texte+ligne;
        }

        debut = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">';

        fin = '</table>';

        MM_setTextOfLayer('l0','',debut+texte+fin);
        MM_setTextOfLayer('topFamily','','<a href="#" class="normal" onMouseUp="changeMode()">'+nlmessages["VLT_BS_EXPAND"]+'</a>');
    } else
    {
        for(i=0;i<nbRow;i++)
        {
            var fam1 = root.childrens[i];
            var fam2 = root.childrens[i+nbRow];
            var fam2id = "";
            if (fam2 != null)
            {
                fam2id = fam2.id
            }

            var ligne = "<tr>";
            ligne = ligne + '<td height="10" valign="top" width="13"><img alt="" src="layout/' + pid + '/images/bluearrow.gif" border="0"></td>';
            ligne = ligne + '<td width="300" class="vltMacro1" id="f'+fam1.id+'" VALIGN="TOP">'+link(fam1,level)+'</td>';

            ligne = ligne + '<td height="1" width="1" align="right" valign="bottom" class="bgTd"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td>';
            if (fam2 != null)
            {
                ligne = ligne + '<td height="10" valign="top" width="13"><img alt="" src="layout/' + pid + '/images/bluearrow.gif" border="0"></td>';
                ligne = ligne + '<td width="300" class="vltMacro1" id="f'+fam2.id+'" VALIGN="TOP">'+link(fam2,level)+'</td>';
            }
            ligne = ligne + '</tr>';

            texte = texte+ligne;
        }

        debut = '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
        debut = debut + '<TR><TD COLSPAN="5" WIDTH="100%" HEIGHT="3"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></TD></TR>';

        fin = '<TR><TD COLSPAN="5" WIDTH="100%" HEIGHT="3"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></TD></TR>';
        fin = fin + '</table>';

        MM_setTextOfLayer('l0', '', debut+texte+fin);
        MM_setTextOfLayer('topFamily', '', '<a href="#" onMouseUp="changeMode()"><span class="txt11Abwhite">'+nlmessages["VLT_BS_EXPAND"]+'&nbsp;</span></a>');
    }
}


// this function shows all the families in a two-row-table with expanded [two levels] view mode
function showRep()
{
	var texte = "";
	var debut = "";
	var level = 2;

    if ((typeof(pid) == 'undefined') || (pid == "voltimum"))
    {
        for ( i=0; i < root.childrens.length; i++ )
        {
            var fam0 = root.childrens[i];
            var ligne="<tr>";
            ligne = ligne + '<td class="vltMacroRep" colspan="2" id="f' + fam0.id + '">' + fam0.name + '</td>';
            ligne = ligne + '</tr>';
            texte = texte + ligne;
            var nbRow = fam0.childrens.length / 2;
            nbRow = Math.ceil(nbRow);

            for(j=0; j < nbRow; j++)
            {
                var fam1 = fam0.childrens[j];
                var fam1id ="";
                if (fam1 != null)
                {
                    fam1id = fam1.id
                }
                var fam2 = fam0.childrens[j + nbRow];
                var fam2id = "";
                if (fam2 != null)
                {
                    fam2id = fam2.id
                }
                var ligne = "<tr>";

                if (fam1 != null && fam1.brands != "")
                {
                    link1 = link(fam1, level);
                } else if (fam1 != null)
                {
                    link1 = "<em>" + fam1.name + "</em>";
                }

                if (fam2 != null && fam2.brands != "")
                {
                    link2 = link(fam2, level);
                } else if (fam2 != null)
                {
                    link2 = "<em>" + fam2.name + "</em>";
                } else
                {
                    link2 = "";
                }

                ligne = ligne + '<td width="278" class="vltMacro1" id="f'+fam1id+'">'+link1+'</td>';
                ligne = ligne + '<td width="278" class="vltMacro1" id="f'+fam2id+'">'+link2+'</td>';
                ligne = ligne+'</tr>';
                texte = texte+ligne;
            }
        }

        debut   = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">';
        fin     = '</TABLE>';

        MM_setTextOfLayer('l0','',debut+texte+fin);
        MM_setTextOfLayer('topFamily','','<a href="#" class="normal" onMouseUp="changeMode()">'+nlmessages["VLT_BS_COLLAPSE"]+'</a>');

    } else
    {
        // relaunch version

        for ( i=0; i < root.childrens.length; i++ )
        {
            var fam0 = root.childrens[i];
            var ligne = "<tr>";
            if (i > 0)
            {
                ligne = ligne + '<td class="bdTds" colspan="5" HEIGHT=4><img alt="" src="layout/' + pid + '/images/pixel.gif" height="4" width="1"></td>';
                ligne = ligne + '</tr>';
                ligne = ligne + "<tr>";
            }

            ligne = ligne + '<td class="vltMacroRep" colspan="5" id="f' + fam0.id + '">' + fam0.name + '</td>';

            ligne = ligne + '</tr>';
            texte = texte + ligne;
            var nbRow = fam0.childrens.length / 2;
            nbRow = Math.ceil(nbRow);

            for(j=0; j < nbRow; j++)
            {
                var fam1 = fam0.childrens[j];
                var fam1id ="";
                if (fam1 != null)
                {
                    fam1id = fam1.id
                }
                var fam2 = fam0.childrens[j + nbRow];
                var fam2id = "";
                if (fam2 != null)
                {
                    fam2id = fam2.id
                }

                if (fam1 != null && fam1.brands != "")
                {
                    link1 = link(fam1, level);
                } else if (fam1 != null)
                {
                    link1 = "<BR>&nbsp;<BR><em>" + fam1.name + "</em>";
                }

                if (fam2 != null && fam2.brands != "")
                {
                    link2 = link(fam2, level);
                } else if (fam2 != null)
                {
                    link2 = "<BR>&nbsp;<BR><em>" + fam2.name + "</em>";
                } else
                {
                    link2 = "";
                }

                var ligne = "<tr>";
                ligne = ligne + '<td height="10" valign="top" width="13"><img alt="" src="layout/' + pid + '/images/bluearrow.gif" border="0"></td>';
                ligne = ligne + '<td width="300" class="vltMacro1" id="f'+fam1id+'" VALIGN="TOP">'+link1+'</td>';

                ligne = ligne + '<td height="1" width="1" align="right" valign="bottom" class="bgTd"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td>';
                if (fam2 != null)
                {
                    ligne = ligne + '<td height="10" valign="top" width="13"><img alt="" src="layout/' + pid + '/images/bluearrow.gif" border="0"></td>';
                    ligne = ligne + '<td width="300" class="vltMacro1" id="f'+fam2id+'" VALIGN="TOP">'+link2+'</td>';
                }
                ligne = ligne + '</tr>';
                texte = texte+ligne;
            }
        }

        debut   = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3" WIDTH="100%">';
        fin     = '</TABLE>';

        MM_setTextOfLayer('l0','',debut+texte+fin);
        MM_setTextOfLayer('topFamily','','<a href="#" onMouseUp="changeMode()"><span class="txt11Abwhite">'+nlmessages["VLT_BS_COLLAPSE"]+'</span></a>');
    }
}


// switch between the two different modes
function changeMode()
{
	if (type == "rep")
	{
		type = "dyn";
	} else
	{
		type = "rep";
	}
	show0();
}

// shows all the tree starting from the root
function show0() {
	if(browser=='N') {
		var rep = MM_findObj('replist');
		var l0 = MM_findObj('mainContent');
		l0.pageX=rep.pageX;
		l0.pageY=rep.pageY;
	}
	oldRouge.length=0;
	hide(1);
	clearAll(1);
	if (type=="rep") {
		showRep();
	}
	else {
		showDyn();
	}
}

// used to create all the links associated to each family
// inserita modifica per la verifica del flag L
function link(fam,level) {
	var texte="";
	//window.alert("famiglia:"+fam.name+"\n hasChildren:"+fam.hasChildren)
	if (fam!=null)
		{
		texte = texte+'<A HREF="javascript:show(\''+fam.id+'\','+level+'\)">';
		texte=texte+fam.name;
		if(browser=='N') {texte = texte +'<LAYER CLASS="macrolayer" ID="f'+fam.id+'"></LAYER>';}
		texte = texte+'</A>';
		}
	//else if (fam!=null)  {texte=texte+'<em>'+fam.name+"</em>";}
	return texte;
}

// function used to clear all the layers

function hide(level) {
	for(var i=level;i<layerMax;i++) {
		MM_showHideLayers('l'+i,'','hide');
	}
	MM_showHideLayers('b1','','hide');
}

function clearAll(level) {
	for(var i=level;i<layerMax;i++) {
		MM_setTextOfLayer('l'+i,'','');
	}
}


<!-- ************** function SHOW() ******************* -->
// near the most important, it comes from the old one, but some tricks have been made to make it
// compatible with the new data model and the communication process btween Server&Client

function show(id, level)
{
	layerId ="l"+level;

	if (id != "f")
    {
	    var fam = tree["f"+id];
		if (oldRouge[level] != null)
			setFontColor(oldRouge[level],"hide");
    	var target = MM_findObj('f'+fam.id);
    	oldRouge[level] = target;
		setFontColor(target,"show");
	    hide(level+1);
        if ((typeof(pid) == 'undefined') || (pid == "voltimum"))
            linkStyle = "normal";
		else
			linkStyle = "txt10Abwhite";
	    if ( (level == 2) && (brand == 'all') )
	    {
	        showBrand(fam, level);
		}
		else
		{

		    var texte, debut,i;
		    texte = "";
    		if (fam.list)
			{
                if ((typeof(pid) == 'undefined') || (pid == "voltimum"))
                {
                    var bulletIcon = "";
                } else
                {
                    var bulletIcon = '<img alt=">" src="layout/' + pid + '/images/bluearrow.gif" border="0">';
                }

                for (i=0; i < fam.childrens.length ; i++)
                {
                    fils = fam.childrens[i];

                    if (fils.brands != "")
                    {
                        ligne = '<tr><TD WIDTH=10 VALIGN="top">' + bulletIcon + '</TD><TD COLSPAN="5" WIDTH="100%" CLASS="vltMacro1" ID="f' + fils.id + '"><A CLASS="normal" HREF="javascript:show(\'' + fils.id + '\',' + (level+1) + ')">';
                        ligne = ligne + fils.name+'</A></TD></TR>';
                        texte = texte+ligne;
                    } else
                    {
                        ligne = '<tr><TD WIDTH=1 VALIGN="top">' + bulletIcon + "</TD><td colspan=\"5\" class=\"vltMacro1\" id=\"f" + fils.id + "\"><em>";
                        ligne = ligne + fils.name+'</em></td></tr>';
                        texte = texte + ligne;
                    }
                }
			}

	    	var urlBase ="catalogue.jsp?catalogType="+catalogType+"&family_id="+fam.id+"&brand="+brand+"&universe="+current_universe_id;
	    	var redirect = false;

	    	if ((texte == "") && (fam.list + fam.discovery + fam.assistant == 1))
            {
	    		// redirect immediately if only 1 option available
	    		if (fam.list)
	    		{
                    urlBase = urlBase+"&mode=prodlist";
                } else if (fam.discovery)
    			{
	    		    urlBase = urlBase+"&mode=details";
                } else if (fam.assistant)
    			{
	    		    urlBase = urlBase+"&mode=passist";
	    		}

	    		redirect = true;
	    		window.location = urlBase;
            }

	    	if ((texte != '') || fam.list || fam.discovery || fam.assistant)
            {
	    		var family = nlmessages["VLT_BS_FAMILY_IN_MACRO"];

    			if (texte == '')
				{
	    			family = fam.list ? "<a href=\"catalogue.jsp?catalogType="+catalogType+"&mode=prodlist&family_id="+fam.id+"&brand="+brand+"&universe="+current_universe_id+"\" class=\"" + linkStyle + "\">"+nlmessages["VLT_BS_REF_IN_MACRO"]+"</a>" : "";
				}

	    		var discovery = fam.discovery?"<a href=\"catalogue.jsp?catalogType="+catalogType+"&mode=details&brand="+brand+"&family_id="+fam.id+"&universe="+current_universe_id+"\" class=\"" + linkStyle + "\">"+nlmessages["VLT_BS_DISCOVERY_IN_MACRO"]+"</a>":"";

    			if (fam.hasChildren)
	    		{
	    		    var assistant = fam.assistant ? "<a href=\"catalogue.jsp?catalogType="+catalogType+"&mode=details&family_id="+fam.id+"&brand="+brand+"&universe="+current_universe_id+"\" class=\"" + linkStyle + "\">"+nlmessages["VLT_BS_ASSISTANT_IN_MACRO"]+"</a>":"";
	    		} else
	    		{
	    		    var assistant = fam.assistant ? "<a href=\"catalogue.jsp?catalogType="+catalogType+"&mode=passist&family_id="+fam.id+"&brand="+brand+"&universe="+current_universe_id+"\" class=\"" + linkStyle + "\">"+nlmessages["VLT_BS_ASSISTANT_IN_MACRO"]+"</a>":"";
	    		}

                if ((typeof(pid) == 'undefined') || (pid == "voltimum"))
                {
                    // pre-2004/04-Version
	        		debut = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">';
    	    		debut = debut + '<TR CLASS="bgTdsWhite"><TD WIDTH="1"><IMG SRC="v_images/spacer.gif" WIDTH="1"></TD>';
                    debut = debut + '<td width="96" class="vltMacro1Title" COLSPAN=2>&nbsp;'+family+'</td>';
                    debut = debut + '<td width="96" class="vltMacro1Title">&nbsp;'+discovery+'</td>';
                    debut = debut + '<td width="96" class="vltMacro1Title">&nbsp;'+assistant+'</td>';
                    debut = debut + "<td width='10' class=\"vltMacro1Title\" align=\"right\"><a class=\"normal\" href=\"javascript:hide("+level+")\">x</a></td><td width=\"1\"></td><tr>";
                    texte = debut+texte +'<tr><td height="1" colspan="6"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td></tr></table>';
                } else
                {
                    if (texte == "")
                    {
                        // only show navigation, no families listed...
                        // relaunch version
                        debut = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="100%" class="bgTdsSuperLiBlue">';
                        debut = debut + '<tr><td height="1" colspan="4"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1" colspan="3" class="bgTds"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td></tr>';

                        debut = debut + '<TR><TD WIDTH="1"><IMG SRC="layout/' + pid + '/images/pixel.gif" WIDTH="1"></TD>';
                        debut = debut + '<td width="120"><span class="txt10Ablue"><img alt=">" src="layout/' + pid + '/images/bluearrow.gif" border="0">&nbsp;'+family+'</span></td>';

                        if (discovery)
                        {
                            debut = debut + '<td width="120"><span class="txt10Ablue"><img alt=">" src="layout/' + pid + '/images/bluearrow.gif" border="0">&nbsp;'+discovery+'</span></td>';
                        } else
                        {
                            debut = debut + '<td width="96">&nbsp;</td>';
                        }

                        if (assistant)
                        {
                            debut = debut + '<td width="120"><span class="txt10Ablue"><img alt=">" src="layout/' + pid + '/images/bluearrow.gif"  border="0">&nbsp;'+assistant+'</span></td>';
                        } else
                        {
                            debut = debut + '<td width="96">&nbsp;</td>';
                        }
                        debut = debut + '<td width="1" class="bgTds"></td><td width="10" class="bgTds" align="right"><a href="javascript:hide('+level+')"><img src="layout/' + pid + '/images/closex.gif" ALT="X" border=0></a></td><td width="1" class="bgTds"></td></tr>';
                        texte = debut+texte + '<tr><td height="1" colspan="4"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1" colspan="3" class="bgTds"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td></tr></table>';

                    } else
                    {
                        // relaunch version with families listed

                        debut = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3" WIDTH="100%">';
                        debut = debut + '<TR>';
                        debut = debut + '<TD WIDTH="96" CLASS="bgTds" COLSPAN="2"><span class="txt10Awhite">'+family+'</span></td>';

                        if (discovery)
                        {
                            debut = debut + '<td width="96" class="bgTds"><span class="txt10Awhite"><img alt="-" src="layout/' + pid + '/images/bluearrow.gif" border="0">&nbsp;'+discovery+'</span></td>';
                        } else
                        {
                            debut = debut + '<td width="96" class="bgTds">&nbsp;</td>';
                        }

                        if (assistant)
                        {
                            debut = debut + '<td width="96" class="bgTds"><span class="txt10Awhite"><img alt=">" src="layout/' + pid + '/images/bluearrow.gif" border="0">&nbsp;'+assistant+'</span></td>';
                        } else
                        {
                            debut = debut + '<td width="96" class="bgTds">&nbsp;</td>';
                        }

                        debut = debut + '<TD WIDTH="1" class="bgTds"><IMG SRC="layout/' + pid + '/images/pixel.gif" WIDTH="1"></TD><td width="10" class="bgTds" align="right"><a href="javascript:hide('+level+')"><img src="layout/' + pid + '/images/closex.gif" ALT="X" border=0></a></td>';

                        debut = debut + '</tr>';

                        debut = debut + '</table>';

                        debut = debut + '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3" WIDTH="100%" class="plBorderFull">';

                        texte = debut + texte + '<tr><td height="1" width=1><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1" width="95"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td><td height="1"><img alt="" src="layout/' + pid + '/images/pixel.gif" height="1" width="1"></td></tr>';

                        texte = texte + '</table>';
                    }
                }


                if (redirect)
                {
                    MM_setTextOfLayer(layerId,'', "&nbsp;" + nlmessages["VLT_BS_LOADING"] + "...");
                } else {
                    MM_setTextOfLayer(layerId,'',texte);
                }

                var f1 = MM_findObj(layerId);

                if (browser != "NS")
                {
                    var top = fullOffsetTop(oldRouge[level]) + oldRouge[level].offsetHeight + 2;
                    var left = fullOffsetLeft(oldRouge[level]) + oldRouge[level].offsetWidth / 6;
                    if ((left+f1.offsetWidth)>(document.body.offsetWidth+document.body.scrollLeft)){left = document.body.offsetWidth + document.body.scrollLeft - 1.9*f1.offsetWidth;}
                    //if ((top+f1.offsetHeight)>(document.body.offsetHeight+document.body.scrollTop)){top = document.body.offsetHeight + document.body.scrollTop - 1.2*f1.offsetHeight;}
                    f1.style.top= top;
                    f1.style.left= left;
                } else
			 	{
    				var top = fullOffsetTop(oldRouge[level]);
	    			var left = fullOffsetLeft(oldRouge[level]);
	    			f1.pageX=left;
	    			f1.pageY=top;
				}
	    		MM_showHideLayers(layerId,'','show');
			} else
			{
			    MM_showHideLayers(layerId,'','hide');
			}
		}
	}
}

<!-- Change BGColor of a given Obj-->
function setBgColor(obj,col)
{
/*
	if(browser != "N")
	{
		if(col=='hide')

			obj.style.backgroundColor = col;
	}
	else
	{
		obj.document.backgroundColor = col;
	}
*/
}

<!-- Change BGColor of a given Obj-->
function setFontColor(obj,action)
{
	if (action=="show")
	{
		obj.style.fontWeight="bold";
		obj.firstChild.style.color="#000";
	}
	else
	{
		obj.style.fontWeight="normal";
		if(obj.firstChild)
			obj.firstChild.style.color="";
	}
}

<!-- Shows brands icons-->
function showBrand(fam, level)
{
		var texte, debut,i;
		texte="";
		brands = fam.brands.split("-");
        if ((typeof(pid) == 'undefined') || (pid == "voltimum"))
        {
            if ( fam.brands != "" )
            {
                for(i = 0; i < brands.length; i++)
                {
                    brandlink = "<img src=\"v_images/logosmall/"+brands[i]+".gif\" border=\"0\" width=\"100\" height=\"30\">";
                    ligne = "<tr><td width=\"1\"></td><td align=\"center\" bgcolor=\"#FFFFFF\" colspan=\"4\"><a href=\"javascript:goBrand('"+stagingUrl+"','"+brands[i]+"','"+minisite+"','"+content+"','"+fam.idParent+"','"+fam.id+"');\">"+brandlink+"</a></td><td width=\"1\"></td></tr>";
                    texte = texte + ligne;
                }
            } else
            {
                ligne="<tr><td width=1></td><td align=\"center\" colspan=4 class=\"vltMacro1Title\" nowrap>nessun brand disponibile</td></tr>";
                texte=texte+ligne;
            }

            debut = '<table border="0" cellspacing="0" cellpadding="0"  width="100%">';
            debut = debut + '<tr><td width="1"></td><td class="vltMacro1Title" nowrap>'+nlmessages["VLT_BS_SELECT_BRAND"]+'</td><td class="vltMacro1Title"></td><td class="vltMacro1Title"></td>';
            debut = debut + "<td class=\"vltMacro1Title\" align=\"right\"><a class=\"normal\" href=\"javascript:MM_showHideLayers('b1','','hide')\">x</a></td><td width=\"1\"></td><tr>";
            texte = debut+texte +'<tr><td height="1" colspan="6"><img src="v_images/spacer.gif"/></td></tr></table>';
        } else
        {
            // relaunch version...
            if ( fam.brands != "" )
            {
                ligne = "";

                for (i = 0; i < brands.length; i++)
                {
                    brandlink = '<img src="image.jsp?brand=' + brands[i] + '" border="0" width="100" height="30">';
                    if ((i % 2) == 0)
                    {
                        if (i > 0)
                        {
                            ligne = ligne + '</TD></TR>';
                        }
                        ligne = ligne + '<TR><td align="center" CLASS="bgTdsWhite">';
                    }
                    ligne = ligne + "<a href=\"javascript:goBrand('" + stagingUrl + "','"+brands[i]+"','"+minisite+"','"+content+"','"+fam.idParent+"','"+fam.id+"');\">"+brandlink+"</a><br><br>";
                }
                ligne = ligne + '</TD></TR>';

                texte = texte + ligne;
            } else
            {
                ligne = "<TR CLASS='bgTds'><td width=1></td><td align=\"center\" colspan=4 class=\"txt10Awhite\" nowrap></td></tr>";
                texte=texte+ligne;
            }

            debut = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="bgTds">';
            debut = debut + '<TR CLASS="bgTds">';
            debut = debut + '<TD class="bgTds"><table width="100%"><tr><td nowrap><span class="txt10Awhite">' + nlmessages["VLT_BS_SELECT_BRAND"] + '</span></td>';

            debut = debut + '<td align="right"><a href="javascript:MM_showHideLayers(\'b1\',\'\',\'hide\')\"><img src="layout/' + pid + '/images/closex.gif" ALT="X" BORDER=0></a></td></tr></table></td></TR>';

            texte = debut+'<tr><td colspan="2"><table style="width: 100%; border: #bebebe 1px solid; background: #FFF;">'+texte +'</table></td></tr></table>';
        }
		MM_setTextOfLayer('b1', '', texte + '');
		if (oldRouge[level] != null)
		{
		    oldRouge[level].style.backgroundColor = "";
			setBgColor(oldRouge[level],"hide");
        }
		oldRouge[level] = MM_findObj('f' + fam.id);
		setBgColor(oldRouge[level],"show");
//		oldRouge[level].style.backgroundColor = "#F7DA00";
		var top = fullOffsetTop( oldRouge[level] ) + oldRouge[level].offsetHeight;
		var left = fullOffsetLeft( oldRouge[level] ) + oldRouge[level].offsetWidth / 6;
		var b1 = MM_findObj("b1");

        /*
		if ((top+b1.offsetHeight)>(document.body.offsetHeight+document.body.scrollTop))
		{
			top = document.body.offsetHeight + document.body.scrollTop - b1.offsetHeight-20;
		}
        */
		b1.style.top = top;
		b1.style.left = left;
		MM_showHideLayers('b1','','show');
}

<!-- utility functions -->
function fullOffsetTop(in_object) {
	if (typeof(in_preserveScroll) == 'undefined') {
		in_preserveScroll = true;
	}

	var originalObject = in_object;
	var originalWidth = in_object.offsetWidth;
	var originalHeight = in_object.offsetHeight;
	var offsetLeft = 0;
	var offsetTop = 0;

	while (in_object)
	{
		offsetLeft += in_object.offsetLeft;
		offsetTop += in_object.offsetTop;
		in_object = in_object.offsetParent;
		// consider scroll offset of parent elements
		if (in_object && !in_preserveScroll)
		{
			offsetLeft += in_object.scrollLeft;
			offsetTop += in_object.scrollTop;
		}
	}

	// MacIE misreports the offsets (even with margin: 0 in body{}), still not perfect
	if (domLib_isMacIE) {
		offsetLeft += 10;
		offsetTop += 10;
	}
    return offsetTop;
}    

function fullOffsetLeft(in_object) {
	if (typeof(in_preserveScroll) == 'undefined') {
		in_preserveScroll = true;
	}

	var originalObject = in_object;
	var originalWidth = in_object.offsetWidth;
	var originalHeight = in_object.offsetHeight;
	var offsetLeft = 0;
	var offsetTop = 0;

	while (in_object)
	{
		offsetLeft += in_object.offsetLeft;
		offsetTop += in_object.offsetTop;
		in_object = in_object.offsetParent;
		// consider scroll offset of parent elements
		if (in_object && !in_preserveScroll)
		{
			offsetLeft += in_object.scrollLeft;
			offsetTop += in_object.scrollTop;
		}
	}

	// MacIE misreports the offsets (even with margin: 0 in body{}), still not perfect
	if (domLib_isMacIE) {
		offsetLeft += 10;
		offsetTop += 10;
	}
    return offsetLeft;
}    


<!-- Funzione per selezionare il brand attualmente usa cookies, noi useremo variabili passate in GET che verranno eventualmente memorizzati con variabili di sessione -->
function goBrand(uri, brand, minisite, content, path1, path2) {
	//setCookie("path1",path1);
	//setCookie("path2",path2);
	window.location = uri+"&brand="+brand+"&universe="+current_universe_id+"&mode=browse&path=path1+"+path1+";path2+"+path2;
}

