
var BSModalAlert = new Class ({
options: {
height:
40,
width:
80,
paddingLeft:
0,
paddingRight:
0,
paddingTop:
0,
paddingBottom:
0
},
initialize: function(options) {
this.setOptions(options);

this.eventPosition = this.position.bind(this);
this.overlay = new Element('div').setProperty('id', 'bs_ma_overlay').injectInside(document.body);

this.center = new Element('div').setProperty('id', 'bs_ma_center').setStyles({display: 'none'}).injectInside(document.body);

this.contents = new Element('div').setProperty('id', 'bs_ma_contents').injectInside(this.center);
this.fx = {
overlay: this.overlay.effect('opacity', { duration: 200 }).set(0),
center: this.center.effect('opacity', { duration: 200})
};
},
open: function(html) {
this.position();
this.setup(true);

this.center.setStyles({display: '', visibility: 'hidden'});
this.contents.setHTML(html);
this.top = Window.getScrollTop();
if (this.contents.offsetHeight < Window.getHeight()) {
this.top += ((Window.getHeight() - this.contents.offsetHeight) / 2);
}
this.center.setStyles({
width: this.contents.offsetWidth + 'px',
height: this.contents.offsetHeight + 'px',
paddingLeft: this.options.paddingLeft + 'px',
paddingRight: this.options.paddingRight + 'px',
paddingTop: this.options.paddingTop + 'px',
paddingBottom: this.options.paddingBottom + 'px',
marginLeft: -(this.contents.offsetWidth + this.options.paddingLeft + this.options.paddingRight)/2,
top: this.top + 'px'
});
this.contents.setStyles({visibility: 'visible'});
this.fx.center.custom(1);
this.fx.overlay.custom(0.6);
return false;
},
position: function() {
this.overlay.setStyles({top: Window.getScrollTop()+'px', height: Window.getHeight()+'px'});
},
setup: function(open) {
var elements = $A($$('object'));
elements.extend($$(window.ie6 ? 'select' : 'embed'));
elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
var fn = open ? 'addEvent' : 'removeEvent';
window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
},
close: function() {
this.fx.overlay.clearTimer();
this.center.style.display = 'none';
this.center.style.width = 'auto';
this.fx.overlay.chain(this.setup.pass(false, this)).custom(0);
return false;
}
});
BSModalAlert.implement(new Options(), new Events());
window.addEvent (window.ie ? 'load' : 'domready', function() { BSModalAlert = new BSModalAlert(); });
