window.addEvent('domready',function(){
    var tickerScroller = {
        pos:0,
        speed:1,
        stocks:$('market-ticker').getChildren(),
        startX:$('market-ticker').getSize()['x'],
        endX:-($('market-ticker').getLast().getCoordinates()['right']-$('market-ticker').getCoordinates()['left']),
        start:function(){
            this.run.bind(this).periodical(20);
            this.stocks.setStyle('position','relative');
            this.pos=this.startX;
        },
        reset:function(){
            this.pos=this.startX;
        },
        run:function(){
            if(this.pos<this.endX){
                this.reset();
            }
            this.stocks.setStyle('left',this.pos);
            this.pos-=this.speed;
        }
    }
    tickerScroller.start();
    tickerScroller.stocks.each(function(ele){
        ele.getFirst().addEvent('click',function(){
            var background = new Element('div',{
                'class':'lightbox-background'
            });
            var frame = new IFrame({
                src:this.get('href'),
                'class':'lightbox-center',
                styles:{
                    'margin-top':'-195px',
                    'margin-left':'-250px',
                    width:'500px',
                    height:'390px'
                }
            });
            document.body.appendChild(frame);
            document.body.appendChild(background);            
            var obj = {
                background:background,
                frame:frame
            }
            function close(){
                this.background.dispose();
                this.frame.dispose();
            }
            background.addEvent('click',close.bind(obj));
            return false;
        }.bind(ele.getFirst()));
    });
});
