
// Ensures it is not into a frame.
if (parent.frames.length > 0) {
  // It is the case so breaks it.
  window.top.location.href = location.href;
}

/** Defines if the client navigator is MSIE one. */
isMsie = ((navigator.appVersion.indexOf("MSIE 7.0") != -1 ||navigator.appVersion.indexOf("MSIE 6.0") != -1 || navigator.appVersion.indexOf("MSIE 5.5") != -1)) ? true : false;

/*
 * Updates the opacity factor of the element cur.
 */
function updateOpacity(cur, factor)
{
  if(document.getElementById) {
    if(document.all) {
      if (isMsie) {
        cur.style.filter = "alpha(opacity=" + factor * 100 + ")";
      }
      else {
        cur.filters.alpha.opacity = factor * 100;
      }
    }
    else {
      cur.style.setProperty("-moz-opacity", factor, "");
    }
  }
}

/*
 * Returns the with of the document body.
 */
function getInnerWidth()
{
  // According to client navigator.
  if (document.all) {
    return document.body.offsetWidth;
  }
  else {
    // Netscape.
    return window.innerWidth;
  }
} 

/**
 * Shows or hides menu elements according to its current state, and of specified elements.
 * toggleID: id of the menu.
 * elementIDs: array of id of all menu items.
 * subToggleIDs: array of id of all menu items which are sub-menu.
 * subElementInformation: briefly "array of array of array"
 *  -> array of element information whose indexes corresponds to subToggleID ones,
 *  -> each information is an array of elementIDs, subToggleIDs, subElementInformation of the subToggle
 *  ->  which are all free array themself.
 */
function showHideMenu(toggleID, elementIDs, subToggleIDs, subElementInformation)
{
	// Gets the menu element.
	var toggle = document.getElementById(toggleID);

	// According to its current state.
	if (toggle.className == "closed") {
		// Sets all sub elements visible.
		for(elementIndex = 0; elementIndex < elementIDs.length; elementIndex++) {
			var el = document.getElementById(elementIDs[elementIndex]);
			el.style.display = "inline" ;
		}

		// Sets the menu "opened".
		toggle.className = "opened";
	}
	else {
		// Checks if sub toggleIDs must be managed.
		if (subToggleIDs != null) {
			// For each of them.
			for(subToggleIndex = 0; subToggleIndex < subToggleIDs.length; subToggleIndex++) {
				var subToggle = document.getElementById(subToggleIDs[subToggleIndex]);
				// Checks if it is opened.
				if (subToggle.className == "opened") {
					// It is the case, so call this method on this subToggle.
					showHideMenu(subToggleIDs[subToggleIndex], subElementInformation[subToggleIndex], null, null);
				}
			}
		}

		// Sets all sub elements hidden.
		for(elementIndex = 0; elementIndex < elementIDs.length; elementIndex++) {
			var el = document.getElementById(elementIDs[elementIndex]);
			el.style.display = "none" ;
		}

		// Sets the menu "closed".
		toggle.className = "closed";
	}
}

