// JavaScript Document

String.prototype.br2nl= function()
{
	var ch = this;
	ch = ch.split('<\/br>').join('\r\n');
	ch = ch.split('<br>').join('\r\n');
	ch = ch.split('<BR>').join('\r\n');
	return ch;
}

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

function wpOcF()
{
		
	if (window.XMLHttpRequest)                 //  Objet de la fenêtre courant
	{ 
		return new XMLHttpRequest();     //  Firefox, Safari, ...
	} 
	else 
	   if (window.ActiveXObject)                    //  Version Active
	   {
		  return new ActiveXObject("Microsoft.XMLHTTP");   // Internet Explorer 
	   }
		
}; // wpOcF

function wpECz(str, chars) 
{
	str = str.toString();
	if (str)
	{
	    return wphnS(wpjMc(str, chars), chars);
	}
	else
	{
		return "";
	}
}

function wphnS(str, chars) 
{
	str = str.toString();
	if (str)
	{
		chars = chars || "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}
	else
	{
		return "";
	}
}

function wpjMc(str, chars) 
{
	str = str.toString();
	if (str)
	{
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
	else
	{
		return "";
	}
	
}

function wpWWB(ch, length, wpmUc)
{
	var i =0;
	var c = 0;
	var wpcsK = "";
	if (!wpmUc)
	{
		var wpmUc = '...';
	}
    length = length || 30;
	length = length - wpmUc.length;
	
//    return ch.length > length ? ch.slice(0, length - wpmUc.length) + wpmUc : String(ch);

	if (ch.length <= length)
	{
		return ch;
	}
	else
	{
		c = 0;
		while ((ch.length>0) && (c< length))
		{
			if (c < length)
			{
				if (ch.substr(0,1)!='&')
				{
					wpcsK+=ch.substr(0,1);
					ch = ch.substr(1,ch.length-1);
				}
				else
				{//il y a un &...;
					wpcsK+=ch.substr(0,ch.indexOf(';'));
					ch = ch.substr(ch.indexOf(';')+1);
				}
							  
	//		wpBGs = tx.substring(tx.indexOf('<AddressStrPerso2>')+17,tx.indexOf('</AddressStrPerso2>'));
				c++;
			}
		}
		if (ch.length > 0)
		{
			wpcsK += wpmUc;
		}
		return wpcsK;	
	}
} // wpWWB

function NavTo(What, Key, Key2, KeyName)
{ // Remonte récursivement jusqu'au parent et exécute le NavTo racine.

	var p = parent;
	var i = 0;
	while(String(p.window.location).indexOf("index.php",0)<0 && i < 10)
	{
		p = p.parent;
		i++;
	}
	// p est positionné sur index.
	p.NavTo(What, Key, Key2, KeyName);

} // NavTo(What, Key)



function wpvzy(KeyWriteTo)
{ // Remonte récursivement jusqu'au parent et exécute le SendMsg racine.
	var p = parent;
	var i = 0;
	while(String(p.window.location).indexOf("index.php",0)<0 && i < 10)
	{
		p = p.parent;
		i++;
	}
	// p est positionné sur index
	p.wpvzy(KeyWriteTo);
}

function wpTIG()
{
	var p = parent;
	var i = 0;
	while(String(p.window.location).indexOf("index.php",0)<0 && i < 10)
	{
		p = p.parent;
		i++;
	}
	p.scrollTo(0,0);	
} // wpTIG()

function wpZpG()
{
	var p = parent;
	var i = 0;
	while(String(p.window.location).indexOf("index.php",0)<0 && i < 10)
	{
		p = p.parent;
		i++;
	}
	p.$("divMenuSub_Messages").style.display="none";
	p.$("iframeSearch").style.display="none";
	p.$("divRegister").style.display="none";
	p.frames['iframeCenter'].location.href="ContactAdmin.php";
	p.$("iframeCenter").style.display="block";
} // wpTIG()


function wpNTg(obj) {
//http://www.quirksmode.org/js/findpos.html
// renvoie la position absolue d'un objet.
	var wpMJB = curtop = 0;
	if (obj)
	{
		if (obj.offsetParent)
		{
			do
			{
				wpMJB += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
			while (obj = obj.offsetParent);
		}
	}
	return [wpMJB,curtop];
} // wpNTg

/*
function WapinReload()
{ // Remonte récursivement jusqu'au parent et exécute location.reload() ;

	var p = parent;
	var i = 0;
	while(String(p.window.location).indexOf("index.php",0)<0 && i < 10)
	{
		p = p.parent;
		i++;
	}
	// p est positionné sur index.
	p.window.location.reload(true);

} // WapinReload
*/

