﻿/*
*	Auteur : Alexandre Koch 
*	mail : auteur@hazart.Com
*	date : février 2007
*
*	Tout modification de ce fichier ou réutilisation du code
*	doit faire l'objet d'une demande par mail à son auteur.
*
*/

var oGet = new Object();

var strGet = document.location.search;
if (strGet.charAt(0)=='?') strGet=strGet.substring(1);
var tabGet = strGet.split('&');
for (var i=0; i < tabGet.length; i++) {
	var tabTemp = tabGet[ i].split('=');
	oGet[tabTemp[0]]=tabTemp[1];
}

function popup(lien,w,h,nom) {
	if (w == undefined) w = screen.width;
	if (h == undefined) h = screen.height;
	if (nom==undefined) nom = 'popup';
	window.open(lien,nom,'width='+w+',height='+h+',resizable=1,toolbar=0,location=0,directories=0,addressbar=0,scrollbars=0,status=0,menubar=0,top='+(screen.height-h)/2+',left='+(screen.width-w)/2);
}

function popimage(img,message) {
	w=open("",'popup','top='+(screen.height-100)/2+',left='+(screen.width-100)/2+',width=100,height=100,toolbar=0,location=0,directories=0,addressbar=0,scrollbars=0,status=0,menubar=0');
	w.document.write("<html><head>");
	w.document.write("<script type='text/javascript'>function checksize() { if (document.images[0].complete) { window.moveTo((screen.width-document.images[0].width+10)/2,(screen.height-document.images[0].height+30)/2);window.resizeTo(document.images[0].width+10,document.images[0].height+30);window.focus();} else { settimeout('checksize()',250) } }</"+"script>");
	if (message) w.document.write("<script type='text/javascript'>alert('Utilise la fonction \"enregistrer sous...\" de ton navigateur pour enregistrer cette image.');</script>");
	if (message) w.document.write("<body onload='checksize()' onblur='window.close()' topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
	else  w.document.write("<body onload='checksize()' onblur='window.close()' onclick='window.close()' topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<img src='"+img+"' border='0' alt='image' />")
	w.document.write("</body></head></html>");
	w.document.close();
} 

function addEcouteur(obj, evType, fn){
	if (eval(obj.addEventListener)) obj.addEventListener(evType, fn, false);
	else if (eval(obj.attachEvent)) obj.attachEvent("on"+evType, fn);
}

function ajoutFavoris(lien,titre) {
	if (document.all) window.external.AddFavorite(lien, titre);
	else  {
		alert("Pour ajouter ce site à vos favoris appuyer sur les touches CTRL+D sur pc et CMD+D sur mac");
		//window.sidebar.addPanel(titre,lien,"");
	}
}


function encode_utf8(texte) {
	texte = texte.replace(/\r\n/g,"\n");
	var utftext = "";
	for(var n=0; n<texte.length; n++) {
		var c=texte.charCodeAt(n);
		if (c<128) utftext += String.fromCharCode(c);
		else if ((c>127) && (c<2048)) {
			 utftext += String.fromCharCode((c>>6)|192);
			 utftext += String.fromCharCode((c&63)|128);
		} else {
			utftext += String.fromCharCode((c>>12)|224);
			utftext += String.fromCharCode(((c>>6)&63)|128);
			utftext += String.fromCharCode((c&63)|128);
		}
	}
	return utftext;
}
