﻿function WinOpen(value) {
    //WinOpen(name       ,height,width,top,left,resizable,scrollbars,status,toolbar,location,directories,menubar)
    //WinOpen(this.target,400   ,  200,  0,    0,       0,         0,     0,      0,       0,          0,      0)
    var argv = WinOpen.arguments;
    var argc = WinOpen.arguments.length;
    var name = (argc > 0) ? argv[0] : null;
    var height = (argc > 1) ? argv[1] : null;
    var width = (argc > 2) ? argv[2] : null;
    var top = (argc > 3) ? argv[3] : null;
    var left = (argc > 4) ? argv[4] : null;
    var resizable = (argc > 5) ? argv[5] : null;
    var scrollbars = (argc > 6) ? argv[6] : null;
    var status = (argc > 7) ? argv[7] : null;
    var toolbar = (argc > 8) ? argv[8] : null;
    var location = (argc > 9) ? argv[9] : null;
    var directories = (argc > 10) ? argv[10] : null;
    var menubar = (argc > 11) ? argv[11] : null;
    var scrH = screen.availHeight - 30;
    var scrW = screen.availWidth - 10;

    if (height == 0 || width == 0) {
        var options = "height=" + scrH + ",";
        options += "width=" + scrW + ",";
        top = 0;
        left = 0;
    } else {
        var options = (height != null) ? "height=" + height + "," : "";
        options += (width != null) ? "width=" + width + "," : "";
        if (top == 0 && left == 0) {
            var left = (scrW - width) / 2;
            var top = (scrH - height) / 2;
        }
    }

    options += (top != null) ? "top=" + top + "," : "";
    options += (left != null) ? "left=" + left + "," : "";

    if (resizable == null || resizable == 1) { options += "resizable=yes,"; } else { options += "resizable=no,"; }
    if (scrollbars == null || scrollbars == 1) { options += "scrollbars=yes,"; } else { options += "scrollbars=no,"; }
    if (status == null || status == 1) { options += "status=yes,"; } else { options += "status=no,"; }
    if (toolbar == null || toolbar == 1) { options += "toolbar=yes,"; } else { options += "toolbar=no,"; }
    if (location == null || location == 1) { options += "location=yes,"; } else { options += "location=no,"; }
    if (directories == null || directories == 1) { options += "directories=yes,"; } else { options += "directories=no,"; }
    if (menubar == null || menubar == 1) { options += "menubar=yes"; } else { options += "menubar=no"; }


    var mywindow = window.open('about:blank', name, options);
    mywindow.focus();

}


function modalWin(filepath) 
    {
        if (window.showModalDialog) {
            window.showModalDialog(filepath , 'newsletter', "dialogWidth:640px;dialogHeight:450px");
        } else {
            window.open(filepath, 'newsletter', 'height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes'); 
            
        } 
}