﻿//Globals
var blackBackground, whiteBox, boxTitle, closeLink;

//Renault Light Box Class
var RenaultLightBox = new Class({

    //implements
    Implements: [Options],

    //options 
    options: {
        dataContainer: null, width: 650, cssWidth: 0
    },

    //initialization 
    initialize: function(options) {
        //set options
        this.setOptions(options);
    },

    //show box
    showBox: function(options) {
        this.setOptions(options);
        this.createElements();
    },

    //create elements
    createElements: function() {
        //Create main box elements
        blackBackground = new Element('div', { id: 'blackBackground' });
        whiteBox = new Element('div', { id: 'whiteBox' });

        whiteBox.set('html', $(this.options.dataContainer).get('html'));

        closeLink = new Element('a', { id: 'closeLink', text: 'Close [x]', href: '#' });
        //Inject elements
        closeLink.inject(whiteBox, 'top');
        whiteBox.inject($('aspnetForm'), 'top');
        blackBackground.inject($('aspnetForm'), 'top');
        //Positioning fixes
        blackBackground.setStyle('height', window.getScrollSize().y);
        whiteBox.setStyle('top', window.getScroll().y + 100);
        whiteBox.setStyle('left', (window.getSize().x - this.options.width) / 2);
        whiteBox.setStyle('width', this.options.cssWidth)
        //Hook up close button
        closeLink.addEvent('click', function(e) {
            blackBackground.dispose();
            whiteBox.dispose();
            e.stop();
        });
    } .protect()


});

