function wwe_ticker_v2 ( options ) {

    var me = this;

    if ( options == null )
       options = new Array();

    this.options = {
      'container'   :   options[ 'container'   ],
      'displayMode' : ( options[ 'displayMode' ]        || 'default' ),
      'interval'    : ( options[ 'interval'    ] * 1000 ||  5000     ),
      'animSpeed'   : ( options[ 'animSpeed'   ] * 1000 ||  2000     )
    }

    this.initDone = false;

    this.init = function(){

        if( ! this.options.container ){
            return false;
        }

        if( ! this.items || this.items.length < 1 ){
            return false;
        }

        this.initControlPanel();

        this.content_container = $( '#' + this.options.container + ' .ticker_content_container' );

        this.currItem  = 0;

        this.initDone = true;
    }


    this.play = function() {

        if ( ! this.initDone )
          this.init();

        if ( ! this.running ) {
            // falls nach einem stop wieder aufgerufen
            this.content_container.removeClass( 'stopped' );
            var $content = $( 'ul', this.content_container );
            $( 'li', $content ).remove();
        }

        this.firstRun = true;
        this.running  = true;

        // :)
        this.controlControls();

        // lets go
        this.render();
        if ( !this.timer )
          this.timer = setInterval( function(){ me.render() }, this.options.interval );

    }


    // haelt die aktuelle meldung an
    this.pause = function() {

        if( this.options.displayMode == 'ti_display_default' ) {
            $( '#' + this.options.container + ' .layer' ).remove();
        }

        clearInterval( this.timer );
        this.timer = null;
        this.running = false;
        this.controlControls();
    }


    // stoppt den ticker und zeigt alle meldungen an
    this.stop = function (){

        this.pause();

        var $content = $( 'ul', this.content_container );

        // cleanup
        $( 'li', $content ).remove();

        // alle anzeigen
        for( var i = 0; i< this.items.length; i++ ) {
            $content.append( this.items[i] );
            $( this.items[i] ).css( 'display', 'list-item' );
        }

        this.content_container.addClass( 'stopped' );
    }


    this.render = function () {

        switch ( this.options.displayMode ) {

            case 'ti_display_default' :
                this.renderDefault();
                break;
            case 'ti_display_roll_vertical':
                this.renderRollVertical();
                break;
            case 'ti_display_fadeinout':
                this.renderFadeInOut();
                break;
            default:
                this.renderDefault();
                break;
        }
    }


    this.renderDefault = function () {

        var cc = this.content_container;

        var $layer = $('<div class="layer"></div>');

        $layer.css({
                     'width'           :  cc.css( 'width' ),
                     'height'          :  cc.css( 'height'),
                     'background-color':  cc.css( 'background-color' ),
                     'position'        : 'absolute',
                     'top'             : '0px',
                     'right'           : '0px'
        });

        cc.append( $layer );

        var $content = $( '#' + this.options.container + ' .ticker_content ul' );

        var next = this.getNextContentItem();
        $content.html(next);

        $layer.animate( {width: '0px'}, this.options.animSpeed, function(){ $layer.remove(); } );
    }


    // vertikales rollen
    this.renderRollVertical = function() {

        var $content = $( '#' + this.options.container + ' .ticker_content ul' );

        if ( this.firstRun ) {
            next = this.getNextContentItem();
            $( next ).css( 'top','0' );
            $content.html( next );
        }
        else {

            var next = this.getNextContentItem();

            $content.append(next);

            if( $( 'li', $content ).length > 2)
              $( $( 'li', $content )[0] ).remove();

            $( 'li', $content ).each(function(){
                  $(this).css( 'top', '0px' );
            });

            $( 'li', $content ).each(function(){
                $(this).animate( {top: '-=' + $(this).css('height')}, me.options.animSpeed );
            });
        }

        this.firstRun = false;
    }


    // fadein / fadeout
    this.renderFadeInOut = function() {

        var $content = $( '#' + this.options.container + ' .ticker_content ul' );

        if ( this.firstRun )
          $content.html( this.getNextContentItem() );

        else {
            $('li',$content).fadeOut( me.options.animSpeed, function() {
                $content.html( me.getNextContentItem() );
                $('li', $content).fadeIn( me.options.animSpeed );
            } );

        }

        this.firstRun = false;

    }


    this.getNextContentItem = function () {

        if( this.currItem >= this.items.length )
            this.currItem = 0;

        this.currItem++;

        return this.items[ this.currItem - 1 ];
    }

    this.initControlPanel = function(){

        this.btn_play  = $( '#' + this.options.container + ' .ticker_panel a.play'  );
        this.btn_stop  = $( '#' + this.options.container + ' .ticker_panel a.stop'  );
        this.btn_pause = $( '#' + this.options.container + ' .ticker_panel a.pause' );

        this.addButtonEffects( this.btn_play,  'play'  );
        this.addButtonEffects( this.btn_stop,  'stop'  );
        this.addButtonEffects( this.btn_pause, 'pause' );

    }

    this.addButtonEffects = function ( $btn, type ) {

        $btn.bind('mouseover focus', function(){
            $('img', $btn ).attr('src','/static/img/' + wwe_domaingroup + '/icons/' + type + '_hover.gif');
        });

        $btn.bind('mouseout blur', function(){
            $('img', $btn ).attr('src', '/static/img/' + wwe_domaingroup + '/icons/' + type + '.gif');
        });

    }

    this.buildItems = function( html, nodeElem, topNode ) {

        var $items;

        if ( topNode ) {
            $topNode = $( html ).find( topNode );
            $items = $( nodeElem, topNode );
        }
        else {
            $items = $( html ).find( nodeElem );
        }

        this.items = $items;
    }


    this.controlControls = function(){

        if( this.running ) {
            this.btn_play.css ( 'display', 'none' );
            this.btn_pause.css( 'display', 'inline' );

        }
        else {
            this.btn_play.css ( 'display', 'inline' );
            this.btn_pause.css( 'display', 'none' );
        }
    }

}


