// 2005-2007 E-site - Fonctionnalité générique pour les documents gérer sous E-site //////////

// Fonction Handle /////////////////////////////////////
/*if(typeof(RichText)!='undefined')
{
  MyRichText=new Object();
  for(var tag in RichText) MyRichText[tag]=RichText[tag].concat();
}*/
function AccessFontAugmente()
{
	var contenu = document.getElementById('contenu');
	if (contenu)
		AccessFontChange('+', contenu);
	else {
		var contenus = document.getElementsByClassName('contenu');
		if (contenus.length != 0) {
			var nbContenus = contenus.length;
			for(var i=0; i<nbContenus; i++) {
				AccessFontChange('+', contenus[i]);
			}
		}
	}
}

function AccessFontDiminue()
{
	var contenu = document.getElementById('contenu');
	if (contenu)
		AccessFontChange('-', contenu);
	else {
		var contenus = document.getElementsByClassName('contenu');
		if (contenus.length != 0) {
			var nbContenus = contenus.length;
			for(var i=0; i<nbContenus; i++) {
				AccessFontChange('-', contenus[i]);
			}
		}
	}
}

function AccessFontChange(sens, element) {
	//paramètres
	var defaultSize = '12px';
	var stepSize = 10;
	var acceptedTags = "P H1 H2 H3 H4 H5 H6 LI A STRONG EM U B I TD OPTION INS BLOCKQUOTE ADDRESS ABBR ACRONYM CITE CODE DFN Q SAMP PRE";
	
	if (!element.style.fontSize)
		element.style.fontSize = defaultSize;
	
	var taille = element.style.fontSize.substr(0, element.style.fontSize.length-2);
	
	//changement de taille
	if (sens == '+')
		element.style.fontSize = (parseInt(taille)+stepSize) + 'px';
	else {
		if (parseInt(taille)-stepSize >= 12)
			element.style.fontSize = (parseInt(taille)-stepSize) + 'px';
	}
	
	//récursivité
	var childs = element.childNodes;
	if (childs.length != 0) {
		var nbChilds = childs.length;
		for(var i=0; i<nbChilds; i++) {
			if (childs[i].tagName && acceptedTags.search(childs[i].tagName > -1))
				AccessFontChange(sens, childs[i]);
		}
	}
}

function AccessFontUpdate()
{
   var BaliseValide="P H1 H2 H3 H4 H5 H6 LI A STRONG EM U B I TD OPTION INS BLOCKQUOTE ADDRESS ABBR ACRONYM CITE CODE DFN Q SAMP PRE";
   var contenu=document.getElementById('contenu');
	
   if(contenu)
   {
      var elm=contenu.getElementsByTagName('*');
   
      for(nb=0; nb<elm.length; nb++)
	     if(BaliseValide.search(elm[nb].tagName)>-1)
		    elm[nb].style.fontSize=(MyRichText[elm[nb].tagName])?MyRichText[elm[nb].tagName][0]+'px':MyRichText['P'][0]+'px';
			
	  contenu.style.fontSize=MyRichText['P'][0]+'px';
   }
}

function mailami(lang)
{
   var long=haut=450;

   AccessWin=window.open(einden_tools+'envoyer_ce_contenu_par_email.php?lang='+lang+'&referer='+escape(document.URL), 'envoyer_ce_contenu_par_email', 'width='+long+', height='+haut+', toolbar=no, status=no, scrollbars=no, resizable=no, menubar=no');
   AccessWin.moveTo((window.screen.availWidth-long)/2, (window.screen.availHeight-haut)/2);
   AccessWin.focus();
}

// Vérification Champs obligatoire ////////////////////
function champ_obligatoire(message)
{
   var input=document.getElementsByTagName('input');
   var textarea=document.getElementsByTagName('textarea');
   if(!message) message='Veuillez compléter les champs obligatoires !';
  
   for (var i=0; i<input.length; i++)
      if(input[i].className=='obligatoire' && (input[i].value.length<1)) { alert(message); return false }
	 
   for (var i=0; i<textarea.length; i++)
      if(textarea[i].className=='obligatoire' && textarea[i].value.length<1) { alert(message); return false }

   return true;
}

// Champs INPUT ////////////////////////////////////
function Search_champ_focus(elm, autoclean) { if(elm.value==autoclean) elm.value=''; }
function Search_champ_blur(elm, autoclean)  { if(!elm.value && autoclean) elm.value=autoclean; }

// Ajout aux favoris ///////////////////////////////
function favoris()
{
   if (window.sidebar) window.sidebar.addPanel(document.title, document.URL,""); // IE
   else if (document.all) window.external.AddFavorite(document.URL, document.title); // Netscape, firefox, etc.
}
