var windows = new Array();

function showMapWindow(id, theme, modal, url, width, height, title) {
    if(windows[id] == null) {
        windows[id] = new Window(id, {
            className:theme, 
            width: width, 
            height: height, 
            title: title});
        windows[id].setURL(url);
    } else {
        windows[id].refresh();
    }
        //win.setDestroyOnClose();
    windows[id].showCenter(modal);
}

function showScheduleWindow(id, elementId, theme, modal, url, width, height, title) {
    if(windows[id] == null) {
        windows[id] = new Window(id, {className:theme, width: width, height: height, title: title})
        windows[id].setURL(url);
    } else {
        windows[id].refresh();
    }
    //win.setDestroyOnClose();
    
    var element = $(elementId);
    var y = element.positionedOffset()['top'];
    var clientHeight = document.viewport.getHeight();
    var pageYOffset = document.viewport.getScrollOffsets()['top'];
    if(y - pageYOffset + height > clientHeight - 50) {
        y = y - ((y - pageYOffset + height) - (clientHeight - 50));
        if(y < 0) {
            y = 100;
        }
    }
    windows[id].setLocation(y, element.positionedOffset()['left']);
    windows[id].show(modal);
}
