// JavaScript Document
function focusLogin(url){
	document.form1.urlCible.value = url;
	if (document.getElementById && document.getElementById('focusLogin') != null){
	//	document.getElementById('focusLogin').style.visibility='visible';
		document.getElementById('focusLogin').style.display='inline';
		document.getElementById('identifiezVous').innerHTML='';
				//	document.getElementById('rub3').id='rub3focusLogin';
//		alert(document.getElementById('rub3focusLogin').innerHTML);
				// alert(document.getElementById('focusLogin').style.background-color);
		//document.getElementById('dossier').id="DossierChauffe";
		//alert(document.getElementById('page').getElementsByTagName("*")[0].id);
		//document.getElementById('form1').className='votreDossierChauffe';
	//	document.getElementById('focusLogin').firstChild.data="COUCOU!!!";
		
	}
}

/*
function correctPNG()
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
window.attachEvent("onload", correctPNG);
*/



/** INFOBULLE
 * ----------
 * Jeremie Patonnier <jep@ibilab.net>
 * Version : 1.0
 * ----------
 * Objet JavaScript qui permet de créer des infobulles hautement personnalisées
 * ----------
 * Propriétés de l'objet :
 * 1 - infoBulle::decY : integer : Defaut : 20
 *                Décalage de l'infobulle par rapport au pointeur de la souris
 *                sur l'axe des Y.
 * 2 - infoBulle::decX : integer : Defaut : 0
 *                Décalage de l'infobulle par rapport au pointeur de la souris
 *                sur l'axe des X.
 * 3 - infoBulle::width : integer : Defaut : 210
 *                Largeur de l'infobulle (en pixel). il est conseillé que cette
 *                valeur soit egale à la valeur du style CSS width de l'infobulle. 
 * 4 - infoBulle::enableAlt  : Boolean : Defaut : false
 *                Indique si l'objet doit se baser sur le contenu de l'attribut
 *                alt pour générer le contenue de l'infobulle (true) ou bien 
 *                uniquement sur la contenue de l'attribut title (false).
 * 5 - infoBulle::enableDrag : Boolean : Defaut : true
 *                Indique si l'infobulle doit suivre la souris (true) ou rester
 *                à un emplacement fixe sur la page (false);  
 * ----------
 * Méthodes de l'objet :
 * 1 - infoBulle::setTo(OBJ, TEXTE): 
 *                Méthode qui permet d'assigner l'infobulle à l'objet OBJ et de 
 *                rajouter le texte TEXTE à la suite du texte de l'infobulle 
 *                pour cet objet.  
 * 2 - infoBulle::registerPointer(URLIMG): 
 *                Méthode permetant de rajouter un pointeur suivant la souris 
 *                à l'infobulle. Ce pointeur est une image dont l'URL est URLIMG.
 * 3 - infoBulle::registerFormat(REGEXP,FORMAT):
 *                Méthode permettant de spécifié des règles de formatage du texte.
 *                La portion de texte à formater est identifié grace à un objet 
 *                REGEXP, la règle de formatage est la chaine de caratère FORMAT.
 * ----------
 * Styliser l'infobulle :
 * Le texte de l'infobulle est à l'interieur d'une balise DIV identifié par #insideBulle
 * qui est elle même contenue dans une balise DIV identifié par #infoBulle
 * ---------- 
 * Exemple d'utilisation :
 *
 * <img src="test.jpg" id="test" alt="Photo test : Voici une infobulle personnalisé" />
 * <script type="text/javascript">
 *   bulle = new infoBulle();
 *   bulle.enableAlt = true; 
 *   bulle.setTo(document.getElementById("test"));
 *   bulle.registerFormat(/^(.*:)/,"<strong>$1</strong>");
 * </script>
 * <style type="text/css">
 *   #infoBulle{
 *     background:#FCC;
 *     border:1px solid #999; 
 *   }
 *   #insideBulle{
 *     margin:10px;
 *     font:0.8em Arial,Helvetica,sans-serif; 
 *   } 
 * </style>   
 *
 */

OPE = (window.opera)?true:false;
IE  = (document.all && !OPE)?true:false;
MOZ = (document.getELementById && !IE)?true:false;

if(!IE) document.captureEvents(Event.MOUSEMOVE);

function infoBulle(){
  // Creation des conteneurs
  d = document.getElementsByTagName("body");
  body = d[0];
  this.mainIB     = document.createElement('div');
  this.mainIB.id  = "infoBulle";
  this.mainIB.style.position = "absolute";
  this.mainTXT    = document.createElement('div');
  this.mainTXT.id = "insideBulle";
  this.mainIB.appendChild(this.mainTXT);
  body.appendChild(this.mainIB);
  
  //Decallage de l'infobulle
  this.decY = 20;
  this.decX = 0;
  
  //Prise en compte de l'attribut alt
  this.enableAlt = false;
  
  //L'infobulle doit-elle suivre la souris
  this.enableDrag = true;
  
  //Largeur de l'infobulle
  this.width = 210;
  
  //Régles de formatage
  this.format = new Array();
}

infoBulle.prototype.registerPointer = function(src){
  this.pointeur = document.createElement('img');
  this.pointeur.src = src;
  this.pointeur.style.position = "absolute";
  this.pointeur.style.top = 1 - this.pointeur.height + "px";
  this.mainIB.appendChild(this.pointeur);
}

infoBulle.prototype.registerFormat = function(rxp,str){
  if(typeof(rxp) == "function" || typeof(rxp) == "object"){
    this.format.push(new Array(rxp,str));
  }
}

infoBulle.prototype.setTo = function(obj,addtxt){
  if(!window.ibvar) window.ibvar = this;
  if(!obj.ibtxt) obj.ibtxt = (addtxt == undefined)?'':addtxt;
  
  obj.onmouseover = function(){
    txt = (window.ibvar.enableAlt && this.alt != "" && this.alt != undefined)? this.alt : this.title ;
    nbr = window.ibvar.format.length;
    for(i=0; i<nbr; i++){
      txt = txt.replace(window.ibvar.format[i][0],window.ibvar.format[i][1])
    }
    window.ibvar.setText(txt + this.ibtxt);
    this.st = this.title;
    this.title = '';
    if (window.ibvar.enableAlt && this.alt != undefined){
      this.sa = this.alt;
      this.alt = '';
    }
    if(window.ibvar.enableDrag = true) window.ibvar.startDrag();
    window.ibvar.showHide('show');
  }
  
  obj.onmouseout = function(){
    this.title = this.st;
    if (window.ibvar.enableAlt && this.sa != undefined){
      this.alt = this.sa;
    }
    window.ibvar.showHide('hide');
    window.ibvar.stopDrag();
  }
}

/* Méthodes privées */

infoBulle.prototype.setText = function(txt){
  this.mainTXT.innerHTML = txt;
}

infoBulle.prototype.showHide = function(dsp){
  shb = this.mainIB.style;
  if(dsp == undefined){
    shb.display = (shb.display == "block")?"none":"block";
  } else {
    shb.display = (dsp == 'show')?"block":"none";
  }
}

infoBulle.prototype.startDrag = function(){
  if(!window.ibvar) window.ibvar = this;
  document.onmousemove = function(e){
    X = (IE)?event.clientX:e.pageX;
	  Y = (IE)?event.clientY:e.pageY;
	  window.ibvar.mainIB.style.top  = (Y+window.ibvar.decY) + "px";
	  W = body.clientWidth;
	  M = W - window.ibvar.width;
	  window.ibvar.mainIB.style.left = Math.round(M*X/W) + window.ibvar.decX + "px";
	  if(window.ibvar.pointeur){
	    pos = X - Math.round(M*X/W) - Math.floor(window.ibvar.pointeur.width/2)
	    if(pos < 7) pos = 7;
	    if(pos > window.ibvar.width-7-window.ibvar.pointeur.width) pos = window.ibvar.width-7-window.ibvar.pointeur.width;
      window.ibvar.pointeur.style.left = pos + "px";
    } 
  }
}

infoBulle.prototype.stopDrag = function(){
  document.onmousemove = function(e){};
}

function montre(id) {
	var d = document.getElementById(id);
	d.style.display='block';
}

function classeSurvol(id, nouvelleClasse){
	var d = document.getElementById(id);
	d.className=nouvelleClasse;
}
function montreCache(id) {
	var d = document.getElementById(id);
	/*alert(d.style.display);*/
	if (d) {
		if(d.style.display=='block'){
			d.style.display='none';
		} else {
			d.style.display='block';
		}
	}
}

function cache(id) {
	var d = document.getElementById(id);
	if (d) {d.style.display='none';}
}
function toutDeplier(typeTag,base){
	var d;
	var idAChercher = new RegExp(base+'[0-9]+');
	var correspondances = document.getElementsByTagName(typeTag);
	
	for (i = 0; i< correspondances.length; i++){
		if(idAChercher.test(correspondances[i]['id'])){
			d = document.getElementById(correspondances[i]['id']);
			d.style.display='block';
		}
	}
}
function toutPlier(typeTag,base){
	var d;
	var idAChercher = new RegExp(base+'[0-9]+');
	var correspondances = document.getElementsByTagName(typeTag);
	
	for (i = 0; i< correspondances.length; i++){
		if(idAChercher.test(correspondances[i]['id'])){
			d = document.getElementById(correspondances[i]['id']);
			d.style.display='none';
		}
	}
}

function tailleTexte(actionTexte){
	var d = document.getElementById('colonneContenu');
	

	
	if(actionTexte == 'plus'){
		d.style.fontSize='150%';
		recursif(d);
	}
	if(actionTexte == 'moins'){
		d.style.fontSize='smaller';
	}
	function recursif(parent){
			//while(parent.hasChildNodes()){
				var Nsubd = parent.childNodes.length;
				for(i=0; i<Nsubd; i++){
					
					if(parent.childNodes[i].nodeType == 1 || parent.childNodes[i].nodeType == 4){
						parent.childNodes[i].style.fontSize='150%';
						if(parent.childNodes[i].hasChildNodes()){
							recursif(parent.childNodes[i]);
						}
					}
					
				}
				
			//}
			
		}
}


//Gere les checkbox(coche/decoche)
function GereChkbox(case1, case2, a_faire) {

// conteneur = id du bloc (<div>, <p> ...) contenant les checkbox
// a_faire = '0' pour tout décocher
// a_faire = '1' pour tout cocher
// a_faire = '2' pour inverser la sélection

var Chckbox1 = document.getElementById(case1);
var Chckbox2 = document.getElementById(case2);
var blnEtat1=null;
var blnEtat2=null;
blnEtat1 = (a_faire=='0') ? false : (a_faire=='1') ? true : (Chckbox1.checked) ? false : true;
Chckbox1.checked=blnEtat1;
	
blnEtat2 = (a_faire=='0') ? false : (a_faire=='1') ? true : (Chckbox2.checked) ? false : true;
Chckbox2.checked=blnEtat2;		
	
}
function checkDelegationSansTotale(){
	var textCodeCp1 = document.getElementById('codeCp1');
	var textCodeCp2 = document.getElementById('codeCp2');
		
	textCodeCp1.disabled = 'true';
	textCodeCp1.value = '';
	textCodeCp2.disabled = 'true';
	textCodeCp2.value= '';
}

function checkDelegationPartielle(){
	var textCodeCp1 = document.getElementById('codeCp1');
	var textCodeCp2 = document.getElementById('codeCp2');
		
	textCodeCp1.disabled = '';
	textCodeCp2.disabled = '';
}

function GereRadioDelegation(){
	var radioSans = document.getElementById('typeDelegationSans');
	var radioPartielle = document.getElementById('typeDelegationPartielle');
	var radioTotale = document.getElementById('typeDelegationTotale');
	 
	var textCodeCp1 = document.getElementById('codeCp1');
	var textCodeCp2 = document.getElementById('codeCp2');
	if ( radioPartielle.checked == true  ) {
		textCodeCp1.disabled = 'false';
	 	textCodeCp2.disabled = 'false';
	}else {
		textCodeCp1.disabled = 'true';
		textCodeCp1.value = '';
	 	textCodeCp2.disabled = 'true';
	 	textCodeCp2.value= '';
	}
}

