// Surligne topics
var was;

function gotopage()
{
	location.href = page;
	return false;
}
function light(what,cat,id,p,own)
{
	where = what;
	if (!was) { was = where; }
	if (id!=0) { page = "viewtopic.php?cat="+cat+"&id="+id+"&p="+p+"&owntopic="+own; }
	else { page = "viewforum.php?cat="+cat; }

	if (where)
	{
		if(was!=where)
		{
			was.style.background='#CCCCCC';
			was = where;
		}
	}

	where.style.background='#D5D5D5';
	where.style.cursor='hand';

	return false;
}

// affiche ou cache les options sondage
if(document.layers){thisbrowser="NN4";}
if(document.all){thisbrowser="ie";}
if(!document.all && document.getElementById){thisbrowser="NN6";}

function showsondage(state)
{
	if(thisbrowser=="NN4")
	{
		if(state=="1")
		{
			document.options.style.posLeft = (document.body.clientWidth-400)/2;
			document.options.style.visibility='visible';
		}
		else
		{
			document.options.style.visibility='hidden';
		}
	}
	else if(thisbrowser=="ie")
	{
		if(state=="1")
		{
			document.all.options.style.posLeft = (document.body.clientWidth-400)/2;
			document.all.options.style.visibility='visible';
		}
		else
		{
			document.all.options.style.visibility='hidden';
		}
	}
	else if(thisbrowser=="NN6")
	{
		if(state=="1")
		{
			document.getElementById("options").style.posLeft = (document.body.clientWidth-400)/2;
			document.getElementById("options").style.visibility='visible';
		}
		else
		{
			document.getElementById("options").style.visibility='hidden';
		}
	}

}

// infotips
function getCoord(e)
{
	if(!e)
	{
		e = window.event;
	}
	if(!e||(typeof(e.pageX)!='number'&&typeof(e.clientX)!='number'))
	{
		return;
	}

	if( typeof(e.pageX)=='number')
	{
		var xcoord = e.pageX;
		var ycoord = e.pageY;
	}
	else
	{
		var xcoord = e.clientX;
		var ycoord = e.clientY;
		if(!((window.navigator.userAgent.indexOf('Opera')+1)||(window.ScriptEngine&&ScriptEngine().indexOf('InScript')+1)||window.navigator.vendor=='KDE'))
		{
			if(document.documentElement&&(document.documentElement.scrollTop||document.documentElement.scrollLeft))
			{
				xcoord += document.documentElement.scrollLeft; ycoord += document.documentElement.scrollTop;
			}
			else if(document.body&&(document.body.scrollTop||document.body.scrollLeft))
			{
				xcoord += document.body.scrollLeft; ycoord += document.body.scrollTop;
			}
		}
	}
	if(thisbrowser=="NN4")
	{
		document.topdeck.left = xcoord+5;
		document.topdeck.top = ycoord-25;
	}
	if(thisbrowser=="ie")
	{
		document.all.topdeck.style.left = xcoord+5+"px";
		document.all.topdeck.style.top = ycoord-25+"px";
	}
	if(thisbrowser=="NN6")
	{
		document.getElementById("topdeck").style.left = xcoord+5+"px";
		document.getElementById("topdeck").style.top = ycoord-25+"px";
	}
}

function pop(msg,bak) {
	var content ="<table width=\"5\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td class=\"infotips\">"+msg+"</td></tr></table>";
	if(thisbrowser=="NN4")
	{
		document.topdeck.innerHTML = content;
		timeoutShowInfo = window.setTimeout("document.topdeck.style.visibility='visible'",750);
	}
	if(thisbrowser=="ie")
	{
		document.all.topdeck.innerHTML = content;
		timeoutShowInfo = window.setTimeout("document.all.topdeck.style.visibility='visible'",750);
	}
	if(thisbrowser=="NN6")
	{
		document.getElementById("topdeck").innerHTML = content;
		timeoutShowInfo = window.setTimeout("document.getElementById('topdeck').style.visibility='visible'",750);
	}
}

function kill() 
{
	window.clearTimeout(timeoutShowInfo);

	if(thisbrowser=="NN4")
	{
		document.topdeck.style.visibility = "hidden";
	}
	if(thisbrowser=="ie")
	{
		document.all.topdeck.style.visibility = "hidden";
	}
	if(thisbrowser=="NN6")
	{
		document.getElementById("topdeck").style.visibility = "hidden";
	}
}

//popup

function popup(page,width,height)
{
	showPage = window.open(page,'remote', 'width='+width+',height='+height+',left=50,top=50,scrollbars=yes');
	if (showPage.opener == null){ showPage.opener = self; }
}

//Edit post
  function countInstances(open,closed) 
  { 
     var opening = document.hop.contenu.value.split(open); 
     var closing = document.hop.contenu.value.split(closed); 
     return opening.length + closing.length - 2; 
  } 

  function TAinsert(text1,text2) 
  { 
     var ta = document.getElementById('contenu'); 
       
     if (document.selection) { 
        var str = document.selection.createRange().text; 
        ta.focus(); 
        var sel = document.selection.createRange(); 
        if (text2!="") 
        { 
           if (str=="") 
           { 
              var instances = countInstances(text1,text2); 
              if (instances%2 != 0){ sel.text = sel.text + text2;} 
              else{ sel.text = sel.text + text1;} 
           } 
           else 
           { 
              sel.text = text1 + sel.text + text2; 
           } 
        } 
        else 
        { 
           sel.text = sel.text + text1; 
        } 
        
     } 
     else if (ta.selectionStart | ta.selectionStart == 0) 
     { 
        if (ta.selectionEnd > ta.value.length) { ta.selectionEnd = ta.value.length; } 
       
        var firstPos = ta.selectionStart; 
        var secondPos = ta.selectionEnd+text1.length; 
       
        ta.value=ta.value.slice(0,firstPos)+text1+ta.value.slice(firstPos); 
        ta.value=ta.value.slice(0,secondPos)+text2+ta.value.slice(secondPos); 
         
        ta.selectionStart = firstPos+text1.length; 
        ta.selectionEnd = secondPos; 
        ta.focus(); 
     } 
     else 
     { // Opera 
        var sel = document.hop.contenu; 
       
        var instances = countInstances(text1,text2); 
        if (instances%2 != 0 && text2 != ""){ sel.value = sel.value + text2; } 
        else{ sel.value = sel.value + text1; } 
     }  
  } 
function colors()
{
	clr=new Array('00','11','22','33','44','55','66','77','88','99','AA','BB','CC','DD','EE','FF');

	document.write('<table height="20" border="0" cellpadding="0" cellspacing="0">');
	document.write('<tr height="20">');

	var red=15;
	var green=0;
	var blue=0;

	for (green=0;green<16;green++) { document.write('<td width=\"2\"  bgcolor=\"#'+clr[red]+clr[green]+clr[blue]+'\" onclick=\"TAinsert(\'[c:'+clr[red]+clr[green]+clr[blue]+']\',\'[/c]\');\" onmouseover=\"pop(\'Mettre en couleur : [c:'+clr[red]+clr[green]+clr[blue]+']texte[/c]\');\" onmouseout=\"kill();\" onmousemove=\"getCoord(arguments[0]);\"><img src=\"./i/transcolor.gif\" alt=\"\" /></td>'); }

	green=15;
	blue=0;
	red=15;

	for (red=15;red>-1;red--) { document.write('<td width=\"2\"  bgcolor=\"#'+clr[red]+clr[green]+clr[blue]+'\" onclick=\"TAinsert(\'[c:'+clr[red]+clr[green]+clr[blue]+']\',\'[/c]\');\" onmouseover=\"pop(\'Mettre en couleur : [c:'+clr[red]+clr[green]+clr[blue]+']texte[/c]\');\" onmouseout=\"kill();\" onmousemove=\"getCoord(arguments[0]);\"><img src=\"./i/transcolor.gif\" alt=\"\" /></td>'); }

	green=15;
	blue=0;
	red=0;

	for (blue=0;blue<16;blue++) { document.write('<td width=\"2\"  bgcolor=\"#'+clr[red]+clr[green]+clr[blue]+'\" onclick=\"TAinsert(\'[c:'+clr[red]+clr[green]+clr[blue]+']\',\'[/c]\');\" onmouseover=\"pop(\'Mettre en couleur : [c:'+clr[red]+clr[green]+clr[blue]+']texte[/c]\');\" onmouseout=\"kill();\" onmousemove=\"getCoord(arguments[0]);\"><img src=\"./i/transcolor.gif\" alt=\"\" /></td>'); }

	green=15;
	blue=15;
	red=0;

	for (green=15;green>-1;green--) { document.write('<td width=\"2\"  bgcolor=\"#'+clr[red]+clr[green]+clr[blue]+'\" onclick=\"TAinsert(\'[c:'+clr[red]+clr[green]+clr[blue]+']\',\'[/c]\');\" onmouseover=\"pop(\'Mettre en couleur : [c:'+clr[red]+clr[green]+clr[blue]+']texte[/c]\');\" onmouseout=\"kill();\" onmousemove=\"getCoord(arguments[0]);\"><img src=\"./i/transcolor.gif\" alt=\"\" /></td>'); }

	green=0;
	blue=15;
	red=0;

	for (red=0;red<16;red++) { document.write('<td width=\"2\"  bgcolor=\"#'+clr[red]+clr[green]+clr[blue]+'\" onclick=\"TAinsert(\'[c:'+clr[red]+clr[green]+clr[blue]+']\',\'[/c]\');\" onmouseover=\"pop(\'Mettre en couleur : [c:'+clr[red]+clr[green]+clr[blue]+']texte[/c]\');\" onmouseout=\"kill();\" onmousemove=\"getCoord(arguments[0]);\"><img src=\"./i/transcolor.gif\" alt=\"\" /></td>'); }

	green=0;
	blue=15;
	red=15;

	for (blue=15;blue>-1;blue--) { document.write('<td width=\"2\"  bgcolor=\"#'+clr[red]+clr[green]+clr[blue]+'\" onclick=\"TAinsert(\'[c:'+clr[red]+clr[green]+clr[blue]+']\',\'[/c]\');\" onmouseover=\"pop(\'Mettre en couleur : [c:'+clr[red]+clr[green]+clr[blue]+']texte[/c]\');\" onmouseout=\"kill();\" onmousemove=\"getCoord(arguments[0]);\"><img src=\"./i/transcolor.gif\" alt=\"\" /></td>'); }

	document.write('</tr>');
	document.write('</table>');
}

function verif(f)
 
   {
      if (f.nom.value == ''){

      alert('\nLe champ Nom est obligatoire.\n\n' +' Indiquez votre nom.');

      f.nom.focus();

      return false;
   }

     else if (f.mail.value == ''){

      alert('\nLe champ E-mail est obligatoire.\n\n' + 

            'Indiquez votre adresse e-mail.')

      f.mail.focus();

      return false;
   }
   else if (f.mail.value.indexOf ('@',0)== -1 ||
    f.mail.value.indexOf ('.',0) == -1){

      alert('\nUne adresse e-mail contient obligatoirement ' + ' les signes \'@\' et \'.\'.\n\n' +' Entrez correctement votre adresse.');

          f.mail.focus();

      return false;

   }

 else if(f.commentaire.value==''){
          alert('Entrer un Commentaire');
          f.commentaire.focus();
		  return false
      }
   
      
       
   else
      f.submit();

  }
 
 


