//Fonction d'ouverture d'une fenętre centrée horizontalement
function openWin(url, windowname, w, h, options){
	var x=(screen.width-w)/2;
	var y=0;
	newWin=window.open(url, windowname, "width="+w+",height="+h+",top="+y+",left="+x+","+options);
	newWin.focus();
}

//Fonction d'ouverture d'une fenętre en plein écran
function NewWindow(url, windowname, options){
	var x=0;
	var y=0;
	var w=screen.width-10;
	var h=screen.height-40;
	newWin=window.open(url, windowname, "width="+w+",height="+h+",top="+y+",left="+x+","+options);
	newWin.focus();
}

//Fonction de redirection aprčs confirmation
function GotoWithConfirm(element,url){
	ok = confirm('Etes vous certain de vouloir supprimer ' + element + '?');
	if(ok)
		document.location.href = url;
}

//Gestion des images
function twAjustePopUp(){ 
	var images = document.getElementsByTagName('img');
	for (var i = 0 ; i < images.length ; ++i) {
		//Redimensionnement des PopUp
		if(images[i].id == 'twAjustePopUp'){
			if(images[i].complete){ 
				window.resizeTo(images[i].width+14,images[i].height+140); 
				window.moveTo((screen.width-images[i].width)/2,0); 
				window.focus();
				images[i].alt = images[i].src;
			} 
			else{ 
				setTimeout("twAjustePopUp()",1000) 
			}
		}
	} 
}

//Gestion des liens
function behav_link()
{
	var liens = document.getElementsByTagName('a');
	for (var i = 0 ; i < liens.length ; ++i) {
		//Ouverture des liens dans une fenętre externe
		if(liens[i].className.indexOf('ext') >= 0){
			//liens[i].title = 'S\'ouvre dans une nouvelle fenętre';
			liens[i].onclick = function(){
				window.open(this.href);
				return false;
			};
		}
		//Fermeture des fenętres
		if(liens[i].className.indexOf('close') >= 0){
			liens[i].title = 'Fermer cette fenętre';
			liens[i].onclick = function(){
				window.close();
				return false;
			};
		}
		//Print
		if(liens[i].className.indexOf('print') >= 0){
			liens[i].onclick = function(){
				window.print();
				return false;
			};
		}
		//PopUp
		if(liens[i].className.indexOf('popup') >= 0){
			liens[i].onclick = function(){
				openWin(this.href,'','400','400','');
				return false;
			};
		}
		//PopUp galeries
		if(liens[i].className.indexOf('zoom') >= 0){
			liens[i].onclick = function(){
				openWin(this.href,'','800','600','scrollbars=yes,resizable=yes,status=yes');
				return false;
			};
		}
		//Fichiers
		if(liens[i].className.indexOf('fichier') >= 0){
			liens[i].onclick = function(){
				openWin(this.href,'','400','280','');
				return false;
			};
		}
		//Infobulles -> Pas de title
		if(liens[i].className.indexOf('bulle') >= 0){
			liens[i].onmouseover = function(){
				this.title = "";
				return false;
			};
		}
	}
}