/*
// +--------------------------------------------------------------------------+
// | TOUV_JS - Série de fonctions javascript                                  |
// +--------------------------------------------------------------------------+
// | Copyright (C) 2004 Nicolas Thouvenin                                     |
// +--------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or            |
// | modify it under the terms of the GNU Lesser General Public               |
// | License as published by the Free Software Foundation; either             |
// | version 2.1 of the License, or (at your option) any later version.       |
// |                                                                          |
// | This library 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         |
// | Lesser General Public License for more details.                          |
// |                                                                          |
// | You should have received a copy of the GNU Lesser General Public         |
// | License along with this library; if not, write to the Free Software      |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  |
// +--------------------------------------------------------------------------+
*/
/**
 * Fonctions Javascript Génériques permettant
 * une modification dynamique du Style des balises (CSS)
 *
 * @package TOUV_JS
 * @author Nicolas Thouvenin <touv at ouvaton dot org>
 * @license http://opensource.org/licenses/lgpl-license.php LGPL
 * @access public
 * @version $Id$
 */
var IE4 = (document.all && !document.getElementById && !window.opera) ? true : false;
var NN4 = document.layers? true : false;
var IES = (document.all && document.getElementById && !window.opera) ? true : false;
var NN6 = (!document.all && document.getElementById )? true : false;

/* {{{ setStyleBackgroundColor
*/
/**
 * Modifie la couleur de fond d'une balise
 *
 * @param string identifiant de la balise
 * @param string nom ou numéro de couleur
 */
function setStyleBackgroundColor(id, value)
{
		if (NN4);
		else if (IE4) document.all(id).style.backgroundColor = value;
		else document.getElementById(id).style.backgroundColor = value;
}
/* }}}
	 {{{ getStyleBackgroundColor */
/**
 * Récupére la couleur de fond d'une balise
 *
 * @param string identifiant de la balise
 * @return string nom ou numéro de couleur
 */
function getStyleBackgroundColor(id)
{
		if (NN4);
		else if (IE4) return document.all(id).style.backgroundColor;
		else return document.getElementById(id).style.backgroundColor;
}
/* }}}
   {{{ getStyleVisibility*/
/**
 * Récupére l'état de visibilté
 *
 * @param string identifiant de la balise
 * @return string nom ou numéro de couleur
 */
function getStyleVisibility(id)
{
		if (NN4);
		else if (IE4) return document.all(id).style.visibility;
		else return document.getElementById(id).style.visibility;
}
/* }}}
   {{{ setStyleVisibility*/
/**
 * Modifie l'état de visibilté
 *
 * @param string identifiant de la balise
 * @param string mot clef : block, none
 */
function setStyleVisibility(id, value)
{
		if (NN4);
		else if (IE4) document.all(id).style.visibilty= value;
		else document.getElementById(id).style.visibilty= value;
}
/* }}}
	 {{{ setStyleDisplay */
/**
 * Modifie l'affichage d'une balise
 *
 * @param string identifiant de la balise
 * @param string mot clef : block, none
 */
function setStyleDisplay(id, value)
{
		if (NN4);
		else if (IE4) document.all(id).style.display = value;
		else document.getElementById(id).style.display = value;
}
/* }}}
	 {{{ getStyleDisplay */
/**
 * Récupére l'affichage d'une balise
 *
 * @param string identifiant de la balise
 * @return string mot clef : block, none
 */
function getStyleDisplay(id)
{
		if (NN4);
		else if (IE4) return document.all(id).style.display;
		else return document.getElementById(id).style.display;
}
/* }}}
	 {{{ switchStyleDisplay */
/**
 * Affiche une balise si elle n'est pas visible
 * ou la cache si elle l'est
 *
 * @param string identifiant de la balise
 */
function switchStyleDisplay(id) {
		var t = getStyleDisplay(id);
		if ( t == "none") setStyleDisplay(id, "block");
		else if (t == "block") setStyleDisplay(id, "none");
}
/* }}}
	 {{{ changeStyleBackgroundColor */
/**
 * On modifie la couleur de fond, cependant on mémorise la couleur
 * avant la changer pour ensuite pouvoir la restaurer
 *
 * @see restoreStyleBackgroundColor
 * @param string identifiant de la balise
 * @param string nom ou numéro de couleur
 */
var viewItemLastID = 0;
var viewItemLastBG = 0;
function changeStyleBackgroundColor(id, couleur)
{
		if (viewItemLastID) setStyleBackgroundColor(viewItemLastID, viewItemLastBG);
		viewItemLastBG = getStyleBackgroundColor(id);
		viewItemLastID = id;
		setStyleBackgroundColor(id, couleur);
}
/* }}}
	 {{{ changeStyleBackgroundColor */
/**
 * On remet la couleur modifier par la fonction changeStyleBackgroundColor
 *
 * @see changeStyleBackgroundColor
 * @param string identifiant de la balise
 */
function restoreStyleBackgroundColor(id)
{
		if (viewItemLastID) setStyleBackgroundColor(id, viewItemLastBG);
}
/* }}}
	 {{{ setGroupStyleDisplay
*/
/**
 * Pour un groupe de balise, on en affiche qu'une seule et on masque les autres
 *
 * @see setStyleDisplay
 * @param string Prefix du groupe de balise
 * @param integer numero de la balise du groupe à afficher
 * @param integer nombre total de balise dans le groupe
 */
function setGroupStyleDisplay(a, b, m) 
{
    for (i = 1; i <= m; i++) setStyleDisplay(a + i, 'none');
    setStyleDisplay(a + b, 'block');
}


/*
vim:fdm=marker
*/

