// WebCT95 
//
// Copyright (C) 2003 Conseil Général du Val d'Oise. All Rights
// Reserved.
//
// Developed by IDEALX S.A.S. and Bull S.A. 
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.

function loadSubMenus(menuIds,menuLevels,widthName) {
    if (menuIds != null) {
	if (document.getElementById && document.styleSheets) {
	
	    var posInLevel = 0;

	    for (var i = 0; i < menuIds.length; i++) {

		if (i - 1 >= 0) {
		    if (menuLevels[i-1] == menuLevels[i])
			posInLevel++;
		    else
			posInLevel = 0;
		}

		var left_int = positionMatrix[menuLevels[i]][0];
		var left_final = Number(left_int.substr(0, left_int.length - 2)) + Number(139);
		var top_int = positionMatrix[menuLevels[i]][1];
		var top_final = Number(top_int.substr(0, top_int.length - 2)) + Number(20) + Number(15 * posInLevel);

		if (document.getElementById(menuIds[i]) != null) {
		    with (document.getElementById(menuIds[i]).style) {
			visibility = "hidden";
			position = "absolute";
			left = left_final + "px";
			top = top_final + "px";

			switch (widthName) {
			
        		case 'small':
			    width = "12em";
			    break;
	    		
	    		case 'medium':
			    width = "14em";
			    break;
	    		
	    		case 'large':
			    width = "28em";
			    break;
	    		
	    		default:
			    width = "12em";
			    break;
			}
			
			margin = "0";
			padding = "0";
			zIndex = "3";
		    }
		}
	    }
	}
    }
}

function hideSubMenus(menuIds) {
//    alert("hideMenus()");
    if (menuIds != null) {
	if (document.getElementById && document.styleSheets) {

	    for (var i = 0; i < menuIds.length; i++) {

		if (document.getElementById(menuIds[i]) != null) {
		    with (document.getElementById(menuIds[i]).style) {
			visibility = "hidden";
		    }
		}

	    }
	}
    }
}

function showSubMenu(subMenuId, menuIds) {  
    //alert("showMenus()");

    // The following line seems to be understood not too well by MSIE (at least versions < 5.5)
    //if ((subMenuId != null) && (menuIds != null)) {
    if (subMenuId != null) {
		if (menuIds != null) {
			if (document.getElementById && document.styleSheets) {
			
			hideMenus(menuIds);
			
			if (document.getElementById(subMenuId) != null) {
				with (document.getElementById(subMenuId).style) {
				visibility = "visible";
				}
			}
			
			}
		}
    }
}
