function Controle() {
    for(i=0; i<document.forms[0].elements.length; ++i)
        if(document.forms[0].elements[i].value == "")  {
            alert("Tous les champs n'ont pas été remplis!");
            document.forms[0].elements[i].focus();
            return false;
        }
    return true;
}


function ChangeMessage(message,champ,classe)
{
    if(document.getElementById)
    {
        var elt = document.getElementById(champ);
        elt.innerHTML = message;
        elt.className = (classe) ? classe : null;
    }
}

function ajax_req(div,params,actionPage)
{
    var url = actionPage;
    var ajax = new Ajax.Updater
    (
        {success: div},
        url,{method: 'post', parameters: params}
    );
}

//blink

function cligno() {
    if(document.getElementById("blink").style.visibility != 'hidden'){
        document.getElementById("blink").style.visibility = 'hidden';
    }
    else{
        document.getElementById("blink").style.visibility = 'visible';
    }
}
var timer=setInterval("cligno()", 500);

// autres   popup_smileys

function popup_smileys()
{
    var width = 200;
    var height = 150;
    window.open('myspeach/smile.html', 'cp', 'resizable=yes, location=no, width='
        +width+', height='+height+', menubar=no, status=yes, scrollbars=yes, menubar=no');
}


// autres popup avatar

function popup_avatar()
{
    var width = 800;
    var height = 600;
    window.open('/pages_utiles/avatar.php', 'cp', 'resizable=yes, location=no, width='
        +width+', height='+height+', menubar=no, status=yes, scrollbars=yes, menubar=no');
}

		




// autres upload avatar

function popup_upavatar()
{
    var width = 600;
    var height = 150;
    window.open('./pages/membres_upav.php', 'cp', 'resizable=no, location=no, width='
        +width+', height='+height+', menubar=no, status=yes, scrollbars=no, menubar=no');
}
		

// autres PopupImage(img)			

function PopupImage(img) {
    titre="DAYD Image";
    w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');
    w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
    w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
    w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
    w.document.write("");
    w.document.write("</BODY></HTML>");
    w.document.close();
}

// autres

var TabAlpha=new Array();
TabAlpha.length=5;		// 5 images alpha A MODIFIER SI PLUS D'IMAGES
for (var alphaI=0;alphaI<TabAlpha.length;alphaI++) {
    TabAlpha[alphaI]=-1;
}
function ModifAlpha(no,alpha){
    if (document.images["img"+no]) {
        if (document.images["img"+no].filters) {
            TabAlpha[no]=alpha;
            if (tjstimer==0) {
                setTimeout("tjstimerAlpha()",30)
            }
        }
    }
}
var tjstimer=0;
function tjstimerAlpha() {
    var opacity=0;
    for (var alphaI=0;alphaI<TabAlpha.length;alphaI++) {
        if (TabAlpha[alphaI]!=-1) {
            opacity =TabAlpha[alphaI] - document.images["img"+alphaI].filters.alpha.opacity;
            if (opacity!=0) {
                tjstimer=1;
                document.images["img"+alphaI].filters.alpha.opacity+=Math.abs(opacity)/opacity * 5;
            } else {
                TabAlpha[alphaI]=-1
            }
        }
    }
    if (tjstimer==1) {
        setTimeout("tjstimerAlpha()",30);
    } else {
        tjstimer=0
    }
}


// autres function helpline(help)


function helpline(help) {
    document.post.helpbox.value = eval(help + "_help");
}
	
function eff(help) {
    document.post.helpbox.value = eval(help + "_help");
}
	
// Startup variables
var imageTag = false;
var theSelection = false;
	
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
	
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
    && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
    && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;
	
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
	
b_help = "Texte gras: [b]texte[/b] (alt+b)";
i_help = "Texte italique: [i]texte[/i] (alt+i)";
u_help = "Texte souligné: [u]texte[/u] (alt+u)";
q_help = "Citation: [cite]texte cité[/cite] (alt+q)";
ajou_help = "Ajouter le message et/ou l'image au forum";
texte_help = "Tapez votre texte ici!";
chem_help = "Chemin menant a votre image.";
exp_help = "Vous le faites expres?";
c_help = "Afficher du code: [code]code[/code] (alt+c)";
l_help = "Liste: [list]texte[/list] (alt+l)";
o_help = "Liste ordonnée: [list=]texte[/list] (alt+o)";
p_help = "Insérer une image: [img]http://image_url/[/img] (alt+p)";
w_help = "Insérer un lien: [url]http://url/[/url] ou [url=http://url/]Nom[/url] (alt+w)";
a_help = "Fermer toutes les balises BBCode ouvertes";
s_help = "Couleur du texte: [color=red]texte[/color] Astuce: #FF0000 fonctionne aussi";
f_help = "Taille du texte: [size=x-small]texte en petit[/size]";
	
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[cite]','[/cite]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]');
imageTag = false;
	
	
// Replacement for arrayname.length property
function getarraysize(thearray) {
    for (i = 0; i < thearray.length; i++) {
        if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
            return i;
    }
    return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
    thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
    thearraysize = getarraysize(thearray);
    retval = thearray[thearraysize - 1];
    delete thearray[thearraysize - 1];
    return retval;
}

function bbfontstyle(bbopen, bbclose) {
    var txtarea = document.post.reponse;

    if ((clientVer >= 4) && is_ie && is_win) {
        theSelection = document.selection.createRange().text;
        if (!theSelection) {
            txtarea.value += bbopen + bbclose;
            txtarea.focus();
            return;
        }
        document.selection.createRange().text = bbopen + theSelection + bbclose;
        txtarea.focus();
        return;
    }
    else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
    {
        mozWrap(txtarea, bbopen, bbclose);
        return;
    }
    else
    {
        txtarea.value += bbopen + bbclose;
        txtarea.focus();
    }
    storeCaret(txtarea);
}


function bbstyle(bbnumber) {
    var txtarea = document.post.reponse;

    donotinsert = false;
    theSelection = false;
    bblast = 0;

    if (bbnumber == -1) { // Close all open tags & default button names
        while (bbcode[0]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];
            buttext = eval('document.post.addbbcode' + butnumber + '.value');
            eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
        }
        imageTag = false; // All tags are closed including image tags :D
        txtarea.focus();
        return;
    }

    if ((clientVer >= 4) && is_ie && is_win)
    {
        theSelection = document.selection.createRange().text; // Get text selection
        if (theSelection) {
            // Add tags around selection
            document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
            txtarea.focus();
            theSelection = '';
            return;
        }
    }
    else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
    {
        mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
        return;
    }

    // Find last occurance of an open tag the same as the one just clicked
    for (i = 0; i < bbcode.length; i++) {
        if (bbcode[i] == bbnumber+1) {
            bblast = i;
            donotinsert = true;
        }
    }

    if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
        while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];
            buttext = eval('document.post.addbbcode' + butnumber + '.value');
            eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
            imageTag = false;
        }
        txtarea.focus();
        return;
    } else { // Open tags

        //	if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
        //		txtarea.value += bbtags[15];
        //		lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
        //		document.post.addbbcode14.value = "Img";	// Return button back to normal state
        //		imageTag = false;
        //	}

        // Open tag
        txtarea.value += bbtags[bbnumber];
        if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
        arraypush(bbcode,bbnumber+1);
        eval('document.post.addbbcode'+bbnumber+'.value += "*"');
        txtarea.focus();
        return;
    }
    storeCaret(txtarea);
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
    var selLength = txtarea.textLength;
    var selStart = txtarea.selectionStart;
    var selEnd = txtarea.selectionEnd;
    if (selEnd == 1 || selEnd == 2)
        selEnd = selLength;

    var s1 = (txtarea.value).substring(0,selStart);
    var s2 = (txtarea.value).substring(selStart, selEnd)
    var s3 = (txtarea.value).substring(selEnd, selLength);
    txtarea.value = s1 + open + s2 + close + s3;
    return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
    if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

// autres lupalu membres_perso

function lu(oui) {
    var src=document.images[oui].src;
    var yo =[oui];
    src=src.substring(src.lastIndexOf("/")+1);
    if (src=='green.gif') {
        document.images[oui].src='data/red.gif';
    }
    else{
        document.images[oui].src='data/green.gif';
    }
    var w=window.open("pages/luoupa.php?idlu="+yo,"popback","width=1, height=1, toolbars=no, scrollbars=no, menubars=no, status=no");
    w.document.close;
    w.blur();
}

// autres date et accueil

calendar = new Array();
for(i=0;i<12;i++) calendar[i] = new Array();

calendar[0][1] = "<blink><b>Bonne année!</b></blink>";
calendar[0][22] = "<blink><b>Bon annif Mam!</b></blink>";
calendar[0][31] = "Bon annif Jean-paul!"; // le mois est le mois - 1
calendar[1][14] = "<blink><b>Bonne fête les amoureux!</b></blink>";
calendar[2][13] = "<blink><b>Bon annif Marie!</b></blink>";
calendar[2][21] = "C'est le printemps!";
calendar[2][22] = "Les hirondelles ne font pas le printemps";
calendar[2][23] = "<blink><b>Bon annif Papounet!</b></blink>";
calendar[3][1] = "<blink><b>Bonne Fetes les Poissons!</b></blink>";
calendar[3][9] = "<blink><b>Bon Annif Flo!</b></blink>";
calendar[4][1] = "Bonne fete les mugets";
calendar[4][23] = "Bon Annif Cecile!";
calendar[5][16] = "Bon Annif <a href=\"index.php?page=mick\">Mick,mon frère!</a>";
calendar[4][1] = "Bonne fete les mugets";
calendar[9][2] = "<blink><b>Bon Annif Marc!</b></blink>";
calendar[9][3] = "<blink><b>Bon Annif Sky!</b></blink>";
calendar[9][13] = "<blink><b>Bon Annif Caro!</b></blink>";
calendar[9][15] = "<blink><b>Bon Annif Alice!</b></blink>";
calendar[10][4] = "<blink><b>C'est mon annif!</b></blink>";
calendar[10][10] = "<blink><b>Bon annif Eric!</b></blink>";
calendar[10][16] = "<blink><b>Bon annif Romain!</b></blink>";
calendar[10][18] = "<blink><b>Bon annif Orion!</b></blink>";
calendar[10][20] = "<blink><b>Bon annif Lili!</b></blink>";
calendar[10][23] = "<blink><b>Bon annif Denis!</b></blink>";
calendar[11][1] = "<blink><b>Bonne fete Florence!</b></blink>";
calendar[11][2] = "Qui mange un oeuf, mange un boeuf!";
calendar[11][3] = "Un veau averti en nomme deux!";
calendar[11][4] = "Pierre qui roule est a la masse!";
calendar[11][5] = "Pourquoi boire et conduire, alors que l'on peut fumer et planer?";
calendar[11][6] = "Tu t'es vu quand j'ai bu?";
calendar[11][7] = "Un veau tient mieux que deux tu l'auras";
calendar[11][8] = "Tant va la cruche a l'eau qu'a la fin elle se casse!";
calendar[11][9] = "Y en pas aujourd'hui, c'est la penurie.";
calendar[11][10] = "Quand le doigt montre le ciel, l'imbecile regarde le doigt.";



date = new Date();
m = date.getMonth();
d = date.getDate();
j = date.getDay();

var mois = new Array("janvier","fevrier","mars","avril","mai","juin","juillet", "aout", "septembre", "octobre", "novembre", "decembre");
var jour = new Array("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi");


// ------------------
// PrintDate
// ------------------

function PrintMDJ() {

    msg = String(calendar[m][d]);
    if(msg=="undefined") msg = "Faites l'amour pas la guerre...";
    document.write(msg);

}

// ------------------
// PrintDate
// ------------------

function time_of_day() {
    var time=date.getHours();
    time_statement=""
    if(time>=6 && time<8)
        time_statement="Déja levé?, "
    if(time>=8 && time<12)
        time_statement="Bonne matinée,"
    if(time>=12 && time<13)
        time_statement="Bon appétit, "
    if(time>=13 && time<17)
        time_statement="Bon après-midi, "
    if(time>=17 && time<22)
        time_statement="Bonsoir, "
    if(time>=22 || time<6)
        time_statement="Bonne nuit, "
}
time_of_day();
function PrintDate()
{
    document.write(time_statement+ " Nous sommes le " + jour[j] + " " + d + " " + mois[m]+"</b>");
}

// lien menu
function description(texte) {
    window.status = texte;
    return true;
}
function effaceetat() {
    window.status="";
}

// autres  ShowHide

var bck = null;

function ShowHide(id) {
    var itm = null;
   
    if (document.getElementById)
    {
        itm = document.getElementById(id);
    }
    else if (document.all)
    {
        itm = document.all[id];
    }
    else if (document.layers)
    {
        itm = document.layers[id];
    }

    if (!itm) return;

    if (document.getElementById(id)!= bck )
    {
        if (itm.style)
        {
            if (itm.style.display == "none")
            {
                if (bck!=null)
                {
                    bck.style.display = "none";
                }
                itm.style.display = "";
                bck = document.getElementById(id);
            }
            else
            {
                itm.style.display = "none";
            }
        }
    }
    else
    {
        itm.visibility = "show";
        bck.visibility = "hide";
        bck = document.getElementById(id);
    }
}

// fonction js_menu

function Js_Menu(id) {

    if (document.getElementById)
    {
        document.getElementById(id).style.display = "";

        var a_cacher = (id == 'sous_menu_p')? 'sous_menu_d':'sous_menu_p';

        document.getElementById(a_cacher).style.display = "none";
    }
}