
addListenner(window, "load", installPicturePopup, true);

/**
 * Place l'ouverture du popup de l'image sur le clic
 */
function installPicturePopup()
{
    var linklist = document.getElementsByTagName('a');
    for (var i = 0; i < linklist.length; i++) {
        if (/shadow/.test(linklist[i].className)) {
            linklist[i].onclick = openPicturePopup;
        }
        if (/popup-custom/.test(linklist[i].className)) {
            //linklist[i].onclick = openPicturePopup;
            linklist[i].onclick = function () {
              window.open(this.href, 'zoomillustration', 'height=300, width=280, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes, status=no');
              return false;
            }
        }
    }

} // end function "installImagePopup"



/**
 * Créé le popup du zoom de l'image
 */
function openPicturePopup ()
{
    var image = this.childNodes;
    for (var i = 0; i < image.length; i++) {
        if (image[i].nodeName == 'IMG') {
            var popup = window.open('', 'zoomillustration', 'height=300, width=280, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes, status=no');
            popup.document.write(getPopupWindow(this.href, this.title));
            popup.document.close();
        }
    }

    return false;

} // end function "openPicturePopup"




function getPopupWindow (url, title)
{
    var popupContent = '';
    popupContent += '<html>\r\n';
    popupContent += '    <head>\r\n';
    popupContent += '        <title>Kavadenn : ' + title + '</title>\r\n';
    popupContent += '    </head>\r\n';
    popupContent += '    <body style="background : #ffffff;">\r\n';
    popupContent += '        <img src="' + url + '" alt="' + title + '"/>\r\n';
    popupContent += '    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\r\n';
    popupContent += '    <!--\r\n';
    popupContent += '    var images = document.getElementsByTagName(\'img\');\r\n';

    popupContent += '    images[0].onload = function () {\r\n';
    popupContent += '    	if (this.width > 50 && this.height > 100) {\r\n';
    popupContent += '    		window.resizeTo(this.width + 40, this.height + 70);\r\n';
    popupContent += '    	}\r\n';
    popupContent += '    };\r\n';

    popupContent += '    // -->\r\n';
    popupContent += '    </SCRIPT>\r\n';
    popupContent += '    </body>\r\n';
    popupContent += '</html>\r\n';

    return popupContent;
} // end function "getPopupWindow"


