/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \

|		

|		Copyright (c) 2007

|		Design + HTML/CSS/DOM JavaScript : Smart Agence

|		http://www.smartagence.com/

|		

\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */







var $jQ = jQuery.noConflict();

if(!siteMapManager) {

	var siteMapManager;

}



function $id(sID) {

	return document.getElementById(sID);

}





/* ______________________[ 00 | Rollover image-maps ]________________________ */



function highlightRegion(sImgID,sNewSrc){

	document.getElementById(sImgID).src = sNewSrc;

};





/* ______________________[ 01 | Interactivite du menu principal (menu horizontal) ]________________________ */



/* A special thanks goes to Eric Shepherd for his ALA article about "Hybrid CSS Dropdowns":  http://www.alistapart.com/articles/hybrid/ 

	and to Patrick Griffiths and Dan Webb for their htmldog.com article "Sons of Suckerfish": http://www.htmldog.com/articles/suckerfish/ */

function SmartHover(who) {

	if (document.all && document.getElementById && document.getElementsByTagName && document.getElementById(who)) {

		var navRoot=document.getElementById(who);

		var aLI = navRoot.getElementsByTagName("LI");

		for (i=0;i<aLI.length;i++) {

			if (aLI[i].nodeName=="LI") {

				aLI[i].onmouseover = function() {this.className += " over";};

				aLI[i].onmouseout = function() {this.className=this.className.replace(" over", "");};

			}

		}

	}

	

	if(!(navigator.userAgent.indexOf('Gecko') != -1)) {

		SmartFocus(who);

	}

};



function SmartFocus(who) {

	var navLnk=document.getElementById(who).getElementsByTagName("A");

	var navItm=document.getElementById(who).getElementsByTagName("LI");

	

	for (var n=0;n<navItm.length;n++) {

		if (navItm[n].className!="on") {

			navItm[n].className="y";

		}

	}

	for (var i=0;i<navItm.length;i++) {

		navLnk[i].onfocus = function() {

			if (this.parentNode.id == who) {

				this.parentNode.className += " over";

			} else {

				this.parentNode.parentNode.parentNode.className += " over";

			}

		};

		navLnk[i].onblur = function() {

			if (this.parentNode.parentNode.id == who) {

				this.parentNode.className=this.parentNode.className.replace(" over", "");

			} else {

				this.parentNode.parentNode.parentNode.className=this.parentNode.parentNode.parentNode.className.replace(" over", "");

			}

		};

	}

};





/* ______________________[ 02 | Gestion de la taille du texte d un article ]________________________ */



function SmartSize() {

	var args=SmartSize.arguments;

	if (document.getElementById&&document.getElementById("Tplus")&&document.getElementById("Tmoins")) {

		var cibleplus=document.getElementById("Tplus");

		var ciblemoins=document.getElementById("Tmoins");

		cibleplus.onclick=function() {

			for (n=0;n<args.length;n++) {

				if (document.getElementById(args[n])) {

					var cibletxt=document.getElementById(args[n]);

					var sizestr=cibletxt.style.fontSize.substring(0,cibletxt.style.fontSize.length-2);

					var sizeinter=cibletxt.style.lineHeight.substring(0,cibletxt.style.lineHeight.length-2);

					sizestr=sizestr!=""?parseInt(sizestr):12;

					cibletxt.style.fontSize=sizestr+1+"px";

				}

			}

		};

		ciblemoins.onclick=function() {

			for (n=0;n<args.length;n++) {

				if (document.getElementById(args[n])) {

					var cibletxt=document.getElementById(args[n]);

					var sizestr=cibletxt.style.fontSize.substring(0,cibletxt.style.fontSize.length-2);

					var sizeinter=cibletxt.style.lineHeight.substring(0,cibletxt.style.lineHeight.length-2);

					sizestr=sizestr!=""?parseInt(sizestr):12;

					cibletxt.style.fontSize=sizestr-1+"px";

				}

			}

		};

	}

};





/* ______________________[ 03 | Lancement dï¿½une impression pour les navigateurs compatibles ]________________________ */



function DirectPrint() {

	if (window.print) self.print();

};





/* ______________________[ 04 | Miscellaneous ]________________________ */



function OpenPopup(url,nom,option) {

	window.open(url,nom,option);

};

function select_redirect(bitRedirect,oSelect) {

	var adresse = oSelect.options[oSelect.selectedIndex].value;

	if ((bitRedirect == 1) && (adresse !=''))

		window.open(adresse,'directory','width=500px,height=550px,scrollbars=yes');

}

function select_redirect2(bitRedirect,oSelect) {

	var adresse = oSelect.options[oSelect.selectedIndex].value;

	if ((bitRedirect == 1) && (adresse !='')) {

		var oCegeFrame = document.getElementById('cegeframe');

		oCegeFrame.src=adresse;

		with(oCegeFrame) {

			style.display = "block";

		}

	}

}





/* ______________________[ 05 | Ajout de la page courante aux favoris ]________________________ */



/* Mettre la page courante en favoris MSIE et Firefox */

function myBookmark() {

	if (document.getElementById&&document.getElementById("favoris")) {

		var el=document.getElementById("favoris");

		var operaStr="&lsaquo; Ctrl + T &rsaquo; pour ajouter aux favoris.";

		if (document.all&&navigator.userAgent.indexOf("Opera")==-1) {

			window.external.AddFavorite(document.location,document.title);

		} else if (window.sidebar) {

			window.sidebar.addPanel(document.title,document.location.href,"");

		} else if (navigator.userAgent.indexOf("Opera")!=-1) {

			el.title=operaStr;

			window.status=operaStr;

		}

	}

};





/* ______________________[ 06 | <select/> au clavier ]________________________ */



/* Thanks goes to Cameron Adams from http://www.themaninblue.com/ */

function initSelect(whichSelect) {

	if (document.getElementById&&document.getElementById(whichSelect)) {

		var theSelect=document.getElementById(whichSelect);

		theSelect.changed=false;

		theSelect.onfocus=selectFocussed;

		theSelect.onchange=selectChanged;

		theSelect.onkeydown=selectKeyed;

		theSelect.onclick=selectClicked;

		return true;

	}

};



function selectChanged(theElement) {

	var theSelect;

	if (theElement&&theElement.value) {

		theSelect=theElement;

	} else {

		theSelect=this;

	}

	if (!theSelect.changed) {

		return false;

	}

	if (theSelect.value&&theSelect.value!="0") window.location=theSelect.value;

	return true;

};



function selectClicked() {

	this.changed=true;

};



function selectFocussed() {

	this.initValue=this.value;

	return true;

};



function selectKeyed(e){

	var theEvent;

	var keyCodeTab="9";

	var keyCodeEnter="13";

	var keyCodeEsc="27";

	if (e) {

		theEvent=e;

	} else {

		theEvent=event;

	}

	if ((theEvent.keyCode==keyCodeEnter||theEvent.keyCode==keyCodeTab)&&this.value!=this.initValue) {

		this.changed=true;

		selectChanged(this);

	} else if (theEvent.keyCode==keyCodeEsc) {

		this.value=this.initValue;

	} else {

		this.changed=false;

	}

	return true;

};





/* ______________________[ 07 | faux select ]________________________ */



function SmartPos() {

	navBase=document.getElementById("otherSites").getElementsByTagName("UL");

	for (i=0; i<navBase.length; i++) {

	if (navBase[i].parentNode.className=='simuSelect') {

		var pos=navBase[i].offsetHeight+18;

		navBase[i].style.margin="-"+pos+"px 0 0 9px";

		}

	}	

}



function CreateSelect () {

  if (document.getElementById&&document.getElementById('otherSites')){

	var cible=document.getElementById('otherSites');

	var t="<p class='plabel'>Autres sites du groupe Cegelec</p><div class='simuSelect' id='SimuPays'><p><strong>S&eacute;lectionnez un pays</strong></p><ul><li><a target='_blank' href='http://www.cegelec.de'>Allemagne</a></li><li><a target='_blank' href='http://www.cegelec.at'>Autriche</a></li><li><a target='_blank' href='http://www.comsip.com.bh'>Bahre&iuml;n</a></li><li><a target='_blank' href='http://www.cegelec.be'>Belgique</a></li><li><a target='_blank' href='http://www.cegelec.com.br'>Br&eacute;sil</a></li><li><a target='_blank' href='http://www.cameroun.cegelec.com'>Cameroun</a></li><li><a target='_blank' href='http://www.cegelec.com.cn'>Chine</a></li><li><a target='_blank' href='http://www.cegelec.es'>Espagne</a></li><li><a target='_blank' href='http://www.cegelec.co.id'>Indon&eacute;sie</a></li><li><a target='_blank' href='http://www.cegelec.lu'>Luxembourg</a></li><li><a target='_blank' href='http://www.maroc.cegelec.com'>Maroc</a></li><li><a target='_blank' href='http://www.cegelec.nl'>Pays-Bas</a></li><li><a target='_blank' href='http://www.cegelec.pl'>Pologne</a></li><li><a target='_blank' href='http://www.cegelec.pt'>Portugal</a></li><li><a target='_blank' href='http://www.cegelec.cz'>R&eacute;publique tch&egrave;que</a></li><li><a target='_blank' href='http://www.cegelec.ch'>Suisse</a></li></ul></div><p class='pchoix'>ou</p><div class='simuSelect' id='SimuAct'><p><strong>S&eacute;lectionnez une activit&eacute;</strong></p><ul><li><a target='_blank' href='http://www.ndt.cegelec.com'>Contr&ocirc;le non destructif</a></li><li><a target='_blank' href='http://www.defense.cegelec.com'>D&eacute;fense</a></li><li><a target='_blank' href='http://www.espace.cegelec.com'>Espace</a></li><li><a target='_blank' href='http://www.catex.cegelec.com'>Formations en &laquo; P&eacute;trole et gaz &raquo;</a></li><li><a target='_blank' href='http://www.maintenance-globale.cegelec.com/'>Maintenance globale</a></li><li><a target='_blank' href='http://www.oilandgas.cegelec.com'>Petrole et gaz</a></li><li><a target='_blank' href='http://www.evolynx.eu'>S&eacute;curit&eacute;</a></li><li><a target='_blank' href='http://www.transport.cegelec.fr/'>Transport</a></li></ul></div>"+cible.innerHTML;

		cible.innerHTML=t;

	}

};



function SmartSelect(who) {

	var args = SmartSelect.arguments;

	for (n=0;n<args.length;n++) {

		if (document.getElementById(args[n])) {

			mySelect=document.getElementById(args[n]);

			myList=mySelect.getElementsByTagName("UL")[0];

			myInput=mySelect.getElementsByTagName("P")[0];

			ProcessSelect(mySelect, myList, myInput);

		}

	}  

};



function ProcessSelect (Sel, list, inp) {

	list.className="cache";  

	inp.onclick = function() {

		affichSelect (Sel, list, inp);

	};	

	inp.onmouseout = null;

	list.onmouseover = function() { this.parentNode.firstChild.nodeType==1?this.className="overIE":this.className="over";};

	list.onmouseout = function() { this.className="cache";}; 

};



function affichSelect (Sel, list, inp) {

	if (list.className=="cache"){

		list.parentNode.firstChild.nodeType==1?list.className="overIE":list.className="over";

	} else {

		list.className="cache";

	}

}





/* ______________________[ 08 | Bouton generique - (c) remy@smartpixel / Smart Agence, 2007]________________________ */



function AddToolButton(sContainerID, oParams){

	var DOM = document.createElement && document.getElementById && document.getElementById(sContainerID);

	if(DOM){

		var cible=document.getElementById(sContainerID).getElementsByTagName('UL');

		

		if(cible){

			var oLi = document.createElement("LI");

			var oLink = document.createElement("A");

			var oImg = document.createElement("IMG");

			

			with(oLink){

				id = oParams.linkId;

				title = oParams.imgAlt;

				href = oParams.linkHREF ? oParams.linkHREF : "javascript:;";

				onclick = oParams.onclick ? oParams.onclick : "";

			};

			

			with(oImg){

				src = oParams.imgSrc;

				alt = oParams.imgAlt;

			};

			

			oLink.appendChild(oImg);

			oLi.appendChild(oLink);

			

			// insertion ... avant un element existant

			if(oParams.insertBefore){

				var oNext = document.getElementById(oParams.insertBefore).parentNode;

				cible[0].insertBefore(oLi,oNext);

			}

			else{

				// ou en fin de liste

				cible[0].appendChild(oLi);

			}

		}	// end if cible

	}	// end if DOM

};	// end AddToolButton()





/* ______________________[ 09 | Interactivite carte du departement ]________________________ */



function SmartCarte(cible) {

	if (document.getElementById&&document.getElementById(cible)) {

		var root=document.getElementById(cible).getElementsByTagName("AREA");

		for (a=0;a<root.length;a++) {

			if (root[a].nodeName=="AREA") {

				root[a].onmouseover=function() {

					var divid="d"+this.id.substring(1,this.id.length);

					SmartShowHide(divid);

				}

				root[a].onmouseout=function() {

					var divid="d"+this.id.substring(1,this.id.length);

					SmartShowHide(divid);

				}

			}

		}

	}

}



function SmartShowHide(who) {

	var div=document.getElementById(who);

	div.className=div.className==""?"over":"";

}



function SmartDL() {

	var args=SmartDL.arguments;

	if(typeof args[0] === "object") {

		SmartDLEffect(args[0],args[1]);

	} else if (document.getElementById && $id(args[n])) {

		for (n=0;n<args.length;n+=2) {

			SmartDLEffect($id(args[n]),args[n+1]);

		}

	}

};



function SmartDLEffect(oRoot,ClickFx) {

	var root=oRoot.getElementsByTagName("DT");

	var Sister = null;

	for (a=0;a<root.length;a++) {

		Sister = DOMUtils.getNextSibling(root[a]);

		if(Sister && Sister.nodeName == "DD") {

			if (root[a].className!="on") {

				Sister.className="off";

			}

			else {

				Sister.className="on";

			}

			SmartOpenClose(root[a],Sister,ClickFx);

		}

	}

};



function SmartOpenClose(who,Sister,ClickFx) {

	if (ClickFx==1) {

		who.onclick=function() {

			who.className=(who.className=="on"?"off":"on");

			Sister.className=(Sister.className=="on"?"off":"on");

		}

	} else {

		who.onclick=function() {

			for (a=0;a<who.parentNode.childNodes.length;a++) {

				if (who.parentNode.childNodes[a].nodeName=="DT") {who.parentNode.childNodes[a].className="";}

				else if (who.parentNode.childNodes[a].nodeName=="DD") {who.parentNode.childNodes[a].className="off";}

			}

			AllDT=who.parentNode.getElementsByTagName("DT");

			AllDD=who.parentNode.getElementsByTagName("DD");

			for (b=0;b<AllDT.length;b++) {

				AllDT[b].className="off";

			}

			for (c=0;c<AllDD.length;c++) {

				AllDD[c].className="off";

			}

			who.className="on";

			Sister.className=(Sister.className==" on"?"":"on");

		}

	}

};











/* ______________________[ 10 | Lancement des scripts ]________________________ */



window.onload=function() {

	CreateSelect();

	SmartPos();

	SmartHover("NavigationPrincipale");

	SmartSelect("SimuPays", "SimuAct");

	AddToolButton("TxtTools",{linkId:"print",linkHREF:"javascript:DirectPrint();",imgSrc:"/fileadmin/templates/img/ico_print.gif",imgAlt:"Imprimer cette page",insertBefore:"Send"});

	AddToolButton("TxtTools",{linkId:"Tmoins",imgSrc:"/fileadmin/templates/img/ico_tmoins.gif",imgAlt:"Texte plus petit",insertBefore:"print"});

	AddToolButton("TxtTools",{linkId:"Tplus",imgSrc:"/fileadmin/templates/img/ico_tplus.gif",imgAlt:"Texte plus grand",insertBefore:"Tmoins"});

	AddToolButton("TxtTools",{linkId:"favoris",linkHREF:"javascript:myBookmark();",imgSrc:"/fileadmin/templates/img/ico_favori.gif",imgAlt:"Ajouter aux favoris"});

	SmartSize("ColB","ColC","ColD","ColMenu","ColContenu","ColContextuelle");

	if(siteMapManager) {

		siteMapManager.initialize("plansite",true).makeTreesC();

	}

	if(document.getElementById("selectCountry")) {

		var oSelectCountry = document.getElementById("selectCountry");

		oSelectCountry.onchange = function() {

			select_redirect2(1,this);

		};

	}

	if(document.getElementById("selectDivision")) {

		var oSelectDivision = document.getElementById("selectDivision");

		oSelectDivision.onchange = function() {

			select_redirect2(1,this);

		};

	}

	SmartCarte("Map");

};







var MosaicTooltip=function() {

	$jQ(".bubbleInfo").each(function () {

									  

		var trigger = $jQ(this).find(".trigger");

		var popup = $jQ(this).find(".popup");

		

		trigger.mouseenter(function () {

			popup.stop(true,true).show();

		});

		

		var process =null;

		trigger.mouseleave(function () {

			process = window.setTimeout(function(){popup.stop(true,true).fadeOut();},500);

		});

		

		popup.mouseenter(function () {

			window.clearTimeout(process);

			process = null;

			popup.css("display","block");

		}).mouseleave(function(){popup.stop(true,true).fadeOut();});

	

	});

};

	

	

$jQ(document).ready(

	function($jQ) {

		if(!$jQ.browser.msie || ($jQ.browser.msie && $jQ.browser.version >= 6)) {

			$jQ("body").addClass("jQOn");

			//$jQ("#Historique dd").not($jQ("div dd.on")).hide(0);

			$jQ("#Historique dd").hide(0);

			$jQ("#Historique dt").addClass("off").click(

				function() {

					$dt = $jQ(this);

					if($dt.next().is("dd")) {

						if($jQ($dt).hasClass("on")) {

							$jQ($dt).removeClass("on");

						} else {

							$jQ($dt).addClass("on");

						}

						$jQ($dt).next().slideToggle("fast");

					}

				}

			);

			$jQ("#Historique div dl.event:first-child dt").removeClass("off").toggleClass("on");

			$jQ("#Historique div dl.event:first-child dd").removeClass("off").slideToggle("fast");

		} else {

			document.getElementsByTagName("body")[0].className += "jsOn";

			if($id("Historique")) {

				var aDL = $id("Historique").getElementsByTagName("dl");

				for(var i=0;i<aDL.length;i++) {

					SmartDL(aDL[i],1);

				}

			}

		}

		MosaicTooltip();

	});



/*$("#actus td#presse");*/

