﻿    var QuickEditIsDirty = false;
    function QuickEditEmbedded(popupUrl, tooltip) {
        var win = new Window('window_id', {className: "alphacube", 
                                           title: tooltip,
                                           top:300, left:300,
                                           recenterModal: true,
                                           width:700, height:600,
                                           resizable: true,
                                           minimizable: false,
                                           url: popupUrl,
                                           showEffect: Effect.SlideDown,
                                           showEffectOptions: {duration:1},
                                           hideEffect: Effect.SlideUp,
                                           hideEffectOptions: {duration:1}})
        win.setDestroyOnClose();
        win.showCenter(true, 1);
        win.setZIndex(100);
        
        var myDelegate = {
            canClose: function(win) {
                if (QuickEditIsDirty) {
                    var msg = 'You have made changes that have not yet been saved!\n';
                    msg += 'Are you sure you want to close this Quick Edit window.\n\n';
                    msg += 'Click "OK" to continue without saving your changes.\n';
                    msg += 'Click "CANCEL" to go back and save yout changes.\n';
                    if (!confirm(msg)) return false;
                }
                return true;
            }
        }
        win.setDelegate(myDelegate);
        
        var myObserver = {
            onClose: function(eventName, win) {
                setTimeout('window.location.reload();', 1000);
            }
        }
        Windows.addObserver(myObserver);
    }

    function SizedQuickEditEmbedded(popupUrl, tooltip, w, h, onCloseScript) {
        var win = new Window('window_id', { className: "alphacube",
            title: tooltip,
            top: 300, left: 300,
            recenterModal: true,
            width: w, height: h,
            resizable: true,
            minimizable: false,
            url: popupUrl
        })
        win.setDestroyOnClose();
        win.showCenter(true, 1);
        //win.setZIndex(100);

        var myDelegate = {
            canClose: function(win) {
                if (QuickEditIsDirty) {
                    var msg = 'You have made changes that have not yet been saved!\n';
                    msg += 'Are you sure you want to close this Quick Edit window.\n\n';
                    msg += 'Click "OK" to continue without saving your changes.\n';
                    msg += 'Click "CANCEL" to go back and save yout changes.\n';
                    if (!confirm(msg)) return false;
                }
                return true;
            }
        }
        win.setDelegate(myDelegate);

        var myObserver = {
            onClose: function(eventName, win) {
                if (onCloseScript) {
                    setTimeout(onCloseScript, 1000);
                } else {
                    setTimeout('window.location.reload();', 1000);
                }
            }
        }
        Windows.addObserver(myObserver);
    }

