/* Clientcide Copyright (c) 2006-2009, http://www.clientcide.com/wiki/cnet-libraries#license*/

//Contents: Fx.Marquee

//This lib: http://www.clientcide.com/js/build.php?excludeLibs[]=mootools-core&excludeLibs[]=mootools-more&require[]=Fx.Marquee&compression=jsmin


Fx.Marquee = new Class({ Extends: Fx.Morph, options: { mode: 'horizontal', message: '', revert: true, delay: 5000, cssClass: 'msg', showEffect: { opacity: 1 }, hideEffect: { opacity: 0 }, revertEffect: { opacity: [0, 1] }, currentMessage: null }, initialize: function(container, options) { container = document.id(container); var msg = this.options.currentMessage || (container.getChildren().length == 1) ? container.getFirst() : ''; var wrapper = new Element('div', { styles: { position: 'relative' }, 'class': 'fxMarqueeWrapper' }).inject(container); this.parent(wrapper, options); this.current = this.wrapMessage(msg); }, wrapMessage: function(msg) {
    if (document.id(msg) && document.id(msg).hasClass('fxMarquee')) { var wrapper = document.id(msg); } else { var wrapper = new Element('span', { 'class': 'fxMarquee', styles: { position: 'relative'} }); if (document.id(msg)) wrapper.grab(document.id(msg)); else if ($type(msg) == "string") wrapper.set('html', msg); }
    return wrapper.inject(this.element);
}, announce: function(options) { this.setOptions(options).showMessage(); return this; }, showMessage: function(reverting) {
    (function() {
        var chain = this.$chain ? $A(this.$chain) : []; this.clearChain(); this.element = document.id(this.element); this.current = document.id(this.current); this.message = document.id(this.message); this.start(this.options.hideEffect).chain(function() {
            if (reverting) { this.message.hide(); if (this.current) this.current.show(); } else { if (this.message) this.message.dispose(); this.message = this.wrapMessage(this.options.message); if (this.current) this.current.hide(); }
            this.start((reverting) ? this.options.revertEffect : this.options.showEffect).chain(function() { if (this.$chain) this.$chain.combine(chain); else this.$chain = chain; this.fireEvent((reverting) ? 'onRevert' : 'onMessage'); if (!reverting && this.options.revert) this.showMessage(true); else this.callChain.delay(this.options.delay, this); } .bind(this));
        } .bind(this));
    }).delay((reverting) ? this.options.delay : 10, this); return this;
}
});