﻿/**************** Cration pop-ups */
function browserFix(split_attr) {
    var sizeFix = new Array();
    var w = 0;
    var h = 0;
    // modifie la grosseur de la fenetre pour le browser en question
    if ($.browser.msie) {
        if ($.browser.version >= 7) {
            // toolbar
            if (split_attr[6] == 1) { w += 0; h += 29; }
        } else {
            // menubar
            if (split_attr[9] == 1) { w += 0; h += -19; }
        }

        // scrollbar
        if (split_attr[4] == 1) { w += 16; h += 0; }

    } else if ($.browser.mozilla) {
        // scrollbar
        if (split_attr[4] == 1) { w += 16; h += 0; }
        // location
        if (split_attr[5] == 1) { w += 0; h += 6; }
        // toolbar
        if (split_attr[6] == 1) { w += 0; h += -6; }

    } else if ($.browser.safari) {
        // scrollbar
        if (split_attr[4] == 1) { w += 16; h += 0; }

    }
    sizeFix[0] = w;
    sizeFix[1] = h;
    return sizeFix
}


function createLinkPop() {
    var doc_loc = document.location + " ";
    
    // trouve les liens avec la class popup
    popUpLinks = $("a.popup");

    for (i = 0; i < popUpLinks.length; i++) {
        // Extrait la valeur du rel et fait un array avec
        attr = $(popUpLinks[i]).attr("rel");
        split_attr = attr.split(",");
        // modifier la taille de la fenetre pour les browser different
        sizeFix = browserFix(split_attr);
        
        dimensionFenetre = "width=" + (parseInt(split_attr[0]) + sizeFix[0]) + ",height=" + (parseInt(split_attr[1]) + sizeFix[1]) + ",top=" + split_attr[2] + ",left=" + split_attr[3] + ",scrollbars=" + split_attr[4] + ",location=" + split_attr[5] + ",toolbar=" + split_attr[6] + ",status=" + split_attr[7] + ",resizable=" + split_attr[8] + ",menubar=" + split_attr[9];
        $(popUpLinks[i]).attr("rel", dimensionFenetre)
        $(popUpLinks[i]).attr("name", "pop" + Math.round(100000 * Math.random()))
        $(popUpLinks[i]).click(function() {
            popupwin = window.open($(this).attr("href"), $(this).attr("name"), $(this).attr("rel"));
            return false;
        });
    }
}
