/**
 * create Cinema in SAPO.namespace
 */ 
if(!SAPO.Cinema || typeof(SAPO.Cinema) == 'undefined') {
    SAPO.namespace('Cinema');
}


/**
 * Sapo.Cinema.newsFocusDynamic4 constructor
 */
SAPO.Cinema.newsFocusDynamic4 = function(options)
{
    this.init(options);
};


/**
 * Sapo.Cinema.newsFocusDynamic4 methods
 */
SAPO.Cinema.newsFocusDynamic4.prototype = {       

   divClass: null,

    /**
     * init
     */    
    init: function(args) {
        if (args && args.divClass) {
            this.divClass = args.divClass;
        } else {
            this.divClass = 'newsFocusDynamic';
        }
        //   
        this.enhanceNews(); 
    },   
   
    
    /**
     * enhance news
     * TODO cleanup, workaround event firing in inner elements like P
     */    
    enhanceNews: function() {
        // fecth list         
        $$('.' + this.divClass + ' li.item').each( function (el) { 
            // fetch this item's image url 
            var src = $(el).getElementsByTagName('img')[0].src;
            var href= $(el).down('a').href;
            // bind mouse over   
            el.observe('mouseover', function(ev) { 
                var target = $(ev.target);
                // IE6 HACK
                if (typeof(target.hasClassName) == 'function') {
                    if (!target.hasClassName('item')) { target = target.up('.item'); }
                }
                // match LI 
                if (target.hasClassName('item')) {
                    $$('li.item').each( function (el) { el.removeClassName('active'); } );
                    target.addClassName('active');
                    $('newsThumb').src = src; 
                    $('newsThumb').up('a').href = href; 
                }                        
            } );
            el.observe('mouseout', function() { /* */ } );
        } );
    }
    
  
}

