/*----------------------------------------------------GENERAL----------------------------------------------------------*/
function a(a) {return document.getElementById(a);}
function static_lexode() {return '';}
function position_ad(t,p) {
        if(document.getElementById(p) != null)
        {
                var preload = document.getElementById(t);
                var tag = document.getElementById(p);
                tag.appendChild(preload);
                preload.style.display = '';
        }
}
function canAjax() {
    if(window.XMLHttpRequest || window.ActiveXObject) return true;
    return false;
}

function isLoading(status) {
    if (a('load')) a('load').style.visibility=status?'visible':'hidden';
}

function bigPhoto(id)
{
    if(a('big_' + id).style.display == 'none')
    {
        a('big_' + id).style.display = 'block';
    }
    else
    {
        a('big_' + id).style.display = 'none';
    }
}

function xmlGetObject() {
    xmlo=null;
    if (window.XMLHttpRequest) {// FF
        xmlo = new XMLHttpRequest();
    } else if(window.ActiveXObject) {// IE
        xmlo = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    }
    return xmlo;
}

function xmlGet(eltid,script) {
    var xhro = xmlGetObject(); //création de l'obket xmlhttp
    if (xhro==null) return; //si impossible, on sort
    isLoading(true);
    xhro.open("GET", script, true);
    xhro.onreadystatechange = function() {
        if(xhro.readyState == 4) {
            eltid.innerHTML=(xhro.responseText);
            isLoading(false);
        }
    }
    xhro.send(null);
}
// la même avec perso du txt wait
function xmlGetWithWaitMsg(eltid,script,msg) {
    xmlGet(eltid,script);
}
// le meme avec une callback func
function xmlGetWithFunc(eltid,script,func) {
    var xhro = xmlGetObject(); //création de l'obket xmlhttp
    if (xhro==null) return; //si impossible, on sort
    isLoading(true);
    xhro.open("GET", script, true);
    xhro.onreadystatechange = function() {
        if(xhro.readyState == 4) {
            eltid.innerHTML=(xhro.responseText);
            isLoading(false);
            func();
        }
    }
    xhro.send(null);
}
function xmlPost(eltid,script,postdata) {
    var xhro = xmlGetObject();
    if (xhro==null) return;
    isLoading(true);
    xhro.open("POST", script, true);
    xhro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhro.send(postdata);
    xhro.onreadystatechange = function() {
        if(xhro.readyState == 4) {
            eltid.innerHTML=(xhro.responseText);
            isLoading(false);
        }
    }
}


function swap(el) {
    if(a(el).style.display=='block' || a(el).style.display=='') a(el).style.display='none';
    else a(el).style.display='block';
}

function removeAllChildren(elt) {
    while(elt.hasChildNodes()) elt.removeChild(elt.firstChild);
}

function openWindow(url,w,h) {
     var fenetre;
     if (fenetre==null || fenetre.closed) {
         var width=w;
         var height=h;
         var left=window.screen.width/2-(width/2);
         var top=window.screen.height/2-(height/2);
         fenetre=window.open(url,'_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width='+width+'px, height='+height+'px,left='+left+'px, top='+top+'px');
     } else {
         fenetre.focus();
     }
}

function Messagerie_newMsg(ref) {
    writePan=window.open('http://www.lexode.com/messagerie/ecrire.php'+((ref==''||ref==undefined)?'':'?ref='+ref),'ecrire','height=480,width=640,resizable=yes,scrollbars=yes,titlebar=no,toolbar=no,menubar=no,directories=no,top=50,left=50');
}











//NOTES
function setNote(s,e,n,img,imgb) {
    xmlGetNote(a('notes'+s+'-'+e),a('moy_notes'+s+'-'+e),'/inc/ajax/setNote.php?s='+s+'&e='+e+'&n='+n+'&img='+img+'&imgb='+imgb);
}

function xmlGetNote(eltid,eltid2,script) {
    var xhro = xmlGetObject(); //création de l'obket xmlhttp
    if (xhro==null) return; //si impossible, on sort
    isLoading(true);
    xhro.open("GET", script, true);
    xhro.onreadystatechange = function() {
        if(xhro.readyState == 4) {
            isLoading(false);
            data=xhro.responseText.split('----------');

            eltid.innerHTML=data[0];
            eltid2.innerHTML=data[1];
        } else {
            eltid.innerHTML='<img src="'+static_lexode()+'/style/loader.gif" alt="Loader" />';
        }
    }
    xhro.send(null);
}

noteMsg = new Array("Attribuer une note","Mauvais","Moyen","Assez bien","Bien","Très bien !");

function setStars(rub,nb,id,img,imgb) {
    for(i=1;i<=5;i++) {
        if(i<=nb) {
            a('star'+rub+'-'+i+'-'+id).src=static_lexode()+'/images/'+img;
        } else {
            a('star'+rub+'-'+i+'-'+id).src=static_lexode()+'/images/'+imgb;
        }
    }
    if (a('notes_infos'+rub+'-'+id)) a('notes_infos'+rub+'-'+id).innerHTML=noteMsg[nb];
}

function cleanStars(rub,nb,id,img,imgb) {
    for(i=1;i<=5;i++) {
        if(i<=nb) {
            a('star'+rub+'-'+i+'-'+id).src=static_lexode()+'/images/'+img;
        } else {
            a('star'+rub+'-'+i+'-'+id).src=static_lexode()+'/images/'+imgb;
        }
    }
    if (a('notes_infos'+rub+'-'+id)) a('notes_infos'+rub+'-'+id).innerHTML=noteMsg[0];
}



















//MAIL TO FRIEND
function mailfriend(url) {
    openWindow('/inc/mailfriend.php?aze='+url,500,450);
}
function mail2friend(section,elt,url,check) {
    openWindow('/inc/mail2friend.php?section='+section+'&elt='+elt+'&url='+URLencode(url)+'&check='+check,500,450);
}

//COMMENTAIRES
function comments(s,e,uri,dbt) {
    xmlGet(a('comments'), '/inc/ajax/comments.php?s='+s+'&e='+e+'&uri='+uri+'&dbt='+dbt);
}
function delcom(id,h,s,e,uri,dbt) {
    var xhro = xmlGetObject(); //création de l'obket xmlhttp
    if (xhro==null) return; //si impossible, on sort
    isLoading(true);

    script='/inc/ajax/delcom.php?id='+id+'&h='+h;
    xhro.open("GET", script, true);
    xhro.onreadystatechange = function() {
        if(xhro.readyState == 4) {
            isLoading(false);
            //a('footer').innerHTML=xhro.responseText;
            comments(s,e,uri,dbt);
        }
    }
    xhro.send(null);
}
function warncom(id,h) {
    xmlGet(a('trashbox'),'/inc/ajax/warncom.php?id='+id+'&h='+h);
    a('warncom'+id).src=static_lexode()+'/style/icones/warn_check.gif';
}
/*--------------------------------------------------- KESKIDI----------------------------------------------------------*/
function keskidi_suivi(u,art,h) {
    xmlGet(a(u), '/inc/ajax/keskidi_suivi.php?artist='+art+'&h='+h);
}

/*----------------------------------------------GALERIE - WALLPAPERS---------------------------------------------------*/


var currentimg=null;
function swapGalerieImage(idimg,uri,type) {
    if(currentimg != idimg) {
        currentimg=idimg;
        isLoading(true);
        url='/inc/ajax/swapGalerieImage.php?id='+idimg+'&link='+uri+'&t='+type+'&uniq='+Math.random();
        var xhro = xmlGetObject(); //création de l'obket xmlhttp
        if (xhro==null) return; //si impossible, on sort
        isLoading(true);
        xhro.open("GET", url, true);
        xhro.onreadystatechange = function() {
            if(xhro.readyState == 4) {
                eval(xhro.responseText);
                isLoading(false);
            }
        }
        xhro.send(null);
        isLoading(false);
        comments('galerie',idimg,uri+'?i='+idimg,0);
    }
}
/*----------------------------------------------------CINE----------------------------------------------------------*/
function loadSelectMois(annee) {
    xmlGet(a('selectMois'),"/inc/ajax/cine_select_sorties.php?annee="+annee);
}


/*----------------------------------------------------SONDAGES---------------------------------------------------------*/
function updateSondNbRep(nbrep) {
    xmlGet(a('reps'),"/inc/ajax/sondage_rep.php?nbrep="+nbrep);
}
function updateSondNbRepDom(nbrep) {
    var elem = a('putfieldshere');
    while(elem.hasChildNodes()) elem.removeChild(elem.firstChild);
    for(i=1;i<=nbrep;i++) {
        var tr = document.createElement('tr');
        var th=document.createElement('th');
        th.innerHTML ='Réponse '+i;
        tr.appendChild(th)
        var td=document.createElement('td');
        var input=document.createElement('input');
        input.className='ichamp';
        input.name='rep_'+i;
        input.type='text';
        input.style.width='100%';
        td.appendChild(input);
        tr.appendChild(td);
        elem.appendChild(tr);
    }
}
/*-------------------------------------------------------3B------------------------------------------------------------*/
function change3BImage(src,id) {
    a('bigImg').src=src;
    a('idphoto3b').value=id;
    a('warnphoto').src=static_lexode()+'/style/icones/warn.gif';
}
function change3BImagePrivate(img) {
    a('bigImg').innerHTML='<img src="'+img+'" alt="Photo privée" />';
}
function supervote(id) {
    openWindow('/3b/supervote.php?idm='+id,400,200);
}
function flash3B(id,hash) {
    xmlGet(a('flash'),"/inc/ajax/flash3b.php?id="+id+"&h="+hash+"&aze="+Math.random());
}
function swap3b(uid,url,i,p) {
    a('big').innerHTML = 'Chargement en cours';
    xmlGet(a('big'),"/inc/ajax/top3b.php?uid="+uid+'&url='+url+'&i='+i+'&p='+p);
}
function warn3bPhoto(h) {
    id=a('idphoto3b').value;
    xmlGet(a('trashbox'),'/inc/ajax/3b_photo_warn.php?id='+id+'&h='+h);
    a('warnphoto').src=static_lexode()+'/style/icones/warn_check.gif';
}
function del3bPhoto(id,h) {
    xmlGet(a('photo_'+id), '/inc/ajax/3b_del_photo.php?id='+id+'&h='+h);
}
/*-------------------------------------------------------FAV------------------------------------------------------------*/
function fav(u,w,i,h) {
    xmlGet(a(u), '/inc/ajax/favoris.php?t='+w+'&i='+i+'&h='+h);
}
function fav(u,w,i,h,z) {
    xmlGet(a(u), '/inc/ajax/favoris.php?t='+w+'&i='+i+'&h='+h+'&z='+z);
}

function showFav(s) {
    if(a('favbox').style.display=='block') {
        a('favbox').style.display='none';
        fuckPubz(false);
    } else {
        xmlGet(a('favbox'), '/inc/ajax/favbox.php?s='+s);
        a('favbox').style.display='block';
        fuckPubz(true);
    }
}
function delFav(u,w,i,h) {
    xmlGet(a(u), '/inc/ajax/favoridel.php?t='+w+'&i='+i+'&h='+h);
}


/*---- HELPBOX----*/
function helpBox(s,u) {
    xmlGet(a('helpbox'),'/inc/ajax/help.php?s='+s+'&u='+u);
    fuckPubz(true);
    a('helpbox').style.display='block';
}
function closeHelp() {
    a('helpbox').style.display='none';
    fuckPubz(false);
    while(a('helpbox').hasChildren) {
        a('helpbox').removeChild(a('helpbox').firstChild);
    }
}


function html_special_chars(str) {
    var encoded = "";
    for (var i = 0; i < str.length; i++ ) {
        var ch = str.charAt(i);
        if (ch =="<") encoded += "&lt;";
        else if (ch == ">") encoded += "&gt;";
        else if (ch =='"') encoded += "&quote;";
        else encoded += ch;
    }
    return encoded;
}
function URLencode(plaintext)
{
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" + // Numeric
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
        "abcdefghijklmnopqrstuvwxyz" +
        "-_.!~*'()"; // RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";

    var encod = ['%80','%82','%83','%84','%85','%86','%87','%88','%89','%8A',
    '%8B','%8C','%8E','%91','%92','%93','%94','%95','%96','%97','%98','%99',
    '%9A','%9B','%9C','%9E','%9F',
    '%A9'];
    var encod2 = encod.join('|');

    var encoded = "";

    for (var i = 0; i < plaintext.length; i++ ) {
        var ch = plaintext.charAt(i);
        // espace x-www-urlencoded, pas %20
        if (ch == " ") encoded += "+";
        // safe
        else if (SAFECHARS.indexOf(ch) != -1) encoded += ch;
        // autres
        else {
            var charCode = ch.charCodeAt(0);
            // Caractères du 8859-15
            if(charCode == 8364)      encoded += "%80";
            else if(charCode == 8218) encoded += "%82";
            else if(charCode == 402)  encoded += "%83";
            else if(charCode == 8222) encoded += "%84";
            else if(charCode == 8230) encoded += "%85";
            else if(charCode == 8224) encoded += "%86";
            else if(charCode == 8225) encoded += "%87";
            else if(charCode == 710)  encoded += "%88";
            else if(charCode == 8240) encoded += "%89";
            else if(charCode == 352)  encoded += "%8A";
            else if(charCode == 8249) encoded += "%8B";
            else if(charCode == 338)  encoded += "%8C";
            else if(charCode == 381)  encoded += "%8E";
            else if(charCode == 8216) encoded += "%91";
            else if(charCode == 8217) encoded += "%92";
            else if(charCode == 8220) encoded += "%93";
            else if(charCode == 8221) encoded += "%94";
            else if(charCode == 8226) encoded += "%95";
            else if(charCode == 8211) encoded += "%96";
            else if(charCode == 8212) encoded += "%97";
            else if(charCode == 732)  encoded += "%98";
            else if(charCode == 8482) encoded += "%99";
            else if(charCode == 353)  encoded += "%9A";
            else if(charCode == 8250) encoded += "%9B";
            else if(charCode == 339)  encoded += "%9C";
            else if(charCode == 382)  encoded += "%9E";
            else if(charCode == 376)  encoded += "%9F";
            // UTF8 outside
            else if(charCode > 255) {
                // Debug pour ajouter des specs chars
                //alert(charCode);
                encoded += "+";
            }
            // 8859-1 / 8-bit
            else {
                encoded += "%";
                encoded += HEX.charAt((charCode >> 4) & 0xF);
                encoded += HEX.charAt(charCode & 0xF);
            }
        }
    }
    for(var i = 0; i < encod.length; i++) {
        encoded = encoded.replace(new RegExp('('+encod[i]+'){1,}'+'('+encod2+')','gi'), '$1+$2');
    }
    return encoded;
};
function bwgo(str) {
    if((str.indexOf(' ') == -1 || str.indexOf(' ') > 20) && str.length>20) {
        str = str.substring(0,20) + ' ' + str.substring(20,str.length);
    }
    return str;
}




function fuckPubz(iAmOk) {
    eltsToHide=new Array('object','embed','select');
    for(var k=0; k<eltsToHide.length; k++) {
        elt=eltsToHide[k];
        flash=document.getElementsByTagName(elt);
        if (flash.length>0) for(i=0;i<flash.length;i++) flash[i].style.visibility=(iAmOk)?'hidden':'';
    }
}




/*--------------------------------------------------- STYLE----------------------------------------------------------*/

function ajoutbold(chp_input) {
    demurl = prompt('Texte à mettre en gras','');
    if (demurl != null && demurl != '') {
        ajbold = '[b]'+demurl+'[/b]';
        place(ajbold,chp_input);
    }
}
function ajoutita(chp_input) {
    demurl = prompt('Texte à mettre en italique','');
    if (demurl != null && demurl != '') {
        ajita = '[i]'+demurl+'[/i]';
        place(ajita,chp_input);
    }
}
function ajoutimage(chp_input) {
    demimage = prompt('Adresse Internet de l\'image','http://');
    if (demimage != null && demimage != '' && demimage != 'http://') {
        ajimage = '[img]'+demimage+'[/img]';
        place(ajimage,chp_input);
    }
}
function ajouturl(chp_input) {
    var input = a(chp_input);
    input.focus();
    var prompt1 = 1;
    
    if(typeof document.selection != 'undefined') 
    {
        var range = document.selection.createRange();
        var insText = range.text;  
        if(range.text.length > 0)
        {
            prompt1 = 0;
            demtxt = range.text;
        }
    }
    else if(typeof input.selectionStart != 'undefined')
    {
        var start = input.selectionStart;
        var end = input.selectionEnd;
        if(end - start > 0)
        {
            prompt1 = 0;
            demtxt = input.value.substring(start, end);
        }
    }
    if(prompt1 > 0)
    {
        demtxt = prompt('Texte du lien','');
    }
    demurl = prompt('Adresse Internet','http://');
    if (demurl != null && demurl != '' && demurl != 'http://' && demtxt != null && demtxt != '') {
        ajurl = '[url='+demurl+']'+demtxt+'[/url]';
        place(ajurl,chp_input);
    }
}

function ajoutspoiler(chp_input) {
    
    var input = a(chp_input);
    input.focus();
    var prompt1 = 1;
    
    if(typeof document.selection != 'undefined') 
    {
        var range = document.selection.createRange();
        var insText = range.text;  
        if(range.text.length > 0)
        {
            prompt1 = 0;
            demtxt = range.text;
        }
    }
    else if(typeof input.selectionStart != 'undefined')
    {
        var start = input.selectionStart;
        var end = input.selectionEnd;
        if(end - start > 0)
        {
            prompt1 = 0;
            demtxt = input.value.substring(start, end);
        }
    }
    if(prompt1 > 0)
    {
        demtxt = prompt('Spoiler','');
    }
    
    if (demtxt != null && demtxt != '') {
        ajurl = '[spoiler]'+demtxt+'[/spoiler]';
        place(ajurl,chp_input);
    }
}

function spoil_fct(id)
{
    if(a('spoiler_'+id).style.display == 'none') 
    {
        a('spoiler_'+id).style.display = 'block';
        a('btn_'+id).innerHTML = '<span><a href="javascript:;" onclick="spoil_fct(\''+id+'\'); return false;">Spoiler (cliquez pour masquer)</a></span>';
    } 
    else 
    { 
        a('spoiler_'+id).style.display = 'none'; 
        a('btn_'+id).innerHTML = '<span><a href="javascript:;" onclick="spoil_fct(\''+id+'\'); return false;">Spoiler (cliquez pour afficher)<a/></span>';
    }
}

function ajoutfaute(chp_input) {
    var input = a(chp_input);
    input.focus();
    var prompt1 = 1;
    
    if(typeof document.selection != 'undefined') 
    {
        var range = document.selection.createRange();
        var insText = range.text;  
        if(range.text.length > 0)
        {
            prompt1 = 0;
            demtxt = range.text;
        }
    }
    else if(typeof input.selectionStart != 'undefined')
    {
        var start = input.selectionStart;
        var end = input.selectionEnd;
        if(end - start > 0)
        {
            prompt1 = 0;
            demtxt = input.value.substring(start, end);
        }
    }
    
    if (prompt1 == 0) {
        aj = '[faute]'+demtxt+'[/faute]';
        place(aj,chp_input);
    }
}


function ajoutemail(chp_input) {
    demmail = prompt('Adresse email','');
    if (demmail != null && demmail != '') {
        ajmail = '[mail]'+demmail+'[/mail]';
        place(ajmail,chp_input);
    }

}

function helptxt(help,input_help) {
    help_defaut = 'Utiliser ces boutons pour inserer du code.';

    help_bold = 'Mettre en gras [b]texte[/b]';
    help_ital = 'Mettre en italique [i]texte[/i]';
    help_img = 'Insérer une image [img]http://monimage.jpg[/img]';
    help_url = 'Insérer un lien texte [url=lien]Texte[/url]';
    help_email = 'Insérer un email [mail]login@mail.com[/mail]';
    help_smileys = 'Insérer un smiley';
    help_spoiler = 'Insérer un spoiler [spoiler]texte[/spoiler]';

    a(input_help).value = eval(help);
}
function place(chaine,chp_input) {
    var input = a(chp_input);
    input.focus();
    if(typeof document.selection != 'undefined') {/* pour l'Explorer Internet */
        var range = document.selection.createRange();
        var insText = range.text;
        range.text = chaine;
        /* Ajustement de la position du curseur */
        range = document.selection.createRange();
        if (insText.length == 0) {
            range.move('character', -repfin.length);
        } else {
            range.moveStart('character', repdeb.length + insText.length + repfin.length);
        }
        range.select();
    } else if(typeof input.selectionStart != 'undefined') {/* pour navigateurs plus recents base sur Gecko*/
        var start = input.selectionStart;
        var end = input.selectionEnd;
        var insText = input.value.substring(start, end);

        input.value = input.value.substr(0, start) + chaine + input.value.substr(end);

        /* Ajustement de la position du curseur */
        var pos;
        if (insText.length == 0) {
            pos = start + chaine.length;
        } else {
            pos = start + insText.length;
        }
        input.selectionStart = pos;
        input.selectionEnd = pos;
    }
}
function balise_simple(repdeb, repfin,chp_input) {
    var input = a(chp_input);
    input.focus();
    /* pour l'Explorer Internet */
    if(typeof document.selection != 'undefined') {
        /* Insertion du code de formatage */
        var range = document.selection.createRange();
        var insText = range.text;

        if(insText.length == 0) {
            switch (repdeb) {
                case '[b]' : {
                    ajoutbold(chp_input);
                    break;
                }
                case '[i]' : {
                    ajoutita(chp_input);
                    break;
                }
                case '[img]' : {
                    ajoutimage(chp_input);
                    break;
                }
                case '[mail]' : {
                    ajoutemail(chp_input);
                    break;
                }
            }
        } else {
            range.text = repdeb + insText + repfin;
            /* Ajustement de la position du curseur */
            range = document.selection.createRange();
            if (insText.length == 0) {
                range.move('character', -repfin.length);
            } else {
                range.moveStart('character', repdeb.length + insText.length + repfin.length);
            }
            range.select();
        }
    }
    /* pour navigateurs plus recents base sur Gecko*/
    else if(typeof input.selectionStart != 'undefined') {
        /* Insertion du code de formatage */
        var start = input.selectionStart;
        var end = input.selectionEnd;
        var insText = input.value.substring(start, end);
        if(insText.length == 0) {
            switch (repdeb) {
                case '[b]' : {
                    ajoutbold(chp_input);
                    break;
                }
                case '[i]' : {
                    ajoutita(chp_input);
                    break;
                }
                case '[img]' : {
                    ajoutimage(chp_input);
                    break;
                }
                case '[mail]' : {
                    ajoutemail(chp_input);
                    break;
                }
            }
        } else {
            input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);

            /* Ajustement de la position du curseur */
            var pos;
            if (insText.length == 0) {
                pos = start + repdeb.length;
            } else {
                pos = start + repdeb.length + insText.length + repfin.length;
            }
            input.selectionStart = pos;
            input.selectionEnd = pos;
        }
    }
    /* pour les autres navigateurs */
    else {
        switch (repdeb) {
            case '[b]' : {
                ajoutbold(chp_input);
                break;
            }
            case '[i]' : {
                ajoutita(chp_input);
                break;
            }
            case '[img]' : {
                ajoutimage(chp_input);
                break;
            }
            case '[mail]' : {
                ajoutemail(chp_input);
                break;
            }
        }
    }
}

function smileIt(elt,text) {
    place(text+' ',elt);
}



function report(section, id_elt, helt) {
    var obj = document.createElement('div');
    obj.innerHTML = '<h1 class="principal">Signaler un problème sur ce contenu</h1>';
    obj.innerHTML += '<p>Merci de nous décrire précisément le problème relatif à ce contenu :</p>';
    obj.innerHTML += '<textarea id="tmptxtareport'+section+id_elt+'" cols="40" rows="10"></textarea><br/>';
    obj.innerHTML += '<input class="ibtn" type="button" onclick="if(a(\'tmptxtareport'+section+id_elt+'\').value==\'\') { alert(\'Vous n\\\'avez pas rempli le formulaire !\'); return false; } xmlPost(a(\'alertboxreport\'),\'/inc/ajax/savealert.php\',\'section='+section+'&id_elt='+id_elt+'&helt='+helt+'&data=\'+URLencode(a(\'tmptxtareport'+section+id_elt+'\').value)); return false;" value="Envoyer !" /> <input class="ibtn" type="button" onclick="a(\'alertboxreport\').parentNode.removeChild(a(\'alertboxreport\'));" value="Fermer cette fenêtre" />';
    obj.id = 'alertboxreport';
    obj.style.position='absolute';
    obj.style.top='250px';
    obj.style.backgroundColor="white";
    if(a('alertboxreport')) a('alertboxreport').parentNode.removeChild(a('alertboxreport'));
    a('conteneur').appendChild(obj);
}

function showOnlyOneElt(kelelt,typeToClose,ereg) {
    if (a(kelelt)) {
        //ferme tous les ul
        ulz=a(kelelt).parentNode.getElementsByTagName(typeToClose);
        for(i=0;i<ulz.length;i++) {
            if (ulz[i].id.indexOf(ereg)!=-1) {
                if (ulz[i].style.display!='none') {
                    //ulz[i].style.visibility='hidden';
                    progressClose(ulz[i].id);
                }
            }
        }
        a(kelelt).style.display='';
    }
}
function showOnlyOneEltWithFlush(kelelt,typeToClose,ereg) {
    if (a(kelelt)) {
        //ferme tous les ul
        ulz=a(kelelt).parentNode.getElementsByTagName(typeToClose);
        for(i=0;i<ulz.length;i++) {
            if (ulz[i].id.indexOf(ereg)!=-1) {
                if (ulz[i].style.display!='none') {
                    ulz[i].innerHTML='';
                    ulz[i].style.display='none';
                }
            }
        }
        a(kelelt).style.display='';
    }
}

function progressClose(elt) {
    //alert(navigator.appName);
    //si ie
    if (navigator.appName.indexOf('Microsoft')!=-1) {
        a(elt).style.display='none';a(elt).style.visibility='visible';
    } else {
        actualSize=a(elt).offsetHeight;
        a(elt).style.overflow='hidden';
        a(elt).style.height=actualSize-Math.ceil(actualSize/10)+'px';
        //a('yahookws').value=a(elt).style.height+':'+actualSize;
        if (a(elt).clientHeight>0) setTimeout("progressClose('"+elt+"')", 20);
        else { a(elt).style.display='none';a(elt).style.visibility='visible';a(elt).style.height='';}
    }
}
function progressOpen(elt, curr, wantedSize) {
    //alert(navigator.appName);
    //si ie
    if (navigator.appName.indexOf('Microsoft')!=-1) {
        a(elt).style.display='block';a(elt).style.visibility='visible';
    } else {
        a(elt).style.overflow='hidden';
        curr=curr+Math.ceil(wantedSize/10);
        if(curr>wantedSize) curr=wantedSize;
        a(elt).style.height=curr+'px';
        if (curr<wantedSize) { setTimeout("progressOpen('"+elt+"',"+curr+","+wantedSize+")", 20); }
        else { a(elt).style.display='block';a(elt).style.visibility='visible';a(elt).style.height=wantedSize+'px';}
    }
}
function favboxswappr(section) {
    if(a('favboxbox_'+section).style.display=='none') {
        xmlGet(a('favboxbox_'+section),'/inc/ajax/favbox.php?getfor='+section);
        showOnlyOneElt('favboxbox_'+section,'ul','favboxbox_');
    } else {
        progressClose('favboxbox_'+section);
    }
}
function encloseSelection(textarea, prefix, suffix, fn) {
    textarea.focus();
    var start, end, sel, scrollPos, subst;

    if (typeof(document["selection"]) != "undefined") {
        sel = document.selection.createRange().text;
    } else if (typeof(textarea["setSelectionRange"]) != "undefined") {
        start = textarea.selectionStart;
        end = textarea.selectionEnd;
        scrollPos = textarea.scrollTop;
        sel = textarea.value.substring(start, end);
    }

    if (sel.match(/ $/)) { // exclude ending space char, if any
        sel = sel.substring(0, sel.length - 1);
        suffix = suffix + " ";
    }

    if (typeof(fn) == 'function') {
        var res = (sel) ? fn(sel) : fn('');
    } else {
        var res = (sel) ? sel : '';
    }

    subst = prefix + res + suffix;

    if (typeof(document["selection"]) != "undefined") {
        var range = document.selection.createRange().text = subst;
        textarea.caretPos -= suffix.length;
    } else if (typeof(textarea["setSelectionRange"]) != "undefined") {
        textarea.value = textarea.value.substring(0, start) + subst +
        textarea.value.substring(end);
        if (sel) {
            textarea.setSelectionRange(start + subst.length, start + subst.length);
        } else {
            textarea.setSelectionRange(start + prefix.length, start + prefix.length);
        }
        textarea.scrollTop = scrollPos;
    }
}




function dragMeImFamous(elt,handle) { // (ou pas)
    var ie = (document.all)? true:false;
    var ns4 = (document.layers)? true:false;
    var ns6 = (document.getElementById)? true:false;
    var lastX = 0;
    var lastY = 0;

    if (ie) {
        handle.onmousedown=maislolhein;
    } else if (ns4) {
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=maislolhein;
    } else if (ns6) {
        handle.addEventListener("mousedown", maislolhein, false);
    }
    function maislolhein(e) {
        if (ie) {
            lastX=event.clientX;
            lastY=event.clientY;
            document.onmousemove=doDrag;
            document.onmouseup=endDrag;
        } else if (ns4) {
            lastX=e.pageX;
            lastY=e.pageY;
            document.captureEvents(Event.MOUSEMOVE)
            document.onmousemove=doDrag;
            document.captureEvents(Event.MOUSEUP)
            document.onmouseup=endDrag;
        } else if (ns6) {
            lastX=e.clientX;
            lastY=e.clientY;
            window.onmousemove=doDrag;
            window.onmouseup=endDrag;
        }
    }
    function doDrag(e) {
        if (ie) {
            var difX=event.clientX-lastX;
            var difY=event.clientY-lastY;
            var newX1 = parseInt(elt.style.left)+difX;
            var newY1 = parseInt(elt.style.top)+difY;
            elt.style.left=newX1+"px";
            elt.style.top=newY1+"px";
            lastX=event.clientX;
            lastY=event.clientY;
        } else if (ns4) {
            var difX=e.pageX-lastX;
            var difY=e.pageY-lastY;
            var newX1 = parseInt(elt.left)+difX;
            var newY1 = parseInt(elt.top)+difY;
            elt.left=newX1;
            elt.top=newY1;
            lastX=e.pageX;
            lastY=e.pageY;
        } else if (ns6) {
            var difX=e.clientX-lastX;
            var difY=e.clientY-lastY;
            var newX1 = parseInt(elt.style.left)+difX;
            var newY1 = parseInt(elt.style.top)+difY;
            elt.style.left=newX1+"px";
            elt.style.top=newY1+"px";
            lastX=e.clientX;
            lastY=e.clientY;
        }
    }
    function endDrag(e) {
        if (ie || ns4) {
            document.onmousemove=null;
        } else if (ns6) {
            window.onmousemove=null;
        }
    }
}

// Player musique
var popPlayer = null ;

function ouvrirPlayerMusique(idTitre, idAlbum)
{
	var left=window.screen.width/2-175 ;
	var top=window.screen.height/2-175 ;
	
	var oDate = new Date(); 
	
	var configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=770, height=360, scrollbars=yes, left=" + left + ", top=" + top ;
	
	var get = '' ;
	var ancre = '' ;
	if(idTitre != null)
	{
		get = 'idTitre='+idTitre ;
		ancre = '#titre'+idTitre ;
	}
	else if(idAlbum != null)
		get = 'idAlbum='+idAlbum ;
		
	get += '&nocache='+ oDate.getTime() ;
	
	if(popPlayer != null)
		popPlayer.close() ;
	
	popPlayer = window.open('/musique/player.php?'+get+''+ancre, 'PlayerLexode', configuration) ;
	popPlayer.focus() ;
}

// Popup sonnerie
function ouvrirSonnerie(idSonnerie)
{
	var left=window.screen.width/2-175 ;
	var top=window.screen.height/2-175 ;
	
	var configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=400, height=320, scrollbars=yes, left=" + left + ", top=" + top ;

	var pop = window.open('/musique/sonnerie.php?idSonnerie='+ idSonnerie, 'SonnerieLexode', configuration) ;
	pop.focus() ;
}

function deplierBlackList(idBlackList)
{
    var tLignes = document.getElementsByTagName('tr');

    for(i = 0; i < tLignes.length; i++)
    {
        if(tLignes[i].getAttribute("class") == "a-" + idBlackList)
        {
            if(tLignes[i].style.display == 'none')
            {
                tLignes[i].style.display = 'table-row';
                document.getElementById('repli-' + idBlackList).innerHTML = '<a href="javascript:;" onclick="deplierBlackList(' + idBlackList + '); return false;"><img src="/images/icones/ico_fleche_haut.gif" alt="Replier" title="Replier" /></a>';
            }
            else
            {
                tLignes[i].style.display = 'none';
                document.getElementById('repli-' + idBlackList).innerHTML = '<a href="javascript:;" onclick="deplierBlackList(' + idBlackList + '); return false;"><img src="/images/icones/ico_fleche_bas.gif" alt="D&eacute;plier" title="D&eacute;plier" /></a>';
            }
        }
    }
}

function afficherBlackList(texte)
{
    
    fuckPubz(true);
    var selectes = document.getElementsByTagName('select');
    for(i=0; i < selectes.length; i++)
    {
        selectes[i].style.display = "none";
    }
    document.getElementById("calque").style.width = 450 + 'px';
    document.getElementById("calque").style.height = 500 + 'px';
    document.getElementById("calque").innerHTML = texte;
    addEventA(window, 'scroll', function() { centrerA('calque'); });
    addEventA(window, 'resize', function() { centrerA('calque'); });

    document.getElementById("calque").style.display = 'block';

    document.getElementById("masque").style.display = 'block';
    centrerA('calque');
}

function cacherBlackList()
{
    fuckPubz(false);
    var selectes = document.getElementsByTagName('select');
    for(i=0; i < selectes.length; i++)
    {
        selectes[i].style.display = "inline";
    }
    document.getElementById("calque").innerHTML = '';
    document.getElementById("calque").style.display = 'none';
    document.getElementById("masque").style.display = 'none';
}

function centrerA(calque) {

    if (window.innerWidth) {    // all except Explorer
    
        var larg = windowWidth = window.innerWidth;
        var haut = windowHeight = window.innerHeight;

    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

        var larg = windowWidth = document.documentElement.clientWidth;
        var haut = windowHeight = document.documentElement.clientHeight;

    } else if (document.body) { // other Explorers

        var larg = windowWidth = document.body.clientWidth;
        var haut = windowHeight = document.body.clientHeight;
    
    }
    
    var top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 ;
    var left = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0 ;
   

    larg = left + (larg /2) - ((document.getElementById(calque).offsetWidth)/2);
	haut = top + (haut / 2) - ((document.getElementById(calque).offsetHeight)/2);
    document.getElementById(calque).style.padding = '5px';
    document.getElementById(calque).style.textAlign = 'left';
    document.getElementById(calque).style.top = haut+'px';
    document.getElementById(calque).style.left = larg+'px';

}

function addEventA(obj, evType, fn)
{
    if (obj.addEventListener)
    {
        obj.addEventListener(evType, fn, false) ;
        return true ;
    } 
    else if (obj.attachEvent)
    {
        return  obj.attachEvent("on"+evType, fn) ;
    }
    else 
    {
        return false ;
    }
}


