﻿function popUp(windowProperties) {
    var day = new Date();
    var id = day.getTime();
    var getVal = "";

    // is this needed in Sitefinity?
    windowProperties = jQuery.evalJSON(windowProperties);

    if (windowProperties.url.indexOf("[Sitefinity]") != -1) {
        getVal = "/Sitefinity/Admin/ControlTemplates/Pages/Dialogs/GetPageId.ashx?id=" + windowProperties.url.replace("[Sitefinity]", "");
        jQuery.get(getVal, function(data) {        
            eval("page" + id + " = window.open('" + data +
            "?popup=true', '" + id +
            "', 'toolbar=" + windowProperties.toolbar +
            ",scrollbars=" + windowProperties.scrollbars +
            ",location=" + windowProperties.location +
            ",statusbar=" + windowProperties.statusbar +
            ",menubar=" + windowProperties.menubar +
            ",resizable=" + windowProperties.resizable +
            ",width=" + windowProperties.width +
            ",height=" + windowProperties.height + "');");            
        });
    } else {
         eval("page" + id + " = window.open('" + windowProperties.url +
            "?popup=true', '" + id +
            "', 'toolbar=" + windowProperties.toolbar +
            ",scrollbars=" + windowProperties.scrollbars +
            ",location=" + windowProperties.location +
            ",statusbar=" + windowProperties.statusbar +
            ",menubar=" + windowProperties.menubar +
            ",resizable=" + windowProperties.resizable +
            ",width=" + windowProperties.width +
            ",height=" + windowProperties.height + "');");
    }
}

function closeWindow() {
    self.close();
}
