var min=10;
var max=17;
function augmenter_texte() {
   var p = Array($('texte'));
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function reduire_texte() {
   var p = Array($('texte'));
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}


/** ###############################################
* Verif d'un formulaire.
* 
* Version : 1.2.6
* 
* tous les champs dont la classe = "require type_MonType"
* vont etre vérifiés où 
* MonType => (texte,email,date,select)
* 
* @subpackage langage_{$lg}.js :: les textes d'erreurs
* 
* Modifications :
* 	- 10-01-2007 :: ajout de la verif des boutons radios..
* 	- 25-01-2007 :: Correction d'un bug sur le motif (.*) => ([^\s]*) 
* 	- 08-06-2007 :: autorise les mail en majuscule dans [verifMail()]
* 	- 19-06-2007 :: ajout du test sur les passwords (2eme champ de verif)
* 	- 17-10-2007 :: Changement de strategie sur les passwords. le champs PEUT etre vide. si non vide => test
* 	- 08-10-2007 :: ajout du type [pseudo]
* 	- 09-10-2007 :: ajout du type [intOrNull]
* 	- 26-11-2007 :: ajout du type [tel], [telOrNull] ainsi que de la fonction [verifTel] de verification du format du tel
* 
*/
var couleur_de_bordure="#A89036"; /* marron clair */
function verification(forme)
{	
	var counts = getElementsByClass('require',forme,'*');
	var i, count, matches, countHolder;
	
	// pour les boutons radio
	var radios = new Array();
	var radiosChecked = new Array();
	
	// pour les checkbox multiples
	var checkboxes = new Array();
	var checkboxesChecked = new Array();
	
	//print_r(counts);
	
	for (i=0; i<counts.length; i++)
	{
		count = counts[i];
		
		// recup du type d'input
		matches = count.className.match(/type_([^\s]*)/);
		count.TheType = RegExp.$1;
		
		switch(count.TheType)
		{
			case'texte':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				init(count.id);
				break;
				
			case'email':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( !(verifMail(count.value)) )
				{
					alert (email_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			
				
			case'cp':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( !(verifCP(count.value)) )
				{
					alert (cp_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			
			case'pass':
				/* changement de strategie
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				*/
				
				if( count.value != '' && !(verifPass(count.value)) )
				{
					alert (pass_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			
			case'pseudo':
				
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( count.value != '' && !(verifPseudo(count.value)) )
				{
					alert (pseudo_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
				
			case'date':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( !(verifDate(count.value)) )
				{
					alert (date_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
				
			case'selectMultiple':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				init(count.id);	
				break;
			case'select':	
				if (count.selectedIndex == 0)
				{
					alert (select_erreur);count.focus();colore(count.id);
					return false;
				}
				
				init(count.id);	
				break;
			case'checkbox':
				if(!count.checked)
				{
					alert (checkbox_erreur);count.focus();colore_parent(count.id);
					return false;
				}
				init_parent(count.id);	
				break;
			case'checkboxes':
				// init de l'ensemble des checkbox de meme id
				if(!checkboxes.in_array(count.name))
				{
					checkboxes=checkboxes.add(0,count.name);
					if(!verifRadio(count.name))
					{
						alert (checkboxes_erreur);
						count.focus();
						colore_parent(count.id);
						return false;	
					}
				}
				init_parent(count.id);
				break;
			case'radio':
				// init de l'ensemble des radios de meme id
				if(!radios.in_array(count.name))
				{
					radios=radios.add(0,count.name);
					if(!verifRadio(count.name))
					{
						alert (radio_erreur);
						count.focus();
						colore_parent(count.id);
						return false;	
					}
				}
				init_parent(count.id);
				break;
			case'int':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( (isNaN(count.value)) )
				{
					alert (int_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			case'intOrNull':
				
				if( (count.value != '' && isNaN(count.value)) )
				{
					alert (int_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			
			case'tel':
				if(count.value == '')
				{
					alert (tel_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( !verifTel(count.value) )
				{
					alert (tel_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			
			case'telMobile':
				if(count.value == '')
				{
					alert (texte_erreur);count.focus();colore(count.id);
					return false;
				}
				
				if( !verifTelMobile(count.value) )
				{
					alert (telMobile_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			case'telOrNull':
				
				if( (count.value != ''  && !verifTel(count.value)) )
				{
					alert (tel_erreur);count.focus();colore(count.id);
					return false;				
				}
				
				init(count.id);	
				break;
			case'cgv':
				if(!count.checked)
				{
					alert (cgv_erreur);count.focus();colore_parent(count.id);
					return false;
				}
				init_parent(count.id);	
				break;
		}
		
		// Date Fin supérieure à une autre
		if(matches = count.className.match(/DateFin_([^\s]*)/))
		{
			count.TheDateFin = RegExp.$1;
			if(count.value != '' && 
			   format_date($(count.TheDateFin).value,'mysql') > format_date(count.value,'mysql') )
			{
				alert (dateFin_erreur);count.focus();colore(count.id);
				return false;	
			}
		}
		
		// Verification du 2eme mot de passe
		if(matches = count.className.match(/passIdentique_([^\s]*)/))
		{
			count.ThePass = RegExp.$1;
			if( count.value != $(count.ThePass).value)
			{
				alert (passIdentique_erreur);count.focus();colore(count.id);
				return false;	
			}
		}
	}
	
	return true;
	
}

/********************************************************
* Verif d'une @ email
*
*
*
*/
function verifMail(email) 
{ 
	// on doit accepter les majuscules 
	// => on met tout en minuscule pour tester
	email = email.toLowerCase();
	
	// vérif validité email par REGEXP
   	var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
   	return (reg.exec(email)!=null);
}
function verifPass(pass) 
{ 
	// vérif validité email par REGEXP
   if(pass.length<6)return false;

   return true;
}


function verifCP(cp)
{
  if (cp.length!=5)
  {return false;}  
  else {return true;}
}


/*
 * Verifie si un bt radio est coché pour un meme name
 */
function verifRadio(libName)
{ 
	// recup de tous les bt radio du meme nom
	//var inputRadios = $(libName);
	var inputRadios = window.document.getElementsByName(libName);
	var inputRadiosLength=inputRadios.length;
	//alert(inputRadiosLength);
	
	for(var i=0;i<inputRadiosLength;i++)
	{
		if(inputRadios[i].checked)return true;
		//alert(inputRadios[i].value);
	}
	
	return false;
}

/**
 * @param {Object} tel
 * @return {Bool} 
 */
function verifTel(tel)
{
	var regTel = /^(\(?[+0-9]{1,2}\d{2}\)?)?(\d{1,2})\D{0,1}(\d{2})\D{0,1}(\d{2})\D{0,1}(\d{2})\D{0,1}(\d{2})$/;
	if (!(regTel.exec(tel)!=null))return(false);
	else return(true);
} 

function verifTelMobile(tel)
{
	var regTel = /^(\(?[+0-9]{1,2}\d{2}\)?)?(06|6)\D{0,1}(\d{2})\D{0,1}(\d{2})\D{0,1}(\d{2})\D{0,1}(\d{2})$/;
	if (!(regTel.exec(tel)!=null))return(false);
	else return(true);	
}
/* ###############################################
* 
*
*/
function format_date(chaineDate,format)
{
	switch(format)
	{
		case'fr':
			if( matches = chaineDate.match(/([0-9]{4})[-|\/]([0-9]{2})[-|\/]([0-9]{2})/) )
			maDate=RegExp.$3+"/"+RegExp.$2+"/"+RegExp.$1;
			break;
		case'mysql':
			if( matches = chaineDate.match(/([0-9]{2})[-|\/]([0-9]{2})[-|\/]([0-9]{4})/) )
			maDate=RegExp.$3+"-"+RegExp.$2+"-"+RegExp.$1;
			break;
	}
	return maDate;
}

/* ###############################################
* 
*/
function verifDate(chaineDate)
{
   if (chaineDate == "") return false;
   //date formatée en JJ/MM/AAAA
   var ladate = (chaineDate).split("/")
   // ou formatée en JJ-MM-AAAA
   if(ladate.length != 3)ladate = (chaineDate).split("-")
   
   // Si je n'ai pas récupéré trois éléments ou bien s'il ne s'agit pas d'entiers, pas la peine non plus d'aller plus loin
   if ((ladate.length != 3) || isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) 
   {
	   //date formatée MySQL
	   ladate = (chaineDate).split(" ");
	   ladate = (ladate[0]).split("-");
	   if ((ladate.length != 3) || isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2])))
	   {
		   //alert("Mauvais format de date : ecrire une date de la forme \"JJ/MM/AAAA\" ou \"AAAA-MM-JJ\"");
		   return false;
	   }
	   else {a=ladate[0];ladate[0]=ladate[2];ladate[2]=a}
   }

   // Sinon, c'est maintenant que je crée la date correspondante. Attention, les mois sont étalonnés de 0 à 11
   var unedate = new Date(eval(ladate[2]),eval(ladate[1])-1,eval(ladate[0]))

   var annee = unedate.getYear()
   if ((Math.abs(annee)+"").length < 4) annee = annee + 1900

   // Il ne reste plus qu'à vérifier si le jour, le mois et l'année obtenus sont les mêmes que ceux saisis par l'utilisateur.
   if (((unedate.getDate() == eval(ladate[0])) && (unedate.getMonth() == eval(ladate[1])-1) && (annee == eval(ladate[2]))) == false )
   {
	   //alert ("Votre date n'est pas valide!");
   	   return false;
   }
   return true;
}

/* ###############################################
* 
*
*/
function formatMysqlDate(chaineDate,champDate)
{
	var ladate = (chaineDate).split("/");
	champDate.value=ladate[2]+"/"+ladate[1]+"/"+ladate[0];
}

/* ###############################################
* Coloration du border d'un input
*
*
*
*/
function colore(id)
{
	with(document.getElementById(id).style) 
	{
      	borderColor="#ff0000";
    }
}
function init(id)
{
	with(document.getElementById(id).style) 
	{
      	borderColor=couleur_de_bordure;
    }
}
/*
 * coloration du parent d'un input (checkbox, radio ..)
 */
function colore_parent(id)
{
	// recup de l'id  du parent:
	matches = $(id).className.match(/parent_([^\s]*)/);
	if(!matches)return true;
	
	var TheParent = RegExp.$1;
	var blocParent = $(TheParent);
	//alert(TheParent);
	
	with(blocParent.style)
	{
		border="1px solid #ff0000";
    }
    
}
function init_parent(id)
{
	// recup de l'id  du parent:
	matches = $(id).className.match(/parent_([^\s]*)/);
	if(!matches)return true;
	
	var TheParent = RegExp.$1;
	var blocParent = $(TheParent);
	//alert(TheParent);
	
	with(blocParent.style) 
	{
      	borderColor=couleur_de_bordure;
    }
    
}

/*============================================================================
	Function de preload
	PREREQUIS:
	# le nb total d'images
	# la variable pause ( à "false")
	# le nom "timer" du timer
	# le cpt pour le num de l'image en cours
	# le tableau [liste_img] de la liste des chemins des images
	# le tableau [liste_alt] de la liste des alts des images
===========================================================================*/
var image=new Array();
function preload(liste_img)
{
	var nb_img=liste_img.length;
	
	for(i=0;i<nb_img;i++)
	{
		image[i]= new Image();
		image[i].src=liste_img[i];
	}
}

/*============================================================================
	Function de slide show
	PREREQUIS:
	# le nb total d'images
	# la variable pause ( à "false")
	# le nom "timer" du timer
	# le cpt pour le num de l'image en cours
	# le tableau [liste_img] de la liste des chemins des images
	# le tableau [liste_alt] de la liste des alts des images
===========================================================================*/
function roulement(image)
{
	// on met à jour les boutons play et pause
	maj_commandes();
	
	//alert(nb_max);
	//on change la photo
	TheDiv=document.getElementById(image);
	
	TheDiv.innerHTML="<img  class='photo' src='"+liste_img[cpt]+"' alt='"+liste_alt[cpt]+"' />";
	cpt++;
	if (cpt==nb_max)cpt=0;

	if(pause == false)timer=window.setTimeout("roulement('"+image+"')",4000);	
}

/*============================================================================
	Function pour les images des commandes
	PREREQUIS:
	# le nb total d'images
	# la variable pause 
	# les IDs des boutons play et pause
	# Les chemins des images ON et OFF
===========================================================================*/
function maj_commandes()
{
	ThePlay=document.getElementById('img_play');
	ThePause=document.getElementById('img_pause');
	if(pause == true)
	{
		//ThePause.src='images/diapo_pause_on.gif';
		//ThePlay.src='images/diapo_play_off.gif';
		ThePlay.style.display='';
		ThePause.style.display='none';
	}
	else
	{
		//ThePause.src='images/diapo_pause_off.gif';
		//ThePlay.src='images/diapo_play_on.gif';
		ThePlay.style.display='none';
		ThePause.style.display='';
	}
	//alert(ThePlay.src);
}

function blankInput(objInput) {
	// Met la valeur courante en tampon
	var lastValue = objInput.value;
	
	// Vide le champ
	objInput.value='';
	
	// gestionnaire d'évenement
	if (window.addEventListener) {
	  objInput.addEventListener("blur", yep, false);
	} else if (window.attachEvent) {
	  objInput.attachEvent("onblur", yep);
	}
	
	
	function yep(){
		// Supprimme l'évènement du gestionnaire
		if (window.addEventListener) {
		  objInput.removeEventListener("blur", yep, false);
		} else if (window.attachEvent) {
		  objInput.detachEvent("onblur", yep);
		}
		
		// Traitement du champ si il est tjs vide
		if(objInput.value == '')objInput.value = lastValue;
	}
}

/* ######################################################################################*/
/* ############################# MENU ARCHIVES DHTML ##################################### */
function Chargement_archives(strMenu)
{
    CacherMenus_archives();
    $(strMenu).style.display="";
}

function CacherMenus_archives()
{
    // on cache les archives (au niveau des annees):
    for(i=2000;i<=2035;i++)
    {
      for(j=1;j<=12;j++)
      {
          if(j<10)m='0'+j;
          else m=j;
          if (document.getElementById('mois_'+m+i))
          {
              with($('mois_'+m+i).style) {display="none";}
              //alert('mois_'+m+i);
          }
      }
    }
}

function MontrerMenu_archives(strMenu)
{
    CacherMenus_archives();
    $(strMenu).style.display="";
}

/*============================================================================
	Function qui ajoute un bloc paragraphe pour la création de page
	PREREQUIS:
	
===========================================================================*/
var id_paragraphe=1000000;
function ajoute_paragraphe(block)
{
	TheBlock=$(block);
	//alert(TheBlock.innerHTML);
	
	TheChamp ='<div id="para_'+id_paragraphe+'" class="block_paragraphe" >\n';
	
	TheChamp+='<div class="champ"><div class="module_lib">Sous titre</div><div class="module_2_colonnes">';
	TheChamp+='<input type="text" name="gaea_paragraphes[lib_paragraphes][]" value="" id="lib_'+id_paragraphe+'" size="80" />';
	TheChamp+='</div><div class="clr"></div></div>';
	
	TheChamp+='<div class="champ"><div class="module_lib">Paragraphe</div><div class="module_2_colonnes">';
	TheChamp+='<textarea name="gaea_paragraphes[texte_paragraphes][]" id="texte_'+id_paragraphe+'" rows="7" cols="60" ></textarea>';	  
	TheChamp+='</div><div class="clr"></div></div>';
	
	TheChamp+='<div class="champ"><div class="module_lib">Visuel<br /></div><div class="module_2_colonnes">';
	TheChamp+='<input type="file" name="gaea_paragraphes[visuel][]" id="visuel'+id_paragraphe+'" size="40" />';		  
	TheChamp+='</div><div class="clr"></div></div>';
	
	//TheChamp+='<img src="img/supprime.gif" alt="Supprimer" onmouseover="return overlib(\'Supprimer le paragraphe\');" onmouseout="nd();" onclick="supprime_champ(\'para_'+id_paragraphe+'\')" /><br class="clr" />';
	TheChamp+='<input value="Supprimer le paragraphe" type="button" class="bouton_bg" onclick="supprime_champ(\'para_'+id_paragraphe+'\')" /><br class="clr" />';
	TheChamp+='</div>';
	
	//# recup des values
	values=new Array();
	recup_values(TheBlock);
	
	
	TheBlock.innerHTML+=TheChamp;
	
	// le innerHTML change => on reload le calendar
	for(i=0;i<size;i++)
	{
		// si c'est un fils de type balise
        if (TheBlock.childNodes[i].nodeType == 1)
        {
		TheSpan=TheBlock.childNodes[i];
		//alert(TheSpan.id);
		}
	}
	
	//# on réinjecte les values
	reinjecte_values(TheBlock)
	
	id_paragraphe++;

	return false;
}
	/*#######################################*/
	// supprime un champ
	function supprime_champ(id_champ)
	{
		TheChamp=$(id_champ);
		TheChamp.innerHTML="";
		return false;
	}
	//############################
	//# fonction qui recupère toutes les
	//# values des petits fils de TheBlock
	//# 
	//# prérequis : le tab values
	function recup_values(TheBlock)
	{
		//# recup des values
		size=TheBlock.childNodes.length;
		for(i=0;i<size;i++)
		if (TheBlock.childNodes[i].nodeType == 1)
		{
			values[i]=new Array();
			for(j=0;j<TheBlock.childNodes[i].childNodes.length;j++)
			values[i][j]=TheBlock.childNodes[i].childNodes[j].value;
		}
	}
	
	//############################
	//# fonction qui réinjecte toutes les
	//# values des petits fils de TheBlock
	//# 
	//# prérequis : le tab values
	function reinjecte_values(TheBlock)
	{
		for(j=0;j<TheBlock.childNodes.length;j++)
		if (TheBlock.childNodes[j].nodeType == 1)
		{
			for(k=0;k<TheBlock.childNodes[j].childNodes.length;k++)
			if(values[j] && values[j][k])TheBlock.childNodes[j].childNodes[k].value=values[j][k];
		}
	}

/*
 * Function add_favori()
 * 
 * @param String phrase titre du favoris
 * @param String lien lien à bookmarquer
 * 
 */
function add_favori(phrase,lien)
{
   if (window.sidebar)window.sidebar.addPanel(phrase, lien,"");
   else if( document.all )window.external.AddFavorite(lien, phrase);
   	else return true;
}

/**
 * @param {String} page :: url relative de la page a appeler
 * @param {String} nom :: nom de la page a appeler
 * @param {Int} top:: marge haute
 * @param {Int} left :: marge gauche
 * @param {Int} width :: largeur de la fenetre
 * @param {Int} height :: hauteur de la fenetre
 */
var F1=null;
function fenetre( page , nom , top , left , width , height )
{  
	F1=window.open(page,nom, 'top='+top+',left='+left+', width='+width+', height='+height+', resizable=yes, toolbar=no, scrollbars=yes, status=yes');
}

/* ############################################################################ */
/* ############################################################################ */
/* ############################################################################ */
/* ############################################################################ */
/* ###############################################
* fonction équivalente de print_r de php
*
*
*
*/
function print_r(input)
{
	var ret;
	for(var i in input)
	{
		ret +="["+i+"] = "+input[i]+"\n";
	}
	alert(ret);
}

/* ###############################################
* possibilité d'appeller plusieurs id différents pour 
* obtenir un tableau d'éléments à parcourir ensuite : 
* var el = $('id1', 'id2', 'id3');. 
*
* fonction de Matthew Pennell : 
* http://www.thewatchmakerproject.com/journal/292/a-better-dollar-function-getelementsbyanything
*
*/
function $() {
	var elements = new Array();
	for (var i=0,len=arguments.length;i<len;i++) {
		var element = arguments[i];
		if (typeof element == 'string') {
			var matched = document.getElementById(element);
			if (matched) {
				elements.push(matched);
			} else {
				var allels = (document.all) ? document.all : document.getElementsByTagName('*');
				var regexp = new RegExp('(^| )'+element+'( |$)');
				for (var i=0,len=allels.length;i<len;i++) if (regexp.test(allels[i].className)) elements.push(allels[i]);
			}
			if (!elements.length) elements = document.getElementsByTagName(element);
			if (!elements.length) {
				elements = new Array();
				var allels = (document.all) ? document.all : document.getElementsByTagName('*');
				for (var i=0,len=allels.length;i<len;i++) if (allels[i].getAttribute(element)) elements.push(allels[i]);
			}
			if (!elements.length) {
				var allels = (document.all) ? document.all : document.getElementsByTagName('*');
				for (var i=0,len=allels.length;i<len;i++) if (allels[i].attributes) for (var j=0,lenn=allels[i].attributes.length;j<lenn;j++) if (allels[i].attributes[j].specified) if (allels[i].attributes[j].nodeValue == element) elements.push(allels[i]);
			}
		} else {
			elements.push(element);
		}
	}
	if (elements.length == 1) {
		return elements[0];
	} else {
		return elements;
	}
}


/* ###############################################
* recup d'element par le nom de sa classe
*
*
*
*/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/*
 *  
 * 
 */

Array.prototype.var_dump = function() {
 if (arguments.length) var indent = arguments[0];
 else var indent = "   "; // indentation des éléments du tableau
 html = "a{";
 var i = 0;
 for (var elt in this) {
   var typeelt = typeof this[elt];
   if (typeelt == "function") continue;
   html += i ? ", " : "";
   if (typeelt == "object") html += "\n" + indent + "[" + elt + "]:" + this[elt].var_dump(indent + indent);
   else {
       html += "[" + elt + "]:";
       if (typeelt == "string") html += "\"" + this[elt] + "\"";
       else html += this[elt];
   }
   i++;
 }
 html += "}";
 return html;
}
/*
 * identique à in_array() en php
 */
Array.prototype.in_array = function(valeur) {
 for (var i in this) {
   if (this[i] == valeur) return true;
 }
 return false;
}
/* ###############################################
* Cette classe permet à l'objet "Array" (tableau), 
* de disposer de méthodes supplémentaires: suppression d'un élément, 
* ajout d'un élément, échange de deux éléments, extraction du dernier élément, 
* obtention du maximum, du minimum et de la valeur moyenne.
*/
//# on étends les méthodes du tableau..
ExtendArray();
function ExtendArray() {
 Array.prototype.remove = Array_Remove;
 Array.prototype.add = Array_Add;
 Array.prototype.swap = Array_Swap;
 // removes and returns last element
 Array.prototype.pop = Array_Pop;
 // use these with arrays of ints
 Array.prototype.min = Array_GetMin;
 Array.prototype.max = Array_GetMax;
 Array.prototype.avg = Array_GetAvg;
}


 function Array_Remove(c) {
  var tmparr = new Array();
  for (var i=0; i<this.length; i++) if (i!=c) tmparr[tmparr.length] = this[i];
   return tmparr;
 }

 function Array_Add(c, cont) {
  var tmparr = new Array();
  for (var i=0; i<this.length; i++) {
   if (i==c) tmparr[tmparr.length] = cont;
    tmparr[tmparr.length] = this[i];
  }
  if (!tmparr[c]) tmparr[c] = cont;
   return tmparr;
 }

 function Array_Swap(x, z) {
  var zvalue = this[z];
  this[z] = this[x];
  this[x] = zvalue;
  return this;
 }

 function Array_Pop() {
  var item = this[this.length-1];
  this.length--;
  return item;
 }

 function Array_GetMin() {
  var Min = this[0];
  if (isNaN(Min*1) && !IsDate(Min)) return '';
  for (var i=0; i<this.length; i++) if (this[i]*1<Min) Min = this[i];
  return Min;
 }

 function Array_GetAvg() {
  var Total = 0;
  if (isNaN(this[0]*1) && !IsDate(this[0])) return '';
  for (var i=0; i<this.length; i++) if (this[i] != 0) Total += this[i]*1;
  var Avg = Total/(Comps.length+1)
  if ((Avg+"").indexOf(".") > -1) { 
   if (GetMax(i)-GetMin(i) > 50)
    Avg = Math.round(Avg);
    // if difference between min and max > 50, round
    else Avg = (Avg+"").substring(0,(Avg+"").indexOf(".")+((bFloat) ? 3 : 2));
    // else if all values were whole round to 2 places, else 3
   }
  return (Avg>0) ? Avg : "";
 }

 function Array_GetMax() {
  var Max = this[0];
  if (isNaN(Max*1) && !IsDate(Max)) return '';
  for (var i=0; i<this.length; i++) if (this[i]*1>Max) Max = this[i];
  return Max;
 }

 /*============================================================================
	Function pour le menu dynamique pour IE
	
===========================================================================*/
function hover(obj){
  if(document.all){
    UL = obj.getElementsByTagName('ul');
    
    if(UL.length > 0){
      MonSousMenu = UL[0].style;
      if(MonSousMenu.display == 'none' || MonSousMenu.display == ''){
        MonSousMenu.display = 'block';
      }else{
        MonSousMenu.display = 'none';
      }
    }
  }
}

function setHover()
//addEvent(window, 'load', function()
{
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function(){
      hover(this);
    }
    LI[i].onmouseout = function(){
      hover(this);
    }
  }
}