
global_date = new Date();
global_date = global_date.getTime();

var isMozilla = (navigator.userAgent.toLowerCase().indexOf('gecko')!=-1) ? true : false;
var regexp = new RegExp("[\r]","gi");

function strlen(mot)
        {
        return(mot.length);
        }

function file(fichier)
     {
     
	today = new Date;
	sec = today.getTime();
	intpos = fichier.indexOf("?");
	if(intpos > 0)
		fichier = fichier+'&anticache='+sec;
	else
		fichier = fichier+'?anticache='+sec;
		
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
     xhr_object.open("GET", fichier, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
     }
     
function fileindiv(fichier, div, att, post, error_txt)
	{
	if(att == 1)
		{
		// ON AFFICHE L'IMAGE D'ATTENTE
		// ON CHOPPE LA TAILLE ACTUELLE DU DIV
		haut = gebi(div).offsetHeight;
		gebi(div).innerHTML = '<div style="height:'+haut+'px" class="att_blanc">&nbsp;</div>';
		}
	mydate = new Date;
	mydate = mydate.getTime();
	

	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	xhr_object.onreadystatechange = function()
		{
		//alert(xhr_object.readyState);
		if(xhr_object.readyState == 4)
			{
			//gebi(div).innerHTML = xhr_object.responseText;
			if(xhr_object.status==200)
				loadPageRes(xhr_object.responseText, div);
			else
				{
				if(!error_txt)
					error_txt = "Erreur de chargement de la page (Erreur "+xhr_object.status+")";
				loadPageRes(error_txt, div);
				}
			}
		};
	today = new Date;
	sec = today.getTime();
	intpos = fichier.indexOf("?");
	if(intpos > 0)
		fichier = fichier+'&anticache='+sec;
	else
		fichier = fichier+'?anticache='+sec;
	if(post)
		{
		xhr_object.open("POST",fichier,true);
		xhr_object.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr_object.send(post);
		}
	else
		{
		xhr_object.open("GET", fichier, true);
		xhr_object.send(null);
		}
	}
	
function gestiondisplay(div)
	{
	// Ouvre, ferme un bloc
	div = gebi(div);
	
	if(div)
		{
		disp = div.style.display;
		if(disp != 'block')
			{
			div.style.display='block';
			}
		else
			div.style.display='none';
		}
	}

function afficheBox(divname, content, e, over, moveit, zindex, noflash)
	{
	if(divname == "")
		divname = "dhtml_pop";
		
	if(!vn(zindex))
		zindex = 2000;
		
	if(moveit != false)
		moveit = true;
		
	if(!document.getElementById(divname))
		{
		obj = document.createElement("div");
                obj.id = divname;
		var b = document.getElementsByTagName("body")[0];
		if (b.firstChild != null)		
			b.insertBefore(obj, b.firstChild);
		else
			b.appendChild(div);
		}
	
	/*if(!document.getElementById(divname))
		{
		obj = document.createElement("div");
                obj.id = divname;
		}
	
	obj = gebi(divname);	
	var b = document.getElementsByTagName("body")[0];
	
	if (b.firstChild != null)		
		b.insertBefore(obj, b.firstChild);
	else
		b.appendChild(div);*/
		
	// Z index
	gebi(divname).style.zIndex = zindex;
	
	// Scroll top :
	scrolltop = getScrollTop()
	scrollleft = getScrollLeft()
	
	if(divname != "photo_viewer")
		{
		gebi(divname).setAttribute('class', 'affiche_box'); 
		gebi(divname).setAttribute('className', 'affiche_box'); 
		}
	if(e != '')
		{
		get_x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : scrollleft+event.clientX;
		get_y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : scrolltop+event.clientY;
		}
	else
		{
		get_x = 100;
		get_y = 100;
		}
	//window.status='X : '+get_x+' - Y : '+get_y;
	
	
	obj = document.getElementById(divname);
	
	// ON PLACE LE CONTENU
	if(content!='' && over!=1)
		obj.innerHTML = '<!-- close bouton --><a href="#" class="fermer_lien" style="display:block;text-align:right;margin-bottom:5px" class="petitefont" onclick="closeBox(\''+divname+'\', '+noflash+');return(false);">[x] Fermer</a>'+content;
	else if(content!='')
		obj.innerHTML = content;
	else if (content == "")
		{
		content = obj.innerHTML;
		if(content.indexOf('<!-- close bouton -->') < 0)
			obj.innerHTML = '<!-- close bouton --><a href="#" style="display:block;text-align:right" class="petitefont" onclick="closeBox(\''+divname+'\', '+noflash+');return(false);">[x] Fermer</a>'+content;
		}
		
	// ON AFFICHE LE BLOC
	obj.style.display='block';
		
	// ON ESSAYE DE NE PAS DEBORDER DU CADRE
	obj_larg = obj.offsetWidth;
	obj_haut = obj.offsetHeight;
	if(obj_larg == 461)
		obj_larg = 620;
	win_larg = document.documentElement.offsetWidth;
	win_haut = ecran_hauteur;
	win_scrolltop = scrolltop;
	//alert(win_scrolltop);
	
		// A GAUCHE
		if(get_x < 50)
			get_x = 50;
	
		// A DROITE
		if((get_x+obj_larg)>win_larg)
			{
			get_x = (win_larg-obj_larg);
			}
			
		// A GAUCHE
		if(get_x < 50)
			get_x = 50;
			
		// En bas
		old_get_y = get_y;
		bas_panneau = get_y+obj_haut-win_scrolltop;
		bas_ecran = win_haut;
		if(!over && bas_panneau+30>bas_ecran)
			{
			get_y = get_y-30-(bas_panneau-bas_ecran);
			if(get_y < 50)
				get_y = 50;
			}
		//alert(old_get_y+' - '+bas_panneau+' - '+bas_ecran+' - '+get_y)
	
	if(moveit)
		{
		if(over == 1)
			obj.style.top=(get_y+20)+"px";
		else
			obj.style.top=(get_y+10)+"px";
		obj.style.left=(get_x-50)+"px";
		}
	//alert(divname);
	//alert(func);
	//obj.onmouseout = new Function("closeBox('"+divname+"')");
	//alert(get_x+' - '+get_y);
	
	afficheOmbre(divname, '', zindex-5);
	if(noflash)
		cacheElement(true, true);
	
	//alert(divname+' : '+gebi(divname).style.zIndex)
	}

function closeBox(divname, noflash)
	{
	if(!divname || divname == "")
		divname = "dhtml_pop";
	obj = document.getElementById(divname);
	if(obj)
		obj.style.display='none';
	
	// On affiche l'ombre
	afficheOmbre(divname)
		
	//new Effect.Fade(divname);
	
	if(noflash)
		cacheElement(false, true);
	}
	
function afficheOmbre(divname, decal, zindex)
	{
	// On essaye d'afficher une ombre sous un element
	if(!gebi(divname))
		return(false);
		
	// Z index
	if(!vn(zindex))
		zindex = 45;
		
	// Decal
	if(!vn(decal))
		decal = 2;
		
	// ID de l'ombre
	divname_ombre = divname+'_ombre';
	
	// Création du div
	if(!gebi(divname_ombre))
		{
		obj = document.createElement("div");
                obj.id = divname_ombre;
		var b = document.getElementsByTagName("body")[0];
		if (b.firstChild != null)		
			b.insertBefore(obj, b.firstChild);
		else
			b.appendChild(div);
		gebi(divname_ombre).setAttribute('class', 'affiche_box_ombre'); 
		gebi(divname_ombre).setAttribute('className', 'affiche_box_ombre'); 
		}
	
	// Visibilité
	gebi(divname_ombre).style.display = gebi(divname).style.display;
	if(gebi(divname).style.position == 'fixed')
		gebi(divname_ombre).style.position = 'fixed';
		
	// Style
	gebi(divname_ombre).style.zIndex = zindex;
	gebi(divname_ombre).style.width = gebi(divname).offsetWidth+'px';
	gebi(divname_ombre).style.height = gebi(divname).offsetHeight+'px';
	gebi(divname_ombre).style.left = decal+getLeft(gebi(divname))+'px';
	gebi(divname_ombre).style.top = decal+getTop(gebi(divname))+'px';
	}

function resizeImage(myimg, x, y)
	{
	i1 = new Image();
	i1.src = myimg.src;
	if(x != 0 && i1.width>x)
		myimg.width=x;
	else if(y != 0 && i1.height > y)
		myimg.height = y;
	}

function vn(x)
        {
        var anum=/(^\d+$)|(^\d+.\d+$)/
        if (anum.test(x) && x!=0)
                testresult=true
        else
                testresult=false
        return (testresult)
        }

function ScanCookie(variable)
	{
	cook = document.cookie;
	variable += "=";
	place = cook.indexOf(variable,0);
	if (place <= -1)
		return("0");
	else
		{
		end = cook.indexOf(";",place)
		if (end <= -1)
			return(unescape(cook.substring(place+variable.length,cook.length)));
		else
			return(unescape(cook.substring(place+variable.length,end)));
		}
	}

function CreationCookie(nom,valeur,permanent)
	{
	if(permanent)
		{
		dateExp = new Date(2020,11,11);
		dateExp = dateExp.toGMTString();
		ifpermanent = 'expires=' + dateExp + ';';
		}
	else
		ifpermanent = '';
	document.cookie = nom+'='+escape(valeur)+';'+ifpermanent+';path=/;domain:.forumconstruire.com';
	}

function EffaceCookie(nom)
	{
	CreationCookie(nom,'',true);
	}

function addEngine() 
	{
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))
		{
    		window.sidebar.addSearchEngine("http://www.forumconstruire.com/construire/fc.src", "http://www.forumconstruire.com/construire/images/favicon.png", "ForumConstruire.com", "maison");
  		} 
	else 
		{
		var strQuery = "Encoding=ISO-8859-1&Name=ForumConstruire.com&URI=http%3A%2F%2Fwww.forumconstruire.com%2Fconstruire%2Fsearch.php%3Fsearch_keywords%3DTEST";
		var strAddURI = "http://www.microsoft.com/windows/ie/searchguide/spbuilder.mspx?" + strQuery;
		try 
			{ 
			window.external.AddSearchProvider(strAddURI); 
			}
		catch(eX)
			{
			alert("Échec de l'ajout d'un moteur de recherche.\nUtilisez-vous IE7 ?");
			}
  		}
	}

function insertBBcode(formulaire, champ, selec, smiley)
{
        if (isMozilla)
        {
        // Si on est sur Mozilla

                oField = document.getElementById(formulaire).elements[champ];

                objectValue = oField.value;

                deb = oField.selectionStart;
                fin = oField.selectionEnd;

                objectValueDeb = objectValue.substring( 0 , oField.selectionStart );
                objectValueFin = objectValue.substring( oField.selectionEnd , oField.textLength );
                objectSelected = objectValue.substring( oField.selectionStart ,oField.selectionEnd );

        //      alert("Debut:'"+objectValueDeb+"' ("+deb+")\nFin:'"+objectValueFin+"' ("+fin+")\n\nSelectionné:'"+objectSelected+"'("+(fin-deb)+")");
	        if(smiley == "1")
                	oField.value = objectValueDeb + selec + objectSelected + objectValueFin;
                else
                	oField.value = objectValueDeb + "[" + selec + "]" + objectSelected + "[/" + selec + "]" + objectValueFin;
                oField.selectionStart = strlen(objectValueDeb);
                if(smiley == "1")
                	oField.selectionEnd = strlen(objectValueDeb + selec + objectSelected);
                else
                	oField.selectionEnd = strlen(objectValueDeb + "[" + selec + "]" + objectSelected + "[/" + selec + "]");
                oField.focus();
                oField.setSelectionRange(
                        objectValueDeb.length + selec.length + 2,
                        objectValueDeb.length + selec.length + 2);
        }
        else
        {
        // Si on est sur IE

                oField = document.getElementById(formulaire).elements[champ];
                var str = document.selection.createRange().text;

                if (str.length>0)
                {
                // Si on a selectionné du texte
                        var sel = document.selection.createRange();
                        if(smiley == 1)
                        	sel.text = selec + str;
                        else
                        	sel.text = "[" + selec + "]" + str + "[/" + selec + "]";
                        sel.collapse();
                        sel.select();
                }
                else
                {
                        oField.focus(oField.caretPos);
                //      alert(oField.caretPos+"\n"+oField.value.length+"\n")
                        oField.focus(oField.value.length);
                        oField.caretPos = document.selection.createRange().duplicate();

                        var bidon = "%~%";
                        var orig = oField.value;
                        oField.caretPos.text = bidon;
                        var i = oField.value.search(bidon);
	                if(smiley == 1)
                        	oField.value = orig.substr(0,i) + selec + orig.substr(i, oField.value.length);
                        else
                        	oField.value = orig.substr(0,i) + "[" + selec + "][/" + selec + "]" + orig.substr(i, oField.value.length);
                        var r = 0;
                        for(n = 0; n < i; n++)
                        {if(regexp.test(oField.value.substr(n,2)) == true){r++;}};
                        pos = i + 2 + selec.length - r;
                        //placer(document.getElementById(formulaire).elements[champ], pos);
                        var r = oField.createTextRange();
                        r.moveStart('character', pos);
                        r.collapse();
                        r.select();

                }
        }
}

function rechercheMembre(formchamp, e, tformnom)
	{
	if(!tformnom || tformnom == "")
		{
		formnom = "";
		autosubmit = false;
		}
	else
		{
		autosubmit = true;
		formnom = tformnom;
		}
	champ = formchamp;
	
	timeouter = "";
	afficheBox("cherche_membre", '<b>Entrez le pseudo du membre :</b><form name="recherche_membre_form" onSubmit="return(false)"><input type="text" name="pseudo" value="" style="width:150px" onKeyUp="if(this.value.length>1) { document.getElementById(\'cherche_membre_result\').innerHTML = \'Recherche en cours ... \';timeouter = setTimeout(\'rechercheMembreAjax(\\\'\'+this.value+\'\\\', '+autosubmit+')\', 1000)}" onKeyDown="clearTimeout(timeouter);" /></form><div id="cherche_membre_result"></div>', e, 0);
	document.recherche_membre_form.pseudo.focus();
	}

timeouter = "";
a=0;

function rechercheMembreAjax(pseudo, formnom)
	{
	a++;
	document.getElementById('cherche_membre_result').innerHTML = file("/membres/ajax_cherchePseudo.php?autosubmit="+autosubmit+"&pseudo="+escape(pseudo));
	}

function ecrireDans(divname, content)
	{
	if(document.getElementById)
		document.getElementById(divname).innerHTML = content;
	else
		alert('Votre navigateur n\'est pas compatible avec ce site');
	}

function ajouteTr(div, texte)
	{
	elem = document.getElementById("tr_"+div);
	td = document.getElementById("td_"+div);
	plus = document.getElementById("plus_"+div);
	sep1 = document.getElementById("sep1_"+div);
	sep2 = document.getElementById("sep2_"+div);
	etat = elem.style.display;
	if(etat == "none")
		{
		if(document.all)
			elem.style.display = "block";
		else
			elem.style.display = "table-row";
		if(texte != '')
			td.innerHTML = texte;
		if(plus)
			plus.innerHTML = "[-]";
		if(sep1)
			{
			if(document.all)
				sep1.style.display = "block";
			else
				sep1.style.display = "table-row";
			}
		if(sep2)
			{
			if(document.all)
				sep2.style.display = "block";
			else
				sep2.style.display = "table-row";
			}
			
		}
	else
		{
		elem.style.display = "none";
		if(texte != '')
			td.innerHTML = "&nbsp;";
		if(plus)
			plus.innerHTML = "[+]";
		if(sep1)
			sep1.style.display = "none";
		if(sep2)
			sep2.style.display = "none";
		}
	}

function afficheSmiley(formulaire, champ, e, bigsmile)
	{
	afficheBox("cherche_membre", file("/ajax/getsmiley.php?big="+bigsmile+"&formulaire="+escape(formulaire)+"&champ="+escape(champ)), e, false);
	}

function gebi(t)
	{
	if(!document.getElementById)
		window.status = 'Votre navigateur ne vous permet pas de profiter au maximum de ce site';
	else
		return(document.getElementById(t));
	}

element_to_show = new Array();
function cacheElement(mode, noselect)
	{
	eltsToHide=new Array('iframe', 'object','embed');
	if(!noselect)
		eltsToHide[3] = 'select';
	for(var k=0; k<eltsToHide.length; k++) 
    		{
        	elt=eltsToHide[k];
	        flash=document.getElementsByTagName(elt);
	        if (flash.length>0) 
	        	{
			for(i=0;i<flash.length;i++) 
				{
				if(mode)
					{
					if(flash[i].style.visibility != 'hidden')
						element_to_show[flash[i]] = true;
					flash[i].style.visibility='hidden';
					}
				else
					{
					if(element_to_show[flash[i]])
						flash[i].style.visibility='visible';
					}
				}
	        	}
    		}
	}


var timeronglet;

var alertboxtimer;

function afficheAlertBox(texte, classe, temps, largeur, fixe)
	{
	clearTimeout(alertboxtimer);
	if(classe == "")
		classe = "alerte";
		
	// La box existe ?
	divname = 'alert_box';
	if(!document.getElementById(divname))
		{
		obj = document.createElement("div");
                obj.id = divname;
		var b = gebi('general_bloc');
		if (b.firstChild != null)		
			b.insertBefore(obj, b.firstChild);
		else
			b.appendChild(div);
		}
		
	gebi(divname).innerHTML = '';
	if(temps=='')
		gebi(divname).innerHTML += '<a href="#" style="display:block;text-align:right;margin-bottom:5px" class="petitefont" onclick="closeAlertBox();afficheOmbre(\''+divname+'\');return(false);">[x] Fermer</a>'
		
	if(texte!="")
		gebi(divname).innerHTML += texte;
	// ON POSITIONNE LE BLOC
	margin_left = ((document.documentElement.offsetWidth-largeur)/2)-150;
	gebi(divname).style.left = margin_left+"px";
	margin_top = 340;
		
	// Fixe
	if(fixe == '')
		{
		gebi(divname).style.position = 'fixed';
		}
	else
		gebi(divname).style.position = 'absolute';
	
	gebi(divname).style.top = margin_top+"px";
	gebi(divname).style.width = largeur+"px";
	gebi(divname).setAttribute('class', classe); 
	gebi(divname).setAttribute('className', classe); 
	//alert(largeur+' - '+margin_top+' - '+margin_left);
	//gebi('alerte_box').style.display = 'block';
	cacheElement(true);
	gebi(divname).style.display='block';
	afficheOmbre(divname, 10);
	if(vn(temps))
		alertboxtimer = setTimeout("closeAlertBox()", (temps*1000));
	}
	
function closeAlertBox()
	{
	divname = 'alert_box';
	gebi(divname).style.display='none';
	cacheElement(false);
	//afficheOmbre(divname)
	}
	
function loadPageRes(html, p)
{
		var a;
		var js = '';
	
		var e = /<script[^>]+src\="(.+)"[^>]*><\/script>/gi;
		var r;
		var h;
		h = html;
		while (r = e.exec(h))
		{
			var elt = document.createElement('script');
                        elt.type = 'text/javascript';
                        elt.src = r[1];
			var b = document.getElementsByTagName("body")[0];
			if (b.firstChild != null)		
				b.insertBefore(elt, b.firstChild);
			else
				b.appendChild(elt);
	
			// On enlève de h
			var h = h.substr(0, r.index) + h.substr(r.index + r[0].length);
			if (r = e.exec(h)){} // A laisser... sinon Firefox fait le moisi :|
			var e = /<script[^>]+src\="(.+)"[^>]*><\/script>/gi;
		}
	
		
		while ((a = h.indexOf('<script ')) != -1)
		{
			var b = h.substr(a, h.length - a);
			var fin = h.indexOf('</script>' /**/);
			if (fin > -1)
			{
				var js2 = b.substr(0, fin - a);
				var c = js2.indexOf('>');
				js += js2.substr(c + 1);
				h = h.substr(0, a) + h.substr(fin + /**/ 9);
			}
		}
	
	if (document.getElementById(p))
	{
		document.getElementById(p).innerHTML = h;
	}
	try
	{
		if (js)
			eval(js);
	}
	catch(e){alert(e);};
}

function getLeft(l)
{
  if (l.offsetParent) return (l.offsetLeft + getLeft(l.offsetParent));
  else return (l.offsetLeft);
}
function getTop(l)
{
  if (l.offsetParent) return (l.offsetTop + getTop(l.offsetParent));
  else return (l.offsetTop);
}
function getLeft2(l)
{
  if (l.offsetParent) return (l.offsetLeft + getLeft2(l.offsetParent));
  else return (l.offsetLeft);
}
function getTop2(l)
{
  if (l.offsetParent) return (l.offsetTop + getTop2(l.offsetParent));
  else return (l.offsetTop);
}

function getScrollTop() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getScrollTop() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

function getScrollLeft() {
  var scrOfX = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}

function correctPNG()
	{
/*	type_gg = typeof(GBrowserIsCompatible);
	if(type_gg != 'function')
		{*/
		for(var i=0; (i<document.images.length && i< 70); i++)
			{
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG" && (imgName.indexOf('FORUMCONSTRUIRE.COM')>0 || imgName.indexOf('QUELCONSTRUCTEUR.COM')>0 || imgName.indexOf('VITEUNDEVIS.COM')>0 || imgName.indexOf('QUELARCHITECTE.COM')>0 || imgName.indexOf('QUELMAITREDOEUVRE.COM')>0))
				{
				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
				//alert(strNewHTML);
				i = i-1
				}
			}
	//	}
	}

function ajouteEvent(element, evenement, fonction)
	{
	evenement_ie = "on"+evenement;
	if (element.addEventListener) 
		{
		element.addEventListener(evenement, fonction, false);
		} 
	else if (element.attachEvent) 
		{
		element.attachEvent(evenement_ie, fonction);
		}
	}

	
function ajouterPageFavoris(title, url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }
	
function ajouterFavoris() {

 title = document.title; 
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

 url = document.location.href;
  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }
 	
function decoupeStr(texte, debut, fin, include)
	{
	pos = texte.indexOf(debut);
	if(pos <= 0)
		pos = 0;		
	pos2 = texte.indexOf(fin, pos);
	if(pos2 <= 0)
		pos2 = 0;
	
	d1 = pos+debut.length;
	d2 = pos2;
	
	if(!include)
		pos += debut.length;
	else
		pos2 += fin.length;
	
	new_string = texte.substring(pos, pos2);
	
	return(new_string);

	}
	
function getLayoutOffsets()
	{
	var _d = document;
	var _w = window;
        var _de = _d.documentElement;   
        var xScroll, yScroll;
        if (window.innerHeight && window.scrollMaxY){   
                xScroll = _w.innerWidth + _w.scrollMaxX;
                yScroll = _w.innerHeight + _w.scrollMaxY;
        }else if (document.body && document.body.scrollHeight > document.body.offsetHeight){
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
        }else if (document.body) {
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
        }
        var windowWidth, windowHeight;
        if (self.innerHeight){
                windowWidth = _de.clientWidth ? _de.clientWidth : self.innerWidth;
                windowHeight = self.innerHeight;
        }else if (_de && _de.clientHeight){
                windowWidth = _de.clientWidth;
                windowHeight = _de.clientHeight;
        }else if (_d.body){
                windowWidth = _d.body.clientWidth;
                windowHeight = _d.body.clientHeight;
        }       
        pageHeight = yScroll < windowHeight ? windowHeight : yScroll;
        pageWidth = xScroll < windowWidth ? xScroll : windowWidth;
        return [pageWidth,pageHeight,windowWidth,windowHeight];
	}
	
ecran_larg = getLayoutOffsets()[2];
ecran_hauteur = getLayoutOffsets()[3];

var deja_redim_bloc = new Array;

function getParentWidth(l, nb)
{
	parent_bloc = l.parentNode;
	parent_width = parent_bloc.offsetWidth;
	parent_width = parseInt(parent_width);
	parent_bloc_id = parent_bloc.id;
	parent_bloc_id_short = parent_bloc_id.substring(0, 12);
	
	// Classe du div
	parent_classe = (!document.all)?parent_bloc.getAttribute("class"):parent_bloc.getAttribute("className");
	//alert(parent_classe);
	
	if(parent_bloc_id_short != 'message_bloc' && parent_classe != 'quote' && nb<10)
		{
		nb++;
		parent_width = getParentWidth(parent_bloc, nb);
		}
	else
		{
		premier_bebe = parent_bloc.firstChild.id;
		//alert('Bloc '+parent_bloc.id+' / Fils : '+premier_bebe);
		if(premier_bebe == 'first_post_pub' && !deja_redim_bloc[parent_bloc_id])
			{
			parent_width -= 350;
			//deja_redim_bloc[parent_bloc_id] = true;
			}
		}
	return(parent_width);
}
	
function chercheIdIn(id, div)
{
    if (div && div.hasChildNodes())
    {
        var a = 0;
        while (a < div.childNodes.length)
        {
            var fils = div.childNodes[a];
            if (fils.id && fils.id == id)
            {
                return true;
            }
        a++;
        }
    }
    return false;
}

function autoresizeimgonforum(img)
	{
	if(this.width>=500 || !vn(this.width))
		{
		url = img.src;
		i1 = new Image;
		i1.src = url;
		img_width = i1.width;
		
		if(vn(img_width))
			{	
			// On définit la largeur optimale
			parent_width = getParentWidth(img, 0);
			//alert(parent_width);
			
			// Largeur parfaite
			perfect_width = parent_width;
					
			//window.status = parent_bloc+" - "+parent_width+" ("+ecran_larg+" / "+img_width+") -->"+perfect_width;
			
			//window.status='Chargement de l\'image '+url+' et redimensionnement de celle-ci ...';
			
			if(vn(perfect_width) && perfect_width < img_width)
				{
				img.width = perfect_width;
				
				// On ajoute un bloc "cette image a été reduite"
				bloc_parent = img.parentNode;
				obj = document.createElement("div");
				bloc_parent.insertBefore(obj, img.nextSibling);
				obj.innerHTML = 'Image redimensionnée automatiquement en '+perfect_width+' pixels';
				//obj.innerHTML += '<br />'+parent_bloc+" - "+parent_width+" ("+ecran_larg+" / "+img_width+") -->"+perfect_width;
				obj.setAttribute('class', 'img_nota'); 
				obj.setAttribute('className', 'img_nota'); 
				obj.style.width = perfect_width+'px';
				}
			}
				
		// On affiche l'image
		img.style.display='inline';
		//alert(img.style.display);
		}
	else 
		{
		img.style.display='inline'
		}
	next_img = img.nextSibling;
	if(next_img.nodeName == 'IMG' && next_img!=img)
		{
		next_img.style.display='none'
		}
	else if(next_img!=img)
		{
		next_img = next_img.nextSibling;
		next_img.style.display='none'
		}
	}
	
function onerrorimgonforum(img)
	{
	next_img = img.nextSibling;
	if(next_img.nodeName == 'IMG')
		{
		next_img.src='/img/nophoto.gif';
		}
	else
		{
		next_img = next_img.nextSibling;
		next_img.src='/img/nophoto.gif';
		}
	}

differeget_array = new Array;
function differeget(fichier, div, uniqid)
	{
	// uniqid sert a ne pas se melanger des les timer
	clearTimeout(differeget_array[uniqid]);
	
	gebi(div).innerHTML = ' - <i>Recherche ...</i>';
	differeget_array[uniqid] = setTimeout("gebi('"+div+"').innerHTML = file('"+fichier+"')", 1000);
	}


if(document.all && navigator.appVersion.indexOf("MSIE 6") != -1)
	{
	window.attachEvent("onload", correctPNG);
	}
	
	
/*********************************************************************
FONCTIONS DE GESTION DES FORMULAIRES 
*********************************************************************/
	
function getradiovalue(champ)
	{
	// Recupere la valeur d'un radio checkée
	if(champ)
		{
		nb_champs = champ.length;
		post = "";
		for(a=0;a<nb_champs;a++)
			{
			if(champ[a].type == "radio" && champ[a].checked)
				return(champ[a].value)
			}
		}
	return(0);
	}
	
function gestioncochecheckbox(formulaire_obj, champ_name, etat)
	{
	// champ_name doit etre sous la forme "variable[xx]".
	// Passe tous les variable[] en l'inverse d'"etat" et variable[xx] en "etat"
	if(formulaire_obj)
		{
		nb_elem = formulaire_obj.elements.length;
		//alert(nb_elem);
		txt = '';
		rech_champ = new Array();
		rech_champ = champ_name.split('[');
		for(a=0;a<nb_elem;a++)
			{
			obj = formulaire_obj.elements[a];
			obj_name = new Array();
			obj_name = obj.name.split('[');
			
			txt += obj.name;
			
			if(obj.name == champ_name)
				{
				txt += ' --> Find !'
				if(obj.checked && (etat == 0 || etat == ''))
					obj.checked = false;
				else if(!obj.checked && (etat == 1 || etat == ''))
					obj.checked = true;
				}
			else if(obj_name[0] == rech_champ[0] && etat != '')
				{
				txt += ' --> Other !'
				if(obj.checked && etat == 1)
					obj.checked = false;
				else if(!obj.checked && etat == 0)
					obj.checked = true;
				}
			txt += '\n';
			}
		//alert(txt);
		}
	}
	
function sendform(formulaire, destination, fichier)
	{
	// ENVOI LES FORMULAIRES EN AJAX
	//alert(formulaire.innerHTML);
	window.status='Formulaire sur les rails'
	nb_champs = formulaire.elements.length;
	
	post = "";
	for(a=0;a<nb_champs;a++)
		{
		if(((formulaire.elements[a].type == "checkbox" || formulaire.elements[a].type == "radio") && formulaire.elements[a].checked) || (formulaire.elements[a].type != "checkbox" && formulaire.elements[a].type != "radio"))
			{
			valeur = encodeURI(formulaire.elements[a].value);
			//alert(valeur);
			post += encodeURI(formulaire.elements[a].name)+"="+valeur+'&';
			}
		}
	//alert(post);
	
	window.status='Formulaire envoyé'
	fileindiv(fichier, destination, 1, post);
	}
	
function stripslashes (str) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +      fixed by: Mick@el
    // +   improved by: marrtins    // +   bugfixed by: Onno Marsman
    // +   improved by: rezna
    // +   input by: Rick Waldron
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: stripslashes('Kevin\'s code');    // *     returns 1: "Kevin's code"
    // *     example 2: stripslashes('Kevin\\\'s code');
    // *     returns 2: "Kevin\'s code"
    return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {            case '\\':
                return '\\';
            case '0':
                return '\0';
            case '':                return '';
            default:
                return n1;
        }
    });}

function striptags(strMod){
    if(arguments.length<3) strMod=strMod.replace(/<\/?(?!\!)[^>]*>/gi, '');
    else{
        var IsAllowed=arguments[1];
        var Specified=eval("["+arguments[2]+"]");
        if(IsAllowed){
            var strRegExp='</?(?!(' + Specified.join('|') + '))\b[^>]*>';
            strMod=strMod.replace(new RegExp(strRegExp, 'gi'), '');
        }else{
            var strRegExp='</?(' + Specified.join('|') + ')\b[^>]*>';
            strMod=strMod.replace(new RegExp(strRegExp, 'gi'), '');
        }
    }
    return strMod;
}

function print_r(obj) {
  win_print_r = window.open('about:blank', 'win_print_r');
  win_print_r.document.write('<html><body>');
  r_print_r(obj, win_print_r);
  win_print_r.document.write('</body></html>');
 }

 function r_print_r(theObj, win_print_r) {
  if(theObj.constructor == Array ||
   theObj.constructor == Object){
   if (win_print_r == null)
    win_print_r = window.open('about:blank', 'win_print_r');
   }
   for(var p in theObj){
    if(theObj[p].constructor == Array||
     theObj[p].constructor == Object){
     win_print_r.document.write("<li>["+p+"] =>"+typeof(theObj)+"</li>");
     win_print_r.document.write("<ul>")
     r_print_r(theObj[p], win_print_r);
     win_print_r.document.write("</ul>")
    } else {
     win_print_r.document.write("<li>["+p+"] =>"+theObj[p]+"</li>");
    }
   }
  win_print_r.document.write("</ul>")
 }
