if (!window.console) {
    window.console = {};
    window.console.debug = function () {}
} else {
    if (!console.debug) {
        console.debug = function () {}
    }
}
function reportError(B) {
    var C = {
        success: function () {},
        failure: function () {}
    };
    var A = "lineNumber=" + B.lineNumber + "&message=" + B.message + "&name=" + B.name + "&description=" + B.description + "&number=" + B.number + "&ua=" + B.ua + "&stack=" + tools.removeCChars(B.stack);
    YAHOO.util.Connect.asyncRequest("POST", "errors.php", C, A)
}
function checkMethod(A) {
    return function () {
        try {
            A.call(this, arguments)
        } catch(B) {
            ef.bugs.add(B, "js")
        }
    }
}
var SETTINGS = {
    url: "",
    dimensions: [0, 0],
    weight: "0",
    format: ""
};
var lang = {
    compressor: {
        bits24: "24 bity"
    },
    warning: {
        emptyProjectDescription: "Podaj ogólny opis projektu",
        emptyEmail: "Podaj Twój adres email."
    },
    error: {
        session_expired: "Twoja sesja wygasła. Strona zostanie przeładowana bo wybraniu Ok.",
        main: "Błąd",
        requestFailure: "Wystąpił problem z serwerem. Proszę spróbować za chwilę."
    },
    tooltip: {
        hide: "Ukryj",
        hideTips: "Ukryj porady",
        nextTip: "Następna porada",
        prevTip: "Poprzednia porada"
    },
    tip: {
        save: "Wybierz <b>Plik</b> a następnie <b>Zapisz zdjęcie</b> aby zapisać zdjęcie na dysku swojego komputera. Możesz również użyć klawiszy <b>Shift+S</b>.",
        start: "Wybierz <b>Plik</b> a następnie <b>Nowe zdjęcie</b> aby dodać zdjęcie i rozpocząć pracę z programem. Możesz również użyć klawiszy <b>Shift+U</b>.",
        cropp: "Kliknij dwukrotnie w kadr lub wciśnij <b>Enter</b> aby wyciąć odpowiedni fragment zdjęcia. Po najechaniu kursorem na zdjęcie obszar kadru możesz przesuwać za pomocą <b>&larr;</b> i <b>&rarr;</b> z opcjonalnie wciśniętnym klawiszem <b>Shift</b>.",
        clipboard: "Użyj klawiszy <span style='font-weight: 900'>Ctrl+V</span> aby wkleić ścieżkę do obrazka ze schowka systemowego.",
        sliderDialog: "Zdjęcie zostanie zmodyfikowane dopiero po wybraniu <b>Ok.</b>",
        red_eye: "Zaznacz obszar, w którym ma zostać usunięty efekt czerwonych oczu. Następnie kliknij dwukrotnie w zaznaczoną część zdjęcia lub w przycisk <b>Usuń czerwone oczy</b> aby wykonać operację.",
        red_eye_ext: "Zaznacz obszar, w którym ma zostać usunięty efekt czerwonych oczu. Następnie kliknij dwukrotnie w zaznaczoną część zdjęcia, przycisk <b>Usuń czerwone oczy</b> lub otwórz menu kontekstowe i wybierz <b>Usuń czerwone oczy</b> aby wykonać operację.",
        textInput: "Wprowadź nową wartość i wciśniej <b>Enter</b> lub wyjdź z pola na przykład przy pomocy klawisza <b>Tab</b> lub myszy.",
        upload: "Wybierz jedną z metod ładowania zdjęcia. Załaduj zdjęcie z dysku swojego komputera, wpisz adres URL zdjęcia lub edytuj zdjęcie testowe."
    },
    cropp: {
        imgToSmall: "Oba wymiary zdjęcia muszą wynosić przynajmniej 30px."
    },
    randomTips: ["Wykorzystaj kółko myszy <br> ( ang. mouse wheel ) do zmiany rozmiaru zdjęcia", "Korzystaj z kilku skrótów klawiszowych przyśpieszających pracę z edytorem np. <b>Shift+S</b> otwiera dialog do zapisywania zdjęcia.", "Początkowa postać zdjęcia jest dostępna po wybraniu <b>Edycja</b> a następnie <b>Resetuj</b>."],
    photoSignature: {
        header: "Podpis zdjęcia",
        instructions: "Wpisz tekst, który zostanie dodany jako podpis zdjęcia."
    },
    colorPicker: {
        illegalHex: "Nieprawidłowa wartość szesnastkowa",
        showColorDetails: "Pokaż detale koloru",
        hideColorDetails: "Ukryj detale koloru",
        currentColor: "Aktualnie wybrany kolor: {rgb}",
        closestWebsafe: "Najbliższy bezpieczny (websafe) kolor: {rgb}. Kliknij aby wybrać."
    },
    menu: {
        file: {
            main: "Plik",
            saveOnDisc: "Zapisz zdjęcie",
            sharePhoto: "Udostępnij zdjęcie",
            uploadFile: "Nowe zdjęcie",
            uploadNk: "Wyślij na nasza-klasa.pl",
            exit: "Wyjście"
        },
        edit: {
            main: "Edycja",
            back: "Cofnij",
            forward: "Ponów",
            reset: "Przywróć początkowe zdjęcie"
        },
        tools: {
            main: "Narzędzia",
            settings: "Ustawienia",
            addFrame: "Dodaj ramkę",
            cropp: "Kadrowanie",
            colorMask: "Kolorowa maska",
            compression: "Kompresja",
            converter: "Konwerter",
            toolbarHide: "Ukryj pasek narzędzi",
            toolbarShow: "Pokaż pasek narzędzi",
            zoomer: "Lupa",
            showTip: "Pokaż następną poradę"
        },
        efects: {
            brightness: "Jasność",
            main: "Efekty",
            sepia: "Sepia",
            negative: "Negatyw",
            contrast: "Kontrast",
            blur: "Rozmycie",
            charcoal: "Malowania kredkami",
            oilpaint: "Farb olejnych",
            bw: "Czarno-biały",
            mirror: "Lustrzane odbicie",
            pixelate: "Efekt pikseli",
            redEye: "Usunięcie czerwonych oczu",
            rotate: "Obrót zdjęcia",
            rotate90r: "90 stopni w prawo",
            rotate180: "180 stopni",
            rotate90l: "90 stopni w lewo",
            wetFloor: "Efekt mokrej podłogi",
            oldImg: "Efekt starego zdjęcia"
        },
        help: {
            faq: "FAQ",
            main: "Pomoc",
            forum: "Forum",
            contact: "Kontakt",
            about: "O programie"
        }
    },
    framePicker: {
        addFrame: "Ramki",
        tip: "Kliknij dwukrotnie na ramkę lub zaznacz ją i wybierz Ok aby została dodana do zdjęcia.",
        editor: "Wpisz tekst, który zostanie dodany jako podpis zdjęcia.",
        editorHeader: "Podpis zdjęcia"
    },
    buttons: {
        ok: "Ok",
        cut: "Wytnij",
        clear: "Wyczyść",
        send: "Wyślij",
        share: "Udostępnij",
        cancel: "Anuluj",
        saveOnDisc: "Zapisz na dysku",
        compress: "Kompresuj",
        convert: "Konwertuj",
        converterButton: {
            title: "kliknij aby rozwinąć listę"
        }
    },
    info: {
        sendMessageSuccess: "Wiadomość została wysłana."
    },
    loading: "Pobieranie danych...",
    wait_cancel: "anuluj bieżącą operację",
    toolbar: {
        closeButton: {
            hide: "Ukryj pasek narzędzi",
            show: "Pokaż pasek narzędzi"
        },
        backButton: {
            back: "Pokaż główny pasek narzędzi"
        },
        warnings: {
            valueError: "Wprowadzono nieprawidłową wartość"
        }
    },
    editor: {
        fontStyle: "Styl czcionki",
        fontColor: "Kolor czcionki",
        bgColor: "Kolor tła",
        bold: "Pogrubienie",
        italic: "Pochylenie",
        underline: "Podkreślenie"
    }
};
var ef = function () {
    return {
        exit: function () {
            try {
                dialogsMgr.confirmDialogShow("Czy napewno chcesz zamknąć program i powrócić do strony głównej edytujfotke.pl ?", "Zamknięcie programu", function () {
                    location.href = "/"
                },
                null)
            } catch(A) {
                ef.bugs.add(A, "js")
            }
        },
        defaultView: function () {
            try {
                cropper.off();
                zoomerMgr.hide();
                tooltipMgr.hide();
                redEyeMgr.hide()
            } catch(A) {
                console.debug(A)
            }
        },
        toolsInit_: function () {
            converter.init();
            converter.setFormat("jpg");
            upload.init();
            dialogsMgr.init();
            save.init();
            compressor.init();
            cropper.init();
            clipboard.init();
            historyMgr.init()
        },
        coreInit_: function () {
            ef.bugs.init();
            editor.init();
            topMenuBar.init();
            photoMgr.init();
            toolbar.init();
            Event.on(window, "resize", function () {},
            this, true)
        },
        createData: function (F, B) {
            var A = B || {};
            var E = "";
            for (var C in A) {
                if (A.hasOwnProperty(C)) {
                    E += YAHOO.lang.substitute("{key}={value}&", {
                        key: C,
                        value: A[C]
                    })
                }
            }
            E = YAHOO.lang.substitute("cmd={cmd}&" + E + "position={position}", {
                cmd: F,
                position: historyMgr.getPosition()
            });
            var D = photoMgr.hasChanged();
            if (D && !A.width && !A.height) {
                E += YAHOO.lang.substitute("&width={width}&height={height}", {
                    width: D[0],
                    height: D[1]
                })
            }
            return E
        },
        setCookie_: function () {
            document.cookie = "PHPSESSID=; epath=/dev/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
            document.cookie = "PHPSESSID=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT"
        },
        init: function () {
            this.coreInit_();
            this.toolsInit_();
            this.setCookie_();
            upload.show({
                close: false,
                cancel: false
            })
        },
        rotationBridge: function (A, C, B) {
            try {
                this.rotation(B)
            } catch(C) {
                ef.bugs.add(C, "js", "ef.rotationBridge")
            }
        },
        rotation: function (A) {
            this.send("rotation", {
                direction: A
            })
        },
        sendBridge: function (B, C, A) {
            try {
                this.send(A)
            } catch(C) {
                ef.bugs.add(C, "js", "ef.sendBridge")
            }
        },
        send: function (A, B, C) {
            if (!C) {
                C = {}
            }
            if (!C.onSuccess) {
                C.onSuccess = function () {}
            }
            if (!C.onFailure) {
                C.onFailure = function () {}
            }
            this.defaultView();
            this.request = new Ajax({
                data: this.createData(A, B),
                callback: {
                    onSuccess: function (F) {
                        C.onSuccess.call(C.scope);
                        try {
                            var D = JSON.parse(F.responseText)
                        } catch(E) {
                            ef.bugs.add(E, "json", "ef.send", F.responseText);
                            return
                        }
                        loadMgr.run(D)
                    },
                    onFailure: function (D) {
                        C.onFailure.call(C.scope);
                        dialogsMgr.errorShow(D.responseText)
                    }
                }
            });
            this.request.send()
        }
    }
}();
ef.ui = function () {
    return {}
}();
ef.bugs = function () {
    var B = "bts.php",
        C;
    var A = function (G, E, F) {
        var H = {
            success: function (J) {
                var I = JSON.parse(J.responseText);
                if (I.status === 0) {
                    alert("W trakcie działania aplikacij wystąpił błąd. Informacja została już wysłana do administratorów www.edytujfotke.pl w celu analizy i naprawy. Za utrudnienia przepraszamy.")
                } else {
                    alert("W trakcie działania aplikacij wystąpił błąd. Za utrudnienia przepraszamy.")
                }
            },
            failure: function () {},
            scope: this
        };
        F = {
            type: E || "null",
            lineNumber: G.lineNumber || "null",
            fileName: G.fileName,
            line: G.line || "null",
            sourceURL: G.sourceURL || "null",
            message: (G.message) ? G.message.replace(/[\r\n]/g, "<br>") : "null",
            name: G.name || "null",
            description: G.description || "null",
            number: G.number || "null",
            ua: C || "null",
            stack: (G.stack) ? G.stack.replace(/[\n\r\t]/g, "") : "null",
            data: F
        };
        YAHOO.util.Connect.asyncRequest("POST", B, H, "data=" + encodeURIComponent(JSON.stringify(F)))
    };
    var D = function (H, F, G, E) {
        var I = {
            success: function (K) {
                var J = JSON.parse(K.responseText);
                if (J.status === 0) {
                    alert("W trakcie działania aplikacij wystąpił błąd. Informacja została już wysłana do administratorów www.edytujfotke.pl w celu analizy i naprawy. Za utrudnienia przepraszamy.")
                } else {
                    alert("W trakcie działania aplikacij wystąpił błąd. Za utrudnienia przepraszamy.")
                }
            },
            failure: function () {},
            scope: this
        };
        G = {
            type: F || "null",
            lineNumber: H.lineNumber || "null",
            line: "null",
            sourceURL: "null",
            number: "null",
            ua: C || "null",
            fileName: H.fileName,
            message: (H.message) ? H.message.replace(/[\r\n]/g, "<br>") : "null",
            name: H.name || "null",
            data: G,
            stack: H.stack,
            description: E
        };
        YAHOO.util.Connect.asyncRequest("POST", B, I, "data=" + encodeURIComponent(JSON.stringify(G)))
    };
    return {
        init: function () {
            C = "n/a";
            for (key in YAHOO.env.ua) {
                if (YAHOO.env.ua.hasOwnProperty(key) && YAHOO.lang.isNumber(YAHOO.env.ua[key]) && YAHOO.env.ua[key] > 0) {
                    C = key + "-" + YAHOO.env.ua[key]
                }
            }
        },
        add: function (H, F, G, E) {
            switch (F) {
            case "js":
                A(H, F, G);
                break;
            case "json":
                D(H, F, G, E);
                break;
            default:
                throw new Error("ef.bugs.add - unrecognized error type")
            }
        }
    }
}();
var Dom = YAHOO.util.Dom,
    Event = YAHOO.util.Event,
    DDM = YAHOO.util.DragDropMgr,
    Connect = YAHOO.util.Connect,
    JSON = YAHOO.lang.JSON,
    configuration = {
    CSS: {
        IDs: {
            errorDialog: "error-dialog",
            zoomer: "zoomer",
            zoomerMiniature: "zoomer-miniature",
            topMenuBar: "top-menu-bar",
            topMenuBarHelp: "top-menu-bar-help",
            topMenuBarEffects: "top-menu-bar-effects",
            topMenuBarRotate: "top-menu-bar-rotate",
            topMenuBarTools: "top-menu-bar-tools",
            topMenuBarEdit: "top-menu-bar-edit",
            topMenuBarFile: "top-menu-bar-file",
            topMenuBarSettings: "top-menu-bar-settings",
            wait: "wait",
            img: "userImage",
            topRuler: "top-ruler",
            leftRuler: "left-ruler",
            editor: "editor",
            photoContainer: "photo-container",
            toolbar: "toolbar",
            toolbarBackButton: "toolbar-back-button",
            toolbarCloseButton: "toolbar-close-button",
            toolbarTools: "toolbar-tools",
            photoInfo: "photo-info",
            editorDialog: "editor-dialog",
            textEditor: "text-editor",
            photoWidth: "photo-width",
            photoHeight: "photo-height",
            photoWeight: "photo-size",
            photoFormat: "photo-format",
            photoWidthWarning: "photo-width-warning",
            photoHeightWarning: "photo-height-warning",
            imageRatioChecbox: "image-ratio-checkobx",
            metricType: "metric-type",
            uploadPanelResize: "upload-panel-resize-input",
            uploadSelectLink: "upload-select-link",
            uploadPanel: "upload-panel",
            uploaderOverlay: "uploader-overlay",
            uploadControls: "upload-panel-controls",
            uploadPanelLabel: "upload-panel-label",
            uploadScaleButton: "upload-panel-scale",
            uploadUrl: "upload-panel-url-input",
            uploadTest: "upload-panel-test-input",
            uploadTestImgCheckbox: "upload-test-img-checkbox",
            uploadDefaultView: "upload-default-view",
            uploadUploadView: "upload-upload-view",
            uploadText: "upload-text",
            uploadTestTick: "upload-panel-test-tick",
            uploadUrlTick: "upload-panel-url-tick",
            uploadTick: "upload-panel-upload-tick",
            uploadProgressbar: "upload-panel-progressbar-container",
            progressbarStatus: "upload-progress-bar-container",
            progressbarInner: "upload-panel-progressbar-inner",
            progressbarStatus: "upload-panel-progressbar-status",
            tooltip: "tooltip",
            tooltipCloseButton: "tooltip-close-button",
            tooltipNextButton: "tooltip-next-button",
            tooltipPreviousButton: "tooltip-previous-button",
            maskPickerDialog: "mask-picker-dialog",
            maskPicker: "color-picker",
            maskPickerMask: "color-mask",
            maskPickerOpacity: "mask-picker-opacity",
            maskPickerSlider: "mask-picker-slider",
            maskPickerThumb: "mask-picker-thumb",
            croppHeight: "cropp-height",
            croppWidth: "cropp-width",
            croppX: "cropp-x",
            croppY: "cropp-y",
            croppInfo: "cropp-info",
            croppPosition: "cropp-position",
            croppOk: "cropp-ok",
            croppCancel: "cropp-cancel",
            framePicker: "frame-picker",
            blur: "blur",
            blurImgMask: "blur-image-miniature-mask",
            blurImg: "blur-image-miniature",
            blurSlider: "blur-slider",
            blurThumb: "blur-thumb",
            blurDegree: "blur-degree",
            contrast: "contrast",
            contrastImg: "contrast-image-miniature",
            contrastImgMask: "contrast-image-miniature-mask",
            contrastSlider: "contrast-slider",
            contrastThumb: "contrast-thumb",
            contrastDegree: "contrast-degree",
            pixelate: "pixelate",
            pixelateImg: "pixelate-image-miniature",
            pixelateImgMask: "pixelate-image-miniature-mask",
            pixelateSlider: "pixelate-slider",
            pixelateThumb: "pixelate-thumb",
            pixelateDegree: "pixelate-degree",
            brightnessImgMask: "brightness-image-miniature-mask",
            brightnessImg: "brightness-image-miniature",
            brightnessSlider: "brightness-slider",
            brightnessThumb: "brightness-thumb",
            brightnessDegree: "brightness-degree",
            brightness: "brightness",
            compressorDegree: "compression-degree",
            compressorCompressionDegree: "compressor-compression-degree",
            compressor: "compressor",
            compressorSlider: "compressor-slider",
            compressorThumb: "compressor-thumb",
            compressorColorsButton: "compressor-colors-button",
            compressorColorBD: "compressor-color-bd",
            compressorSliderBD: "compressor-slider-bd",
            compressorSizeValue: "compressor-size-value",
            savePhoto: "saving-photo",
            savePhotoFormat: "saving-photo-format",
            savingPhotoContent: "saving-photo-content",
            savingPhotoFormatMenu: "saving-photo-format-menu",
            saveCompressionDegree: "saving-photo-compression-degree",
            saveFileName: "filen",
            saveCompressorSlider: "save-slider",
            saveCompressorThumb: "save-thumb",
            saveSliderBD: "save-slider-bd",
            saveColorBD: "save-color-bd",
            saveColorsButton: "save-colors-button",
            converter: "converter",
            converterContent: "converter-content",
            contact: "contact",
            contactEmail: "contact-email",
            contactSummary: "contact-summary",
            contactDescription: "contact-description",
            contactSummaryWarning: "contact-summary-warning",
            contactEmailWarning: "contact-email-warning",
            sendSuccessDialog: "send-success-dialog",
            about: "about",
            wetFloorDialog: "wet-floor-dialog"
        }
    }
};
String.prototype.toInt = function (A) {
    A = A || 10;
    return parseInt(this, A)
};
Number.prototype.toPx = function () {
    return this + "px"
};
var tools = {
    toInt: function (A) {
        if (YAHOO.lang.isNumber(A)) {
            return A
        }
        return parseInt(A, 10)
    },
    isPx: function (A) {
        return (/^\d{1,3}px$/).test(A)
    },
    isStringNumber: function (A) {
        return (/^\d{1,4}(\.\d+)?$/).test(A)
    },
    isEmail: function (A) {
        return (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i).test(A)
    },
    isUrl: function (A) {
        return (/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/).test(A)
    },
    handleFailure: function () {
        alert(lang.error.requestFailure)
    },
    getBasicCallback: function () {
        var B = function () {
            dialogs.errorDialogShow("requestFailure")
        };
        var A = function (C) {
            eyp.loadImage(C.responseText)
        };
        return {
            success: A,
            failure: B,
            timeout: 1000 * 60
        }
    }
};
var cropper = {
    getCroppCoords: function () {
        var A = this.cropp.getCropCoords();
        A.left += 1;
        A.top += 1;
        return A
    },
    positionShow: function (A, F, B) {
        var D = this.getCroppCoords();
        if (B) {
            this.cacheLeft = D.left;
            this.cacheTop = D.top
        }
        var C = D.left - this.cacheLeft;
        var E = D.top - this.cacheTop;
        this.positionDiv.innerHTML = YAHOO.lang.substitute("{x} x {y}<br/>{xd} x {yd}", {
            x: D.left,
            y: D.top,
            xd: C > 0 ? "+" + C : C,
            yd: E > 0 ? "+" + E : E
        });
        Dom.setStyle(this.positionDiv, "left", A + "px");
        Dom.setStyle(this.positionDiv, "top", F + "px");
        Dom.setStyle(this.positionDiv, "display", "block")
    },
    positionHide: function () {
        if (this.positionDiv) {
            Dom.setStyle(this.positionDiv, "display", "none")
        }
    },
    setWidth: function (D, C) {
        if (D < 0) {
            return
        }
        if (YAHOO.lang.isNumber(D)) {
            this.hideWarning(C);
            var E = this.getCroppCoords();
            var B = photoMgr.getDimensions()[0];
            if (D > (B - E.left)) {
                D = B - E.left
            }
            var A = this.cropp.getResizeObject();
            A.set("width", D, false);
            this.cropp._syncBackgroundPosition();
            C.value = D
        } else {
            this.showWarning(C)
        }
    },
    setHeight: function (B, D) {
        if (B < 0) {
            return
        }
        if (YAHOO.lang.isNumber(B)) {
            this.hideWarning(D);
            var E = this.getCroppCoords();
            var A = photoMgr.getDimensions()[1];
            if (B > (A - E.top)) {
                B = A - E.top
            }
            var C = this.cropp.getResizeObject();
            C.set("height", B, false);
            this.cropp._syncBackgroundPosition();
            D.value = B
        } else {
            this.showWarning(D)
        }
    },
    setX: function (A, C) {
        A -= 1;
        if (YAHOO.lang.isNumber(A)) {
            this.hideWarning(C);
            if (A < -1) {
                A = -1
            } else {
                var E = this.getCroppCoords();
                var B = photoMgr.getDimensions()[0];
                if (A > (B - E.width)) {
                    A = B - E.width
                }
            }
            var D = this.cropp.getResizeEl();
            Dom.setStyle(D, "left", A + "px");
            this.cropp._syncBackgroundPosition();
            C.value = A + 1
        } else {
            this.showWarning(C)
        }
    },
    setY: function (E, B) {
        E -= 1;
        if (YAHOO.lang.isNumber(E)) {
            this.hideWarning(B);
            if (E < -1) {
                E = -1
            } else {
                var D = this.getCroppCoords();
                var A = photoMgr.getDimensions()[1];
                if (E > (A - D.height)) {
                    E = A - D.height
                }
            }
            var C = this.cropp.getResizeEl();
            Dom.setStyle(C, "top", E + "px");
            this.cropp._syncBackgroundPosition();
            B.value = E + 1
        } else {
            this.showWarning(B)
        }
    },
    hideCoords: function () {
        Dom.setStyle(this.coordsContainer, "display", "none")
    },
    showCoords: function () {
        Dom.setStyle(this.coordsContainer, "display", "block")
    },
    toolbarOn: function () {
        var A = this;
        toolbar.off(function () {
            toolbar.hideCoords();
            A.showCoords();
            A.toolbarRefresh_();
            toolbar.on(function () {
                tooltipMgr.show(lang.tip.cropp);
                toolbar.showBackButton({
                    scope: ef,
                    fn: ef.defaultView
                })
            })
        })
    },
    toolbarOff: function () {
        var A = this;
        toolbar.off(function () {
            toolbar.showCoords();
            A.hideCoords();
            toolbar.on(function () {
                tooltipMgr.hide()
            })
        })
    },
    toolbarRefresh_: function () {
        var A = this.getCroppCoords();
        this.widthText.value = A.width;
        this.heightText.value = A.height;
        this.xText.value = A.left;
        this.yText.value = A.top
    },
    switchMode: function () {
        try {
            var B = this;
            if (this.cropp) {
                this.off()
            } else {
                if (queue.getAll().length > 0) {
                    var A = new Ajax({
                        data: ef.createData("resize"),
                        callback: {
                            onSuccess: function (D) {
                                loadMgr.run(JSON.parse(D.responseText), {
                                    resize: false
                                });
                                B.on()
                            },
                            onFailure: function (D) {
                                dialogsMgr.errorShow(D.responseText)
                            }
                        }
                    });
                    A.send()
                } else {
                    this.on()
                }
            }
        } catch(C) {
            ef.bugs.add(C, "js", "cropper.switchMode")
        }
    },
    showWarning: function (A) {
        A.tooltip = new YAHOO.widget.Tooltip(A.id + "-tooltip", {
            context: A,
            text: lang.toolbar.warnings.valueError,
            showDelay: 50
        });
        Dom.setStyle(A, "color", "#F34A4A")
    },
    hideWarning: function (A) {
        if (A.tooltip) {
            A.tooltip.destroy();
            A.tooltip = null
        }
        Dom.setStyle(A, "color", "#000")
    },
    shortcutsInit_: function () {
        var A = this;
        this.cancelButton = new YAHOO.widget.Button(configuration.CSS.IDs.croppCancel);
        this.cancelButton.on("click", function () {
            A.off()
        });
        this.okButton = new YAHOO.widget.Button(configuration.CSS.IDs.croppOk, {
            width: "80px"
        });
        this.okButton.on("click", function () {
            A.send()
        });
        this.enter = new YAHOO.util.KeyListener(document, {
            keys: YAHOO.util.KeyListener.KEY.ENTER
        },
        {
            fn: function (C, B) {
                Event.stopEvent(B);
                A.send()
            }
        });
        this.enter.disable()
    },
    init: function () {
        this.toolbarInit_();
        this.shortcutsInit_();
        this.positionDiv = Dom.get(configuration.CSS.IDs.croppPosition)
    },
    toolbarInit_: function () {
        var B = this;
        this.widthText = Dom.get(configuration.CSS.IDs.croppWidth);
        this.heightText = Dom.get(configuration.CSS.IDs.croppHeight);
        this.xText = Dom.get(configuration.CSS.IDs.croppX);
        this.yText = Dom.get(configuration.CSS.IDs.croppY);
        this.coordsContainer = Dom.get(configuration.CSS.IDs.croppInfo);

        function A() {
            this.select();
            Dom.setStyle(this, "color", "#000")
        }
        this.widthText.onfocus = A;
        this.heightText.onfocus = A;
        this.xText.onfocus = A;
        this.yText.onfocus = A;
        this.widthText.onblur = function () {
            B.setWidth(tools.toInt(this.value), this)
        };
        this.heightText.onblur = function () {
            B.setHeight(tools.toInt(this.value), this)
        };
        this.xText.onblur = function () {
            B.setX(tools.toInt(this.value), this)
        };
        this.yText.onblur = function () {
            B.setY(tools.toInt(this.value), this)
        }
    },
    cmInit_: function () {
        return
    },
    off: function () {
        if (this.cropp) {
            this.widgetOff_();
            this.toolbarOff();
            this.positionHide();
            ef.photo.resize.mouseWheelEnable()
        }
    },
    widgetOff_: function () {
        if (this.cropp) {
            this.cropp.destroy();
            this.cropp = null;
            this.enter.disable();
            ef.photo.resize.init()
        }
    },
    on: function () {
        this.widgetOn_();
        ef.photo.resize.mouseWheelDisable()
    },
    widgetOn_: function () {
        var C = this;
        var A = photoMgr.getImg();
        var B = photoMgr.getDimensions();
        if (B[0] < 30 || B[1] < 30) {
            dialogsMgr.errorShow(lang.cropp.imgToSmall);
            return
        }
        ef.photo.resize.destroy();
        this.cropp = new YAHOO.widget.ImageCropper(A, {
            keyTick: 5,
            shiftKeyTick: 50,
            minWidth: 20,
            minHeight: 20,
            initWidth: Math.round(tools.toInt(Dom.getStyle(A, "width")) * 0.8),
            initHeight: Math.round(tools.toInt(Dom.getStyle(A, "height")) * 0.8)
        });
        Event.addListener(this.cropp.getResizeEl(), "dblclick", function () {
            C.send()
        });
        this.cropp.on("dragEvent", function (D) {
            D = D[0][0].e;
            C.positionShow(D.clientX + 10, D.clientY + 10);
            C.toolbarRefresh_()
        });
        this.cropp.on("resizeEvent", function (D) {
            C.toolbarRefresh_()
        });
        Event.addListener(this.cropp.getResizeEl(), "mousedown", function (D) {
            C.positionShow(D.clientX + 10, D.clientY + 10, true)
        });
        Event.addListener(this.cropp.getResizeEl(), "mouseup", function (D) {
            C.positionHide()
        });
        this.enter.enable();
        this.toolbarOn();
        this.cmInit_()
    },
    getCroppData: function () {
        var A = this.getCroppCoords();
        return YAHOO.lang.substitute("cmd=cropping&x={x}&y={y}&w={w}&h={h}&position={position}", {
            x: A.left,
            y: A.top,
            w: A.width,
            h: A.height,
            position: historyMgr.getPosition()
        })
    },
    send: function () {
        ef.dialogs.wait.show();
        var A = new Ajax({
            data: this.getCroppData(),
            callback: {
                onSuccess: function (B) {
                    loadMgr.run(JSON.parse(B.responseText));
                    ef.defaultView()
                },
                onFailure: function (B) {
                    dialogsMgr.errorShow(B.responseText)
                }
            }
        });
        A.send()
    }
};
var wetFloorMgr = {
    init_: function () {
        var E = this;

        function C() {
            E.sendRequest_()
        }
        function F() {
            E.hide()
        }
        this.window_ = new YAHOO.widget.Dialog(configuration.CSS.IDs.wetFloorDialog, {
            modal: true,
            fixedcenter: true,
            visible: false,
            constraintoviewport: true,
            buttons: [{
                text: lang.buttons.send,
                handler: C,
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: F
            }],
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        var B = "<div id='{id}-img-container'><div id='{id}-img-mask'></div><img id='{id}-img'></img></div>";
        B += "<div id='{id}-controls'><div class='line'><div class='label'>Wysokość:</div><input type='submit' id='wetfloor-dialog-height' name='wetfloor-dialog-height' value='50%'></div>";
        B += "<div class='line'><div class='label'>Przezroczystość:</div><input type='submit' id='wetfloor-dialog-opacity' name='wetfloor-dialog-opacity' value='50%'></div></div>";
        B += "<div class='clear'></div>";
        B = YAHOO.lang.substitute(B, {
            id: configuration.CSS.IDs.wetFloorDialog
        });
        this.heightMenuItems_ = [{
            text: "10%",
            value: 0.1
        },{
            text: "20%",
            value: 0.2
        },{
            text: "30%",
            value: 0.3
        },{
            text: "40%",
            value: 0.4
        },{
            text: "50%",
            value: 0.5
        },{
            text: "60%",
            value: 0.6
        },{
            text: "70%",
            value: 0.7
        },{
            text: "80%",
            value: 0.8
        },{
            text: "90%",
            value: 0.9
        },{
            text: "100%",
            value: 1
        },];
        this.opacityMenuItems_ = [{
            text: "90%",
            value: 0.1
        },{
            text: "80%",
            value: 0.2
        },{
            text: "70%",
            value: 0.3
        },{
            text: "60%",
            value: 0.4
        },{
            text: "50%",
            value: 0.5
        },{
            text: "40%",
            value: 0.6
        },{
            text: "30%",
            value: 0.7
        },{
            text: "20%",
            value: 0.8
        },{
            text: "10%",
            value: 0.9
        },{
            text: "0%",
            value: 1
        },];
        this.window_.setBody(B);
        this.window_.setHeader(lang.menu.efects.wetFloor);
        this.window_.showEvent.subscribe(function () {
            this.blurButtons()
        });
        this.window_.render(document.body);
        this.heightMenu_ = new YAHOO.widget.Button("wetfloor-dialog-height", {
            type: "split",
            menu: this.heightMenuItems_
        });

        function D(I, H) {
            var G = H[0],
                J = H[1];
            var K = J.cfg.getProperty("text");
            E.heightMenu_.set("label", K);
            E.sendRequestMin_()
        }
        this.heightMenu_.getMenu().subscribe("click", D);
        this.opacityMenu_ = new YAHOO.widget.Button("wetfloor-dialog-opacity", {
            type: "split",
            menu: this.opacityMenuItems_
        });

        function A(I, H) {
            var G = H[0],
                J = H[1];
            var K = J.cfg.getProperty("text");
            E.opacityMenu_.set("label", K);
            E.sendRequestMin_()
        }
        this.opacityMenu_.getMenu().subscribe("click", A);
        this.mask_ = Dom.get("wet-floor-dialog-img-mask");
        this.img_ = Dom.get("wet-floor-dialog-img");
        this.container_ = Dom.get("wet-floor-dialog-img-container")
    },
    sendRequest_: function () {
        var B = this;
        ef.dialogs.wait.show();
        var A = new Ajax({
            mask: false,
            data: ef.createData("wetFloor", {
                opacity: 1 - tools.toInt(this.opacityMenu_.get("label")) / 100,
                reflectionHeight: tools.toInt(this.heightMenu_.get("label")) / 100
            }),
            callback: {
                onSuccess: function (C) {
                    if (loadMgr.run(JSON.parse(C.responseText))) {
                        B.hide()
                    }
                },
                onFailure: function (C) {
                    dialogsMgr.errorShow(C.responseText)
                }
            }
        });
        A.send()
    },
    sendRequestMin_: function () {
        var C = photoMgr.getDimensions();
        scale = C[0] / 200,
        C[1] = Math.round(C[1] / scale);
        var B = this;
        this.showMask_();
        var A = new Ajax({
            url: "thumbnail.php",
            mask: false,
            data: ef.createData("wetFloor", {
                opacity: 1 - tools.toInt(this.opacityMenu_.get("label")) / 100,
                reflectionHeight: tools.toInt(this.heightMenu_.get("label")) / 100,
                width: 200,
                height: C[1]
            }),
            callback: {
                onSuccess: function (E) {
                    var D = JSON.parse(E.responseText);
                    B.imgShow_(D.file)
                },
                onFailure: function (D) {
                    dialogsMgr.errorShow(D.responseText)
                }
            },
            waitDialog: false
        });
        A.send()
    },
    imgShow_: function (B) {
        this.img_.src = B;
        var A = this;
        this.img_.onload = function () {
            Dom.setStyle(this, "display", "block");
            Dom.setStyle(A.container_, "width", this.offsetWidth + "px");
            Dom.setStyle(A.container_, "height", this.offsetHeight + "px");
            A.hideMask_()
        }
    },
    showMask_: function () {
        Dom.setStyle(this.img_, "display", "none");
        var B = Dom.getStyle(this.container_, "width");
        var A = Dom.getStyle(this.container_, "height");
        Dom.setStyle(this.mask_, "width", B);
        Dom.setStyle(this.mask_, "height", A);
        Dom.setStyle(this.mask_, "display", "block")
    },
    hideMask_: function () {
        Dom.setStyle(this.mask_, "display", "none")
    },
    defaultView_: function () {
        this.heightMenu_.set("label", "100%");
        this.opacityMenu_.set("label", "0%")
    },
    show: function () {
        try {
            if (!this.window_) {
                this.init_()
            }
            this.defaultView_();
            this.sendRequestMin_();
            this.window_.show()
        } catch(A) {
            ef.bugs.add(A, "js", "wetFloorMgr.show")
        }
    },
    hide: function () {
        this.window_.hide()
    }
};
var dialogsMgr = {
    confirmDialogShow: function (B, E, C, A) {
        var D = null;
        if (A === null) {
            A = function () {
                D.hide()
            }
        }
        D = new YAHOO.widget.SimpleDialog("confirm-dialog", {
            width: "300px",
            fixedcenter: true,
            visible: false,
            draggable: false,
            close: false,
            text: B,
            modal: true,
            icon: YAHOO.widget.SimpleDialog.ICON_HELP,
            constraintoviewport: true,
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            },
            buttons: [{
                text: "Tak",
                handler: C,
                isDefault: true
            },{
                text: "Nie",
                handler: A
            }]
        });
        D.setHeader(E);
        D.showEvent.subscribe(function () {
            this.blurButtons()
        });
        D.render(document.body);
        D.show()
    },
    loginDialogShow: function () {
        if (!this.loginDialog_) {
            this.loginDialogInit_()
        }
        this.loginDialog_.show()
    },
    loginDialogHide: function () {
        this.loginDialog_.hide()
    },
    loginDialogInit_: function () {
        var D = this;
        var C = function () {
            ef.dialogs.wait.show();
            D.request = new Ajax({
                url: "nk_login.php",
                data: ef.createData("nk", {
                    login: Dom.get("login-dialog-name").value,
                    password: Dom.get("login-dialog-password").value
                }),
                callback: {
                    onSuccess: function (E) {
                        console.debug("success", E.responseText);
                        ef.dialogs.wait.hide()
                    },
                    onFailure: function (E) {
                        console.debug("failure", E);
                        ef.dialogs.wait.hide()
                    }
                }
            });
            D.request.send()
        };
        var B = function () {
            this.hide()
        };
        this.loginDialog_ = new YAHOO.widget.SimpleDialog("login-dialog", {
            fixedcenter: true,
            modal: true,
            visible: false,
            draggable: false,
            close: false,
            constraintoviewport: true,
            buttons: [{
                text: "Wyślij zdjęcie",
                handler: C,
                isDefault: true
            },{
                text: "Anuluj",
                handler: B
            }]
        });
        this.loginDialog_.showEvent.subscribe(function () {
            this.blurButtons();
            Dom.get("login-dialog-name").focus()
        });
        this.loginDialog_.hideEvent.subscribe(function () {
            Dom.get("login-dialog-name").value = "";
            Dom.get("login-dialog-password").value = ""
        });
        var A = '<label for="login-dialog-name">Login lub e-mail:</label><input type="textbox" id="login-dialog-name" /><br/>';
        A += '<label for="login-dialog-password">Hasło:</label><input type="password" id="login-dialog-password" />';
        this.loginDialog_.setBody(A);
        this.loginDialog_.setHeader("Wyślij zdjęcie na nasza-klasa.pl");
        this.loginDialog_.render(document.body)
    },
    wetFloorShow: function () {
        wetFloorMgr.show()
    },
    wetFloorHide: function () {
        wetFloorMgr.hide()
    },
    aboutDialog_: undefined,
    contactDialog_: undefined,
    errorDialog_: undefined,
    onErrorClick_: function () {},
    errorShow: function (A) {
        if (A == "session_expired") {
            this.onErrorClick_ = function () {
                location.reload(false)
            }
        } else {
            this.onErrorClick_ = function () {}
        }
        if (lang.error.hasOwnProperty(A)) {
            A = lang.error[A]
        }
        if (!this.errorDialog_) {
            this.errorInit_()
        }
        this.errorDialog_.cfg.setProperty("text", A);
        this.errorDialog_.show();
        this.errorDialog_.blurButtons()
    },
    errorInit_: function () {
        var B = this;
        var A = function () {
            this.hide();
            B.onErrorClick_()
        };
        this.errorDialog_ = new YAHOO.widget.SimpleDialog(configuration.CSS.IDs.errorDialog, {
            width: "300px",
            fixedcenter: true,
            visible: false,
            draggable: false,
            close: false,
            text: "",
            modal: true,
            icon: YAHOO.widget.SimpleDialog.ICON_WARN,
            constraintoviewport: true,
            buttons: [{
                text: lang.buttons.ok,
                handler: A
            }]
        });
        this.errorDialog_.setHeader(lang.error.main);
        this.errorDialog_.render(document.body)
    },
    contactClear_: function () {
        this.contactDescription_.value = "";
        this.contactDescription_.relatedElement.firstChild.nodeValue = 0;
        this.contactEmail_.value = "";
        this.contactSummary_.value = ""
    },
    contactInit_: function () {
        var E = this;

        function D() {
            var H = this.getAttribute("maxlength");
            var I = this.value.length;
            if (I > H) {
                this.relatedElement.className = "lengthlimit"
            } else {
                this.relatedElement.className = ""
            }
            this.relatedElement.firstChild.nodeValue = I
        }
        function C(K) {
            var H = this.getAttribute("maxlength");
            var J = this.value.length;
            var I = K.keyCode;
            if (J >= H && I != 8 && I != 37 && I != 38 && I != 39 && I != 40) {
                return false
            } else {
                return true
            }
        }
        var B = function () {
            var H = E.contactDescription_;
            H.value = H.value.substring(0, parseInt(H.getAttribute("maxlength"), 10));
            this.submit()
        };
        var G = function () {
            this.cancel()
        };
        var F = function () {
            E.contactClear_()
        };
        this.contactDialog_ = new YAHOO.widget.Dialog(configuration.CSS.IDs.contact, {
            modal: true,
            fixedcenter: true,
            visible: false,
            constraintoviewport: true,
            buttons: [{
                text: lang.buttons.send,
                handler: B,
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: G
            },{
                text: lang.buttons.clear,
                handler: F
            }],
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        this.contactDialog_.validate = function () {
            var I = this.getData();
            var H = true;
            if (I.contactSummary === "") {
                Dom.setStyle(configuration.CSS.IDs.contactSummaryWarning, "display", "inline");
                H = false
            } else {
                Dom.setStyle(configuration.CSS.IDs.contactSummaryWarning, "display", "none")
            }
            if (!tools.isEmail(I.contactEmail)) {
                Dom.setStyle(configuration.CSS.IDs.contactEmailWarning, "display", "inline");
                H = false
            } else {
                Dom.setStyle(configuration.CSS.IDs.contactEmailWarning, "display", "none")
            }
            return H
        };
        var A = function (H) {
            E.contactClear_();
            tooltipMgr.smallShow(lang.info.sendMessageSuccess)
        };
        this.contactDialog_.callback = {
            success: A,
            failure: tools.handleFailure,
            timeout: 1000 * 60
        };
        this.contactDialog_.render();
        Dom.setStyle(configuration.CSS.IDs.contact, "display", "block");
        this.contactDescription_ = Dom.get(configuration.CSS.IDs.contactDescription);
        this.contactCounter_ = document.createElement("div");
        this.contactCounter_.relatedElement = this.contactDescription_;
        this.contactCounter_.innerHTML = "<span>0</span>/" + this.contactDescription_.getAttribute("maxlength");
        this.contactDescription_.parentNode.insertBefore(this.contactCounter_, this.contactDescription_.nextSibling);
        this.contactDescription_.relatedElement = this.contactCounter_.getElementsByTagName("span")[0];
        this.contactDescription_.onkeyup = this.contactDescription_.onchange = D;
        this.contactDescription_.onkeydown = C;
        this.contactDescription_.onkeyup();
        this.contactEmail_ = Dom.get(configuration.CSS.IDs.contactEmail);
        this.contactSummary_ = Dom.get(configuration.CSS.IDs.contactSummary)
    },
    contactShow: function () {
        if (!this.contactDialog_) {
            this.contactInit_()
        }
        this.contactDialog_.show()
    },
    aboutInit_: function () {
        this.aboutDialog_ = new YAHOO.widget.Dialog(configuration.CSS.IDs.about, {
            modal: true,
            visible: false,
            constraintoviewport: true,
            fixedcenter: true,
            width: "300px",
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        this.aboutDialog_.render();
        Dom.setStyle(configuration.CSS.IDs.about, "display", "block")
    },
    aboutShow: function () {
        if (!this.aboutDialog_) {
            this.aboutInit_()
        }
        this.aboutDialog_.show()
    },
    init: function () {}
};
var upload = {
    unselectResizeImg_: function () {
        this.resizeImg_.checked = false
    },
    isResizeImgChecked_: function () {
        return this.resizeImg_.checked
    },
    createPOST: function () {
        if (this.isResizeImgChecked_()) {
            return {
                editorWidth: editor.getWidth() - 20,
                editorHeight: editor.getHeight() - 20
            }
        } else {
            var A = this.scaleButton_.get("label");
            return {
                scale: 100 - A.substring(0, A.length - 1).toInt()
            }
        }
    },
    defaultView: function () {
        Dom.setStyle("upload-panel-url-fieldset", "display", "block");
        Dom.setStyle("upload-panel-test-fieldset", "display", "block");
        Dom.setStyle("upload-panel-options", "display", "block");
        Dom.setStyle("upload-panel-inctructions", "display", "block");
        Dom.setStyle("upload-panel-upload-fieldset", "visiblity", "visible");
        Dom.setStyle("upload-panel-upload-fieldset", "height", "");
        Dom.setStyle(configuration.CSS.IDs.uploadProgressbar, "display", "none");
        Dom.setStyle("upload-panel-upload-fieldset", "visibility", "visible");
        Dom.setStyle("upload-panel-upload-fieldset", "padding", "10px");
        Dom.setStyle("upload-panel-upload-fieldset", "marginBottom", "10px");
        this.clearForm_();
        Dom.setStyle(editor.get(), "overflow", "hidden");
        this.window_.cfg.setProperty("buttons", [this.ok_, this.cancel_]);
        this.disableOkButton_()
    },
    enableOkButton_: function () {
        var A = this.window_.getButtons();
        A[0].set("disabled", false)
    },
    disableOkButton_: function () {
        var A = this.window_.getButtons();
        A[0].set("disabled", true)
    },
    uploadView: function () {
        Dom.setStyle(configuration.CSS.IDs.uploadProgressbar, "display", "block");
        Dom.setStyle("upload-panel-url-fieldset", "display", "none");
        Dom.setStyle("upload-panel-test-fieldset", "display", "none");
        Dom.setStyle("google-adsense-fieldset", "display", "none");
        Dom.setStyle("upload-panel-options-fieldset", "display", "none");
        Dom.setStyle("upload-panel-options", "display", "none");
        Dom.setStyle("upload-panel-inctructions", "display", "none");
        Dom.setStyle("upload-panel-upload-fieldset", "visibility", "hidden");
        Dom.setStyle("upload-panel-inctructions", "display", "none");
        Dom.setStyle("upload-panel-upload-fieldset", "padding", "0px");
        Dom.setStyle("upload-panel-upload-fieldset", "marginBottom", "0px");
        this.window_.cfg.setProperty("buttons", []);
        this.clearForm_();
        Dom.setStyle(editor.get(), "overflow", "auto")
    },
    onHide: function () {
        Dom.setStyle(editor.get(), "overflow", "auto")
    },
    cancelUpload_: function () {
        this.uploader_.cancel()
    },
    isFileSelected: false,
    uploaderInit_: function () {
        var G = this;
        YAHOO.widget.Uploader.SWFURL = "uploader.swf";
        this.isFileSelected_ = false;

        function F() {}
        function I() {
            G.uploader_.setAllowMultipleFiles(false);
            G.uploader_.setFileFilters([{
                description: "Images",
                extensions: "*.jpg;*.png;*.gif;*.bmp"
            }])
        }
        this.uploadMgr_ = {};
        this.uploadMgr_.upload = function () {
            if (G.isFileSelected_) {
                G.uploadView();
                G.uploader_.setSimUploadLimit(1);
                G.uploader_.uploadAll("upload2.php", "POST", G.createPOST(), "Filedata");
                G.uploader_.clearFileList();
                G.isFileSelected_ = false
            }
        };

        function A(K) {
            G.isFileSelected_ = true;
            G.clearForm_();
            G.showTick_(0);
            G.uploadOption_ = 0
        }
        function C(K) {
            Dom.setStyle(G.progressbarInner_, "width", "0px")
        }
        function B(L) {
            var K = Math.round(100 * (L.bytesLoaded / L.bytesTotal));
            G.progressbarStatus_.innerHTML = K + "%";
            Dom.setStyle(G.progressbarInner_, "width", 2 * K + "px")
        }
        function D(K) {
            try {
                G.progressbarStatus_.innerHTML = "100%";
                Dom.setStyle(G.progressbarInner_, "width", "200px")
            } catch(L) {
                console.debug(L)
            }
        }
        function H(K) {}
        function J(K) {}
        function E(K) {
            try {
                G.hide();
                loadMgr.run(JSON.parse(K.data), {
                    init: true
                })
            } catch(L) {
                ef.bugs.add(L, "json", K.data)
            }
        }
        this.uploader_ = new YAHOO.widget.Uploader(configuration.CSS.IDs.uploaderOverlay);
        this.uploader_.addListener("contentReady", I);
        this.uploader_.addListener("fileSelect", A);
        this.uploader_.addListener("uploadStart", C);
        this.uploader_.addListener("uploadProgress", B);
        this.uploader_.addListener("uploadCancel", J);
        this.uploader_.addListener("uploadComplete", D);
        this.uploader_.addListener("uploadCompleteData", E);
        this.uploader_.addListener("uploadError", H);
        this.uploader_.addListener("click", F)
    },
    initTicks_: function () {
        this.ticks_ = [Dom.get(configuration.CSS.IDs.uploadTick), Dom.get(configuration.CSS.IDs.uploadUrlTick), Dom.get(configuration.CSS.IDs.uploadTestTick)]
    },
    showTick_: function (A) {
        this.hideAllTicks_();
        Dom.setStyle(this.ticks_[A], "visibility", "visible");
        this.enableOkButton_()
    },
    hideTick_: function (A) {
        Dom.setStyle(this.ticks_[A], "visibility", "hidden")
    },
    hideAllTicks_: function () {
        this.hideTick_(0);
        this.hideTick_(1);
        this.hideTick_(2)
    },
    clearForm_: function () {
        this.url_.value = "";
        this.test_.checked = false;
        this.hideAllTicks_();
        this.unselectResizeImg_();
        this.scaleButton_.set("label", "0%")
    },
    handleOk_: function () {
        var B = this;
        try {
            switch (this.uploadOption_) {
            case 0:
                this.uploadMgr_.upload();
                break;
            case 1:
                var A = new Ajax({
                    method: "GET",
                    url: "url.php",
                    data: "cmd=upload&url=" + this.url_.value,
                    callback: {
                        onSuccess: function (F) {
                            try {
                                var D = JSON.parse(F.responseText)
                            } catch(E) {
                                ef.bugs.add(E, "json", "upload.handleOk_, case 1: " + F.responseText)
                            }
                            if (loadMgr.run(D, {
                                init: true
                            })) {
                                B.hide()
                            }
                        },
                        onFailure: function (D) {
                            dialogsMgr.errorShow(D.responseText)
                        }
                    }
                });
                A.send();
                break;
            case 2:
                var A = new Ajax({
                    url: "upload2.php",
                    data: "",
                    callback: {
                        onSuccess: function (E) {
                            B.hide();
                            try {
                                loadMgr.run(JSON.parse(E.responseText), {
                                    init: true
                                })
                            } catch(D) {
                                ef.bugs.add(D, "json", "upload.handleOk_, case 2: " + E.responseText)
                            }
                        },
                        onFailure: function (D) {
                            dialogsMgr.errorShow(D.responseText)
                        }
                    },
                    close: false
                });
                A.send();
                break
            }
        } catch(C) {
            console.debug(C)
        }
    },
    uploadButtonInit_: function () {
        var B = YAHOO.util.Dom.getRegion(configuration.CSS.IDs.uploadSelectLink);
        var A = YAHOO.util.Dom.get(configuration.CSS.IDs.uploaderOverlay);
        Dom.setStyle(A, "width", B.right - B.left + "px");
        Dom.setStyle(A, "height", B.bottom - B.top + "px")
    },
    init: function () {
        this.uploadButtonInit_();
        var B = this;
        this.initTicks_();
        this.ok_ = {
            text: lang.buttons.ok,
            handler: function () {
                B.handleOk_()
            },
            isDefault: true
        };
        this.cancel_ = {
            text: lang.buttons.cancel,
            handler: function () {
                B.hide()
            }
        };
        this.window_ = new YAHOO.widget.Dialog(configuration.CSS.IDs.uploadPanel, {
            visible: false,
            fixedcenter: true,
            constraintoviewport: true,
            modal: true,
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            },
            buttons: [this.ok_, this.cancel_]
        });
        this.url_ = Dom.get(configuration.CSS.IDs.uploadUrl);
        this.urlTick_ = Dom.get(configuration.CSS.IDs.uploadUrlTick);
        this.resizeImg_ = Dom.get(configuration.CSS.IDs.uploadPanelResize);
        this.progressbarInner_ = Dom.get(configuration.CSS.IDs.progressbarInner);
        this.progressbarStatus_ = Dom.get(configuration.CSS.IDs.progressbarStatus);
        this.test_ = Dom.get(configuration.CSS.IDs.uploadTest);
        var B = this;

        function A(E, D, C) {
            B.scaleButton_.set("label", C.cfg.getProperty("text"))
        }
        this.scaleButton_ = new YAHOO.widget.Button(configuration.CSS.IDs.uploadScaleButton, {
            type: "split",
            menu: [{
                text: "0%",
                value: 0,
                onclick: {
                    fn: A
                }
            },{
                text: "10%",
                value: 1,
                onclick: {
                    fn: A
                }
            },{
                text: "20%",
                value: 2,
                onclick: {
                    fn: A
                }
            },{
                text: "30%",
                value: 3,
                onclick: {
                    fn: A
                }
            },{
                text: "40%",
                value: 4,
                onclick: {
                    fn: A
                }
            },{
                text: "50%",
                value: 5,
                onclick: {
                    fn: A
                }
            },{
                text: "60%",
                value: 6,
                onclick: {
                    fn: A
                }
            },{
                text: "70%",
                value: 7,
                onclick: {
                    fn: A
                }
            },{
                text: "80%",
                value: 8,
                onclick: {
                    fn: A
                }
            },{
                text: "90%",
                value: 9,
                onclick: {
                    fn: A
                }
            }],
            label: "0%"
        });
        this.window_.render();
        this.window_.beforeHideEvent.subscribe(function () {
            B.uploadView();
            tooltipMgr.hide()
        });
        this.window_.showEvent.subscribe(function () {
            this.blurButtons()
        });
        this.window_.hideEvent.subscribe(function () {
            B.cancelUpload_();
            B.onHide()
        });
        Event.on(this.url_, "keyup", function () {
            B.test_.checked = false;
            B.hideTick_(0);
            B.hideTick_(2);
            if (tools.isUrl(this.value)) {
                B.showTick_(1);
                B.enableOkButton_();
                B.uploadOption_ = 1
            } else {
                B.hideTick_(1);
                B.disableOkButton_()
            }
        });
        this.kl_ = new YAHOO.util.KeyListener(document, {
            shift: true,
            keys: 85
        },
        {
            fn: upload.show,
            scope: upload,
            correctScope: true
        });
        this.kl_.enable();
        Event.on(this.test_, "click", function () {
            B.url_.value = "";
            if (this.checked) {
                B.showTick_(2);
                B.enableOkButton_();
                B.uploadOption_ = 2
            } else {
                B.hideTick_(2);
                B.disableOkButton_()
            }
        })
    },
    setProperty_: function (A) {
        if (A.close === false) {
            this.window_.cfg.setProperty("close", false)
        } else {
            this.window_.cfg.setProperty("close", true)
        }
        if (A.cancel === false) {
            this.window_.cfg.setProperty("buttons", [this.ok_])
        } else {
            this.window_.cfg.setProperty("buttons", [this.ok_, this.cancel_])
        }
    },
    hide: function () {
        this.window_.hide()
    },
    show: function (A) {
        try {
            ef.defaultView();
            if (!this.window_) {
                this.init_()
            }
            this.defaultView();
            this.uploaderInit_();
            this.setProperty_(A);
            this.disableOkButton_();
            this.window_.show();
            tooltipMgr.show(lang.tip.upload, 0)
        } catch(B) {
            console.debug(B)
        }
    }
};
var toolbar = {
    getMetricSystem: function () {
        return this.metricType
    },
    setMetricSystem: function (A) {
        this.metricType = A
    },
    getPtRatio: function () {
        return this.ptRatio
    },
    setPtRatio: function (A) {
        this.ptRatio = A
    },
    metricType: "px",
    ptRatio: 0,
    metricConverterInit_: function () {
        var A = Dom.get("metric").offsetWidth;
        this.setPtRatio(A / 100)
    },
    changeMetricSystem: function (A) {
        this.setMetricSystem(A);
        var B = photoMgr.getDimensions();
        switch (this.metricType) {
        case "px":
            this.setImg(B[0], B[1]);
            break;
        case "pt":
            this.setImg(B[0] * this.getPtRatio(), B[1] * this.getPtRatio());
            break
        }
    },
    hideCloseButton: function () {
        Dom.setStyle(this.closeButton, "visibility", "hidden")
    },
    showCloseButton: function () {
        Dom.setStyle(this.closeButton, "visibility", "visible")
    },
    toHideButton: function () {
        Dom.setStyle(this.closeButton, "background", "transparent url(layout_sprite.png) no-repeat scroll -20px -100px");
        Dom.setStyle(this.closeButton, "position", "relative");
        Dom.setStyle(this.closeButton, "left", "0px");
        Dom.setStyle(this.closeButton, "visibility", "visible");
        this.closeButtonTooltip.cfg.setProperty("text", lang.toolbar.closeButton.hide)
    },
    toShowButton: function () {
        Dom.setStyle(this.closeButton, "background", "transparent url(layout_sprite.png) no-repeat scroll -20px -140px");
        Dom.setStyle(this.closeButton, "position", "relative");
        Dom.setStyle(this.closeButton, "left", "16px");
        Dom.setStyle(this.closeButton, "visibility", "visible");
        this.closeButtonTooltip.cfg.setProperty("text", lang.toolbar.closeButton.show)
    },
    showBackButton: function (A) {
        Dom.setStyle(this.backButton, "visibility", "visible");
        if (!A) {
            throw new Error("toolbar.showBackButton : cfg is undefined")
        }
        Event.addListener(this.backButton, "click", function () {
            A.fn.call(A.scope)
        })
    },
    hideBackButton: function () {
        Dom.setStyle(this.backButton, "visibility", "hidden");
        Event.addListener(this.backButton, "click", function () {})
    },
    buttonsInit_: function () {
        var B = this;
        this.backButton = Dom.get(configuration.CSS.IDs.toolbarBackButton);
        this.backButtonTooltip = new YAHOO.widget.Tooltip(configuration.CSS.IDs.toolbarBackButton + "-tooltip", {
            context: this.backButton,
            text: lang.toolbar.backButton.back,
            showDelay: 500
        });
        this.closeButton = Dom.get(configuration.CSS.IDs.toolbarCloseButton);
        this.closeButton.onclick = function () {
            B.changeMode()
        };
        this.closeButtonTooltip = new YAHOO.widget.Tooltip(configuration.CSS.IDs.toolbarCloseButton + "-tooltip", {
            context: this.closeButton,
            text: lang.toolbar.closeButton.hide,
            showDelay: 500
        });

        function A(F, E, D) {
            var G = D.cfg.getProperty("text");
            B.metricSystemButton.set("label", G);
            B.changeMetricSystem(G)
        }
        var C = [{
            text: "px",
            value: 1,
            onclick: {
                fn: A
            }
        },{
            text: "pt",
            value: 2,
            onclick: {
                fn: A
            }
        }];
        this.metricSystemButton = new YAHOO.widget.Button(configuration.CSS.IDs.metricType, {
            type: "split",
            menu: C
        });
        this.metricSystemButton.on("focus", function () {
            this.blur()
        })
    },
    showWarning: function (A) {
        A.tooltip = new YAHOO.widget.Tooltip(A.id + "-tooltip", {
            context: A,
            text: lang.toolbar.warnings.valueError,
            showDelay: 50
        });
        Dom.setStyle(A, "color", "#F34A4A")
    },
    hideWarning: function (A) {
        if (A.tooltip) {
            A.tooltip.destroy();
            A.tooltip = null
        }
        Dom.setStyle(A, "color", "#000")
    },
    toPx: function (A) {
        switch (this.getMetricSystem()) {
        case "px":
            return Math.round(A);
        case "pt":
            return Math.round(A / this.getPtRatio());
        default:
            alert("error#101")
        }
    },
    coordsRefresh: function () {
        var A = photoMgr.getDimensions();
        this.setImgWidth(tools.toInt(A[0]));
        this.setImgHeight(tools.toInt(A[1]));
        this.setImgWeight(photoMgr.getWeight());
        this.setImgFormat(photoMgr.getFormat())
    },
    textInputFlag: false,
    showTextInputTip: function () {
        if (!this.textInputFlag) {
            tooltipMgr.show(lang.tip.textInput);
            this.textInputFlag = true;
            return true
        }
    },
    coordsControlsInit_: function () {
        var A = this;
        Event.addListener(this.widthText, "focus", function () {
            this.select();
            this.cache = this.value;
            var C = this;
            A.textInputKL = new YAHOO.util.KeyListener(document, {
                keys: YAHOO.util.KeyListener.KEY.ENTER
            },
            {
                fn: function () {
                    B("width", C);
                    C.cache = C.value
                }
            });
            this.tip = A.textInputKL.enable();
            A.showTextInputTip()
        });
        Event.addListener(this.heightText, "focus", function () {
            this.select();
            this.cache = this.value;
            var C = this;
            A.textInputKL = new YAHOO.util.KeyListener(document, {
                keys: YAHOO.util.KeyListener.KEY.ENTER
            },
            {
                fn: function () {
                    B("height", C);
                    C.cache = C.value
                }
            });
            A.textInputKL.enable();
            this.tip = A.showTextInputTip()
        });

        function B(D, G) {
            if (G.tip === true) {
                tooltipMgr.hide();
                G.tip = false
            }
            try {
                var I = G.value.toInt();
                if (YAHOO.lang.isNumber(I)) {
                    if (G.value == G.cache) {
                        return
                    }
                    var H = photoMgr.getDimensions();
                    var F, C, E;
                    if (D == "width") {
                        F = A.toPx(I);
                        if (F < 20) {
                            tooltipMgr.show("Minimalna szerokość zdjęcia to 20px.");
                            G.value = G.cache;
                            return
                        }
                        if (A.keepProportionsIsChecked()) {
                            E = F / H[0];
                            C = tools.toInt(H[1] * E);
                            photoMgr.setDimensions(F, C, {
                                anim: true
                            })
                        } else {
                            C = H[1];
                            photoMgr.setWidth(F, {
                                anim: true
                            })
                        }
                    } else {
                        C = A.toPx(I);
                        if (C < 20) {
                            tooltipMgr.show("Minimalna wysokość zdjęcia to 20px.");
                            G.value = G.cache;
                            return
                        }
                        if (A.keepProportionsIsChecked()) {
                            E = C / H[1];
                            F = tools.toInt(H[0] * E);
                            photoMgr.setDimensions(F, C, {
                                anim: true
                            })
                        } else {
                            F = H[0];
                            photoMgr.setHeight(C, {
                                anim: true
                            })
                        }
                    }
                    A.hideWarning(G);
                    queue.add(new Command("resize", {}));
                    historyMgr.add({
                        cmd: "resize",
                        src: Dom.get(configuration.CSS.IDs.img).src,
                        width: F,
                        height: C,
                        weight: photoMgr.getWeight()
                    })
                } else {
                    A.showWarning(G)
                }
            } catch(J) {
                console.debug(J)
            }
        }
        Event.addListener(this.widthText, "blur", function () {
            B("width", this)
        });
        Event.addListener(this.heightText, "blur", function () {
            B("height", this)
        });
        this.coordsRefresh()
    },
    keepProportionsIsChecked: function () {
        return this.keepProportions.checked
    },
    hideCoords: function () {
        Dom.setStyle(this.info, "display", "none")
    },
    showCoords: function () {
        Dom.setStyle(this.info, "display", "block")
    },
    setValue_: function (A, B) {
        if (tools.isStringNumber(B)) {
            this.hideWarning(A);
            switch (this.getMetricSystem()) {
            case "px":
                A.value = B.toFixed(0);
                break;
            case "pt":
                A.value = (B * this.getPtRatio()).toFixed(1);
                break;
            default:
                alert("error#1230")
            }
        } else {
            this.showWarning(A)
        }
    },
    setImgWidth: function (A) {
        this.setValue_(this.widthText, A)
    },
    setImgHeight: function (A) {
        this.setValue_(this.heightText, A)
    },
    setImgWeight: function (A) {
        this.weightText.firstChild.nodeValue = A + "kb"
    },
    setImgFormat: function (A) {
        this.formatText.firstChild.nodeValue = A
    },
    setImg: function (B, A) {
        this.setImgWidth(B);
        this.setImgHeight(A)
    },
    animsInit_: function () {
        var A = this;
        this.hideAnim = new YAHOO.util.Anim(this.toolbar, {
            marginLeft: {
                to: -151
            }
        },
        0.2);
        this.hideAnim.onStart.subscribe(function () {
            A.hideCloseButton()
        });
        this.hideAnim.onComplete.subscribe(function () {
            ef.photo.dd.init();
            A.toShowButton();
            editor.moveToLeft();
            A.showCloseButton();
            A.visible_ = false;
            topMenuBar.menuItemSetProperty([2, 6, 0], "text", lang.menu.tools.toolbarShow)
        });
        this.showAnim = new YAHOO.util.Anim(this.toolbar, {
            marginLeft: {
                to: 0
            }
        },
        0.2);
        this.showAnim.onStart.subscribe(function () {
            editor.moveToRight();
            A.hideCloseButton()
        });
        this.showAnim.onComplete.subscribe(function () {
            ef.photo.dd.init();
            A.toHideButton();
            A.showCloseButton();
            A.visible_ = true;
            topMenuBar.menuItemSetProperty([2, 6, 0], "text", lang.menu.tools.toolbarHide)
        })
    },
    disableDimensionsEdit: function () {
        this.disableWidthEdit();
        this.disableHeightEdit()
    },
    enableDimensionsEdit: function () {
        this.enableWidthEdit();
        this.enableHeightEdit()
    },
    disableWidthEdit: function () {
        this.widthText.setAttribute("disabled", "disabled")
    },
    enableWidthEdit: function () {
        this.widthText.removeAttribute("disabled")
    },
    disableHeightEdit: function () {
        this.heightText.setAttribute("disabled", "disabled")
    },
    enableHeightEdit: function () {
        this.heightText.removeAttribute("disabled")
    },
    coreInit_: function () {
        this.toolbar = Dom.get(configuration.CSS.IDs.toolbar);
        this.info = Dom.get(configuration.CSS.IDs.photoInfo);
        this.widthText = Dom.get(configuration.CSS.IDs.photoWidth);
        this.heightText = Dom.get(configuration.CSS.IDs.photoHeight);
        this.weightText = Dom.get(configuration.CSS.IDs.photoWeight);
        this.formatText = Dom.get(configuration.CSS.IDs.photoFormat);
        this.keepProportions = Dom.get(configuration.CSS.IDs.imageRatioChecbox);
        Event.addListener(this.keepProportions, "change", function () {
            ef.photo.resize.init()
        });
        Dom.setStyle(this.toolbar, "height", Dom.getClientHeight() - 56 - 40 - 2 + "px")
    },
    visible_: true,
    init: function () {
        this.coreInit_();
        this.metricConverterInit_();
        this.buttonsInit_();
        this.animsInit_();
        this.coordsControlsInit_()
    },
    off: function (C) {
        if (!this.visible_) {
            C()
        } else {
            var B = this;
            var A = new YAHOO.util.Anim(this.toolbar, {
                marginLeft: {
                    to: -151
                }
            },
            0.2);
            A.onStart.subscribe(function () {
                B.hideCloseButton()
            });
            A.onComplete.subscribe(function () {
                C();
                toolbar.hideBackButton()
            });
            A.animate()
        }
    },
    on: function (C) {
        if (this.visible_) {
            var B = this;
            var A = new YAHOO.util.Anim(this.toolbar, {
                marginLeft: {
                    to: 0
                }
            },
            0.2);
            A.onStart.subscribe(function () {});
            A.onComplete.subscribe(function () {
                C();
                B.showCloseButton()
            });
            A.animate()
        } else {
            C()
        }
    },
    hide_: function () {
        this.hideAnim.animate()
    },
    show_: function () {
        this.showAnim.animate()
    },
    changeMode: function () {
        if (this.visible_) {
            this.hide_()
        } else {
            this.show_()
        }
    }
};
var historyMgr = {
    history_: {
        0: null,
        1: null,
        2: null,
        3: null,
        4: null
    },
    historyLength_: 5,
    historyPosition_: 0,
    historyIndex_: -1,
    enableForward_: function () {
        topMenuBar.enableMenuItem([1, 1]);
        photoMgr.contextmenuEnableItem([2])
    },
    enableBack_: function () {
        topMenuBar.enableMenuItem([1, 0]);
        photoMgr.contextmenuEnableItem([1])
    },
    disableForward_: function () {
        topMenuBar.disableMenuItem([1, 1]);
        photoMgr.contextmenuDisableItem([2])
    },
    disableBack_: function () {
        topMenuBar.disableMenuItem([1, 0]);
        photoMgr.contextmenuDisableItem([1])
    },
    disableReset_: function () {
        topMenuBar.disableMenuItem([1, 2])
    },
    enableReset_: function () {
        topMenuBar.enableMenuItem([1, 2])
    },
    reset: function () {
        try {
            var A = new Ajax({
                data: "cmd=reset",
                callback: {
                    onSuccess: function (D) {
                        try {
                            loadMgr.run(JSON.parse(D.responseText), {
                                init: true
                            })
                        } catch(C) {
                            ef.bugs.add(C, "json", D.responseText)
                        }
                    },
                    onFailure: function (C) {
                        dialogsMgr.errorShow(C.responseText)
                    }
                }
            });
            A.send();
            ef.defaultView()
        } catch(B) {
            ef.bugs.add(B, "js", "historyMgr.reset")
        }
    },
    getPosition: function () {
        return this.historyPosition_
    },
    init: function () {},
    exec_: function (A) {
        cropper.off();
        ef.dialogs.wait.show();
        var B = photoMgr.getImg();
        B.onload = function () {
            ef.dialogs.wait.hide()
        };
        B.src = A.src;
        photoMgr.setDimensions(A.width, A.height, {
            anim: true
        });
        photoMgr.setWeight(A.weight);
        ef.photo.dd.init()
    },
    modifyWeight: function (A) {
        this.history_[this.historyIndex_]["weight"] = A;
        photoMgr.setWeight(A)
    },
    back: function () {
        try {
            this.historyPosition_--;
            this.historyIndex_--;
            this.exec_(this.history_[this.historyIndex_]);
            if (this.historyIndex_ === 0) {
                this.disableBack_();
                if (this.history_[this.historyIndex_].proto) {
                    this.disableReset_()
                }
            }
            this.enableForward_();
            ef.defaultView()
        } catch(A) {
            ef.bugs.add(A, "js", "historyMgr.back")
        }
    },
    forward: function () {
        try {
            this.historyPosition_++;
            this.historyIndex_++;
            this.exec_(this.history_[this.historyIndex_]);
            if (this.historyIndex_ === this.historyLength_ - 1 || this.history_[this.historyIndex_ + 1] === null) {
                this.disableForward_()
            }
            this.enableBack_();
            this.enableReset_();
            ef.defaultView()
        } catch(A) {
            ef.bugs.add(A, "js", "historyMgr.forward")
        }
    },
    historyClear_: function () {
        for (var A = 0; A < this.historyLength_; A++) {
            this.history_[A] = null
        }
        this.historyIndex_ = -1;
        this.historyPosition_ = 0
    },
    resetHistory_: function (A) {
        A.proto = true;
        this.historyClear_();
        this.disableForward_();
        this.disableBack_();
        this.disableReset_()
    },
    add: function (B) {
        if (B.reset) {
            this.resetHistory_(B)
        }
        this.historyPosition_ = 0;
        for (var A = this.historyIndex_ + 1; A < this.historyLength_; A++) {
            this.history_[A] = null
        }
        if (this.historyIndex_ === this.historyLength_ - 1) {
            for (A = 0; A < this.historyLength - 1; A++) {
                this.history_[A] = this.history_[A + 1]
            }
            this.historyIndex_ = this.historyLength_ - 1;
            this.history_[this.historyIndex_] = B;
            if (!B.reset) {
                this.enableBack_()
            }
        } else {
            this.historyIndex_++;
            this.history_[this.historyIndex_] = B;
            if (this.historyIndex_ !== 0 && !B.reset) {
                this.enableBack_()
            }
        }
        this.disableForward_();
        if (!B.reset) {
            this.enableReset_()
        }
    }
};
ef.dialogs = {};
ef.dialogs.wait = function () {
    var A, B;
    var C = function () {
        A = new YAHOO.widget.Panel(configuration.CSS.IDs.wait, {
            fixedcenter: true,
            close: true,
            draggable: false,
            modal: true,
            visible: false
        });
        A.setHeader(lang.loading);
        A.setBody("<img src='css/loading.gif'/>");
        A.render(document.body)
    };
    return {
        show: function (E) {
            if (!A) {
                C()
            }
            if (E) {
                A.cfg.setProperty("close", true);
                var D = Dom.get(configuration.CSS.IDs.wait);
                B = Dom.getElementsByClassName("container-close", "a", D)[0];
                B.setAttribute("title", lang.wait_cancel);
                A.showEvent.subscribe(function () {
                    B.blur()
                });
                Event.removeListener(B, "click");
                Event.on(B, "click", function () {
                    if (E.abort) {
                        E.abort.call(E.scope)
                    } else {
                        Connect.abort(E)
                    }
                    var F = {
                        success: function (I) {
                            try {
                                var G = JSON.parse(I.responseText)
                            } catch(H) {
                                ef.bugs.add(H, "json", "ef.dialogs.wait abort", I.responseText)
                            }
                        },
                        failure: function () {},
                        scope: this
                    };
                    Connect.asyncRequest("POST", "main.php", F, "cmd=abort");
                    this.hide()
                },
                this, true)
            } else {
                A.cfg.setProperty("close", false)
            }
            A.show()
        },
        hide: function () {
            if (A) {
                A.hide()
            }
        }
    }
}();
var converter = {
    getFormat: function () {
        return this.format
    },
    setFormat: function (A) {
        this.format = A;
        photoMgr.setFormat(A)
    },
    hide: function () {
        if (this.window) {
            this.window.hide()
        }
    },
    init: function () {
        var B = this;
        this.windowEl = Dom.get(configuration.CSS.IDs.converter);
        this.window = new YAHOO.widget.Dialog(this.windowEl, {
            visible: false,
            fixedcenter: true,
            modal: true,
            close: true,
            draggable: true,
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        var C = function () {
            this.cancel()
        };
        var A = function () {
            var D = B.menu.get("label");
            B.request = new Ajax({
                data: ef.createData("convert", {
                    format: D
                }),
                callback: {
                    onSuccess: function (E) {
                        B.hide();
                        B.setFormat(D);
                        loadMgr.run(JSON.parse(E.responseText))
                    },
                    onFailure: function (E) {}
                }
            });
            B.request.send()
        };
        this.window.showEvent.subscribe(function () {
            this.blurButtons()
        });
        this.window.cfg.queueProperty("buttons", [{
            text: lang.buttons.convert,
            handler: A,
            isDefault: true
        },{
            text: lang.buttons.cancel,
            handler: C
        }]);
        this.window.render();
        this.windowContent = Dom.get(configuration.CSS.IDs.converterContent);
        this.setFormat(SETTINGS.format)
    },
    menuShow: function () {
        var E = this;

        function D(J, I, H) {
            E.menu.set("label", H.cfg.getProperty("text"))
        }
        var F = this.getFormat();
        var C = [{
            text: "bmp",
            value: 1,
            onclick: {
                fn: D
            }
        },{
            text: "gif",
            value: 2,
            onclick: {
                fn: D
            }
        },{
            text: "jpg",
            value: 3,
            onclick: {
                fn: D
            }
        },{
            text: "png",
            value: 5,
            onclick: {
                fn: D
            }
        }];
        var G = [];
        for (var B = 0, A = C.length; B < A; B++) {
            if (F != C[B].text) {
                G.push(C[B])
            }
        }
        if (this.menu) {
            this.menu.destroy()
        }
        this.menu = new YAHOO.widget.Button({
            type: "split",
            menu: G,
            id: "formatMenu",
            title: lang.buttons.converterButton.title,
            container: this.windowContent
        });
        this.menu.on("focus", function () {
            this.blur()
        });
        this.menu.set("label", G[0].text);
        this.menu.appendTo(this.windowEl.lastChild)
    },
    show: function () {
        try {
            ef.defaultView();
            this.menuShow();
            this.window.show()
        } catch(A) {
            console.debug(A, "js", "converter.show")
        }
    }
};
var compressor = {
    sliderInit_: function () {
        this.slider_ = YAHOO.widget.Slider.getHorizSlider(configuration.CSS.IDs.compressorSlider, configuration.CSS.IDs.compressorThumb, 0, 200, 10);
        this.degreeInformation_ = Dom.get(configuration.CSS.IDs.compressorCompressionDegree);
        var A = this;
        this.slider_.subscribe("change", function (B) {
            A.degreeInformation_.innerHTML = Math.round(B / 2) + "%"
        });
        this.slider_.subscribe("slideEnd", function () {
            try {
                this.lock();
                var C = "cmd=compressTmp&compressDegree=" + Math.round(A.slider_.getValue() / 2) + "&position=" + historyMgr.getPosition();
                var B = new Ajax({
                    mask: false,
                    data: C,
                    callback: {
                        onSuccess: function (F) {
                            var E = JSON.parse(F.responseText);
                            A.imgSize_.innerHTML = E.size + "kb";
                            A.slider_.unlock()
                        }
                    },
                    waitDialog: false
                });
                B.send()
            } catch(D) {
                console.debug(D)
            }
        })
    },
    menuShow_: function () {
        Dom.setStyle(configuration.CSS.IDs.compressorColorBD, "display", "block");
        Dom.setStyle(configuration.CSS.IDs.compressorSliderBD, "display", "none");
        var B = this;
        format = converter.getFormat();

        function A(E, D, G) {
            var F = new Ajax({
                mask: false,
                data: "cmd=compressTmp&compressColors=" + B.colors_ + "&position=" + historyMgr.getPosition(),
                callback: {
                    onSuccess: function (I) {
                        var H = JSON.parse(I.responseText);
                        B.imgSize_.innerHTML = H.size + "kb"
                    }
                }
            });
            F.send();
            B.colors_ = G.value;
            B.colorsButton_.set("label", G.cfg.getProperty("text"))
        }
        switch (format) {
        case "bmp":
            B.colors_ = "16777216";
            var C = [{
                text: lang.compressor.bits24,
                value: "16777216",
                onclick: {
                    fn: A
                }
            },{
                text: "256",
                value: "256",
                onclick: {
                    fn: A
                }
            }];
            break;
        case "gif":
            B.colors_ = "256";
            var C = [{
                text: "256",
                value: "256",
                onclick: {
                    fn: A
                }
            },{
                text: "16",
                value: "16",
                onclick: {
                    fn: A
                }
            },{
                text: "2",
                value: "2",
                onclick: {
                    fn: A
                }
            }];
            break
        }
        this.colorsButton_ = new YAHOO.widget.Button(configuration.CSS.IDs.compressorColorsButton, {
            type: "split",
            menu: C
        });
        this.colorsButton_.set("label", C[0].text);
        this.setMode_("menu")
    },
    init: function () {
        var B = this;
        this.window_ = new YAHOO.widget.Dialog(configuration.CSS.IDs.compressor, {
            visible: false,
            fixedcenter: true,
            modal: true,
            close: true,
            draggable: true,
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        this.window_.showEvent.subscribe(function () {
            this.blurButtons()
        });
        var C = function () {
            this.cancel()
        };
        var A = function () {
            switch (B.getMode_()) {
            case "slider":
                var D = {
                    compressDegree: Math.round(B.slider_.getValue() / 2)
                };
                break;
            case "menu":
                var D = {
                    compressColors: B.colors_
                };
                break
            }
            B.request = new Ajax({
                data: ef.createData("compress", D),
                callback: {
                    onSuccess: function (E) {
                        B.window_.hide();
                        loadMgr.run(JSON.parse(E.responseText))
                    },
                    onFailure: function (E) {}
                }
            });
            B.request.send()
        };
        this.window_.cfg.queueProperty("buttons", [{
            text: lang.buttons.compress,
            handler: A,
            isDefault: true
        },{
            text: lang.buttons.cancel,
            handler: C
        }]);
        this.window_.render();
        this.sliderInit_()
    },
    setMode_: function (A) {
        this.mode_ = A
    },
    getMode_: function () {
        return this.mode_
    },
    setImgSize_: function (A) {
        if (!this.imgSize_) {
            this.imgSize_ = Dom.get(configuration.CSS.IDs.compressorSizeValue)
        }
        this.imgSize_.innerHTML = A + "kb"
    },
    sliderShow_: function () {
        Dom.setStyle(configuration.CSS.IDs.compressorSliderBD, "display", "block");
        Dom.setStyle(configuration.CSS.IDs.compressorColorBD, "display", "none");
        this.slider_.setValue(0, true, true, true);
        this.setMode_("slider")
    },
    show: function () {
        try {
            ef.defaultView();
            switch (converter.getFormat()) {
            case "bmp":
            case "gif":
                this.menuShow_();
                break;
            case "jpg":
            case "png":
                this.sliderShow_();
                break;
            default:
                throw new Error("compressor.show(): unsupported file extension")
            }
            this.setImgSize_(photoMgr.getWeight());
            this.window_.show()
        } catch(A) {
            ef.bugs.add(A, "js", "compressor.show")
        }
    }
};
var save = {
    sliderInit: function () {
        this.slider = YAHOO.widget.Slider.getHorizSlider(configuration.CSS.IDs.saveCompressorSlider, configuration.CSS.IDs.saveCompressorThumb, 0, 200, 10);
        this.slider.subscribe("change", function (A) {
            Dom.get(configuration.CSS.IDs.saveCompressionDegree).innerHTML = Math.floor(A / 2) + "%"
        })
    },
    compressMenuInit: function (F) {
        var E = this;

        function D(J, I, H) {
            E.colors = H.value;
            E.colorsButton.set("label", H.cfg.getProperty("text"))
        }
        switch (F) {
        case "bmp":
            E.colors = "16777216";
            var G = [{
                text: lang.compressor.bits24,
                value: "16777216",
                onclick: {
                    fn: D
                }
            },{
                text: "256",
                value: "256",
                onclick: {
                    fn: D
                }
            }];
            Dom.get(configuration.CSS.IDs.saveColorsButton).value = lang.compressor.bits24;
            break;
        case "gif":
            E.colors = "256";
            var G = [{
                text: "256",
                value: "256",
                onclick: {
                    fn: D
                }
            },{
                text: "16",
                value: "16",
                onclick: {
                    fn: D
                }
            },{
                text: "2",
                value: "2",
                onclick: {
                    fn: D
                }
            }];
            Dom.get(configuration.CSS.IDs.saveColorsButton).value = "256";
            break
        }
        if (this.colorsButton) {
            var B = this.colorsButton.getMenu().getItems();
            var A = B.length;
            this.colorsButton.getMenu().addItems(G);
            E.colorsButton.set("label", G[0].text);
            for (var C = 0; C < A; C++) {
                this.colorsButton.getMenu().removeItem(0)
            }
        } else {
            this.colorsButton = new YAHOO.widget.Button(configuration.CSS.IDs.saveColorsButton, {
                type: "split",
                menu: G
            });
            this.colorsButton.on("focus", function () {
                this.blur()
            })
        }
    },
    init: function () {
        var B = this;
        this.window = new YAHOO.widget.Dialog(configuration.CSS.IDs.savePhoto, {
            visible: false,
            fixedcenter: true,
            modal: true,
            close: true,
            draggable: true,
            width: "320px",
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        var C = function () {
            this.cancel()
        };
        var A = function () {
            try {
                var H = Dom.get(configuration.CSS.IDs.saveFileName).value;
                switch (B.mode) {
                case "slider":
                    var D = Math.floor(B.slider.getValue() / 2);
                    break;
                case "menu":
                    var D = B.colors;
                    break;
                default:
                    break
                }
                var G = YAHOO.lang.substitute("download.php?format={format}&fc={fc}&compress={compress}&position={position}", {
                    format: B.formatMenu.get("label"),
                    fc: H,
                    position: historyMgr.getPosition(),
                    compress: D
                });
                var E = photoMgr.hasChanged();
                if (E) {
                    G += YAHOO.lang.substitute("&width={width}&height={height}", {
                        width: E[0],
                        height: E[1]
                    })
                }
                location.href = G
            } catch(F) {
                ef.bugs.add(F, "js", "save.handleSubmit")
            }
        };
        this.window.cfg.queueProperty("buttons", [{
            text: lang.buttons.saveOnDisc,
            handler: A,
            isDefault: true
        },{
            text: lang.buttons.cancel,
            handler: C
        }]);
        this.formatMenuInit();
        this.sliderInit();
        this.window.render();
        this.kl = new YAHOO.util.KeyListener(document, {
            shift: true,
            keys: 83
        },
        {
            fn: save.show,
            scope: save,
            correctScope: true
        });
        this.kl.enable()
    },
    formatMenuInit: function () {
        var B = this;

        function A(F, E, D) {
            B.formatMenu.set("label", D.cfg.getProperty("text"));
            B.compressControlShow(D.cfg.getProperty("text"))
        }
        var C = [{
            text: "bmp",
            value: 1,
            onclick: {
                fn: A
            }
        },{
            text: "gif",
            value: 2,
            onclick: {
                fn: A
            }
        },{
            text: "jpg",
            value: 3,
            onclick: {
                fn: A
            }
        },{
            text: "png",
            value: 5,
            onclick: {
                fn: A
            }
        }];
        this.formatMenu = new YAHOO.widget.Button(configuration.CSS.IDs.savePhotoFormat, {
            type: "split",
            menu: C
        });
        this.formatMenu.on("focus", function () {
            this.blur()
        })
    },
    clearForm: function () {
        Dom.get(configuration.CSS.IDs.saveFileName).value = "";
        this.slider.setValue(0, true, true, false)
    },
    setFormat: function () {
        this.formatMenu.set("label", converter.getFormat())
    },
    resetSlider: function () {
        Dom.get(configuration.CSS.IDs.saveCompressionDegree).innerHTML = "0%";
        this.slider.setValue(0, true, true, true)
    },
    compressSliderShow: function () {
        Dom.setStyle(configuration.CSS.IDs.saveSliderBD, "display", "block");
        Dom.setStyle(configuration.CSS.IDs.saveColorBD, "display", "none")
    },
    compressMenuShow: function () {
        Dom.setStyle(configuration.CSS.IDs.saveColorBD, "display", "block");
        Dom.setStyle(configuration.CSS.IDs.saveSliderBD, "display", "none")
    },
    compressControlShow: function (A) {
        switch (A) {
        case "bmp":
        case "gif":
            this.mode = "menu";
            this.compressMenuShow();
            this.compressMenuInit(A);
            break;
        case "jpg":
        case "png":
            this.mode = "slider";
            this.compressSliderShow();
            break;
        default:
            break
        }
    },
    show: function () {
        try {
            ef.defaultView();
            this.resetSlider();
            this.compressControlShow(converter.getFormat());
            this.setFormat();
            this.clearForm();
            this.window.show()
        } catch(A) {
            ef.bugs.add(A, "js", "save.show")
        }
    }
};
var topMenuBar = {
    render_: function () {
        this.menuItems = [{
            text: lang.menu.file.main,
            submenu: {
                id: configuration.CSS.IDs.topMenuBarFile,
                itemdata: [[{
                    text: "<span id='save-icon' class='icon'></span>" + lang.menu.file.saveOnDisc,
                    helptext: "Shift + S",
                    onclick: {
                        fn: save.show,
                        scope: save
                    }
                },{
                    text: "<span id='upload-icon' class='icon'></span>" + lang.menu.file.uploadFile,
                    helptext: "Shift + U",
                    onclick: {
                        fn: upload.show,
                        scope: upload,
                        obj: {
                            close: true,
                            cancel: true
                        }
                    }
                }], [{
                    text: "<span id='exit-icon' class='icon'></span>" + lang.menu.file.exit,
                    onclick: {
                        fn: ef.exit,
                        scope: ef
                    }
                }]]
        }
    },{
        text: lang.menu.edit.main,
        submenu: {
            id: configuration.CSS.IDs.topMenuBarEdit,
            itemdata: [[{
                text: "<span id='back-icon' class='icon'></span>" + lang.menu.edit.back,
                disabled: true,
                onclick: {
                    fn: historyMgr.back,
                    scope: historyMgr
                }
            },{
                text: "<span id='forward-icon' class='icon'></span>" + lang.menu.edit.forward,
                disabled: true,
                onclick: {
                    fn: historyMgr.forward,
                    scope: historyMgr
                }
            }], [{
                text: "<span id='reset-icon' class='icon'></span>" + lang.menu.edit.reset,
                disabled: true,
                onclick: {
                    fn: historyMgr.reset,
                    scope: historyMgr
                }
            }]]
    }
},{
    text: lang.menu.tools.main,
    submenu: {
        id: configuration.CSS.IDs.topMenuBarTools,
        itemdata: [[{
            text: "<span id='frame-icon' class='icon'></span>" + lang.menu.tools.addFrame,
            onclick: {
                fn: framePicker.show,
                scope: framePicker
            }
        },{
            text: "<span id='cropp-icon' class='icon'></span>" + lang.menu.tools.cropp,
            onclick: {
                fn: function (B, A) {
                    cropper.switchMode();
                    this.blur()
                }
            }
        },{
            text: "<span id='mask-icon' class='icon'></span>" + lang.menu.tools.colorMask,
            onclick: {
                fn: mask.show,
                scope: mask
            }
        },{
            text: "<span id='compress-icon' class='icon'></span>" + lang.menu.tools.compression,
            onclick: {
                fn: compressor.show,
                scope: compressor
            }
        },{
            text: "<span id='converter-icon' class='icon'></span>" + lang.menu.tools.converter,
            onclick: {
                fn: converter.show,
                scope: converter
            }
        },{
            text: "<span id='zoom-icon' class='icon'></span>" + lang.menu.tools.zoomer,
            onclick: {
                fn: zoomerMgr.show,
                scope: zoomerMgr
            }
        }], [{
            text: "<span id='tip-icon' class='icon'></span>" + lang.menu.tools.settings,
            submenu: {
                id: configuration.CSS.IDs.topMenuBarSettings,
                itemdata: [{
                    text: lang.menu.tools.toolbarHide,
                    onclick: {
                        fn: checkMethod(toolbar.changeMode),
                        scope: toolbar
                    }
                },{
                    text: lang.menu.tools.showTip,
                    onclick: {
                        fn: checkMethod(function () {
                            tooltipMgr.nextTip(true)
                        }),
                        scope: tooltipMgr
                    }
                },]
            }
        }]]
}
},{
    text: lang.menu.efects.main,
    submenu: {
        id: configuration.CSS.IDs.topMenuBarEffects,
        itemdata: [{
            text: "<span id='sepia-icon' class='icon'></span>" + lang.menu.efects.sepia,
            onclick: {
                fn: ef.sendBridge,
                scope: ef,
                obj: "sepia"
            }
        },{
            text: "<span id='negative-icon' class='icon'></span>" + lang.menu.efects.negative,
            onclick: {
                fn: ef.sendBridge,
                scope: ef,
                obj: "negative"
            }
        },{
            text: "<span id='contrast-icon' class='icon'></span>" + lang.menu.efects.contrast,
            onclick: {
                fn: contrastDialog.show,
                scope: contrastDialog
            }
        },{
            text: "<span id='brightness-icon' class='icon'></span>" + lang.menu.efects.brightness,
            onclick: {
                fn: brightnessDialog.show,
                scope: brightnessDialog
            }
        },{
            text: "<span id='blur-icon' class='icon'></span>" + lang.menu.efects.blur,
            onclick: {
                fn: blurDialog.show,
                scope: blurDialog
            }
        },{
            text: "<span id='charcoal-icon' class='icon'></span>" + lang.menu.efects.charcoal,
            onclick: {
                fn: ef.sendBridge,
                scope: ef,
                obj: "charcoal"
            }
        },{
            text: "<span id='oilpaint-icon' class='icon'></span>" + lang.menu.efects.oilpaint,
            onclick: {
                fn: ef.sendBridge,
                scope: ef,
                obj: "oilpaint"
            }
        },{
            text: "<span id='bw-icon' class='icon'></span>" + lang.menu.efects.bw,
            onclick: {
                fn: ef.sendBridge,
                scope: ef,
                obj: "bw"
            }
        },{
            text: "<span id='mirror-icon' class='icon'></span>" + lang.menu.efects.mirror,
            onclick: {
                fn: ef.sendBridge,
                scope: ef,
                obj: "mirror"
            }
        },{
            text: "<span id='pixelate-icon' class='icon'></span>" + lang.menu.efects.pixelate,
            onclick: {
                fn: pixelateDialog.show,
                scope: pixelateDialog
            }
        },{
            text: "<span id='red-eye-icon' class='icon'></span>" + lang.menu.efects.redEye,
            onclick: {
                fn: redEyeMgr.show,
                scope: redEyeMgr
            }
        },{
            text: "<span id='wet-floor-icon' class='icon'></span>" + lang.menu.efects.wetFloor,
            onclick: {
                fn: dialogsMgr.wetFloorShow,
                scope: dialogsMgr
            }
        },{
            text: "<span id='rotate-icon' class='icon'></span>" + lang.menu.efects.rotate,
            submenu: {
                id: configuration.CSS.IDs.topMenuBarRotate,
                itemdata: [{
                    text: "<span id='rotate90r-icon' class='icon'></span>" + lang.menu.efects.rotate90r,
                    onclick: {
                        fn: ef.rotationBridge,
                        obj: "90",
                        scope: ef
                    }
                },{
                    text: "<span id='rotate180-icon' class='icon'></span>" + lang.menu.efects.rotate180,
                    onclick: {
                        fn: ef.rotationBridge,
                        obj: "180",
                        scope: ef
                    }
                },{
                    text: "<span id='rotate90l-icon' class='icon'></span>" + lang.menu.efects.rotate90l,
                    onclick: {
                        fn: ef.rotationBridge,
                        obj: "270",
                        scope: ef
                    }
                }]
            }
        }]
    }
},{
    text: lang.menu.help.main,
    submenu: {
        id: configuration.CSS.IDs.topMenuBarHelp,
        itemdata: [{
            text: '<span title="Formularz kontaktowy"><span id="contact-icon" class="icon"></span>' + lang.menu.help.contact + '</span>',
            onclick: {
                fn: dialogsMgr.contactShow,
                scope: dialogsMgr
            }
        }, {
            text: '<span title="Strona pomocy (nowa zakładka)"><span id="about-icon" class="icon"></span>Pomoc</span>',
            onclick: {
                fn: function() {
			openInNewTag('help.html');
		}
	    }
	}, {
            text: '<span title="Informacje o edytorze"><span id="faq-icon" class="icon"></span>' + lang.menu.help.about + '</span>',
            onclick: {
                fn: dialogsMgr.aboutShow,
                scope: dialogsMgr
            }
        },]
    }
}];

function openInNewTag(url) {
	window.open(url, '_blank');
}

this.menu = new YAHOO.widget.MenuBar(configuration.CSS.IDs.topMenuBar, {
    lazyload: false,
    itemdata: this.menuItems,
    zIndex: 99999
});
this.menu.render(document.body)
},
get: function () {
    return this.menu
},
menuItemSetProperty: function (E, C, D) {
    var A = this.menu.getItems();
    if (YAHOO.lang.isArray(E)) {
        for (var B = 0; B < E.length; B++) {
            if (E.length - 1 === B) {
                A[E[B]].cfg.setProperty(C, D)
            } else {
                A = A[E[B]].cfg.getProperty("submenu").getItems()
            }
        }
    } else {
        throw new Error("topMenuBar.menuItemSetProperty_: [ " + E + " ] first parameter must be an array.")
    }
},
disableMenuItem: function (A) {
    this.menuItemSetProperty(A, "disabled", true)
},
enableMenuItem: function (A) {
    this.menuItemSetProperty(A, "disabled", false)
},
init: function () {
    this.render_()
}
};

function Ajax(A) {
    this.data = A.data || null;
    this.callback = A.callback || {
        onSuccess: null,
        onFailure: null,
        scope: this
    };
    if (A.waitDialog === false) {
        this.waitDialog = false
    }
    if (A.close === false) {
        this.close = false
    } else {
        this.close = true
    }
    this.method = A.method || "POST";
    this.url = A.url || "main.php";
    if (A.hasOwnProperty("mask")) {
        this.mask = A.mask
    } else {
        this.mask = true
    }
}
Ajax.prototype = {
    timeout: 1000 * 60,
    onStart: function () {},
    onEnd: function () {
        if (this.mask) {
            ef.dialogs.hide()
        }
    },
    onSuccess: function (A) {
        if (this.callback.onSuccess) {
            this.callback.onSuccess.call(this.callback.scope, A)
        } else {
            this.onEnd()
        }
    },
    onFailure: function (A) {
        if (this.callback.onFailure) {
            this.callback.onFailure.call(this.callback.scope, A)
        } else {
            dialogs.errorDialogShow(lang.error.requestFailure);
            this.onEnd()
        }
    },
    send: function () {
        this.onStart();
        var A = {
            success: this.onSuccess,
            failure: this.onFailure,
            timeout: this.timeout,
            scope: this
        };
        if (this.method == "GET") {
            this.url += "?" + this.data
        }
        this.request = Connect.asyncRequest(this.method, this.url, A, this.data);
        if (this.waitDialog !== false) {
            if (this.close === false) {
                ef.dialogs.wait.show()
            } else {
                ef.dialogs.wait.show(this.request)
            }
        }
    },
    abort: function () {
        Connect.abort(this.request)
    }
};
var clipboard = {
    flashId: "flashId-HKxmj5",
    clipboardSWF: "clipboard.swf",
    tipShow: function () {},
    add: function (C, B) {
        Dom.get(this.flashId).innerHTML = "";
        var A = '<embed src="' + this.clipboardSWF + '" FlashVars="clipboard=' + encodeURIComponent(C) + '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        Dom.get(this.flashId).innerHTML = A;
        if (B) {
            this.tipShow()
        }
    },
    init: function () {
        if (!Dom.get(this.flashId)) {
            var A = document.createElement("div");
            A.id = this.flashId;
            document.body.appendChild(A)
        }
        this.add(SETTINGS.url, false)
    }
};
var sharePhoto = {
    init: function () {
        Dom.setStyle(configuration.CSS.IDs.sharePhotoDialog, "display", "block");
        var A = function () {
            var D = YAHOO.lang.substitute("main.php?cmd=share&format={format}&position={position}", {
                format: converter.getFormat(),
                position: historyMgr.getPosition()
            });
            var C = img.hasChange();
            if (C) {
                D += YAHOO.lang.substitute("&width={width}&height={height}", {
                    width: C[0],
                    height: C[1]
                })
            }
            location.href = D
        };
        var B = function () {
            this.cancel()
        };
        this.dialog = new YAHOO.widget.Dialog(configuration.CSS.IDs.sharePhotoDialog, {
            modal: true,
            fixedcenter: true,
            visible: false,
            constraintoviewport: true,
            buttons: [{
                text: lang.buttons.share,
                handler: A,
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: B
            }],
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        this.dialog.render()
    },
    show: function () {
        eyp.environmentReset();
        if (!this.dialog) {
            this.init()
        }
        this.dialog.show()
    }
};
var mask = {
    getColor: function () {
        return this.HEX
    },
    getOpacity: function () {
        return Dom.getStyle(this.mask, "opacity")
    },
    setColor: function (A) {
        Dom.setStyle(this.mask, "backgroundColor", A)
    },
    setOpacity: function (A) {
        Dom.setStyle(this.mask, "opacity", A)
    },
    maskHide: function () {
        ef.photo.resize.init();
        ef.photo.dd.init();
        Dom.setStyle(this.mask, "display", "none");
        ef.photo.resize.mouseWheelEnable();
        toolbar.enableDimensionsEdit()
    },
    dialogInit: function () {
        var A = this;
        Dom.setStyle(Dom.get(configuration.CSS.IDs.maskPickerDialog), "display", "block");
        this.dialog = new YAHOO.widget.Dialog(configuration.CSS.IDs.maskPickerDialog, {
            width: "400px",
            close: true,
            xy: [Dom.getClientWidth(), 0],
            visible: false,
            constraintoviewport: true,
            dragable: true,
            zIndex: 999,
            buttons: [{
                text: lang.buttons.ok,
                handler: function () {
                    ef.send("mask", {
                        opacity: A.getOpacity(),
                        color: A.getColor()
                    },
                    {
                        onSuccess: function () {
                            this.hide()
                        },
                        scope: A
                    })
                },
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: function () {
                    this.cancel()
                }
            }],
            effect: {
                effect: YAHOO.widget.ContainerEffect.SLIDE,
                duration: 0.4
            }
        });
        this.dialog.hideEvent.subscribe(function () {
            A.maskHide()
        });
        this.dialog.renderEvent.subscribe(function () {
            A.picker = new YAHOO.widget.ColorPicker(configuration.CSS.IDs.maskPicker, {
                container: A.dialog,
                images: {
                    PICKER_THUMB: "css/picker_thumb.png",
                    HUE_THUMB: "css/hue_thumb.png"
                },
                txt: {
                    ILLEGAL_HEX: lang.colorPicker.illegalHex,
                    SHOW_CONTROLS: lang.colorPicker.showColorDetails,
                    HIDE_CONTROLS: lang.colorPicker.hideColorDetails,
                    CURRENT_COLOR: lang.colorPicker.currentColor,
                    CLOSEST_WEBSAFE: lang.colorPicker.closestWebsafe,
                    R: "R",
                    G: "G",
                    B: "B",
                    H: "H",
                    S: "S",
                    V: "V",
                    HEX: "#",
                    DEG: "\u00B0",
                    PERCENT: "%"
                },
                showhexcontrols: true
            });
            A.picker.on("rgbChange", function (B) {
                var C = B.newValue;
                A.HEX = "#" + YAHOO.util.Color.rgb2hex(C[0], C[1], C[2]);
                A.setColor(A.HEX)
            });
            A.slider = YAHOO.widget.Slider.getHorizSlider(configuration.CSS.IDs.maskPickerSlider, configuration.CSS.IDs.maskPickerThumb, 0, 200, 1);
            A.slider.subscribe("change", function (C) {
                var B = C / 200;
                A.setOpacity(B);
                Dom.get(configuration.CSS.IDs.maskPickerOpacity).innerHTML = B + ((B === 1 || B === 0) ? ".0" : "")
            })
        });
        this.dialog.render()
    },
    pickerShow: function () {
        var A = this;
        if (!this.dialog) {
            this.dialogInit()
        }
        this.slider.setValue(40);
        this.dialog.show()
    },
    maskShow: function () {
        ef.photo.resize.destroy();
        ef.photo.dd.destroy();
        var A = photoMgr.getDimensions();
        Dom.setStyle(this.mask, "width", A[0] + "px");
        Dom.setStyle(this.mask, "height", A[1] + "px");
        var B = Dom.getXY(photoMgr.getImg());
        if (YAHOO.env.ua.ie !== 0) {
            B[0] += 2;
            B[1] += 2
        }
        Dom.setStyle(this.mask, "left", B[0] + "px");
        Dom.setStyle(this.mask, "top", B[1] + "px");
        Dom.setStyle(this.mask, "opacity", "0.2");
        Dom.setStyle(this.mask, "display", "block");
        ef.photo.resize.mouseWheelDisable();
        toolbar.disableDimensionsEdit()
    },
    init: function () {
        this.mask = Dom.get(configuration.CSS.IDs.maskPickerMask);
        Dom.setStyle(this.mask, "zIndex", 1)
    },
    hide: function () {
        this.dialog.hide();
        this.maskHide()
    },
    show: function () {
        try {
            ef.defaultView();
            if (!this.mask) {
                this.init()
            }
            this.maskShow();
            this.pickerShow()
        } catch(A) {
            ef.bugs.add(A, "js", "mask.show")
        }
    }
};
var SliderDialog = function (C, B, A) {
    this.cmd = C;
    this.dialogId = B.dialogId;
    this.miniatureId = B.miniatureId;
    this.maskId = B.maskId;
    this.sliderId = B.sliderId;
    this.sliderThumbId = B.sliderThumbId;
    this.degreeInfo = B.degreeInfo;
    this.onChangeCallback = A.changeCallback ||
    function () {};
    this.startValue = A.startValue || 0;
    this.initialize = A.initialize || null;
    this.okCallback = A.okCallback ||
    function (D) {
        return Math.floor(D / 2)
    }
};
SliderDialog.prototype = {
    sliderInit: function () {
        var A = this;
        this.slider = YAHOO.widget.Slider.getHorizSlider(this.sliderId, this.sliderThumbId, 0, 200, 1);
        this.slider.subscribe("change", function (B) {
            A.onChangeCallback(B)
        });
        Dom.setStyle(this.dialogId, "display", "block")
    },
    createRequestData: function () {
        var A = {};
        var B = photoMgr.hasChanged();
        if (YAHOO.lang.isNumber(this.type)) {
            A.type = this.type
        }
        A.degree = this.okCallback(this.slider.getValue());
        if (B) {
            A.width = B[0];
            A.height = B[1]
        }
        return ef.createData(this.cmd, A)
    },
    dialogInit: function () {
        var B = this;
        var C = function () {
            this.cancel()
        };
        var A = function () {
            B.request = new Ajax({
                data: B.createRequestData(),
                callback: {
                    onSuccess: function (D) {
                        B.dialog.cancel();
                        loadMgr.run(JSON.parse(D.responseText))
                    },
                    onFailure: function (D) {}
                }
            });
            B.request.send()
        };
        if (this.initialize) {
            this.initialize()
        }
        this.dialog = new YAHOO.widget.Dialog(this.dialogId, {
            visible: false,
            fixedcenter: true,
            modal: true,
            close: true,
            draggable: true,
            buttons: [{
                text: lang.buttons.ok,
                handler: A,
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: C
            }],
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            }
        });
        this.dialog.showEvent.subscribe(function () {
            tooltipMgr.show(lang.tip.sliderDialog)
        });
        this.dialog.beforeHideEvent.subscribe(function () {
            Connect.abort(B.request);
            tooltipMgr.hide()
        });
        this.sliderInit();
        this.dialog.render()
    },
    init: function () {
        this.dialogInit()
    },
    loadingShow: function () {
        Dom.setStyle(this.miniatureId, "background", "#fff url(css/loading_min.gif) no-repeat center center")
    },
    miniatureInit: function () {
        var A = photoMgr.getDimensions();
        if (A[1] > A[0]) {
            this.miniatureWidth = Math.round(A[0] / (A[1] / 140));
            this.miniatureHeight = 140
        } else {
            this.miniatureHeight = Math.round(A[1] / (A[0] / 140));
            this.miniatureWidth = 140
        }
        var B = Dom.get(this.miniatureId);
        Dom.setStyle(B, "width", this.miniatureWidth + "px");
        Dom.setStyle(B, "height", this.miniatureHeight + "px")
    },
    sliderDefaultView_: function () {
        this.slider.setValue(this.startValue, true, true, true);
        this.onChangeCallback(this.startValue)
    },
    setDegreeInfo_: function (A) {
        Dom.get(this.degreeInfo).innerHTML = A + "%"
    },
    show: function () {
        try {
            ef.defaultView();
            if (!this.slider) {
                this.init()
            }
            this.miniatureInit();
            this.dialog.show();
            this.sliderDefaultView_()
        } catch(A) {
            ef.bugs.add(A, "js", "SliderDialog.show")
        }
    }
};
var contrastDialog = new SliderDialog("contrast", {
    dialogId: configuration.CSS.IDs.contrast,
    miniatureId: configuration.CSS.IDs.contrastImg,
    maskId: configuration.CSS.IDs.contrastImgMask,
    sliderId: configuration.CSS.IDs.contrastSlider,
    sliderThumbId: configuration.CSS.IDs.contrastThumb,
    degreeInfo: configuration.CSS.IDs.contrastDegree
},
{
    startValue: 100,
    okCallback: function (A) {
        return A - 100
    },
    changeCallback: function (C) {
        var A = this;
        this.loadingShow();
        this.slider.lock();
        var B = Math.floor(C - 100);
        this.setDegreeInfo_(B);
        this.request = new Ajax({
            mask: false,
            url: "thumbnail.php",
            data: ef.createData("contrast", {
                degree: B,
                width: this.miniatureWidth,
                height: this.miniatureHeight
            }),
            callback: {
                onSuccess: function (E) {
                    var D = JSON.parse(E.responseText);
                    var F = new Image();
                    F.onload = function () {
                        Dom.setStyle(A.miniatureId, "background", "#fff url(" + D.file + ")")
                    };
                    F.src = D.file;
                    A.slider.unlock()
                },
                onFailure: function (D) {
                    dialogsMgr.errorShow(D.responseText)
                }
            },
            waitDialog: false
        });
        this.request.send()
    }
});
var pixelateDialog = new SliderDialog("pixelate", {
    dialogId: configuration.CSS.IDs.pixelate,
    miniatureId: configuration.CSS.IDs.pixelateImg,
    maskId: configuration.CSS.IDs.pixelateImgMask,
    sliderId: configuration.CSS.IDs.pixelateSlider,
    sliderThumbId: configuration.CSS.IDs.pixelateThumb,
    degreeInfo: configuration.CSS.IDs.pixelateDegree
},
{
    startValue: 0,
    okCallback: function (A) {
        return Math.floor(A / 2)
    },
    changeCallback: function (C) {
        this.loadingShow();
        this.slider.lock();
        var B = Math.floor(C / 2);
        this.setDegreeInfo_(B);
        var A = this;
        this.request = new Ajax({
            mask: false,
            url: "thumbnail.php",
            data: ef.createData("pixelate", {
                degree: B,
                width: this.miniatureWidth,
                height: this.miniatureHeight
            }),
            callback: {
                onSuccess: function (E) {
                    var D = JSON.parse(E.responseText);
                    var F = new Image();
                    F.onload = function () {
                        Dom.setStyle(A.miniatureId, "background", "#fff url(" + D.file + ")")
                    };
                    F.src = D.file;
                    A.slider.unlock()
                },
                onFailure: function (D) {
                    dialogsMgr.errorShow(D.responseText)
                }
            },
            waitDialog: false
        });
        this.request.send()
    }
});
var blurDialog = new SliderDialog("blur", {
    dialogId: configuration.CSS.IDs.blur,
    miniatureId: configuration.CSS.IDs.blurImg,
    maskId: configuration.CSS.IDs.blurImgMask,
    sliderId: configuration.CSS.IDs.blurSlider,
    sliderThumbId: configuration.CSS.IDs.blurThumb,
    degreeInfo: configuration.CSS.IDs.blurDegree
},
{
    startValue: 0,
    initialize: function () {
        var B = this;
        this.typeButton = new YAHOO.widget.Button("blur-type-button", {
            type: "split",
            menu: "blur-type-select"
        });
        var A = this.typeButton;
        var C = A.getMenu();
        C.clickEvent.subscribe(function (F, E) {
            var D = E[1];
            var G = D.cfg.getProperty("text");
            A.set("label", G);
            B.onChangeCallback(B.okCallback(B.slider.getValue()))
        });
        this.typeButton.on("focus", function () {
            this.blur()
        })
    },
    okCallback: function (A) {
        return Math.floor(A / 2)
    },
    changeCallback: function (C) {
        this.loadingShow();
        this.slider.lock();
        var B = Math.floor(C / 2);
        this.setDegreeInfo_(B);
        switch (this.typeButton.get("label")) {
        case "motion":
            this.type = 0;
            break;
        case "radial":
            this.type = 1;
            break;
        case "simple":
            this.type = 2;
            break
        }
        var A = this;
        this.request = new Ajax({
            mask: false,
            url: "thumbnail.php",
            data: ef.createData("blur", {
                degree: B,
                type: this.type,
                width: this.miniatureWidth,
                height: this.miniatureHeight
            }),
            callback: {
                onSuccess: function (E) {
                    var D = JSON.parse(E.responseText);
                    var F = new Image();
                    F.onload = function () {
                        Dom.setStyle(A.miniatureId, "background", "#fff url(" + D.file + ")")
                    };
                    F.src = D.file;
                    A.slider.unlock()
                },
                onFailure: function (D) {
                    dialogsMgr.errorShow(D.responseText)
                }
            },
            waitDialog: false
        });
        this.request.send()
    }
});
var brightnessDialog = new SliderDialog("brightness", {
    dialogId: configuration.CSS.IDs.brightness,
    miniatureId: configuration.CSS.IDs.brightnessImg,
    maskId: configuration.CSS.IDs.brightnessImgMask,
    sliderId: configuration.CSS.IDs.brightnessSlider,
    sliderThumbId: configuration.CSS.IDs.brightnessThumb,
    degreeInfo: configuration.CSS.IDs.brightnessDegree
},
{
    startValue: 100,
    initialize: function () {},
    okCallback: function (A) {
        return Math.floor(A - 100)
    },
    changeCallback: function (C) {
        this.loadingShow();
        this.slider.lock();
        var B = Math.floor(C - 100);
        this.setDegreeInfo_(B);
        var A = this;
        this.request = new Ajax({
            mask: false,
            url: "thumbnail.php",
            data: ef.createData("brightness", {
                degree: B,
                width: this.miniatureWidth,
                height: this.miniatureHeight
            }),
            callback: {
                onSuccess: function (E) {
                    var D = JSON.parse(E.responseText);
                    var F = new Image();
                    F.onload = function () {
                        Dom.setStyle(A.miniatureId, "background", "#fff url(" + D.file + ")")
                    };
                    F.src = D.file;
                    A.slider.unlock()
                },
                onFailure: function (D) {
                    dialogsMgr.errorShow(D.responseText)
                }
            },
            waitDialog: false
        });
        this.request.send()
    }
});
var framePicker = {
    rowLength_: 4,
    hide: function () {
        this.window.hide()
    },
    frames: [{
        label: "Ogólne",
        imgs: [{
            id: "frame#1",
            src: "images/frames/type1.gif",
            type: "type1",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#2",
            src: "images/frames/type2.gif",
            type: "type2",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#3",
            src: "images/frames/type3.gif",
            type: "type3",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#4",
            src: "images/frames/type4.gif",
            type: "type4",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#5",
            src: "images/frames/type5.gif",
            type: "type5",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#6",
            src: "images/frames/type6.png",
            type: "type6",
            width: "150px",
            height: "115px",
            subscription: false
        }]
    },{
        label: "Ogólne II",
        imgs: [{
            id: "frame#7",
            src: "images/frames/frame1.gif",
            type: "type7",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#8",
            src: "images/frames/frame2.gif",
            type: "type8",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#9",
            src: "images/frames/frame3.gif",
            type: "type9",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#10",
            src: "images/frames/frame4.gif",
            type: "type10",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#11",
            src: "images/frames/frame5.gif",
            type: "type11",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#12",
            src: "images/frames/frame6.gif",
            type: "type12",
            width: "150px",
            height: "115px",
            subscription: false
        }]
    },{
        label: "Dziecięce",
        imgs: [{
            id: "frame#13",
            src: "images/frames/kids/type13.gif",
            type: "type13",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#14",
            src: "images/frames/kids/type14.gif",
            type: "type14",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#15",
            src: "images/frames/kids/type15.gif",
            type: "type15",
            width: "150px",
            height: "160px",
            subscription: false
        },{
            id: "frame#16",
            src: "images/frames/kids/type16.gif",
            type: "type16",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#17",
            src: "images/frames/kids/type17.gif",
            type: "type17",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#18",
            src: "images/frames/kids/type18.gif",
            type: "type18",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#19",
            src: "images/frames/kids/type19.gif",
            type: "type19",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#20",
            src: "images/frames/kids/type20.gif",
            type: "type20",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#21",
            src: "images/frames/kids/type21.gif",
            type: "type21",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#22",
            src: "images/frames/kids/type22.gif",
            type: "type22",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#23",
            src: "images/frames/kids/type23.gif",
            type: "type23",
            width: "150px",
            height: "115px",
            subscription: false
        },{
            id: "frame#24",
            src: "images/frames/kids/type24.gif",
            type: "type24",
            width: "150px",
            height: "115px",
            subscription: false
        }]
    }],
    setFrame: function (E, A) {
        A = A || {};
        var D = {};
        D.type = E.type;
        if (A.text) {
            D.text = A.text
        }
        var C = this;
        var B = new Ajax({
            data: ef.createData("frame", D),
            callback: {
                onSuccess: function (F) {
                    C.hide();
                    loadMgr.run(JSON.parse(F.responseText))
                },
                onFailure: function (F) {
                    dialogsMgr.errorShow(F.responseText)
                }
            }
        });
        B.send()
    },
    init: function () {
        try {
            var B = this;

            function A() {
                if (B.selectedFrame) {
                    B.setFrame(B.selectedFrame)
                }
            }
            function D() {
                this.hide()
            }
            this.window = new YAHOO.widget.Dialog(configuration.CSS.IDs.framePicker, {
                visible: false,
                draggable: true,
                close: true,
                constraintoviewport: true,
                fixedcenter: true,
                modal: true,
                effect: {
                    effect: YAHOO.widget.ContainerEffect.FADE,
                    duration: 0.4
                }
            });
            this.window.showEvent.subscribe(function () {
                this.blurButtons()
            });
            this.window.setHeader(lang.framePicker.addFrame);
            this.getBody_();
            this.window.setBody("<div id='frame-picker-tab-view'></div>");
            this.window.cfg.queueProperty("buttons", [{
                text: lang.buttons.ok,
                handler: A,
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: D
            }]);
            this.window.render(document.body);
            this.tabView.appendTo("frame-picker-tab-view");
            this.renderBody_()
        } catch(C) {
            console.debug(C)
        }
    },
    editorText: "<p style='padding-bottom: 4px;'>" + lang.framePicker.editor + "</p>",
    renderTabBody_: function (A) {
        var D = this;
        var E = this.frames[A].imgs;
        for (var B = 0; B < E.length; B++) {
            var C = Dom.get(E[B].id);
            Dom.setStyle(C, "background", "url(" + E[B].src + ") no-repeat center center");
            Dom.setStyle(C, "width", E[B].width);
            Dom.setStyle(C, "height", E[B].height);
            (function (F) {
                Event.addListener(C, "dblclick", function () {
                    D.setFrame(F)
                });
                Event.addListener(C, "click", function () {
                    if (D.selectedFrame) {
                        Dom.setStyle(D.selectedFrame.id, "borderColor", "#F2F2F2")
                    }
                    Dom.setStyle(this, "border", "1px solid #808080");
                    D.selectedFrame = F
                })
            })(E[B])
        }
    },
    renderBody_: function () {
        for (var A = 0; A < this.frames.length; A++) {
            this.renderTabBody_(A)
        }
    },
    getTabBody_: function (C) {
        var E = this.frames[C].imgs;
        var B = 0;
        var A = "";
        for (var D = 0; D < E.length; D++) {
            A += "<span style='display: inline-block;'><div id='" + E[D].id + "' class='frame' name='" + E[D].type + "'></div></span>";
            B++;
            if (B == this.rowLength_) {
                A += "<br>";
                B = 0
            }
        }
        this.tabView.addTab(new YAHOO.widget.Tab({
            label: this.frames[C].label,
            content: A,
            active: (C === 0) ? true : false
        }))
    },
    getBody_: function () {
        this.tabView = new YAHOO.widget.TabView();
        for (var A = 0; A < this.frames.length; A++) {
            this.getTabBody_(A)
        }
    },
    blurAll_: function () {
        if (this.selectedFrame) {
            Dom.setStyle(this.selectedFrame.id, "borderColor", "#F2F2F2");
            this.selectedFrame = null
        }
    },
    selectedFrame: null,
    show: function () {
        try {
            ef.defaultView();
            if (!this.window) {
                this.init()
            }
            this.blurAll_();
            this.window.show()
        } catch(A) {
            ef.bugs.add(A, "js", "framePicker.show")
        }
    }
};
var photoMgr = {
    defaultSize: SETTINGS.dimensions,
    defaultWeight: SETTINGS.weight,
    photo: null,
    resetSize: false,
    commitWidth: null,
    commitHeight: null,
    contextmenuInit: function (A) {
        var B = this;
        if (this.contextmenu_) {
            this.contextmenuDestroy()
        }
        var C = [{
            text: lang.menu.efects.main,
            submenu: {
                id: "effects-context-menu",
                itemdata: [{
                    text: "<span id='sepia-icon' class='icon'></span>" + lang.menu.efects.sepia,
                    onclick: {
                        fn: ef.sendBridge,
                        obj: "sepia",
                        scope: ef
                    }
                },{
                    text: "<span id='negative-icon' class='icon'></span>" + lang.menu.efects.negative,
                    onclick: {
                        fn: ef.sendBridge,
                        scope: ef,
                        obj: "negative",
                        scope: ef
                    }
                },{
                    text: "<span id='charcoal-icon' class='icon'></span>" + lang.menu.efects.charcoal,
                    onclick: {
                        fn: ef.sendBridge,
                        scope: ef,
                        obj: "charcoal",
                        scope: ef
                    }
                },{
                    text: "<span id='oilpaint-icon' class='icon'></span>" + lang.menu.efects.oilpaint,
                    onclick: {
                        fn: ef.sendBridge,
                        scope: ef,
                        obj: "oilpaint",
                        scope: ef
                    }
                },{
                    text: "<span id='bw-icon' class='icon'></span>" + lang.menu.efects.bw,
                    onclick: {
                        fn: ef.sendBridge,
                        scope: ef,
                        obj: "bw",
                        scope: ef
                    }
                },{
                    text: "<span id='mirror-icon' class='icon'></span>" + lang.menu.efects.mirror,
                    onclick: {
                        fn: ef.sendBridge,
                        scope: ef,
                        obj: "mirror",
                        scope: ef
                    }
                }]
            }
        },{
            text: "<span id='back-icon' class='icon'></span>" + lang.menu.edit.back,
            onclick: {
                fn: historyMgr.back,
                scope: historyMgr
            }
        },{
            text: "<span id='forward-icon' class='icon'></span>" + lang.menu.edit.forward,
            onclick: {
                fn: historyMgr.forward,
                scope: historyMgr
            }
        }];
        this.contextmenu_ = new YAHOO.widget.ContextMenu("image-content-menu", {
            trigger: this.getImg(),
            itemdata: C,
            lazyload: false
        });
        this.contextmenu_.render(document.body);
        Event.addListener(this.getImg(), "click", function () {
            B.contextmenuHide()
        })
    },
    contextmenuDestroy: function () {
        this.contextmenu_.destroy();
        this.contextmenu_ = null
    },
    contextmenuHide: function () {
        this.contextmenu_.hide()
    },
    contextmenuConfigItem_: function (E, C, D) {
        var A = this.contextmenu_.getItems();
        if (YAHOO.lang.isArray(E)) {
            for (var B = 0; B < E.length; B++) {
                if (E.length - 1 === B) {
                    A[E[B]].cfg.setProperty(C, D)
                } else {
                    A = A[E[B]].cfg.getProperty("submenu").getItems()
                }
            }
        } else {
            throw new Error("photoMgr.contextmenuDisableItem: [ " + E + " ] first parameter must be an array.")
        }
    },
    contextmenuEnableItem: function (A) {
        this.contextmenuConfigItem_(A, "disabled", false)
    },
    contextmenuDisableItem: function (A) {
        this.contextmenuConfigItem_(A, "disabled", true)
    },
    setSignature: function () {
        photoSignature.show()
    },
    setFormat: function (A) {
        toolbar.setImgFormat(A)
    },
    getFormat: function () {
        return converter.getFormat()
    },
    getImg: function () {
        return this.photo
    },
    getDimensions: function () {
        return [this.width, this.height]
    },
    getImgContainer: function () {
        return this.photoContainer
    },
    init: function () {
        this.photo = Dom.get(configuration.CSS.IDs.img);
        this.photoContainer = Dom.get(configuration.CSS.IDs.photoContainer);
        this.weight = this.defaultWeight;
        this.width = this.defaultSize[0];
        this.commitWidth = this.width;
        this.height = this.defaultSize[1];
        this.commitHeight = this.height;
        if (Dom.getStyle(this.photo, "width") == "auto" || Dom.getStyle(this.photo, "height") == "auto") {
            Dom.setStyle(this.photo, "width", this.width + "px");
            Dom.setStyle(this.photo, "height", this.height + "px")
        }
        Dom.setStyle(this.photoContainer, "width", this.width + "px");
        Dom.setStyle(this.photoContainer, "height", this.height + "px");
        this.contextmenuInit()
    },
    getWeight: function () {
        return this.weight
    },
    setWeight: function (B, A) {
        A = A || {};
        if (this.weight != B) {
            this.weight = B;
            toolbar.setImgWeight(B)
        }
    },
    setHeight: function (A, B) {
        B = B || {};
        var C = this;
        this.height = A;
        if (B.anim) {
            ef.photo.resize.destroy();
            var D = new YAHOO.util.Anim(this.photo, {
                height: {
                    to: A
                }
            },
            0.4);
            D.onComplete.subscribe(function () {
                Dom.setStyle(C.photoContainer, "height", A + "px");
                ef.photo.resize.init()
            });
            D.animate()
        } else {
            Dom.setStyle(this.photo, "width", Dom.getStyle(this.photo, "width"));
            Dom.setStyle(this.photo, "height", A + "px")
        }
        toolbar.setImgHeight(A)
    },
    setWidth: function (B, A) {
        A = A || {};
        var C = this;
        this.width = B;
        if (A.anim) {
            ef.photo.resize.destroy();
            var D = new YAHOO.util.Anim(this.photo, {
                width: {
                    to: B
                }
            },
            0.4);
            D.onComplete.subscribe(function () {
                Dom.setStyle(C.photoContainer, "width", B + "px");
                ef.photo.resize.init()
            });
            D.animate()
        } else {
            Dom.setStyle(this.photo, "height", Dom.getStyle(this.photo, "height"));
            Dom.setStyle(this.photo, "width", B + "px")
        }
        toolbar.setImgWidth(B)
    },
    setDimensionsBySteps: function (D, F, B) {
        var C = this.getImg();
        var E = tools.toInt(Dom.getStyle(C, "width")) + D;
        var A = tools.toInt(Dom.getStyle(C, "height")) + F;
        this.setDimensions(E, A, B)
    },
    setDimensions: function (C, A, B) {
        B = B || {};
        var D = this;
        this.width = C;
        this.height = A;
        if (B.commit) {
            this.commitWidth = C;
            this.commitHeight = A;
            this.resetDimensions = false
        }
        if (B.anim) {
            ef.photo.resize.destroy();
            var E = new YAHOO.util.Anim(this.photo, {
                width: {
                    to: C
                },
                height: {
                    to: A
                }
            },
            0.4);
            E.onComplete.subscribe(function () {
                Dom.setStyle(D.photoContainer, "width", C + "px");
                Dom.setStyle(D.photoContainer, "height", A + "px");
                ef.photo.resize.init()
            });
            E.animate()
        } else {
            Dom.setStyle(this.photo, "width", C + "px");
            Dom.setStyle(this.photo, "height", A + "px");
            Dom.setStyle(this.photoContainer, "width", C + "px");
            Dom.setStyle(this.photoContainer, "height", A + "px")
        }
        if (B.resizeRefresh) {
            ef.photo.resize.init()
        }
        toolbar.setImg(C, A)
    },
    hasChanged: function () {
        if (this.commitWidth != this.width || this.commitHeight != this.height) {
            return [this.width, this.height]
        } else {
            return false
        }
    }
};
var zoomerMgr = {
    init_: function () {
        var B = this;

        function A() {
            this.request = new Ajax({
                data: ef.createData("zoom", B.zoomer.getZoomCoords()),
                callback: {
                    onSuccess: function (C) {
                        loadMgr.run(JSON.parse(C.responseText));
                        B.hide()
                    },
                    onFailure: function (C) {},
                    scope: B
                }
            });
            this.request.send()
        }
        this.window = new YAHOO.widget.Dialog(configuration.CSS.IDs.zoomer, {
            visible: false,
            fixedcenter: true,
            close: true,
            draggable: true,
            constraintoviewport: true,
            effect: {
                effect: YAHOO.widget.ContainerEffect.FADE,
                duration: 0.4
            },
            buttons: [{
                text: lang.buttons.cut,
                handler: A,
                isDefault: true
            },{
                text: lang.buttons.cancel,
                handler: function () {
                    B.hide()
                }
            }]
        });
        this.window.setHeader(lang.menu.tools.zoomer);
        this.window.showEvent.subscribe(function () {
            this.blurButtons()
        });
        this.window.hideEvent.subscribe(function () {
            B.zoomer.destroy();
            ef.photo.resize.init()
        });
        this.setBody();
        this.window.render(document.body)
    },
    setBody: function () {
        this.window.setBody("<div id='zoomer-miniature'><img src=' " + photoMgr.getImg().src + " '></div>")
    },
    show: function () {
        try {
            var A = this;
            if (queue.getAll().length > 0) {
                this.request = new Ajax({
                    data: ef.createData("resize", {}),
                    callback: {
                        onSuccess: function (C) {
                            loadMgr.run(JSON.parse(C.responseText), {
                                resize: false
                            });
                            A.show()
                        },
                        onFailure: function (C) {},
                        scope: this
                    }
                });
                this.request.send()
            } else {
                if (!this.window) {
                    this.init_()
                } else {
                    this.setBody()
                }
                ef.defaultView();
                ef.photo.resize.destroy();
                this.zoomer = new Zoomer(photoMgr.getImg(), configuration.CSS.IDs.zoomerMiniature, {
                    zoomSize: 200
                });
                this.window.show();
                toolbar.disableDimensionsEdit()
            }
        } catch(B) {
            console.debug(B, "js", "zoomerMgr.show")
        }
    },
    hide: function () {
        if (this.window) {
            this.window.hide();
            toolbar.enableDimensionsEdit()
        }
    }
};
var Zoomer = function (B, C, A) {
    if (B && C) {
        this.img = B;
        this.init(B, C, A)
    }
};
Zoomer.prototype = {
    getZoomCoords: function () {
        var A = this.crop.getCropCoords();
        return {
            zoomWidth: this.zoomSize,
            zoomHeight: this.zoomSize,
            top: A.top + 1,
            left: A.left + 1,
            croppWidth: A.width,
            croppHeight: A.height
        }
    },
    zoomSize: null,
    zoomLevel: null,
    zoomRefresh_: function () {
        var A = this.crop.getCropCoords();
        Dom.setStyle(this.zoom.firstChild, "top", "-" + this.zoomLevel * A.top + "px");
        Dom.setStyle(this.zoom.firstChild, "left", "-" + this.zoomLevel * A.left + "px");
        Dom.setStyle(this.zoom.firstChild, "width", this.basicWidth * this.zoomLevel + "px");
        Dom.setStyle(this.zoom.firstChild, "height", this.basicHeight * this.zoomLevel + "px")
    },
    destroy: function () {
        this.crop.destroy();
        this.resize.destroy()
    },
    init: function (F, G, A) {
        var E = this;
        this.basicWidth = tools.toInt(Dom.getStyle(this.img, "width"));
        this.basicHeight = tools.toInt(Dom.getStyle(this.img, "height"));
        this.zoom = Dom.get(G);
        var C = Math.round(this.basicWidth * 0.5);
        this.zoomSize = A.zoomSize;
        this.zoomLevel = A.zoomSize / C;
        Dom.setStyle(this.zoom.firstChild, "position", "absolute");
        Dom.setStyle(this.zoom, "overflow", "hidden");
        Dom.setStyle(this.zoom, "position", "relative");
        Dom.setStyle(this.zoom, "width", A.zoomSize + "px");
        Dom.setStyle(this.zoom, "height", A.zoomSize + "px");
        Dom.setStyle(this.zoom, "width", A.zoomSize + "px");
        Dom.setStyle(this.zoom, "height", A.zoomSize + "px");
        this.resize = new YAHOO.util.Resize(this.zoom, {
            handles: ["br"],
            knobHandles: true,
            ratio: true,
            status: true
        });
        var D = Dom.getElementsByClassName("yui-resize-handle-br", "div", this.resize.getWrapEl());
        if (D.length != 1) {
            throw "Too many 'br' knobs"
        } else {
            Dom.setStyle(D[0], "bottom", "0px");
            Dom.setStyle(D[0], "right", "0px")
        }
        this.resize.subscribe("resize", function (I) {
            var H = E.crop.getCropCoords();
            E.zoomSize = I.width;
            E.zoomLevel = I.width / H.width;
            E.zoomRefresh_()
        });
        this.crop = new YAHOO.widget.ImageCropper(this.img, {
            initialXY: [0, 0],
            initWidth: C,
            initHeight: C,
            keyTick: 5,
            shiftKeyTick: 50,
            minWidth: 10,
            minHeight: 10,
            handles: ["br"],
            ratio: true
        });
        var B = this.crop.getResizeMaskEl().nextSibling;
        Dom.setStyle(B, "bottom", "0px");
        Dom.setStyle(B, "right", "0px");
        this.zoomRefresh_();
        this.crop.on("moveEvent", function () {
            E.zoomRefresh_()
        });
        this.crop.on("resizeEvent", function (H) {
            E.zoomLevel = E.zoomSize / H[0].width;
            E.zoomRefresh_()
        })
    }
};
var redEyeMgr = {
    send_: function () {
        try {
            var C = this;
            coords = this.cropp.getCropCoords();
            var A = {
                x: coords.left + 1,
                y: coords.top + 1,
                w: coords.width,
                h: coords.height
            };
            var B = new Ajax({
                data: ef.createData("redEye", A),
                callback: {
                    onSuccess: function (E) {
                        C.hide();
                        ef.photo.resize.mouseWheelEnable();
                        loadMgr.run(JSON.parse(E.responseText))
                    },
                    onFailure: function (E) {
                        dialogsMgr.errorShow(E.responseText)
                    }
                }
            });
            B.send()
        } catch(D) {
            console.debug(D)
        }
    },
    context_menu_init: function () {
        var C = [{
            text: "Usuń czerwone oczy",
            onclick: {
                fn: this.send_,
                scope: this
            }
        }];
        var B = this.cropp.getResizeEl();
        this.context_menu = new YAHOO.widget.ContextMenu("red-eye-context-menu", {
            trigger: B,
            itemdata: C,
            lazyload: true
        });
        Event.on(B, "click", function () {
            this.context_menu.hide()
        },
        this, true);
        var A = this.cropp.getWrapEl();
        Event.on(A, "click", function () {
            this.context_menu.hide()
        },
        this, true)
    },
    hide: function () {
        if (this.cropp) {
            this.cropp.destroy()
        }
        var A = this;
        toolbar.off(function () {
            Dom.setStyle("toolbar-red-eye", "display", "none");
            toolbar.showCoords();
            toolbar.on(function () {
                tooltipMgr.hide();
                ef.photo.resize.init()
            })
        })
    },
    croppInit_: function () {
        var C = this;
        this.ok_button = new YAHOO.widget.Button("toolbar-red-eye-ok");
        this.ok_button.subscribe("click", this.send_, this, true);
        this.cancel_button = new YAHOO.widget.Button("toolbar-red-eye-cancel");
        this.cancel_button.subscribe("click", this.hide, this, true);
        toolbar.off(function () {
            toolbar.hideCoords();
            Dom.setStyle("toolbar-red-eye", "display", "block");
            toolbar.on(function () {
                toolbar.showBackButton({
                    scope: ef,
                    fn: ef.defaultView
                })
            })
        });
        ef.photo.resize.destroy();
        ef.photo.resize.mouseWheelDisable();
        this.img = photoMgr.getImg();
        this.cropp = new YAHOO.widget.ImageCropper(this.img, {
            keyTick: 5,
            shiftKeyTick: 50,
            minWidth: 20,
            minHeight: 20,
            handles: "all",
            autoRatio: true
        });
        var B = photoMgr.getDimensions();
        var A = this.cropp.getResizeObject();
        A.set("width", Math.round(B[0] * 0.6), false);
        A.set("height", Math.round(B[1] * 0.6), false);
        this.cropp._syncBackgroundPosition();
        Event.addListener(this.cropp.getResizeEl(), "dblclick", function () {
            C.send_()
        });
        this.context_menu_init();
        if (YAHOO.env.ua.opera === 0) {
            tooltipMgr.show(lang.tip.red_eye_ext)
        } else {
            tooltipMgr.show(lang.tip.red_eye)
        }
    },
    init_: function () {
        this.croppInit_()
    },
    show: function () {
        try {
            var B = this;
            if (queue.getAll().length > 0) {
                var A = new Ajax({
                    data: ef.createData("resize"),
                    callback: {
                        onSuccess: function (D) {
                            loadMgr.run(JSON.parse(D.responseText), {
                                onSuccess: function () {
                                    B.show()
                                },
                                scope: B
                            })
                        },
                        onFailure: function (D) {
                            dialogsMgr.errorShow(D.responseText)
                        }
                    }
                });
                A.send()
            } else {
                this.init_()
            }
        } catch(C) {
            ef.bugs.add(C, "js", "redEyeMgr.show")
        }
    }
};
var editor = {
    get: function () {
        return this.editor
    },
    init: function () {
        this.editor = Dom.get(configuration.CSS.IDs.editor);
        this.topRuler = Dom.get(configuration.CSS.IDs.topRuler);
        this.leftRuler = Dom.get(configuration.CSS.IDs.leftRuler);
        var D = Dom.getClientWidth();
        var A = Dom.getClientHeight();
        var B = tools.toInt(Dom.getStyle(this.editor, "left"));
        var C = tools.toInt(Dom.getStyle(this.editor, "top"));
        Dom.setStyle(this.topRuler, "width", D - B - 149 + "px");
        Dom.setStyle(this.leftRuler, "height", A - C - 38 + "px");
        this.editorWidth_ = D - B - 151;
        Dom.setStyle(this.editor, "width", this.editorWidth_ + "px");
        this.editorHeight_ = A - C - 40;
        Dom.setStyle(this.editor, "height", A - C - 40 + "px");
        Dom.setStyle("advertisement-right", "height", A - C - 40 + "px")
    },
    moveToLeft: function () {
        this.editorWidth_ = this.editorWidth_ + 134;
        Dom.setStyle(this.editor, "width", this.editorWidth_ + "px");
        Dom.setStyle(this.editor, "left", "40px");
        Dom.setStyle(this.leftRuler, "left", "25px");
        Dom.setStyle(this.topRuler, "left", "39px");
        Dom.setStyle(this.topRuler, "width", this.editorWidth_ + 2 + "px");
        ef.photo.dd.init();
        ef.photo.resize.init()
    },
    moveToRight: function () {
        this.editorWidth_ = this.editorWidth_ - 134;
        Dom.setStyle(this.editor, "width", this.editorWidth_ + "px");
        Dom.setStyle(this.editor, "left", "174px");
        Dom.setStyle(this.leftRuler, "left", "159px");
        Dom.setStyle(this.topRuler, "left", "173px");
        Dom.setStyle(this.topRuler, "width", this.editorWidth_ + 2 + "px");
        ef.photo.dd.init();
        ef.photo.resize.init()
    },
    getWidth: function () {
        return this.editorWidth_
    },
    getHeight: function () {
        return this.editorHeight_
    }
};
var loadMgr = {
    setPHPVar_: function (A, C) {
        var B = YAHOO.util.Cookie.set(A, C, {
            path: "/"
        })
    },
    onLoad_: function (B, A) {
        Dom.setStyle(B, "width", "");
        Dom.setStyle(B, "height", "");
        photoMgr.setDimensions(B.offsetWidth, B.offsetHeight, {
            anim: false,
            commit: true
        });
        photoMgr.setWeight(A.size);
        ef.photo.dd.init();
        if (! (A.resize === false)) {
            ef.photo.resize.init()
        }
        historyMgr.add({
            src: B.src,
            width: tools.toInt(Dom.getStyle(B, "width")),
            height: tools.toInt(Dom.getStyle(B, "height")),
            weight: photoMgr.getWeight(),
            reset: (A.init === true) ? true : false
        });
        converter.setFormat(A.file.substring(A.file.length - 3));
        if (A.cropper) {
            historyMgr.modifyWeight(A.size)
        }
        if (A.onSuccess) {
            A.onSuccess.call(A.scope)
        }
        ef.dialogs.wait.hide();
        tooltipMgr.show(lang.tip.save)
    },
    load_: function (E, A) {
        for (var C in A) {
            if (A.hasOwnProperty(C)) {
                E[C] = A[C]
            }
        }
        if (E.error) {
            dialogsMgr.errorShow(E.error)
        } else {
            var D = this;
            var B = photoMgr.getImg();
            B.onload = function () {
                D.onLoad_(this, E)
            };
            this.old_src = B.src;
            B.src = E.file
        }
    },
    abort: function () {
        var A = photoMgr.getImg();
        A.onload = function () {};
        if (this.old_src) {
            A.src = this.old_src;
            this.old_src = null
        }
    },
    run: function (C, A) {
        try {
            if (C.hasOwnProperty("error")) {
                ef.dialogs.wait.hide();
                dialogsMgr.errorShow(C.error);
                return false
            } else {
                if (A && A.init) {
                    ef.dialogs.wait.show()
                } else {
                    ef.dialogs.wait.show({
                        abort: this.abort,
                        scope: this
                    })
                }
                if (C.session_id) {
                    this.setPHPVar_("PHPSESSID", C.session_id)
                }
                this.load_(C, A);
                return true
            }
        } catch(B) {
            ef.bugs.add(B, "js", "loadMgr.run")
        }
    }
};
ef.photo = {};
ef.photo.resize = function () {
    var B;
    var A = function (C) {
        function D(I) {
            if (toolbar.keepProportionsIsChecked()) {
                var H = photoMgr.getDimensions();
                var F = 20;
                var G = 20 * (H[1] / H[0])
            } else {
                var F = 20;
                var G = 20
            }
            if (I > 0) {
                photoMgr.setDimensionsBySteps(F, G, {
                    anim: false
                })
            } else {
                if (H[0] - F < 20 || H[1] - G < 20) {
                    return
                } else {
                    photoMgr.setDimensionsBySteps(-F, -G, {
                        anim: false
                    })
                }
            }
            queue.add(new Command("resize", {}));
            var H = photoMgr.getDimensions();
            historyMgr.add({
                cmd: "resize",
                src: photoMgr.getImg().src,
                width: H[0],
                height: H[1],
                weight: photoMgr.getWeight()
            })
        }
        var E = 0;
        if (!C) {
            C = window.event
        }
        if (C.wheelDelta) {
            E = C.wheelDelta / 120
        } else {
            if (C.detail) {
                E = -C.detail / 3
            }
        }
        if (E) {
            D(E)
        }
        if (C.preventDefault) {
            C.preventDefault()
        }
        C.returnValue = false
    };
    return {
        destroy: function () {
            if (B) {
                B.destroy();
                B = null
            }
        },
        init: function () {
            if (B) {
                this.destroy()
            }
            var C = {
                handles: "all",
                knobHandles: true,
                autoRatio: true,
                status: true,
                minX: Dom.getStyle(editor.get(), "left").toInt(),
                minY: Dom.getStyle(editor.get(), "top").toInt(),
                minWidth: 20,
                minHeight: 20
            };
            if (!toolbar || toolbar.keepProportionsIsChecked()) {
                C.ratio = true
            } else {
                C.autoRatio = true
            }
            B = new YAHOO.util.Resize(configuration.CSS.IDs.photoContainer, C);
            img = photoMgr.getImg();
            B.subscribe("startResize", function (D) {
                this.startWidth = Dom.getStyle(img, "width");
                this.startHeight = Dom.getStyle(img, "height")
            });
            B.subscribe("endResize", function (D) {
                queue.add(new Command("resize", {}));
                historyMgr.add({
                    cmd: "resize",
                    src: img.src,
                    width: D.width,
                    height: D.height,
                    weight: photoMgr.getWeight()
                });
                photoMgr.setDimensions(D.width, D.height, {
                    resizeRefresh: true
                })
            });
            B.subscribe("resize", function (D) {
                if (D.width && D.height) {
                    photoMgr.setDimensions(D.width, D.height, {})
                } else {
                    if (D.width) {
                        photoMgr.setWidth(D.width, {})
                    }
                    if (D.height) {
                        photoMgr.setHeight(D.height, {})
                    }
                }
            });
            this.mouseWheelEnable()
        },
        mouseWheelDisable: function () {
            if (window.removeEventListener) {
                window.removeEventListener("DOMMouseScroll", A, false)
            }
            try {
                window.onmousewheel = null
            } catch(C) {
                ef.bugs.add(C, "js", "ef.photo.resize.mouseWheelDisable: window.onmousewheel")
            }
            try {
                document.onmousewheel = null
            } catch(C) {}
        },
        mouseWheelEnable: function () {
            if (window.addEventListener) {
                window.addEventListener("DOMMouseScroll", A, false)
            }
            window.onmousewheel = document.onmousewheel = A
        }
    }
}();

function Command(B, A) {
    this.name = B;
    this.cfg = A
}
Command.prototype.getName = function () {
    return this.name
};
var queue = function () {
    var A = [];
    return {
        add: function (B) {
            A.push(B)
        },
        clear: function () {
            A = []
        },
        getAll: function () {
            var B = A;
            this.clear();
            return B
        }
    }
}();
ef.photo.dd = function () {
    var A;
    return {
        destroy: function () {},
        init: function () {
            A = new YAHOO.util.DD(configuration.CSS.IDs.photoContainer);
            var D = Dom.getXY(photoMgr.getImg());
            var B = D[0];
            var F = D[1];
            var C = F - Dom.getStyle(configuration.CSS.IDs.editor, "top").toInt();
            var E = B - Dom.getStyle(configuration.CSS.IDs.editor, "left").toInt();
            A.setYConstraint(C, "");
            A.setXConstraint(E, "")
        }
    }
}();
var tooltipMgr = {
    tooltipDialog_: undefined,
    tooltipEl_: undefined,
    tooltipTimeout_: undefined,
    tooltipTime_: 1000 * 20,
    smallDialog_: undefined,
    smallEl_: undefined,
    smallTimeout_: undefined,
    smallTime_: 1000 * 10,
    smallInit_: function () {
        this.smallDialog_ = new YAHOO.widget.Overlay(configuration.CSS.IDs.sendSuccessDialog, {
            visible: false
        });
        this.smallDialog_.setBody(" ");
        this.smallDialog_.render(document.body);
        this.smallEl_ = Dom.get(configuration.CSS.IDs.sendSuccessDialog)
    },
    resetSmallTimeout_: function (B) {
        if (this.smallTimeout_) {
            clearTimeout(this.smallTimeout_)
        }
        var A = this;
        this.smallTimeout_ = setTimeout(function () {
            A.smallHide()
        },
        B || this.smallTime_)
    },
    smallShow: function (B, C) {
        if (!this.smallDialog_) {
            this.smallInit_()
        }
        this.smallDialog_.setBody(B);
        var A = Math.round((Dom.getViewportWidth() - tools.toInt(Dom.getStyle(this.smallEl_, "width"))) / 2);
        this.smallDialog_.moveTo(A, 1);
        this.smallDialog_.show();
        this.resetSmallTimeout_(C)
    },
    smallHide: function () {
        if (!this.smallDialog_) {
            return
        }
        this.smallDialog_.hide();
        clearTimeout(this.smallTimeout_)
    },
    init_: function () {
        var A = this;
        this.tooltipEl_ = Dom.get(configuration.CSS.IDs.tooltip);
        this.tooltipDialog_ = new YAHOO.widget.Overlay(this.tooltipEl_, {
            visible: false,
            width: "198px"
        });
        Dom.setStyle(this.tooltipEl_, "display", "block");
        this.tooltipDialog_.render();
        this.tooltipDialog_.moveTo(Math.round(Dom.getViewportWidth() - 360), 20);
        this.tooltipCloseButton = Dom.get(configuration.CSS.IDs.tooltipCloseButton);
        this.tooltipCloseButton.title = lang.tooltip.hide;
        Event.addListener(this.tooltipCloseButton, "click", function () {
            A.hide()
        });
        this.tooltipNextButton_ = Dom.get(configuration.CSS.IDs.tooltipNextButton);
        this.tooltipNextButton_.title = lang.tooltip.nextTip;
        Event.addListener(this.tooltipNextButton_, "click", function () {
            A.nextTip()
        });
        this.tooltipPreviousButton_ = Dom.get(configuration.CSS.IDs.tooltipPreviousButton);
        this.tooltipPreviousButton_.title = lang.tooltip.prevTip;
        Event.addListener(this.tooltipPreviousButton_, "click", function () {
            A.previousTip()
        });
        this.navButtonsHide_()
    },
    navButtonsShow_: function () {
        Dom.setStyle(this.tooltipPreviousButton_, "display", "block");
        Dom.setStyle(this.tooltipNextButton_, "display", "block")
    },
    navButtonsHide_: function () {
        Dom.setStyle(this.tooltipPreviousButton_, "display", "none");
        Dom.setStyle(this.tooltipNextButton_, "display", "none")
    },
    tipsIndex_: -1,
    previousTip: function (A) {
        if (A) {
            this.tipUnblock_()
        }
        if (this.tipIsBlocked_()) {
            return
        }
        if (this.tipsIndex_ - 1 < 0) {
            this.tipsIndex_ = lang.randomTips.length
        }
        this.show(lang.randomTips[--this.tipsIndex_], this.tooltipTime_, true)
    },
    nextTip: function (A) {
        if (A) {
            this.tipUnblock_()
        }
        if (this.tipIsBlocked_()) {
            return
        }
        if (this.tipsIndex_ + 1 >= lang.randomTips.length) {
            this.tipsIndex_ = -1
        }
        this.show(lang.randomTips[++this.tipsIndex_], this.tooltipTime_, true)
    },
    resetTimeout_: function (B) {
        if (this.tooltipTimeout_) {
            clearTimeout(this.tooltipTimeout_)
        }
        if (B !== 0) {
            var A = this;
            this.tooltipTimeout_ = setTimeout(function () {
                A.hide();
                A.nextTip()
            },
            B || this.tooltipTime_)
        }
    },
    tipMode_: false,
    show: function (A, C, B) {
        if (!this.tooltipDialog_) {
            this.init_()
        }
        this.tooltipDialog_.setBody(A);
        if (B) {
            this.tipMode_ = true;
            this.navButtonsShow_();
            this.tooltipCloseButton.title = lang.tooltip.hideTips
        } else {
            this.tipMode_ = false;
            this.navButtonsHide_();
            this.tooltipCloseButton.title = lang.tooltip.hide
        }
        this.tooltipDialog_.show();
        this.resetTimeout_(C)
    },
    tipBlockedFlag_: false,
    tipIsBlocked_: function () {
        return this.tipBlockedFlag_
    },
    tipBlock_: function () {
        this.tipBlockedFlag_ = true
    },
    tipUnblock_: function () {
        this.tipBlockedFlag_ = false
    },
    hide: function () {
        if (!this.tooltipDialog_) {
            return
        }
        this.tooltipDialog_.hide();
        clearTimeout(this.tooltipTimeout_);
        if (this.tipMode_) {
            this.tipBlock_()
        }
    }
};
ef.register = function () {
    var A = [];
    return {
        add: function (B, C) {
            A.push({
                name: B,
                parameters: C
            })
        },
        get: function () {
            return A
        }
    }
}();

