ie=typeof(ie)!="undefined";
ie6=typeof(ie6)!="undefined";

function $(id){
	return document.getElementById(id);
}//$

function addEvent(src,evt,func){
	if (src.addEventListener){ // DOM Standard
		src.addEventListener(evt,func,false);
		return true;
	}
	else if (src.attachEvent) return src.attachEvent("on"+evt,func); // IE
	else eval('src.on'+evt+'=func'); // navigateurs sans DOM
}//addEvent

function getEvent(e){ // moulinette pour IE
	if (e==null && window.event) e=window.event;
	if (e.target==null && e.srcElement) e.target=e.srcElement;
	if (!e.preventDefault) e.preventDefault=function (){ this.returnValue=false; };
	return e;
}

function popUp(event){
	var e=getEvent(event);
	var lien=e.target;
	while (lien.tagName.toLowerCase()!='a') lien=lien.parentNode;
	window.open(lien.href,'_blank');
	e.preventDefault();
	return false;
}//popUp

function remplaceLiens(){
	var lst=document.getElementsByTagName('a') ;
	for(var i=0;i<lst.length;i++){
		var lien=lst[i];
		if (lien.href && lien.rel && lien.rel=='externe') addEvent(lien,'click',popUp);
	}
}//remplaceLiens

function load_modif_img(ph){
	if (ie) setTimeout("load_modif_imgIE('"+ph.id+"',178);",10);
	ph.style.width='178px';
}//load_modif_img

function load_modif_imgIE(id,w){
	var ph=$(id);
	var tmp=ph.offsetWidth;
	ph.style.width=w+'px';
	ph.style.height=Math.round(w*ph.offsetHeight/tmp)+'px';
}//load_modif_imgIE

function visualiseJPG(elt){
 	var elt=elt.firstChild;
 	while (elt.tagName!='IMG') elt=this.nextSibling(elt);
 	src=elt.src;
	open('/admin/lib/aff_visuel.php?visuel='+src,'_blank','top=0,left=0,width='+screen.width+',height='+screen.height+',location=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no');
}//visualiseJPG

function affichage(num,menu){
	
	// Variables
	var div=$('container_'+num);
	if (div){
		var total=$('total').value;
		var top_menu=$('top_menu');
		
		// On cache tous les div présents
		for (var i=1;i<=total;i++) $('container_'+i).style.display='none';
		
		// On affiche notre div
		div.style.display='block';
		
		// On indique dans le top menu où l'on se trouve
		if (menu) top_menu.innerHTML=menu;
	}
}

function init(){
	remplaceLiens();
}
