﻿// JScript File

var ATOLPopup = new Class({

    initialize: function(_element, _popup, _closeEl) {

        this.element = _element;
        if (this.element == null) {
            return;
        }
        this.popup = _popup;
        this.closeEl = _closeEl;
        this.element.addEvent('click', this.show.bind(this));
        this.closeEl.addEvent('click', this.close.bind(this));
    },

    show: function(e) {
        e = new Event(e).stop();
        if ($('lbOverlay') == null) {
            this.backgroundDiv = new Element('div', { 'id': 'lbOverlay' }).injectInside(document.body);
        }
        else {
            this.backgroundDiv = $('lbOverlay');
        }
        $('lbOverlay').addClass('background');
        this.backgroundDiv.setStyle('opacity', 0);
        var exampleFx = new Fx.Tween(this.backgroundDiv);
        exampleFx.start('opacity', 0, 0.8);


        this.popup.style.display = "block";
        this.popup.style.left = (window.getSize().x / 2) - (this.popup.getSize().x / 2) + "px";
    },

    close: function(e) {
        e = new Event(e).stop();
        this.backgroundDiv.setStyle('opacity', 0);
        this.popup.style.display = 'none';
    }




});
