//variable globales pouvant servir sur un script
var globa;  var globb;  var globc; var globd;   var globe;
var globi=0;var globj=0;var globk=0;
var globx;  var globy;

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, ''); 
};
function getWindowHeight() {
    var h = 0;
    if (typeof(window.innerHeight) == 'number') {
        h = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        h = document.documentElement.clientHeight;
    } else if (document.body && document.body.offsetHeight) {
        h = document.body.offsetHeight;
    }
    return h;
}
function getWindowWidth() {
    var w = 0;
    if (typeof(window.innerWidth) == 'number') {
        w = window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        w = document.documentElement.clientWidth;
    } else if (document.body && document.body.offsetWidth) {
        w = document.body.offsetWidth;
    }
    return w;
}
function cleansearch(s) {
    var e = document.getElementById('searchquery');
    if(s) {
        e.className = 'searchquery_on';
    } else {
        if(e.value == '') {
            e.className = 'searchquery_off';
        }
    }
}
function cleanSubsearch(n,s) {
    var e = document.getElementById('subsearch_'+n);
    if(s) {
        e.className = 'champ_recherche subsearch_'+n+'_on';
    } else {
        if(e.value == '') {
            e.className = 'champ_recherche subsearch_'+n+'_off';
        }
    }
}
function reloadHomePix() {
    var e = document.getElementById('shootingstar');
    var prev = e.innerHTML;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    e.innerHTML = (xhr.responseText);
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = prev;
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = prev;
                }
            }
            else
            {
                e.innerHTML = '<img src="gui/ajax_load.gif" style="margin: 34px" alt="" title="On chope l\'image..." />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=shootingstar",true);
        xhr.send(null);
    }
    ajaxReq();
}
function reloadPosters() {
    var e = document.getElementById('posterwall');
    var prev = e.innerHTML;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { e.innerHTML = (xhr.responseText); } catch(err) { e.innerHTML = prev; }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = prev;
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = prev;
                }
            }
            else
            {
                e.innerHTML = '<img src="gui/ajax_load.gif" style="display: block; margin: 63px auto" alt="" title="Actualisation des affiches..." />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=posterwall",true);
        xhr.send(null);
    }
    ajaxReq();
}
function reloadCelebs() {
    var e = document.getElementById('starwall');
    var prev = e.innerHTML;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { e.innerHTML = (xhr.responseText); } catch(err) { e.innerHTML = prev; }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = prev;
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = prev;
                }
            }
            else
            {
                e.innerHTML = '<img src="gui/ajax_load.gif" style="display: block; margin: 63px auto" alt="" title="Actualisation des photos..." />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=starwall",true);
        xhr.send(null);
    }
    ajaxReq();
}
function getEd(id) {
    var e = document.getElementById('editoholder');
    var prev = e.innerHTML;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try {
                        e.innerHTML = (xhr.responseText);
                    } catch(err) { e.innerHTML = prev }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = prev
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = prev
                }
            } else {
                e.innerHTML = '<img src="gui/ajax_load.gif" style="display: block;margin: 30px auto" alt="" title="Récupération de l\'édito..." />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=edito&ta="+id,true);
        xhr.send(null);
    }
    ajaxReq();
}
function doVote(cat,item,cur) {
    var e = document.getElementById('votetool');
    var childs = e.childNodes;
    if(cat == "tof") {
        if(childs.length == 1)
        {
            e.className = 'notetoftoolbgvoting';
            e.firstChild.style.display = 'none';
            e.innerHTML = e.innerHTML+'<div onclick="vote(\'tof\','+item+',0);" class="votenum'+((cur==0)?' delme':'')+'" title="'+((cur==0)?'Supprimer votre note de 0':'0/5 (pourri)')+'">0</div><div onclick="vote(\'tof\','+item+',1);" class="votenum'+((cur==1)?' delme':'')+'" title="'+((cur==1)?'Supprimer votre note de 1':'1/5 (médiocre)')+'">1</div><div onclick="vote(\'tof\','+item+',2);" class="votenum'+((cur==2)?' delme':'')+'" title="'+((cur==2)?'Supprimer votre note de 2':'2/5 (moyen)')+'">2</div><div onclick="vote(\'tof\','+item+',3);" class="votenum'+((cur==3)?' delme':'')+'" title="'+((cur==3)?'Supprimer votre note de 3':'3/5 (bon)')+'">3</div><div onclick="vote(\'tof\','+item+',4);" class="votenum'+((cur==4)?' delme':'')+'" title="'+((cur==4)?'Supprimer votre note de 4':'4/5 (très bon)')+'">4</div><div onclick="vote(\'tof\','+item+',5);" class="votenum'+((cur==5)?' delme':'')+'" title="'+((cur==5)?'Supprimer votre note de 5':'5/5 (excellent)')+'">5</div><div onclick="vote(\'tof\','+item+',-1);" class="votenumof" title="Annuler">X</div>';
        }
    } else if(cat == "film") {
        if(childs.length == 3)
        {
            e.className = 'notefilm floatright notefilmh';
            var voted = (cur>=0)?'<img src="gui/tri_asc.png" style="position: absolute; top: 20px;left: '+((cur*10)+6)
            +'px;" title="Votre note actuelle - Choisir pour annuler votre note" />':'';
            e.innerHTML = '<div>'+voted+'<img onclick="vote(\'film\','+item+',-1);" src="gui/bgnotfclose.png" '
            +'style="position: absolute; top: 0px;right: 0px; cursor: pointer;" title="Annuler" />'
            +'<div class="film_note_holder_v"><div class="fn_note fn4" onclick="vote(\'film\','+item+',4);" '
            +'title="4/4 claps, ce film est excellent, y\'a pas mieux"></div><div class="fn_note fn3" '
            +'onclick="vote(\'film\','+item+',3);" title="3/4 claps, ce film est très bien"></div><div '
            +'class="fn_note fn2" onclick="vote(\'film\','+item+',2);" title="2/4 claps, ce film est '
            +'pas mal du tout"></div><div class="fn_note fn1" onclick="vote(\'film\','+item+',1);" '
            +'title="1/4 clap, ce film est visible"></div><div class="fn_note fn0" '
            +'onclick="vote(\'film\','+item+',0);" title="0/4 clap, ce film est pourri"></div></div></div>';
        }
    }
}
function vote(cat,item,note) {       
    var e = document.getElementById('votetool');
    function ajaxReq() {
            var xhr = createXHR();
            xhr.onreadystatechange = function() { 
                    if (xhr.readyState == 4) {
                        if (xhr.status == 200) {
                            var ans = xhr.responseText.split("#");
                            if(cat == "tof") {
                                e.innerHTML = ans[0];
                                e.className = 'notetoftoolbg pointer';
                                if(note >= 0) { 
                                    e.title = ans[1];
                                    for (var i = 0; i < e.attributes.length; i++) {
                                        if(e.attributes[i].nodeName == "onclick") {
                                            e.attributes[i].nodeValue = "doVote('tof',"+item+","+ans[2]+");";
                                        }
                                    }
                                }
                            } else if (cat == "film") {
                                e.innerHTML = ans[0];
                                e.className = 'notefilm floatright rel';
                                if(note >= 0) { 
                                    for (var i = 0; i < e.attributes.length; i++) {
                                        if(e.attributes[i].nodeName == "onclick") {
                                            e.attributes[i].nodeValue = "doVote('film',"+item+","+ans[1]+");";
                                        }
                                    }
                                }
                            }
                        } else if (xhr.status == 404) {
                            alert('Le contenu n\'est pas accessible (404).');
                            if(cat == "tof") {
                                e.className = 'notetoftoolbg pointer';
                                while (e.childNodes[1]) {
                                    e.removeChild(e.childNodes[1]);
                                }
                                e.firstChild.style.display = 'block';
                            }
                        } else {
                            alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                            if(cat == "tof") {
                                e.className = 'notetoftoolbg pointer';
                                while (e.childNodes[1]) {
                                    e.removeChild(e.childNodes[1]);
                                }
                                e.firstChild.style.display = 'block';
                            }
                        }
                } else {
                    if(cat == "tof") {
                        e.innerHTML = '<span></span><img style="display: block; margin:auto;" src="gui/wait.gif" alt="" title="Validation" />';
                    } else if(cat == "film") {
                        e.innerHTML = '<img style="display: block; margin:auto;" src="gui/ajax_load.gif" alt="" title="Validation" />';
                    }
                }
            };
            xhr.open("POST","./inc/processvote.php",true);
            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
            xhr.send("cat="+cat+"&item="+item+"&note="+note);
    }
    ajaxReq();
}
function getPublicList(req,ev,id,scr) {
    document.getElementById("resetme_"+id).style.display = "block";
    var e = document.getElementById(id);
    var prev = e.innerHTML;
    if((ev.keyCode < 48 || ev.keyCode > 90) && (ev.keyCode != 0) && (ev.keyCode != 8) && (ev.keyCode != 46)) { return; }
    req = req.trim();
    if(req.length == 0) { return; }
    try { document.getElementById("navigation").innerHTML = ""; } catch (err) {}
    w = document.getElementById("waitholder");
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        e.innerHTML = (xhr.responseText); 
                        w.innerHTML = ''; 
                        if(scr!=0) {
                            try {
                                window.scrollTo(0,document.getElementById(scr).offsetTop);
                            } catch (err) { }
                        }
                    } catch (err) { e.innerHTML = prev; w.innerHTML = ''; }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    w.innerHTML = '';
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    w.innerHTML = '';
                }
            }
            else
            {
                w.innerHTML = '<img src="gui/wait.gif" alt="" title="liste en construction" />';
            }
        };
        xhr.open("POST","./inc/makepubliclist.inc.php",true);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        xhr.send("t="+id+"&q="+req);
    }
    ajaxReq();
}
function createXHR() {
    var httpRequest = false;
    if (window.XMLHttpRequest) {
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) {
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    if (!httpRequest) {
        alert('Abandon :( Impossible de créer une instance XMLHTTP');
        return false;
    }
    return httpRequest;
}
function checkErrs() {
    var e = document.getElementById('querycrit');
    var t = e.parentNode;
    var errors = 0;
    for(var i = 0; i < e.childNodes.length; i++) {
        if(e.childNodes[i].tagName == 'SPAN') {
            if(e.childNodes[i].className == 'field_error') { errors++; }
        }
    }
    if(errors > 0) { t.className = 'errormode'; } else { t.className = ''; }
}
function cVal(c) {
    var eid = c.id;
    var target = "qf_"+eid;
    var source = eid+"v";
    if(c.checked) {
        var text = document.getElementById(source).value;
        var op = '';
        for(var i = 0; i < c.parentNode.childNodes.length; i++) {
            if (c.parentNode.childNodes[i].tagName == 'INPUT') {
                if ((typeof(c.parentNode.childNodes[i].title) != 'undefined') && (c.parentNode.childNodes[i].type == 'radio')) {
                    if(c.parentNode.childNodes[i].checked) {
                        op = c.parentNode.childNodes[i].title;
                    }
                }
            }
        }
        if((text.length > 0) && (op != '')) {
            text = text.trim();
            if(op.substring(0,1) == ' ') {
                text = text.replace(/\s+/g,op);
            } else if(op.substring(0,1) == 'o') {
                text = text.replace(/\s*/g,'');
                text = text+' '+op;
            }
        }
        document.getElementById(target).innerHTML = '<span class="querycritf">'+eid+'</span>="<span class="querycritv">'+text+'</span>"';
        if(text.length <= 0) { 
            document.getElementById(target).className = 'field_error'; 
        } else  { 
            document.getElementById(target).className = ''; 
        }
        c.parentNode.className = 'rowform rbon';
    } else {
        document.getElementById(target).innerHTML = '';
        c.parentNode.className = 'rowform rb';
    }
    checkErrs();
}

function cTypedVal(c) {
    c = document.getElementById(c);
    cVal(c);
}
function cChkVal(c) {
    c = document.getElementById(c);
    cCVal(c);
}
function cSVal(c) {
    var eid = c.id;
    var target = "qf_"+eid;
    if(c.checked) {
        document.getElementById(target).innerHTML = '<span class="querycritf">'+eid+'</span>="<span class="querycritv">OUI</span>"';
        c.parentNode.className = 'rowform rbon';
    } else {
        document.getElementById(target).innerHTML = '';
        c.parentNode.className = 'rowform rb';
    }
    checkErrs();
}
function cCVal(c) {
    var eid = c.id;
    var target = "qf_"+eid;
    if(c.checked) {
        var text = '';
        for(var i = 0; i < c.parentNode.childNodes.length; i++) {
            if (c.parentNode.childNodes[i].tagName == 'INPUT') {
                if (typeof(c.parentNode.childNodes[i].title) != 'undefined') {
                    if(c.parentNode.childNodes[i].checked) {
                        text += c.parentNode.childNodes[i].title+' ';
                    }
                }
            }
        }
        document.getElementById(target).innerHTML = '<span class="querycritf">'+eid+'</span>="<span class="querycritv">'+text.trim()+'</span>"';
        if(text.trim().length <= 0) { 
            document.getElementById(target).className = 'field_error'; 
        } else { 
            document.getElementById(target).className = ''; 
        }
        c.parentNode.className = 'rowform rbon';
    } else {
        document.getElementById(target).innerHTML = '';
        c.parentNode.className = 'rowform rb';
    }
    checkErrs();
}
function swapVis(e) {
    (document.getElementById(e).className == "hidden") ? document.getElementById(e).className="shown":document.getElementById(e).className="hidden";
}
function swapThread(e,tid) {
    var childNodes = e.parentNode.parentNode.childNodes;
    var m = document.getElementById('m'+tid);
    if(e.alt=="-") {
        m.style.display="none";
        e.src="gui/thread_expand.png";
        e.alt="+";
        for (var i = 0; i < childNodes.length; i++) {
            var child = childNodes[i];
            if (child.className == "ulfix") {
                child.style.display="none";
            }
        }
    } else {
        m.style.display="block";
        e.src="gui/thread_collapse.png";
        e.alt="-";
        for (var i = 0; i < childNodes.length; i++) {
            var child = childNodes[i];
            if (child.className == "ulfix") {
                child.style.display="block";
            }
        }    
    }
}
function readMsg(mid,mode) {
    var e = document.getElementById('mr'+mid);
    var w = document.getElementById('usefulldiv'+mid);
    var cn = w.className;
    if(mode == 2) {
        if(cn == 'expand_msg') { mode = 1; } else { mode = 0; }
    }
    var prev = e.innerHTML;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        e.innerHTML = (xhr.responseText);
                    } catch (err) { e.innerHTML = prev; w.className = cn; }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    w.className = cn;
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    w.className = cn;
                }
            } else {
                w.className = 'ufd_wait';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=msgread&mid="+mid+"&mode="+mode,true);
        xhr.send(null);
    }
    ajaxReq();
}
function composeMsg(mid,fid) {
    var e = document.getElementById('compose');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        try { 
                            e.style.display='block';
                            e.innerHTML = (xhr.responseText); 
                        } catch (err) {  }
                    } else if (xhr.status == 404) {
                        alert('Le contenu n\'est pas accessible (404).');
                    } else {
                        alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=msgcomp&mid="+mid+"&fid="+fid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function closeMsgBox() {
    var e = document.getElementById('compose');
    e.innerHTML = ''; 
    e.style.display='none';
}
function doTag(target,tag,arg,lbl) {
    var ta = document.getElementById(target);
    var tag_ar = new Array(
                       "[b]","[/b]",            // 0
                       "[i]","[/i]",            // 2
                       "[u]","[/u]",            // 4
                       "[s]","[/s]",            // 6
                       "[size=","[/size]",      // 8 -- argument : taille 
                       "[color=","[/color]",    // 10 -- argument : rgb
                       "[align=","[/align]",    // 12 -- 1 seul arg  (center, justi, rig, code)     // 8
                       "[list=","[/list]",      // 14 -- list : argument (ol / ul)
                       "[pix=","[/pix]",        // 16 arg : [pix={title}]url[/pix]
                       "[url=","[/url]",        // 18 arg : [url=url]label[/url]
                       "[c=","[/c]",            // 20 arg : cid
                       "[f=","[/f]",            // 22 arg : fid
                       "[spoiler]","[/spoiler]",// 24
                       "[pix]","[/pix]",        // 26
                       "[yt=","[/yt]"           // 28
                    );
    var tagArg = (typeof(arg)=='undefined')?"":arg+"]";
    var tagOpen = tag_ar[tag]+tagArg;
    var tagClose = tag_ar[tag+1];
    
    ta.focus();
    if (typeof(document.selection) != 'undefined') {                // [IE]
        var selected = document.selection.createRange().text;
        ta.focus();
        var sel = document.selection.createRange();
        if(selected && (typeof(lbl) == 'undefined')) {
            document.selection.createRange().text = tagOpen + selected + tagClose;
        }
        else {
            lblin = (typeof(lbl) == 'undefined') ? '':lbl;
            var text = tagOpen+lblin+tagClose;
            if (ta.createTextRange && ta.caretPos) { 
                var caretPos = ta.caretPos; 
                caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1) == ' ') ? text+caretPos.text + ' ' : text+caretPos.text;
            }  else {
                sel.text = sel.text + text;
            }
        }
        ta.focus;
        return;
    }
    else {                                                          // [MOZ]
        var lenSel = ta.textLength;
        var startSel = ta.selectionStart;
        var endSel = ta.selectionEnd;
        var oldScrollTop = ta.scrollTop;
        var sizeSel = endSel - startSel;
        if (endSel && (sizeSel > 0) && (typeof(lbl) == 'undefined')) {
            lblin = typeof(lbl) == 'undefined' ? '':lbl;
            sub1 = (ta.value).substring(0,startSel);
            sub2 = (ta.value).substring(startSel,endSel);
            sub3 = (ta.value).substring(endSel,lenSel);
            ta.value = sub1 + tagOpen + sub2 + tagClose + sub3;
        } else { 
            lblin = typeof(lbl) == 'undefined' ? '':lbl;
            sub1 = (ta.value).substring(0,startSel);
            sub2 = (ta.value).substring(startSel,endSel);
            sub3 = (ta.value).substring(endSel,lenSel);
            ta.value = sub1 + tagOpen + lblin + tagClose + sub2 + sub3;
        }
        ta.selectionStart = sub1.length;
		ta.selectionEnd = sub1.length + sub2.length + lblin.length + tagOpen.length + tagClose.length;
		ta.scrollTop = oldScrollTop;
		ta.focus();
        return;
    }
}
function doSmile(target,smile) {
    var ta = document.getElementById(target);
    if (document.selection) {                                       // [IE]
        ta.focus();
        var sel = document.selection.createRange();
        var text = ":"+smile+":";
        if (ta.createTextRange && ta.caretPos) { 
            var caretPos = ta.caretPos; 
            caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1) == ' ') ? text+caretPos.text + ' ' : text+caretPos.text;
        } else {
            sel.text = sel.text + text;
        }
        return;
    }
    else {                                                          // [MOZ]
        var oldScrollTop = ta.scrollTop; 
        sub1 = (ta.value).substring(0,ta.selectionStart);
        ta.value = (ta.value).substring(0,ta.selectionStart) + ":" + smile + ":" + (ta.value).substring(ta.selectionStart,ta.textLength);
        ta.selectionStart = sub1.length;
		ta.selectionEnd = sub1.length + smile.length + 2;
		ta.scrollTop = oldScrollTop;
		ta.focus();
        return;
    }
}
function doModal(ta,arg,w,h) {
    w = typeof(w) != 'undefined' ? w : 400;
    h = typeof(h) != 'undefined' ? h : 200;
    openModal("inc/modal.inc.php?ta="+ta+"&t="+arg,w,h)
}
function openModal(url,w,h) {
    disPage();
    makePopup(w,h);
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = (xhr.responseText); 
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET",url,true);
        xhr.send(null);
    }
    ajaxReq();   
}
function disPage() {
    var l = document.getElementById('layer');
    l.style.display = 'block';
}
function makePopup(w,h) {
    var m = document.getElementById('MW');
    m.style.width = w+"px";
    m.style.height = h+"px";
    m.style.margin = "-"+(h/2)+"px 0px 0px -"+(w/2)+"px";
}
function adjustModal() {
    var w = document.getElementById("MWcont").clientWidth;
    var h = document.getElementById("MWcont").clientHeight;
    document.getElementById("MW").style.width = w+"px";
    document.getElementById("MW").style.height = h+"px";
}
function cancelModal() {
    document.getElementById('MWcont').innerHTML = '';
    document.getElementById('layer').style.display = 'none';
}
function insertList(t) {
    var ta = document.getElementById("listitems");
    var typ = "ul";
    if (document.getElementById("num").checked == true) { typ = "ol"; }
    var str = ta.value.trim();
    if (str.length == 0) { cancelModal(); return; }
    var reg = new RegExp("\n+","g")
    var arr = "[item]"+str.replace(reg,"[/item][item]")+"[/item]";
    doTag(t,14,typ,arr);
    cancelModal();
}
function insertUrl(t) {
    var url = document.getElementById("urli").value.trim();
    var linkname = document.getElementById("linkname").value.trim();
    if (url.length == 0) { cancelModal(); return; }
    linkname = (linkname.length > 0) ? linkname:url;
    doTag(t,18,url,linkname);
    cancelModal();
}
function insertImg(t) {
    var url = document.getElementById("urli").value.trim();
    var linkname = document.getElementById("linkname").value.trim();
    if (url.length == 0) { cancelModal(); return; }
    linkname = (linkname.length > 0) ? linkname:url;
    doTag(t,16,linkname,url);
    cancelModal();
}
function insertVid(t) {
    var url = document.getElementById("urli").value.trim();
    if (url.length == 0) { cancelModal(); return; }
    doTag(t,28,url);
    cancelModal();
}
function insertStill(t,e) {
    var url = e.id.trim();
    var linkname = e.title.trim();
    if (url.length == 0) { cancelModal(); return; }
    url = 'doc/stills/'+url+'.jpg';
    linkname = (linkname.length > 0) ? linkname:url;
    doTag(t,16,linkname,url);
    cancelModal();
}
function mmar(mid) {
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        if(xhr.responseText == 'ok') {
                            document.getElementById('unread'+mid).innerHTML = '';
                        }
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=mmar&mid="+mid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function postMsg(mode) {
    if((mode!='post') && (mode!='edit')) { mode = 'prev'; }
    disPage();
    if((mode=='post') || (mode=='edit')) {
        h = 200; w = 400;
    } else {
        var h = getWindowHeight();  var w = getWindowWidth();
            h = 0.8 * h;                w = 0.8 * w;
    }
    makePopup(w,h);
    var mid = document.getElementById("mid").value;
    var fid = document.getElementById("fid").value;
    var mst = document.getElementById("mst").value.trim();
    var msb = document.getElementById("msb").value.trim();
    var mto = document.getElementById("mto").value.trim();
    var mbo = document.getElementById("mbo").value.trim();
    mst = encodeURIComponent(mst);
    msb = encodeURIComponent(msb);
    mto = encodeURIComponent(mto);
    mbo = encodeURIComponent(mbo);
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        if(mode=='post') {
                            if(xhr.responseText=='ok') {
                                m.innerHTML = '<div class="msg_sent">Votre message a été posté !</div>';
                                closeMsgBox();
                                t = setTimeout('cancelModal()',1000);
                            } else {
                                m.innerHTML = (xhr.responseText);
                            }
                        } else if(mode=='edit') {
                            if(xhr.responseText=='ok') {
                                m.innerHTML = '<div class="msg_sent">Le message a été mis à jour !</div>';
                                closeMsgBox();
                                readMsg(mid,2);
                                t = setTimeout('cancelModal()',1000);
                            } else {
                                m.innerHTML = (xhr.responseText);
                            }
                        } else {
                            m.innerHTML = (xhr.responseText);
                        }
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("POST","./inc/modal.inc.php",true);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        xhr.send("t="+mode+"msg&mid="+mid+"&fid="+fid+"&mst="+mst+"&msb="+msb+"&mto="+mto+"&mbo="+mbo);
    }
    ajaxReq();
}
function delMsg(mid) {
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        if(xhr.responseText=='sup') { 
                            disPage();
                            h = 200; w = 400;
                            makePopup(w,h);
                            var m = document.getElementById('MWcont');
                            m.innerHTML = '<div class="msg_sent">Le message a été supprimé !</div>';
                            closeMsgBox();
                            document.getElementById('mr'+mid).innerHTML = '';
                            t = setTimeout('cancelModal()',1000);
                        } else if(xhr.responseText!='') { 
                            disPage();
                            h = 200; w = 400;
                            makePopup(w,h);
                            var m = document.getElementById('MWcont');
                            m.innerHTML = '<div class="msg_sent">Le message a été réouvert !</div>';
                            closeMsgBox();
                            document.getElementById('mr'+mid).innerHTML = (xhr.responseText);
                            t = setTimeout('cancelModal()',1000);
                        }
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=delmsg&mid="+mid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function marTh(tid,step) {
    disPage();
    h = 200; w = 400;
    makePopup(w,h);
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        if(step==1) {
                            var ans = xhr.responseText.split("|");
                            for(var i in ans) {
                                document.getElementById('unread'+ans[i]).innerHTML = '';
                            }
                            m.innerHTML = '<div class="msg_sent">Le fil a été marqué comme lu.</div>';
                            adjustModal();
                        } else {
                            m.innerHTML = (xhr.responseText);
                        }
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=marth&tid="+tid+"&step="+step,true);
        xhr.send(null);
    }
    ajaxReq();
}
function handleTh(tid,step) {
    if(step==1) {
        var a = document.getElementById('handle').value;
    } else {
        disPage();
        h = 300; w = 400;
        makePopup(w,h);
    }
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=handleth&tid="+tid+"&step="+step+"&a="+a,true);
        xhr.send(null);
    }
    ajaxReq();
}
function editMsg(mid,fid) {
    var e = document.getElementById('compose');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        try { 
                            e.style.display='block';
                            e.innerHTML = (xhr.responseText); 
                        } catch (err) {  }
                    } else if (xhr.status == 404) {
                        alert('Le contenu n\'est pas accessible (404).');
                    } else {
                        alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=msgedit&mid="+mid+"&fid="+fid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function flag(mid) {
    disPage();
    h = 200; w = 400;
    makePopup(w,h);
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = '<div class="msg_sent">'+(xhr.responseText)+'</div>';
                        readMsg(mid,2);
                        adjustModal();
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=flag&mid="+mid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function newSondage(fid) {
    var e = document.getElementById('compose');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        try { 
                            e.style.display='block';
                            e.innerHTML = (xhr.responseText); 
                        } catch (err) {  }
                    } else if (xhr.status == 404) {
                        alert('Le contenu n\'est pas accessible (404).');
                    } else {
                        alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=sondnew&fid="+fid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function postSondage(mode) {
    if(mode!='post') { mode = 'prev'; }
    disPage();
    if(mode=='post') {
        h = 200; w = 400;
    } else {
        var h = getWindowHeight();  var w = getWindowWidth();
            h = 0.8 * h;                w = 0.8 * w;
    }
    makePopup(w,h);
    var fid = document.getElementById("fid").value;
    var mst = document.getElementById("mst").value.trim();
    var msb = document.getElementById("msb").value.trim();
    mst = encodeURIComponent(mst);
    msb = encodeURIComponent(msb);
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        if(mode=='post') {
                            if(xhr.responseText=='ok') {
                                m.innerHTML = '<div class="msg_sent">Votre sondage a été posté !</div>';
                                closeMsgBox();
                                t = setTimeout('cancelModal()',1000);
                            } else {
                                m.innerHTML = (xhr.responseText);
                            }
                        } else {
                            m.innerHTML = (xhr.responseText);
                        }
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("POST","./inc/modal.inc.php",true);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        xhr.send("t="+mode+"sondage&fid="+fid+"&mst="+mst+"&msb="+msb);
    }
    ajaxReq();
}
function readSondage(mid,mode) {
    var e = document.getElementById('mr'+mid);
    var w = document.getElementById('usefulldiv'+mid);
    var cn = w.className;
    if(mode == 2) {
        if(cn == 'expand_msg') { mode = 1; } else { mode = 0; }
    }
    var prev = e.innerHTML;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        e.innerHTML = (xhr.responseText);
                    } catch (err) { e.innerHTML = prev; w.className = cn; }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    w.className = cn;
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    w.className = cn;
                }
            } else {
                w.className = 'ufd_wait';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=sondageread&mid="+mid+"&mode="+mode,true);
        xhr.send(null);
    }
    ajaxReq();
}
function sondageVote(mid) {
    disPage();
    h = 200; w = 400;
    makePopup(w,h);
    var m = document.getElementById('MWcont');
    var v = document.getElementsByName('sond'+mid);
    var c = '';
    for(var i=0;i<v.length;i++) {
        if(v[i].checked) {
            c = v[i].id;
        }
    }
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = '<div class="msg_sent">'+(xhr.responseText)+'</div>';
                        readSondage(mid,2);
                        adjustModal();
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=sondagevote&mid="+mid+"&vid="+c,true);
        xhr.send(null);
    }
    ajaxReq();
}
function closeSondage(mid) {
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        if(xhr.responseText=='sup') { 
                            disPage();
                            h = 200; w = 400;
                            makePopup(w,h);
                            var m = document.getElementById('MWcont');
                            m.innerHTML = '<div class="msg_sent">Le sondage a été fermé !</div>';
                            closeMsgBox();
                            document.getElementById('mr'+mid).innerHTML = readMsg(mid,3);
                            t = setTimeout('cancelModal()',1000);
                        } else if(xhr.responseText!='') { 
                            disPage();
                            h = 200; w = 400;
                            makePopup(w,h);
                            var m = document.getElementById('MWcont');
                            m.innerHTML = '<div class="msg_sent">Le sondage a été réouvert !</div>';
                            closeMsgBox();
                            document.getElementById('mr'+mid).innerHTML = (xhr.responseText);
                            t = setTimeout('cancelModal()',1000);
                        }
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=sondageclose&mid="+mid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function upAvatar() {
    var files = document.getElementById('imgs').files;
    for (var i = 0, f; f = files[i]; i++) {
        if((f.type == 'image/jpeg') && (f.size <= 512000)) {
            upload(f);
        } else {
            if(f.type != 'image/jpeg') { 
                document.getElementById('avanotif').innerHTML = '<span class="uperrsmg">Fichier <em>'+f.name+'</em> de mauvais type ('+f.type+')</span>'; 
            } else if(f.size > 512000) { 
                document.getElementById('avanotif').innerHTML = '<span class="uperrsmg">Fichier <em>'+f.name+'</em> trop lourd</span>';
            }
        }
    }
}
function upload(file) {
    var formData = new FormData();
    formData.append("t", "avaupload");
    formData.append("file", file);
    var xhr = new XMLHttpRequest();
    xhr.open("POST","./inc/modal.inc.php",true);
    xhr.send(formData);
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            if (xhr.responseText == "ok") {
                replaceIt('avdiv','avatar','');
            } else {
                document.getElementById('avanotif').innerHTML = '<span class="uperrmsg">Fichier <em>'+file.name+'</em> a provoqué une erreur</span>';
            }
        }
    }
    return true;
}
function replaceIt(cible,action,nid) {
    var e = document.getElementById(cible);
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        try { 
                            e.innerHTML = (xhr.responseText);
                        } catch (err) {  }                        
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t="+action+"&nid="+nid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function prevAva(n) {
    var e = document.getElementById('avatar');
    var o = document.getElementById('avatar_ini');
    if (n==0) {
        e.src = o.src;
    } else {
        try {
            e.src = n.src;
        } catch(err) { }
    }
}
function selectAva(src) {
    var e = document.getElementById('avdiv');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        try { 
                            e.innerHTML = (xhr.responseText);
                        } catch (err) {  }                        
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=avalist&src="+src,true);
        xhr.send(null);
    }
    ajaxReq();
}
function avaDel() {
    var e = document.getElementById('avdiv');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        try { 
                            e.innerHTML = (xhr.responseText);
                        } catch (err) {  }                        
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=avadel",true);
        xhr.send(null);
    }
    ajaxReq();
}
function forumDisplay(fid) {
    var e = document.getElementById('df'+fid);
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        try { 
                            e.className = xhr.responseText;
                        } catch (err) {  }                        
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=forumdisplay&fid="+fid,true);
        xhr.send(null);
    }
    ajaxReq();
}
function updateFrank(e) {
    var fid = e.id;
    var rank = e.value;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        alert(xhr.responseText);
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=updfrank&fid="+fid+"&rank="+rank,true);
        xhr.send(null);
    }
    ajaxReq();
}
function updateSrank(e) {
    var fid = e.id;
    var rank = e.value;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        alert(xhr.responseText);
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=updsrank&fid="+fid+"&rank="+rank,true);
        xhr.send(null);
    }
    ajaxReq();
}
function updateAttrib(e) {
    var fid = e.id;
    var val = e.value;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        alert(xhr.responseText);
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=updattrib&fid="+fid+"&val="+val,true);
        xhr.send(null);
    }
    ajaxReq();
}
function updateRest(e) {
    var fid = document.getElementById('fid').value;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText == "c") {
                        document.getElementById('s'+e).className = 'std_boxfield_alt sba_sel l100';
                        document.getElementById('u'+e).checked = true;
                    } else {
                        document.getElementById('s'+e).className = 'std_boxfield_alt l100';
                        document.getElementById('u'+e).checked = false;                    
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=updrest&fid="+fid+"&mid="+e,true);
        xhr.send(null);
    }
    ajaxReq();
}
function subCheck(c,arr) {
    for (i = 0;i < arr.length;i++) {
        document.getElementById(arr[i]).checked = c;
    }
}
function adminMovieTitle(e) {
    var a = document.getElementById("blocaffiche");
    var m = document.getElementById("mode").value;
    if(m == 'man') { return; }
    var def = '<div id="blocaffiche"><input type="hidden" id="mode" value="auto" /><div id="imgcont" class="center"></div><p>En attente</p><div><b>&nbsp;</b></div></div>';
    if(e.value.length == 0) {
        a.innerHTML = def;
    } else {
        function ajaxReq() {
            var xhr = createXHR();
            xhr.onreadystatechange = function() { 
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        try { 
                            a.innerHTML = (xhr.responseText);
                        } catch (err) {  } 
                    } else if (xhr.status == 404) {
                        alert('Le contenu n\'est pas accessible (404).');
                        a.innerHTML = def;
                    } else {
                        alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                        a.innerHTML = def;
                    }
                } else {
                    a.innerHTML = '<div id="blocaffiche"><div id="imgcont" class="center"><img src="gui/ajax_load.gif" alt="" /></div><p>&nbsp;</p><div><b>&nbsp;</b></div></div>';
                }
            };
            xhr.open("GET","./inc/modal.inc.php?t=getaff&tit="+e.value,true);
            xhr.send(null);
        }
        ajaxReq();
    }
}
function afficheManuel() {
    disPage();
    h = 400; w = 400;
    makePopup(w,h);
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = (xhr.responseText);
                        adjustModal();
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=getaffman&tit="+document.getElementById("title").value,true);
        xhr.send(null);
    }
    ajaxReq();
}
function selectaff(e) {
    var t = document.getElementById('affres');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        t.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=getaffman_list&q="+e.value,true);
        xhr.send(null);
    }
    ajaxReq();
}
function pickAff(id,f) {
    var a = document.getElementById("blocaffiche");
    try { 
        a.innerHTML = '<div id="blocaffiche"><input type="hidden" id="mode" value="man" /><input type="hidden" name="affid" value="'+id+'" /><div id="imgcont" class="center"><img src="doc/affiches/'+f+'_th.jpg" alt="" /></div><p>Vous avez choisi l\'affiche manuellement</p><div onclick="afficheManuel();" class="std_lk pointer"><b>Choisir manuellement</b></div></div>';
        cancelModal();
    } catch (err) {  } 
}
function getMovieFlag(pays,ev) {
    var e = document.getElementById("filmpays");
    if(pays.length == 0) {
        e.innerHTML = ""; return;
    } else {
        e.innerHTML = '<img src="smlflag_'+pays+'.jpg" alt="" title="Pays" />';
    }
}
function getMovieLength(tp,ev) {
    tp = parseInt(tp);
    if(ev.keyCode == 38) { tp += 1; document.getElementById("duree").value = tp; }
    if(ev.keyCode == 40) { tp -= 1; document.getElementById("duree").value = tp; }
    var e = document.getElementById("filmduree");
    if((tp.length == 0) || !(parseInt(tp) > 0)) {
        document.getElementById("duree").value = "";
        e.innerHTML = ""; return;
    } else {
        h = Math.floor(tp/60);
        m = tp - (h*60);
        if(m < 10) { m = '0'+m; }
        e.innerHTML = h+" h "+m+ " m";
    }
}
function getCelebSelect(input,ev) {
	var v = input.value;
    if(v.length == 0) { celebOff(); choseMyCel(input,-1); return; }
	var e = document.getElementById("celebs");
	if(e == null) {
		var newdiv = document.createElement('div');
	    newdiv.id = "celebs";
	    newdiv.className = "selectbox";
		input.parentNode.appendChild(newdiv);
		var e = document.getElementById("celebs");
	}
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    e.innerHTML = (xhr.responseText);
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = "404 :(";
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = "wtf ?";
                }
            } else {
                e.innerHTML = '<img style="display: block; margin:40px 68px;" src="gui/wait.gif" alt="" title="liste en construction" />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=celebadm&q="+v,true);
        xhr.send(null);
    }
    ajaxReq();
}
function celebOff() {
	var e = document.getElementById("celebs");
	if(e != null) { e.parentNode.removeChild(e); }
}
function choseMyCel(div,cid) {
    if(cid == -1) {
        div.parentNode.childNodes[2].value = cid;
        if(div.parentNode.childNodes.length > 5) {
            div.parentNode.childNodes[5].value = Math.floor(Math.random()*100001);
        }
        div.focus;
        div.value = '';
    } else {
        var sel = div.parentNode.parentNode.childNodes[3];
        div.parentNode.parentNode.childNodes[2].value = cid;
        sel.focus();
        sel.value = div.childNodes[1].innerHTML;
    }
}
function addCast() {
	var b = document.getElementById("cast");
	var c = b.childNodes[4].cloneNode(true);
	b.appendChild(c);
	b.lastChild.firstChild.className = "shown pointer";
    b.lastChild.childNodes[2].value = "";
	b.lastChild.childNodes[3].value = "";
    b.lastChild.childNodes[4].value = "";
    if(b.lastChild.childNodes.length > 5) {
        b.lastChild.childNodes[5].value = "";
    }
}
function delMe(el) {
	el.parentNode.parentNode.removeChild(el.parentNode);
}
function makeNewCel() {
    if(document.getElementById('layer').style.display != 'block') {
        disPage();
        h = 250; w = 400;
        makePopup(w,h);
    }
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=makenewcel",true);
        xhr.send(null);
    }
    ajaxReq();  
}
function insertNewCel() {
    var m = document.getElementById('MWcont');
    var n = document.getElementById('nom').value;
    var p = document.getElementById('prenom').value;
    var bdj = document.getElementById('bd_day').value;
    var bdm = document.getElementById('bd_month').value;
    var bdy = document.getElementById('bd_year').value;
    var ddj = document.getElementById('dd_day').value;
    var ddm = document.getElementById('dd_month').value;
    var ddy = document.getElementById('dd_year').value;
    var sex3 = document.getElementById('sex3').checked ? 1 : 0;
    var sex2 = document.getElementById('sex2').checked ? 1 : 0;
    var sex1 = document.getElementById('sex1').checked ? 1 : 0;
    var gal = document.getElementById('gal').checked ? 1 : 0;
    var fic = document.getElementById('fiche').checked ? 1 : 0;
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=makenewcel_ins&n="+n+"&p="+p+"&bdj="+bdj+"&bdm="+bdm+"&bdy="+bdy+"&ddj="+ddj+"&ddm="+ddm+"&ddy="+ddy+"&sex3="+sex3+"&sex2="+sex2+"&sex1="+sex1+"&gal="+gal+"&fic="+fic,true);
        xhr.send(null);
    }
    ajaxReq();
}
function getTBCel(input,ev) {
	var v = input.value;
    var a = input.id.split("_");
    var id = a[1];
	var e = document.getElementById("resc_"+id);
    if(v.length == 0) { e.innerHTML = ''; return; }
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    e.innerHTML = (xhr.responseText);
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = "404 :(";
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = "wtf ?";
                }
            } else {
                e.innerHTML = '<img style="display: block; margin:40px 68px;" src="gui/wait.gif" alt="" title="liste en construction" />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=celebtb&q="+v+"&ta="+id,true);
        xhr.send(null);
    }
    ajaxReq();
}
function getTBMov(input,ev) {
	var v = input.value;
    var a = input.id.split("_");
    var id = a[1];
	var e = document.getElementById("resm_"+id);
    if(v.length == 0) { e.innerHTML = ''; return; }
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() { 
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    e.innerHTML = (xhr.responseText);
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                    e.innerHTML = "404 :(";
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                    e.innerHTML = "wtf ?";
                }
            } else {
                e.innerHTML = '<img style="display: block; margin:40px 68px;" src="gui/wait.gif" alt="" title="liste en construction" />';
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=filmtb&q="+v+"&ta="+id,true);
        xhr.send(null);
    }
    ajaxReq();
}
function insertCeleb(that,target) {
    var cid = that.id;
    var nom = that.title;
    if(cid > 0) {
        doTag(target,20,cid,nom);
    }
}
function insertFilm(that,target) {
    var fid = that.id;
    var nom = that.title;
    if(fid > 0) {
        doTag(target,22,fid,nom);
    }
}
function upPosterfield(s) {
    var files = document.getElementById('flag').files;
    for (var i = 0, f; f = files[i]; i++) {
        if((f.type == 'image/jpeg') && (f.size <= s)) {
            document.getElementById('fake_file').innerHTML = f.name;
        } else {
            if(f.type != 'image/jpeg') { 
                document.getElementById('fake_file').innerHTML = 'Fichier de mauvais type ('+f.type+')'; 
            } else if(f.size > s) { 
                document.getElementById('fake_file').innerHTML = 'Fichier trop lourd ('+f.size+' o)';
            }
        }
    }
}
function imgExt(ta) {
    disPage();
    h = 200; w = 400;
    makePopup(w,h);
    var m = document.getElementById('MWcont');
    var fid = document.getElementById('fid').value;
    if(fid<1) { return; }
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        m.innerHTML = (xhr.responseText); 
                    } catch (err) {  }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=imgext&ta="+ta+"&fid="+fid,true); 
        xhr.send(null);
    }
    ajaxReq();
}
function showStill(sid) {
    disPage();
    h = 60; w = 150;
    makePopup(w,h);
    mh = 0.8 * getWindowHeight();
    mw = 0.8 * getWindowWidth();
    var m = document.getElementById('MWcont');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    if (xhr.responseText != "") {
                        try { 
                            m.innerHTML = (xhr.responseText);
                            adjustModalImg();
                        } catch (err) {  }                        
                    }
                } else if (xhr.status == 404) {
                    alert('Le contenu n\'est pas accessible (404).');
                } else {
                    alert('Un problème inconnu est survenu avec la requête. (Code : '+xhr.status+')');
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=showstill&sid="+sid+"&mh="+mh+"&mw="+mw,true);
        xhr.send(null);
    }
    ajaxReq();
}
function adjustModalImg() {
    var w = document.getElementById("img").clientWidth;
    var h = document.getElementById("img").clientHeight + 30;
    document.getElementById("MW").style.width = w+"px";
    document.getElementById("MW").style.height = h+"px";
    document.getElementById("MW").style.marginTop = (-1*(h/2))+"px";
    document.getElementById("MW").style.marginLeft = (-1*(w/2))+"px";
}
function getRefresh() {
    var t = document.getElementById('m_con');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        t.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=getcon",true);
        xhr.send(null);
    }
    ajaxReq();
}
function getMainForum(s) {
    var t = document.getElementById('forumlist');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        t.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=getfofo&s="+s,true);
        xhr.send(null);
    }
    ajaxReq();
}
function getSmallForum(s) {
    var t = document.getElementById('smllflist');
    function ajaxReq() {
        var xhr = createXHR();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    try { 
                        t.innerHTML = (xhr.responseText);
                    } catch (err) {  }
                }
            }
        };
        xhr.open("GET","./inc/modal.inc.php?t=getfofosml&s="+s,true);
        xhr.send(null);
    }
    ajaxReq();
}









