var start = null;

var currSel = null;
var currEltSel = null;
var imgPathFromMenu = "../../../../../img/menu/";
var loaded = new Array();

/**
 * Shows or hides a div of ID 'divID'. If forceOpen is set to true: 
 * it will force the opening of the div
 * @param string divID The ID of the div to open or close
 * @param bool forceOpen Flag to force the opening (true) or closing (false) of the given div
 */
function showHide(divID,forceOpen,particularPath) {
    var styleObj = document.getElementById(divID);
    var imgObj = document.getElementById("img_"+divID);
    if (imgObj == undefined || styleObj == undefined)
        return;
    
    styleObj = styleObj.style;
	
    if (particularPath == undefined)
        particularPath = imgPathFromMenu;
        
    if (forceOpen == undefined)
    {
        if (styleObj.display != "none") {
			styleObj.display = "none";
        }
        else {
            styleObj.display = "block";
        }
    }
    else
    {
        if (forceOpen == true) {
            styleObj.display = "block";
        }
        else {
            styleObj.display = "none";
        }
    }
    
    if (styleObj.display == "none") {
        imgObj.src = particularPath + "plus.gif";
    }
    else {
        imgObj.src = particularPath + "minus.gif";
    }
}

function showHideMenu(divID,forceOpen,particularPath) {
    var styleObj = document.getElementById(divID);
    var imgObj = document.getElementById("img_"+divID);
	
	var tdObj = document.getElementById("td_"+divID);
	var tdContentObj = document.getElementById("td_content_"+divID);
    
	if (imgObj == undefined || styleObj == undefined)
        return;
    
    styleObj = styleObj.style;
	tdObj = tdObj.style;
	tdContentObj = tdContentObj.style;
	
    if (particularPath == undefined)
        particularPath = imgPathFromMenu;
        
    if (forceOpen == undefined)
    {
        if (styleObj.display != "none") {
			styleObj.display = "none";
			tdObj.width = "0%";
			tdContentObj.width = "100%";
        }
        else {
            styleObj.display = "block";
			tdObj.width = "27%";
			tdContentObj.width = "73%";
        }
    }
    else
    {
        if (forceOpen == true) {
            styleObj.display = "block";
			tdObj.width = "27%";
			tdContentObj.width = "73%";
        }
        else {
            styleObj.display = "none";
			tdObj.width = "0%";
			tdContentObj.width = "100%";
        }
    }
    
    if (styleObj.display == "none") {
        imgObj.src = particularPath + "show.gif";
    }
    else {
        imgObj.src = particularPath + "hide.gif";
    }
}


/**
 * Selection
 */
function selectMenu(menuID) {
    if (currSel != null) {
        var currLiObj = document.getElementById(currSel);
        currLiObj.className = undefined;
    }
    currSel = 'li_' + menuID;
    
    var liObj = document.getElementById(currSel);
    liObj.className = "selected";
    showHide(menuID,true);
}

/**
 * Content element selection
 */
function selectElement(eltID,path,redo) {

	if (currEltSel != null) {
        showHide(currEltSel,false,path);
    }
	
	currEltSel = eltID;
    showHide(currEltSel,true,path);
	 
	 
	if (navigator.appName == 'Microsoft Internet Explorer'){
    	//frames[eltID+'_frame'].location.reload();
	}

	
	
	if (redo == undefined)
       selectElement(eltID,path,true);
}
/**
 * Clic on a menu item
 */
function clickMenuItem(menuId) {
    showHide(menuId,true);
    selectMenu(menuId);
}

