// Sortie d'une frame si capture d'un autre site
if (window!=top) {top.location=window.location;}

// Script pour faire apparaitre/disparaitre des blocs div
function HideChamps(champ){
	var Pdiv = document.getElementById(champ + '_hidden');
	Pdiv.className = (Pdiv.className == champ + '_hidden')? champ : champ + '_hidden';
}

function afficheId(baliseId)
  {
  if (document.getElementById && document.getElementById(baliseId) != null)
    {
    document.getElementById(baliseId).style.visibility='visible';
    document.getElementById(baliseId).style.display='block';
    }
  }

function cacheId(baliseId)
  {
  if (document.getElementById && document.getElementById(baliseId) != null)
    {
    document.getElementById(baliseId).style.visibility='hidden';
    document.getElementById(baliseId).style.display='none';
    }
  }

// Script pour le menu
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

// fonctions pour le formulaire de login
function setFocus()
{
    document.implogin.imapuser.focus();
}
function submit_user()
{
    if (document.login.login.value == "") {
        alert('Veuillez entrer votre nom de connexion');
        document.login.login.focus();
        return false;
    } else if (document.login.password.value == "") {
        alert('Veuillez entrer votre mot de passe');
        document.login.passwword.focus();
        return false;
    } else {
        return true;
    }
}
function submit_login()
{
    if (document.implogin.imapuser.value == "") {
        alert('Veuillez entrer votre nom de connexion');
        document.implogin.imapuser.focus();
        return false;
    } else if (document.implogin.pass.value == "") {
        alert('Veuillez entrer votre mot de passe');
        document.implogin.pass.focus();
        return false;
    } else {
        return true;
    }
}
// fonction pour le comptage des formulaires
function compter(f) {
	var max=500;	// 500 caractères maximum
	var txt=f.article.value;
	var nb=txt.length;
	if (nb>max) { 
		alert("Pas plus de "+max+" caractères dans ce champ");
		f.article.value=txt.substring(0,max);
		nb=max;
	}
	f.nbcar.value=nb;
}
function compter2(f) {
	var maxx=100;	// 100 caractères maximum
	var txtt=f.titre.value;
	var nbb=txtt.length;
	if (nbb>maxx) { 
		alert("Pas plus de "+maxx+" caractères dans ce champ");
		f.titre.value=txtt.substring(0,maxx);
		nbb=maxx;
	}
	f.nbcar2.value=nbb;
}


// fonction pour la gestion du bbcode
//function bbcode(code)
//{
//window.document.commentaire.textarea.value += '' + code + '';
//}
function bbcode(area,bbdebut,bbfin)
{
var input = window.document.getElementById(area);
input.focus();
/* pour IE (toujous un cas appar lui )*/
if(typeof document.selection != 'undefined')
{
var range = document.selection.createRange();
var insText = range.text;
range.text = bbdebut + insText + bbfin;
range = document.selection.createRange();
if (insText.length == 0)
{
range.move('character', -bbfin.length);
}
else
{
range.moveStart('character', bbdebut.length + insText.length + bbfin.length);
}
range.select();
}
/* pour les navigateurs plus récents que IE comme Firefox... */
else if(typeof input.selectionStart != 'undefined')
{
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
input.value = input.value.substr(0, start) + bbdebut + insText + bbfin + input.value.substr(end);
var pos;
if (insText.length == 0)
{
pos = start + bbdebut.length;
}
else
{
pos = start + bbdebut.length + insText.length + bbfin.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
}
/* pour les autres navigateurs comme Netscape... */
else
{
var pos;
var re = new RegExp('^[0-9]{0,3}$');
while(!re.test(pos))
{
pos = prompt("insertion (0.." + input.value.length + ";):", "0");
}
if(pos > input.value.length)
{
pos = input.value.length;
}
var insText = prompt("Veuillez taper le texte");
input.value = input.value.substr(0, pos) + bbdebut + insText + bbfin + input.value.substr(pos);
}
}
function smilies(area, img)
{
window.document.getElementById(area).value += '' + img + '';
} 

/*
if (window.document.captureEvents != null) {
    window.document.captureEvents(Event.KEYPRESS);
    window.document.onkeypress = enter_key_trap;
}

// compter les caracteres dans un champ. Servira dasn la page d'admin
<HTML>
<HEAD>
<TITLE>Tout JavaScript.com - Compteur de caractères</TITLE>
<SCRIPT LANGUAGE="JavaScript">
//D'autres scripts sur http://www.toutjavascript.com
//Si vous utilisez ce script, merci de m'avertir !

function timer() {
	compter(document.forms["form1"]);
	setTimeout("timer()",100);
}

</SCRIPT>
</HEAD>

<BODY bgcolor="white" text="#FAFAFF" alink="#000066" link="#000066" vlink="#000066" onload="setTimeout('timer()',100)">
<FONT FACE="Arial" SIZE='-1' COLOR="navy">
<CENTER><B><BIG>Compte le nombre de caractères dans une zone de texte</B></BIG></CENTER>
Compatible IE4+ et NS4+<BR>
<FORM name="form1">
Votre texte :<TEXTAREA name="zone" rows=4 cols="40" onkeypress="compter(this.form)"></TEXTAREA><BR>
Nombre de caractères : <INPUT type="text" name="nbcar" size=3>
</FORM>
<BR><BR>
Le calcul se fait à chaque frappe d'un caractère. Les touches SUPPR et BACKSPACE ne sont pas reconnues, un timer effectue le calcul régulièrement.




<BR><BR><BR><BR><BR><BR><BR>

<BR>
<CENTER><A href="http://www.toutjavascript.com"><FONT size="1" face="arial" color="#CCCCFF">Tout JavaScript.com</FONT></A></CENTER>

</BODY></HTML>

<!-- Script développé par Olivier Hondermarck  -->
<!-- http://www.toutjavascript.com             -->


// page de favoris !!!!
<A HREF="#" onClick="HomePage(this);return(false);"><font color="white"><b><u>Faire de Ratiatum votre page de démarrage</u></b></font></A>

<script language="JavaScript" type="text/JavaScript">
function HomePage(obj)
	{
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage('http://www.ratiatum.com/');
	}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function formHandler(form) {
var windowprops = "location=no, scrollbars=yes,menubars=yes,toolbars=yes, resizable=yes";

var URL = form.site.options[form.site.selectedIndex].value;
popup = window.open(URL,"MenuPopup",windowprops);
}


-->
</SCRIPT>


// un aurtre qui devrait marcher sous IE et firefox
<script>
function addBookmarkForBrowser() {
  if (document.all)
  {
    window.external.AddFavorite(document.location.href, document.title);
  } else {
    var ea = document.createEvent("MouseEvents");
    ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
    var eb = document.getElementsByTagName("head")[0];
    eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
    eb.dispatchEvent(ea);
  }
}
</script>

<a href="javascript:addBookmarkForBrowser();">Add to Favorites</a>
*/