// partie drag & drop



var II_DD_nn6 = document.getElementById && !document.all;
var II_isDrag = false;
var II_DD_x, II_DD_y;
var II_DD_dObj;
var II_DD_tx;
var II_DD_ty;
var II_DD_dx = 0;
var II_DD_dy = 0;
var II_DD_ddx = 0;
var II_DD_ddy = 0;
var _dx1; var _dy1; var _dx; var _dy
function dropObject() {
    II_DD_dObj.style.left = (II_DD_tx + II_DD_dx + 0.75 * II_DD_ddx) + 'px';
    II_DD_dObj.style.top = (II_DD_ty + II_DD_dy + 0.75 * II_DD_ddy) + 'px';
    // alert(II_DD_ddy+'*'+_dy+'/'+_dy1);

}
function movemouse(e) {
    if (II_isDrag) {
        // _dx=_dx1;_dy=_dy1;
        _dx = II_DD_dx;
        _dy = II_DD_dy;
        //alert((e.clientX )+'-'+ (II_DD_x));
        II_DD_dx = (II_DD_nn6 ? (e.clientX - II_DD_x) * 1 : (event.clientX - II_DD_x) * 1);
        II_DD_dy = (II_DD_nn6 ? (e.clientY - II_DD_y) * 1 : (event.clientY - II_DD_y) * 1);
        II_DD_ddx = II_DD_dx - _dx;
        II_DD_ddy = II_DD_dy - _dy;
        dropObject();
        return false;
    }
}

function selectmouseElement(e) {  //alert('l28');
    var fobj = this;
    var topelement = II_DD_nn6 ? "HTML" : "BODY";
    while (fobj.tagName != topelement && fobj.className != "dragme" && fobj.tagName != 'DIV') {
        fobj = II_DD_nn6 ? fobj.parentNode : fobj.parentElement;
    }
    // alert(fobj.tagName+'-'+ this.tagName)
    if (fobj.className == "dragme" || fobj.tagName == 'DIV') {
        II_isDrag = true;
        II_DD_dObj = fobj;
        II_DD_tx = parseInt(II_DD_dObj.style.left + 0);
        II_DD_ty = parseInt(II_DD_dObj.style.top + 0);
        II_DD_x = II_DD_nn6 ? e.clientX : event.clientX;
        II_DD_y = II_DD_nn6 ? e.clientY : event.clientY;
        document.onmousemove = movemouse;
        II_DD_dx = 0; II_DD_dy = 0;

        return false;
    }
}
// l'element dragAnchorEltId sert de poignée.
// c'est l'élément parent le premier qui est de type 'DIV' ou avec une class 'dragme' qui est transporté

function initDragDrop(dragAnchorEltId) {
    document.getElementById(dragAnchorEltId).style.cursor = 'move'
    document.getElementById(dragAnchorEltId).onmousedown = selectmouseElement;
    document.getElementById(dragAnchorEltId).onmouseup = new Function("II_isDrag=false");
    document.getElementById(dragAnchorEltId).onmouseout = new Function("II_isDrag=false;");
}

// fin partie Drag & drop 


// prepa popup: fct generique ecran et scroll
function oldonscroll() { };

var II_scrollX = 0;
var II_scrollY = 0;
var II_windowHeight = 0;

var II_windowWidth = 0;

function II_calculScroll() {
    if (document.all) {
        var de = !document.documentElement.clientWidth ? document.body : document.documentElement
        II_scrollX = de.scrollLeft;
        II_scrollY = de.scrollTop;
        II_windowHeight = de.clientHeight;
        II_windowWidth = de.clientWidth;
    }
    else {
        II_scrollX = window.pageXOffset;
        II_scrollY = window.pageYOffset;
        II_windowHeight = window.innerHeight;
        II_windowWidth = window.innerWidth;
    }
}


//partie Popup
var isnew_page_action = false;
var page_action = null;
var page_action_opener = null;
var page_action_empty_url = null;

function formatUrl(url, iframeopener) {
    if (url.match(/^(http:|www.).+/i) || (url.charAt(0) == '$')) {
    }
    else if (url.charAt(0) == '/') {
        url = top.location.protocol + '//' + top.location.host + (url.indexOf(top.URL_SITE) == 0 ? '/' : top.URL_SITE) + url.substring(1);
    }
    else {
        var urlOpener = (iframeopener ? iframeopener.location.href : window.location.href);
        var indexOf = urlOpener.indexOf('?');
        if (indexOf >= 0)
            urlOpener = urlOpener.substring(0, indexOf);

        indexOf = urlOpener.lastIndexOf('/');
        if (indexOf >= 0)
            urlOpener = urlOpener.substring(0, indexOf + 1);

        url = urlOpener + url;
    }

    return url;
}

function show_page_action(url, paneltitle, close_authorised, isModal, showwhencenter, iframeopener, scrolling, onclosing, onclosed) {
    // alert('l110: url = '+url+' ; currentlocation = '+window.location)
    url = formatUrl(url, iframeopener);

    page_action = document.getElementById("page_action");
    if (showwhencenter) {
        page_action.style.left = '-2000px';
        document.body.style.cursor = 'wait';
    }
    oldonscroll = window.onscroll;
    if (isModal) {
        document.getElementById("page_action_calque").style.visibility = 'visible';
        window.onscroll = function() {
            window.scrollTo(II_scrollX, II_scrollY);
        }
    }

    if (paneltitle + '' != '')
        document.getElementById('page_action_td_titre_fenetre').innerHTML = paneltitle;
    else
        document.getElementById('page_action_td_titre_fenetre').innerHTML = 'Chargement en cours...';

    page_action.className = 'divShow';
    var _dt = new Date()
    var _windowname = _dt.getHours() + "_" + _dt.getMinutes() + "_" + _dt.getSeconds()
    var _window0 = document.getElementById("page_action_iframe");
    if (page_action_empty_url == null) page_action_empty_url = _window0.contentWindow.location.href;
    var _windowParentNode = _window0.parentNode;
    var _iframeHTML = '<iframe id="page_action_iframe" name="page_action_iframe" scrolling="$SCROLL$" src="' + page_action_empty_url + '" frameBorder="0" style="width:200px;height:100px;" ></iframe>';
    if (url == "$panneau$") url = page_action_empty_url.replace('empty.html', 'emptywithpanneau.html')

    if (url == "$htmlareapanneau$") url = page_action_empty_url.replace('empty.html', 'htmlareaemptywithpanneau.html')
    var _iframeScrolling = 'no'
    if (scrolling) {
        if (scrolling.toLowerCase().indexOf('yes') > -1) { _iframeHTML = _iframeHTML.replace('$SCROLL$', 'yes') }
        else if (scrolling.toLowerCase().indexOf('auto') > -1) { _iframeHTML = _iframeHTML.replace('$SCROLL$', 'auto') }
        else { _iframeHTML = _iframeHTML.replace('$SCROLL$', 'no') };
    }
    else { _iframeHTML = _iframeHTML.replace('$SCROLL$', 'no') };
    _windowParentNode.innerHTML = _iframeHTML;
    var _window = _windowParentNode.firstChild;
    // alert(_windowParentNode.innerHTML)
    try {
        _window.src = url;
    }
    catch (e) {
        _window.contentWindow.location.href = url;
    }


    _window.contentWindow.name = _windowname;
    iiCalCb_HideAllCb();
    // ici, l'iframe prend tout la place disponible, mais il est aussi pssible de definir une largeur et une hauteur finie
    _window.style.width = "100%";
    _window.style.height = "100%";

    document.getElementById('page_action_td_close_button_fenetre').style.display = (close_authorised ? 'block' : 'none');

    if (iframeopener)
        page_action_opener = iframeopener;
    else
        page_action_opener = window;
    if (!_window.contentWindow.opener) {
        try {
            _window.contentWindow.opener = page_action_opener;
        }
        catch (exception) {
        }
    }

    //	alert ('_w.opener.loc='+_window.contentWindow.opener.location)
    //	 alert('l166')
    _window.contentWindow.name = "page_action_iframe";


    initDragDrop('page_action_td_titre_fenetre');
    try {
        //alert('1');
        _window.close = function close() {
            //alert('1.1'); 
            var result = true;

            // Execution d'une fonction avant la fermeture
            // Peut annuler la fermeture en retournant false.
            if (onclosing && (onclosing.length > 0))
                eval("result = " + onclosing);
            //alert('1.2');
            if (result === false)
                return;

            close_page_action();

            // Execution d'une fonction après la fermeture
            if (onclosed && (onclosed.length > 0))
                eval(onclosed);
        }

        //alert('2');
        _window.contentWindow.close = function close() {
            _window.close();
        }

        //alert('3');
        setTimeout("asynchronousIframeInit() ", 200);
        setTimeout("asynchronousIframeInit() ", 1000);
        setTimeout("asynchronousIframeInit() ", 2000);
        //alert('4');
    }
    catch (err) {
        //alert('5');
    }
    II_calculScroll();
    document.getElementById("page_action_calque").style.left = II_scrollX + 'px';
    document.getElementById("page_action_calque").style.top = II_scrollY + 'px';
    isnew_page_action = true;
    //alert('fin showpage');
}
/**/
function asynchronousIframeInit() {
    var win_Iframe_Action = frames['page_action_iframe'];
    if (win_Iframe_Action) {
        try {

            win_Iframe_Action.close = function close() { click_close_page_action(); }
            //   if (!win_Iframe_Action.opener) win_Iframe_Action.opener=page_action_opener;
            //   if (!win_Iframe_Action.opener) win_Iframe_Action.opener=window;  
        }
        catch (err) {
        }
    }
}

function center_page_action(_width, _height, paneltitle, cancelbuttontitle, allways) {
    document.body.style.cursor = 'default';

    if ((isnew_page_action || allways) && page_action) {
        page_action.style.left = ((II_windowWidth - _width) / 2 + II_scrollX) + 'px';
        page_action.style.top = ((II_windowHeight - _height) / 2 + II_scrollY) + 'px';
        //	alert('((  '+II_windowHeight+' - '+ _height+')/2+'+II_scrollY+')');
        isnew_page_action = false;
        if (paneltitle + '' != '' && paneltitle != null) {
            document.getElementById('page_action_td_titre_fenetre').innerHTML = paneltitle
        }
        if (cancelbuttontitle + '' != '' && cancelbuttontitle != null) {
            document.getElementById('page_action_img_close_button').title = cancelbuttontitle
        }
    }
    isnew_page_action = false;
}

function hide_page_action() {
    window.onscroll = oldonscroll;
    if (page_action.className == 'divShow') {
        page_action.className = 'divHide';
        iiCalCb_ShowAllCb()
    }
    document.getElementById("page_action_calque").style.visibility = 'hidden';
    document.getElementById("page_action_iframe").style.width = "1px";
    document.getElementById("page_action_iframe").style.height = "1px";
}

function close_page_action() {
    hide_page_action();
    var newUrl = (page_action_empty_url ? page_action_empty_url : formatUrl('/BibliRessources/js/JsPopup/empty.html'));
    try {
        document.getElementById('page_action_iframe').parentNode.firstChild.src = newUrl;
    }
    catch (e) {
        frames['page_action_iframe'].location.href = newUrl;
    }
}

function click_close_page_action() {
    var page = document.getElementById('page_action_iframe');
    var close = true;
    try // Ca peut-être une popup externe et on n'a pas le droit d'appler une fonction JavaScript dans une page externe
    {   // ou n'existe pas
        try {
            close = page.onclick_close_page_action();
        }
        catch (except) {
            close = page.contentWindow.onclick_close_page_action();
        }
    }
    catch (e) {
    }

    if (close === true) {
        try // les évènements onclosing/onclosed peuvent générer des erreurs
        {
            try {
                page.parentNode.firstChild.close();
            }
            catch (except) {
                page.contentWindow.parentNode.firstChild.close();
            }
        }
        catch (err) {
            close_page_action()
        }
    }
}

var HTMLAreaMaxWidth = 0;

var iframe_max_width = 800;
var iframe_max_height = 520;
var iframe_width = iframe_max_width;
var iframe_height = iframe_max_height;
var objIframeInParentWindow = null;
function page_action_iframe_init(div, iFrameId, spewindow, _width, _height) {
    var scroll = false;
    objIframeInParentWindow = null;
    var _window = window;
    if (spewindow) _window = spewindow;
    //alert(div.offsetWidth+'-'+div.offsetHeight);

    if (iFrameId)
        objIframeInParentWindow = _window.parent.document.getElementById(iFrameId);

    if (objIframeInParentWindow) {
        _window.parent.II_calculScroll();
        iframe_max_width = _window.parent.II_windowWidth - 40;
        if (iframe_max_width < 400)
            iframe_max_width = 400
        if (iframe_max_width > 1200)
            iframe_max_width = 1200;

        iframe_max_height = _window.parent.II_windowHeight - 90;
        if (iframe_max_height < 300)
            iframe_max_height = 300;
        if (iframe_max_height > 650)
            iframe_max_height = 650;
    }
    else {
        iframe_max_width = 800;
        iframe_max_height = 520;
    }
    iframe_width = iframe_max_width;
    iframe_height = iframe_max_height;

    var divWidth = _width;
    var divHeight = _height;

    var offsetDiv = 0;

    if (div != null) {
        divWidth = div.offsetWidth;
        divHeight = div.offsetHeight;
        offsetDiv = offsetElement(div);
    }
    if (divWidth < offsetDiv[0])
        divWidth = offsetDiv[0];

    if (divWidth < iframe_width)
        iframe_width = divWidth;
    if (div != null && HTMLAreaMaxWidth && (HTMLAreaMaxWidth > iframe_width - 4))
        iframe_width = HTMLAreaMaxWidth + 4;

    if (divHeight < iframe_height)
        iframe_height = divHeight;

    // on a du scroll //
    if ((iframe_height >= iframe_max_height) || (iframe_width >= iframe_max_width))
        scroll = true;

    if (!objIframeInParentWindow) {
        iframe_width += 28;
        iframe_height += 28;
    }
    else if (scroll) {
        iframe_width += 12;
        iframe_height += 28;
    }

    if (!document.all) {
        // center on parent
        if (!_window.opener && _window.parent) window.opener = window.parent;
        if (!_window.opener) {
            var x = top.screenX + (top.outerWidth - iframe_width) / 2;
            var y = top.screenY + (top.outerHeight - iframe_height) / 2;

        }
        else {
            var x = _window.opener.top.screenX + (_window.opener.top.outerWidth - iframe_width) / 2;
            var y = _window.opener.top.screenY + (_window.opener.outerHeight - iframe_height) / 2;
        }
        if (scroll) {
            iframe_width += 12;
            _window.resizeTo(iframe_width, iframe_height);
        }
        else
            try {
            _window.sizeToContent();
        }
        catch (e) {
        }

        if (!objIframeInParentWindow)
            _window.moveTo(x, y);
    }
    else {
        iframe_width += 3;
        iframe_height += 3;
        var parentPageAction;
        if (_window.parent && _window.parent.document && (parentPageAction = _window.parent.document.getElementById('page_action')) && (parentPageAction.offsetWidth < iframe_max_width) && (parentPageAction.offsetWidth > iframe_width))
            iframe_width = parentPageAction.offsetWidth;

        try {
            _window.resizeTo(iframe_width, iframe_height);
        }
        catch (e) { }

        var x = (screen.availWidth - iframe_width) / 2;
        var y = (screen.availHeight - iframe_height) / 2;

        if (!objIframeInParentWindow)
            _window.moveTo(x, y);
    }

    if (objIframeInParentWindow) {
        objIframeInParentWindow.style.width = iframe_width + 'px';
        objIframeInParentWindow.style.height = iframe_height + 'px';
    }
    // alert('l349-scroll='+scroll+' ; ifh='+iframe_height+'/max:'+iframe_max_height)

    return scroll;

}

function offsetElement(element) {
    var pos = posElement(element);
    var point = maxPointElement(element, [0, 0]);

    for (var i = 0; i < 2; i++)
        point[i] -= pos[i];

    return point;
}

function maxPointElement(element, point) {
    if (element.style && (element.style.position == 'absolute'))
        return point;

    for (var i = 0; i < element.childNodes.length; i++)
        point = maxPointElement(element.childNodes[i], point);

    var pos = posElement(element);
    pos[0] += element.offsetWidth;
    pos[1] += element.offsetHeight;

    for (var i = 0; i < 2; i++)
        if (point[i] < pos[i])
        point[i] = pos[i];

    return point;
}

function posElement(oElement) {
    //obtention du parent
    function getNextAncestor(oElement) {
        var actualStyle;
        //mozilla implémentation de la recomendation W3C
        if (window.getComputedStyle) {
            actualStyle = getComputedStyle(oElement, null).position;
        } 
        // IE 
        else if (oElement.currentStyle) {
            actualStyle = oElement.currentStyle.position;
        }
        //autre 
        else {  
            actualStyle = oElement.style.position;
        }
        //si le style de l'élément est absolute ou fixed alors ca position est dépendante du parent direct
        if (actualStyle == 'absolute' || actualStyle == 'fixed') {
          
            return oElement.offsetParent;
        }
        //sinon on traite le parent direct 
        return oElement.parentNode;
    }
    // (oElement.offsetParent) != 'undefined' indique que le composant est positionné par raport a un parent.
    if (typeof (oElement.offsetParent) != 'undefined') {
        var originalElement = oElement;
        //parcours de toutes les position des parents
        for (var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent) {
            posX += oElement.offsetLeft;
            posY += oElement.offsetTop;
        }
        //s'il n'y a pas de parent qu'il n'y a pas de style ou qu'il n'y a pas de scroll il n'est pas 
        //nécéssaire de calculer le scroll
        if (!originalElement.parentNode || !originalElement.style || typeof (originalElement.scrollTop) == 'undefined') {
            return [posX, posY];
        }

        oElement = getNextAncestor(originalElement);
        //recheche des tailles de scroll dans les parents
        while (oElement && oElement != document.body && oElement != document.documentElement) {
            posX -= oElement.scrollLeft;
            posY -= oElement.scrollTop;
            oElement = getNextAncestor(oElement);
        }
        return [posX, posY];
    } else {
        //retourne la position de l'element dans le cas ou il n'est pas positionné par raport a un parent
        return [oElement.x, oElement.y];
    }

}

function getElementByRightId(rightId, tagName) {
    var objs = document.getElementsByTagName(tagName);
    var obj;
    var obj_i;
    var objId;
    var l = rightId.length;
    var x;
    rightId = rightId.toLowerCase();

    for (i = 0; i < objs.length; i++) {
        objId = objs[i].id.toLowerCase();
        x = objId.indexOf(rightId);
        if (objId.length == x + l) return (objs[i]);
    }
}


function IsDirty(eForm) {
    if (!eForm && theForm) eForm = theForm;
    if (!eForm) { eForm = document.forms[0] }
    if (!eForm) { return false; };
    var iNumElems = eForm.elements.length;

    if (typeof eForm.onhtmlareasgethtml == "function") {
        var coderetouronhtmlareasgethtml = eForm.onhtmlareasgethtml();
    }
    for (var i = 0; i < iNumElems; i++) {
        var eElem = eForm.elements[i];
        if ("text" == eElem.type || "TEXTAREA" == eElem.tagName) {
            if (eElem.value != eElem.defaultValue) return true;
        }
        else if ("checkbox" == eElem.type || "radio" == eElem.type) {
            if (eElem.checked != eElem.defaultChecked) return true;
        }
        else if ("SELECT" == eElem.tagName && eElem.id) {
            var cOpts = eElem.options;
            var iNumOpts = cOpts.length;
            for (var j = 0; j < iNumOpts; j++) {
                var eOpt = cOpts[j];
                // alert(eOpt.defaultSelected);
                if (eOpt.selected != eOpt.defaultSelected) return true;
            }
        }
    }
    return false;
}
function confirmOrNotDirty(msg) {

    if (!IsDirty()) return true;
    return (confirm(msg));
}


function openpopupinparent(w, h, name, url, opener, scrolling) {
    var docdivblock = parent.document.getElementById('page_action');
    if (name + '' == '') name = 'Edition'
    if (!opener) opener = window;
    if (docdivblock) {
        parent.show_page_action(url, name, true, true, true, opener, scrolling); //(url, paneltitle, close_authorised, isModal, opener) 
    }
    else {
        docdivblock = parent.document.getElementById('div_' + name)
        //alert('name='+name);
        fentree = window.open('', name, 'top=' + (screen.height - h) / 2 + ',left=' + (screen.width - w) / 2 + ',width=' + w + ',height=' + h + ',resizable=yes,toolbar=no,location=no,menubar=no,scrollbars=yes,status=no');
        fentree.location = url;
        fentree.opener = opener;
        if (docdivblock) {
            docdivblock.className = 'divShow';
        }
        else {
            //alert('erreur div block');
        }
        fentree.focus();
    };
}
function openpopup(w, h, name, url, opener, scrolling) {
    var docdivblock = document.getElementById('page_action');
    if (name + '' == '') name = 'Edition';
    if (!opener) opener = window;

    if (docdivblock) {
        show_page_action(url, name, true, true, true, opener, scrolling); //(url, paneltitle, close_authorised, isModal,showwhencenter,iframeopener)
    }
    else {
        name = name.replace(" ", "");
        docdivblock = document.getElementById('div_' + name)
        fentree = window.open('', name, 'top=' + (screen.height - h) / 2 + ',left=' + (screen.width - w) / 2 + ',width=' + w + ',height=' + h + ',resizable=yes,toolbar=no,location=no,menubar=no,scrollbars=yes,status=no');
        fentree.location = url;
        fentree.opener = opener;
        if (docdivblock) {
            docdivblock.className = 'divShow';
        }
        else {
            //alert('erreur div block');
        }
        fentree.focus();
    };
}

function openpopupSimpleAndCenter(_w, _h, _name, _url, _closebuttontitle, _opener, scrolling, onclosing, onclosed) {
    var docdivblock = document.getElementById('page_action');
    //if (_name+''=='') _name=null;  
    if (!_opener) _opener = window;
    if (docdivblock) {
        show_page_action(_url, _name, true, true, true, _opener, scrolling, onclosing, onclosed);
        var _spewindow = window.frames[0];
        objIframeInParentWindow = document.getElementById("page_action_iframe");
        page_action_iframe_init(null, "page_action_iframe", _spewindow, _w, _h)
        center_page_action(_w, _h, _name, _closebuttontitle, true)
        return _spewindow
    }
    else {
        if (_name + '' == '') _name = 'Details';
        var _top = (screen.height - _h) / 2;
        var _left = (screen.width - _w) / 2;
        return window.open(_url, _name, 'top=' + _top + ',left=' + _left + ',width=' + _w + ',height=' + _h + ',scrollbars=1,resizable=1');

    }
}
function popupDim(_w, _h, page, _titre, _opener, scrolling) {
    if (!_titre) _titre = " "; // un espace pour éviter de laisser le titre 'chargement en cours'
    if (!_opener) _opener = window;
    openpopupSimpleAndCenter(_w, _h, _titre, page, '', _opener, scrolling)
}
function popup(page, _titre, _opener, scrolling) {
    popupDim(600, 400, page, _titre, _opener, scrolling)
}
var iiCalCb_SelNu = null;
function iiCalCb_InitSelNu() {
    if (!iiCalCb_SelNu) {
        iiCalCb_SelNu = document.getElementsByTagName('select');

        for (iiCalCb_i = 0; iiCalCb_i < iiCalCb_SelNu.length; iiCalCb_i++) {

            if (iiCalCb_SelNu[iiCalCb_i].doNotDisappear != 1) {
                if (!iiCalCb_SelNu[iiCalCb_i].style.visibility) { iiCalCb_SelNu[iiCalCb_i].style.visibility = '' }
                iiCalCb_SelNu[iiCalCb_i].visibility0 = iiCalCb_SelNu[iiCalCb_i].style.visibility
            }
        }
    };
}



function iiCalCb_HideAllCb() {

    if (!document.all) { return; }
    iiCalCb_InitSelNu();
    for (iiCalCb_i = 0; iiCalCb_i < iiCalCb_SelNu.length; iiCalCb_i++) {
        if (iiCalCb_SelNu[iiCalCb_i].doNotDisappear != 1) {
            if (iiCalCb_SelNu[iiCalCb_i].visibility0 == 'visible' || iiCalCb_SelNu[iiCalCb_i].visibility0 == '') {
                iiCalCb_SelNu[iiCalCb_i].style.visibility = 'hidden';

            }
        }
    }
}


function iiCalCb_ShowAllCb() {

    if (!document.all) { return; }
    for (iiCalCb_i = 0; iiCalCb_i < iiCalCb_SelNu.length; iiCalCb_i++) {
        if (iiCalCb_SelNu[iiCalCb_i].doNotDisappear != 1) {
            if (iiCalCb_SelNu[iiCalCb_i].style.visibility == 'hidden') {

                iiCalCb_SelNu[iiCalCb_i].style.visibility = iiCalCb_SelNu[iiCalCb_i].visibility0;

            }
        }
    }
}

function sendMailOrSMS() {
    url = URL_SITE + 'BibliBackOffice/MailingList/ParamSend.aspx';
    var docdivblock = parent.document.getElementById('page_action');
    if (docdivblock)
        parent.show_page_action(url, 'Edition', true, true, true, window);
    else {
        docdivblock = parent.document.getElementById('div_' + name);
        fentree = window.open('', 'sendmail_form', 'top=' + (screen.height - h) / 2 + ',left=' + (screen.width - w) / 2 + ',width=840,height=700,resizable=yes,toolbar=no,location=no,menubar=no,scrollbars=yes,status=no');
        fentree.location = url;
        fentree.opener = window;
        if (docdivblock)
            docdivblock.className = 'divShow';
        fentree.focus();
    }
}

function getWindowOpener() {
    var result = window.opener;
    if (!result && parent) {
        result = parent;
        if (parent.page_action_opener)
            result = parent.page_action_opener;
    }
    return result;
}

var page_action_lastIdTopMessage = null;
var page_action_xhr_object = null;
function checkTopMessage() {
    var _dt = new Date()
    var page_action_TopMessage_url = formatUrl('/BibliRessources/PagesSystem/GetTopMessage.ashx') + '?datetime=' + _dt.getHours() + "_" + _dt.getMinutes() + "_" + _dt.getSeconds()
    if (window.XMLHttpRequest) // Firefox
        page_action_xhr_object = new XMLHttpRequest();
    else if (window.ActiveXObject) // Internet Explorer
        page_action_xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
    else { // XMLHttpRequest non supporté par le navigateur
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
        return;
    }
    page_action_xhr_object.open("GET", page_action_TopMessage_url, true);
    page_action_xhr_object.onreadystatechange = function() {
        if (page_action_xhr_object.readyState == 4) {
            if (page_action_xhr_object.responseText && page_action_xhr_object.responseText.length > 10) {
                var p_id = page_action_xhr_object.responseText.indexOf('<id>')
                var p_id2 = page_action_xhr_object.responseText.indexOf('</id>')
                var p_msg = page_action_xhr_object.responseText.indexOf('<msg>')
                var p_msg2 = page_action_xhr_object.responseText.indexOf('</msg>')
                // si il y a un message réel actif ds le contexte

                if (p_id > 0 && p_id2 > p_id && p_msg > p_id2 && p_msg2 > p_msg) {
                    var sidTopMessage = page_action_xhr_object.responseText.substring(p_id + 4, p_id2)
                    if (sidTopMessage > 0 && sidTopMessage != page_action_lastIdTopMessage) {
                        page_action_lastIdTopMessage = sidTopMessage;
                        var sTopMessage = page_action_xhr_object.responseText.substring(p_msg + 5, p_msg2)
                        alert(sTopMessage)
                    }
                }

            }
        }
    }
    page_action_xhr_object.send(null);
    setTimeout("checkTopMessage() ", 60000);

}
if (window == top) {
    setTimeout("checkTopMessage() ", 2000);
} 