﻿function ZoomImage(TITLE, BODY, UNESCAPEHTML) {
    if (document.forms.length > 0) 
    {
        frm = $(document.forms[0]);
        Form.disable(frm);
        $A(frm.getElementsByTagName('select')).collect(function(aSelect) 
        {
        aSelect.setStyle({ visibility: 'hidden' });
        });
        heightBody = Element.getHeight(frm);
    }
    var heightBody = Element.getHeight($(document.body));      
    //var frmmod = $('divModal');
    var heightVP = document.viewport.getHeight();
    var widthVP = document.viewport.getWidth();
    
    var maxHeight = heightVP;
    if (heightVP < heightBody) maxHeight = heightBody;

    var modTop = document.viewport.getScrollOffsets().top + 100 + 'px';
    var modLeft = 50 + 'px';
    var modWidth = widthVP - 100 + 'px';
    
    if (UNESCAPEHTML == undefined || UNESCAPEHTML == false) {
        BODY = BODY.escapeHTML().gsub('\\r\\n', '<br/>');
    }
    
    var baseContainer=    "<form id=\"MilongaZoomImageMainCtn\">" +
    "<div id=\"MilongaZoomImageCtn\" style=\"width: 100%;" +
    "    height: " + maxHeight  + "px; top: 0px; left: 0px;\">" +
    "</div><div id=\"MilongaZoomImageBox\" style=\"top: " + modTop + "; width: 100%\" >" +
    "    <center>" +
    "       <table id=\"MilongaZoomImageTable\">" +
    "       <tr id=\"TopBande\" style=\"\"><td style=\"padding:3px;color:white;\"><div style=\"float:right;cursor:pointer\" id=\"btnCloseAdminAlert\" onclick=\"javascript:HideZoomImage();\">[ X ]</div>&nbsp;&nbsp;<b>" + TITLE.escapeHTML().gsub('\\r\\n', '<br/>') + "</b></td></tr>" +
    "       <tr><td style=\"padding:10px;\" id=\"MilongaZoomContent\"><hr style=\"width:400px;visibility:hidden;\"/><a href=\"javascript:HideZoomImage();\" title=\"Fermer\" id=\"Zoom_Close_Img\">" + BODY + "</a></td></tr>" +
    "       <tr><td style=\"\" id=\"btnHideZoomCtn\"><a id=\"btnHideMilongaZoomBox\" class=\"ActionButton\" href=\"javascript:HideZoomImage();\">[ FERMER ]</a></td></tr></table>" +
    "    </center>" +
    "</div>" +
    "</form>"
    if (document.forms.length > 0) {
        frm = $(document.forms[0]);
        Element.insert(frm ,  { after: baseContainer });
        $('MilongaZoomImageBox').focus();
    }
}
function HideZoomImage() {
    Element.remove($('MilongaZoomImageMainCtn'));
    if (document.forms.length > 0) {
        frm = $(document.forms[0]);
        Form.enable(frm);
        $A(frm.getElementsByTagName('select')).collect(function(aSelect) {
            aSelect.setStyle({ visibility: 'visible' });
        });
    }
}

