var IB=new Object;
var posX=0;posY=0;
var xOffset=-260;yOffset=150;

fDomOffset = function( oObj, sProp )
{ 
 // oObj : [Object] - Objet dont on désire le positionnement 
 // sProp : [String] - Propriété désirée : offsetLeft - offsetTop 
 var iVal = 0; 
 // On boucle tant que l'on n'est pas à la racine du document 
 while (oObj && oObj.tagName != 'BODY') { 
  eval('iVal += oObj.' + sProp + ';');
  oObj = oObj.offsetParent; 
 } 
 return iVal; 
}  

fSwapSelect = function( sId ) 
{ 
 oObj = document.getElementById(sId); 

 Top_Element  = fDomOffset(oObj, 'offsetTop'); 
 Left_Element  = fDomOffset(oObj, 'offsetLeft'); 
 Largeur_Element  = oObj.offsetWidth; 
 Hauteur_Element  = oObj.offsetHeight; 
 oSelects = document.getElementsByTagName('SELECT'); 
 if (oSelects.length > 0) { 
  for (i = 0; i < oSelects.length; i++) { 
   oSlt = oSelects[i]; 
   Top_Select = fDomOffset(oSlt, 'offsetTop'); 
   Left_Select = fDomOffset(oSlt, 'offsetLeft'); 
   Largeur_Select = oSlt.offsetWidth; 
   Hauteur_Select = oSlt.offsetHeight; 
   isLeft = false; 
   if ((Left_Element > (Left_Select - Largeur_Element)) && (Left_Element < (Left_Select + Largeur_Select))) { 
    isLeft = true; 
   } 
   isTop = false; 
   if ((Top_Element > (Top_Select - Hauteur_Element)) && (Top_Element < (Top_Select + Hauteur_Select))) { 
    isTop = true; 
   } 
   if (isLeft && isTop) { 
    sVis = (oObj.style.visibility == 'hidden') ? 'visible' : 'hidden'; 
    if (oSlt.style.visibility != sVis) {oSlt.style.visibility = sVis;} 
   } else { 
    if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';} 
   } 
  } 
 } 
} 

function AffBulle(texte) 
{
	contenu="<TABLE border=0 cellspacing=0 cellpadding="+IB.NbPixel+"><TR bgcolor='"+IB.ColContour+"'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='"+IB.ColFond+"'><TR><TD><FONT size='-1' face='arial' color='"+IB.ColTexte+"'>"+texte+"</FONT></TD></TR></TABLE></TD></TR></TABLE>&nbsp;";

	var finalPosX=posX-xOffset;
	if (finalPosX<0) finalPosX=0;
	if (document.layers) 
	{
		document.layers["bulle"].document.write(contenu);
		document.layers["bulle"].document.close();
		document.layers["bulle"].top=posY+yOffset;
		document.layers["bulle"].left=finalPosX;
		document.layers["bulle"].visibility="show";
	}

	if (document.all) 
	{
		bulle.innerHTML=contenu;
		document.all["bulle"].style.top=posY+yOffset;
		document.all["bulle"].style.left=finalPosX;
		document.all["bulle"].style.visibility="visible";
	}
	else if (document.getElementById) {
		document.getElementById("bulle").innerHTML=contenu;
		document.getElementById("bulle").style.top=posY+yOffset;
		document.getElementById("bulle").style.left=finalPosX;
		document.getElementById("bulle").style.visibility="visible";
	}

	fSwapSelect('bulle')	
}

function getMousePos(e) 
{
	if (document.all) 
	{
		posX=event.x+document.body.scrollLeft; 
		posY=event.y+document.body.scrollTop;
	}
	else 
	{
		posX=e.pageX; 
		posY=e.pageY; 
	}
}


function HideBulle() 
{
	if (document.layers) 
	{
		document.layers["bulle"].visibility="hide";
	}

	if (document.all) 
	{
		document.all["bulle"].style.visibility="hidden";
	}
	else if (document.getElementById)
	{
		document.getElementById("bulle").style.visibility="hidden";
	}
	fSwapSelect('bulle')	
}

function InitBulle(ColTexte,ColFond,ColContour,NbPixel) 
{
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) 
	{
		window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	
	if (document.all) 
	{
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden;z-index:10'></DIV>");
		document.onmousemove=getMousePos;
	}
	else if (document.getElementById) 
	{
		document.onmousemove=getMousePos;
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
	}
}

function AffMenu(texte) 
{
	// Variables locales
	var menu = ""
	var i = 1
	var strClass=""
	var strLib=""
	var strLien=""
	var ColTexte = IB.ColTexte
	var ColFond = IB.ColFond
	var ColContour = IB.ColContour
	var NbPixel = IB.NbPixel

	//***********
			
	// Construction du tableau
	contenu='	     <TABLE border=0 cellspacing=0 cellpadding=0 style="border:1.5pt outset">'
	contenu=contenu + '		<TR bgcolor="#7F97AF">'
	contenu=contenu + '			<TD>'	
	contenu=contenu + '				<TABLE border="0" bgcolor="#7F97AF">'

	menu = GetCol(texte, i, "¤")

	while (menu != "")
	{
		contenu=contenu + '				<TR>'
		contenu=contenu + '					<TD'
		if (GetCol(texte, i+1, "¤")!="")
		{
			contenu=contenu + '					 style="border-bottom:1.5pt groove" '
		}	

		contenu=contenu + '						 onmouseover="this.style.background=\'#4F607F\'" onmouseout="this.style.background=\'#7F97AF\'">'

		strLib=GetCol(menu, 1, "")
		strLien=GetCol(menu, 2, "")

		contenu=contenu + '						<a id="menu'+i+'" name="menu'+i+'" href="' + strLien + '" style="text-decoration:none;color:#000000;font-family:arial">' + strLib + '</a>'

		contenu=contenu + '					</TD>'
		contenu=contenu + '				</TR>'

		i=i+1
		menu = GetCol(texte, i, "¤")
	}
	contenu=contenu + '				</TABLE>'
	contenu=contenu + '			</TD>'
	contenu=contenu + '		</TR>'
	contenu=contenu + ' </TABLE>'

	IB.ColTexte=""
	IB.ColFond=""
	IB.ColContour=""
	IB.NbPixel=0

	if (document.layers) 
	{
		document.layers["bulle"].document.write(contenu);
		document.layers["bulle"].document.close();
		document.layers["bulle"].top=posY;
		document.layers["bulle"].left=posX;
		document.layers["bulle"].visibility="show";
	}

	if (document.all) 
	{
		bulle.innerHTML=contenu;
		document.all["bulle"].style.top=posY;
		document.all["bulle"].style.left=posX;
		document.all["bulle"].style.visibility="visible";
	}
	else if (document.getElementById) {
		document.getElementById("bulle").innerHTML=contenu;
		document.getElementById("bulle").style.top=posY;
		document.getElementById("bulle").style.left=posX;
		document.getElementById("bulle").style.visibility="visible";
	}
	IB.ColTexte=ColTexte;
	IB.ColFond=ColFond;
	IB.ColContour=ColContour;
	IB.NbPixel=NbPixel;

}

function GetCol(strChaine, iCol, strSep)
{
	var j=1;	
	var strRetour=""

	if (strSep == "")
	{
		strSep = "#";
	}
	
	while (j<=iCol)
	{
		strRetour = strChaine.substring(0, strChaine.indexOf(strSep,0));
		if (strRetour=="" && strChaine!="")
		{
			if 	(j==iCol)
			{
				strRetour=strChaine;
			}
			else if (strChaine.indexOf(strSep,0)!=0)
			{
				strRetour=""
				j=iCol
				}	
		}

		if (j==iCol && strChaine.indexOf(strSep,0)==0)
		{
               // Le caractére suivant étant le séparateur, on a donc une chaîne vide à renvoyer
			strRetour="";
		}

		strChaine = strChaine.substring(strChaine.indexOf(strSep,0)+1,strChaine.length);

		j=j+1;
	}

	return strRetour;
}

	var AMOUNT = 1;
	var TIME = 1;
	var timer = null;

	function scrollIt_down(v){
		var direction=v?1:-1;
		var distance=AMOUNT*direction;
		window.Shoutbox.scrollBy(0,distance);
	}
	
	function down(v){
		if(timer) { clearInterval(timer); timer=null; }
		if(v)timer=setInterval("scrollIt_down(true)",TIME);
	}
	
	function scrollIt_up(v){
		var direction=v?1:-1;
		var distance=AMOUNT*direction;
		window.Shoutbox.scrollBy(0,-distance);
	}
	
	function up(v){
		if(timer) { clearInterval(timer); timer=null; }
		if(v)timer=setInterval("scrollIt_up(true)",TIME);
	}


	var AMOUNT2 = 1;
	var TIME2 = 1;
	var timer2 = null;

	function scrollIt_down2(v){
		var direction=v?1:-1;
		var distance=AMOUNT2*direction;
		window.Shoutbox2.scrollBy(0,distance);
	}
	
	function down2(v){
		if(timer2) { clearInterval(timer2); timer2=null; }
		if(v)timer2=setInterval("scrollIt_down2(true)",TIME2);
	}
	
	function scrollIt_up2(v){
		var direction=v?1:-1;
		var distance=AMOUNT2*direction;
		window.Shoutbox2.scrollBy(0,-distance);
	}
	
	function up2(v){
		if(timer2) { clearInterval(timer2); timer2=null; }
		if(v)timer2=setInterval("scrollIt_up2(true)",TIME2);
	}
	
	function chercher_char(champ){
var a = champ.value;
if (a.search(/"/)==-1)
{
return (true);
//alert("Le contenu des champs est : OK");
}
else{
alert("Pas de Guillemet. Utilisez << >>");
}
}

function outils(a,b,c){
if (c=='gras')
{
i++;
m=i;
var p="";
}
if (c=='br')
{
n++;
m=n;
var p="";
}
if (c=='italique')
{
j++;
m=j;
var p="";
}
if (c=='souligne')
{
l++;
m=l;
var p="";
}
if (c=='mail')
{
q++;
m=q;
if (m%2==1){
p = prompt("Saisir l'adresse e-mail","ici");
p=p+">";
}
}
if (c=='lien')
{
l++;
m=l;
if (m%2==1){
p = prompt("Saisir l'url à lier","http://www.");
p=p+">";
}
}

if (m%2==1){
document.formalaune.textealaune.value+=a+p;
}
else{
document.formalaune.textealaune.value+=b;
}
}

var choix_balise = new Array(20);
for(i=0;i<20;i++) { choix_balise[i] = false;}
var q=0;
var l=0;
function ajouter_balise(champ, ms1, ms2,x)
{
var tmpstr='';
var p='';

if (x==4){
q++;
m=q;
if (m%2==1){
p = prompt("Saisir l'adresse e-mail","ici");
p=p+">";
}
}
if (x==5){
l++;
m=l;
if (m%2==1){
p = prompt("Saisir l'url à lier","http://www.");
p=p+">";
}
}
choix_balise[x]=!choix_balise[x];
tmpstr=(choix_balise[x])?ms1+p:ms2;

if (document.selection)
{
champ.focus();
sel = document.selection.createRange();
sel.text = tmpstr;
}
else
if (champ.selectionStart || champ.selectionStart == '0')
{

champ.value = champ.value.substring(0, champ.selectionStart)
+ tmpstr
+ champ.value.substring(champ.selectionEnd, champ.value.length);
}
else
{
champ.value += tmpstr;
}
}


function test(champ) {
      if(champ.value!="") return true
      alert("Le champ " + champ.name + " est vide !")
      champ.focus()
      return false
   }

function Compter(Target, max, nomchamp)
			{
			   StrLen = Target.value.length
			   if (StrLen > max )
			   {
			      Target.value = Target.value.substring(0,max);
			      CharsLeft = max;
			   }
			   else
			   {
			      CharsLeft = StrLen;
			   }
			   nomchamp.value = max - CharsLeft;
			}

