
jQuery(document).ready(function(){
    jQuery.fn.newsTicker = jQuery.fn.newsticker = function(delay){
        return this.each(function(){
            if (this.nodeName.toLowerCase() != "ul") 
                return;
            delay = delay || 4500;
            var self = this;
            self.items = jQuery("li", self);
            // hide all items (except first one)
            self.items.not(":eq(0)").hide().end();
            // current item
            self.currentitem = 0;
            var doTick = function(){
                jQuery.newsticker(self);
            }
            setInterval(doTick, delay);
        }).addClass("newsticker").hover(function(){
            // pause if hovered over
            this.pause = true;
        }, function(){
            // unpause when not hovered over
            this.pause = false;
        });
    }
    jQuery.newsticker = function(el){
        // return if hovered over
        if (el.pause) 
            return;
        // hide current item
        jQuery(el.items[el.currentitem]).fadeOut("slow", function(){
            jQuery(this).hide();
            // move to next item and show
            el.currentitem = ++el.currentitem % (el.items.size());
            jQuery(el.items[el.currentitem]).fadeIn("slow");
        });
    }
    
    jQuery("#news").newsTicker();
    
});

/*var menu = false;
var hoveritem = false;
window.addEvent('domready', function(){

	menu = $('mainmenu');
    menu.removeClass("fallback");
    menu.getElements('li.first-item a.first-item').each(function(menuitem){
        var position = menuitem.getParent().getPosition();
        var parPos = menuitem.getParent().getParent().getPosition();
        // condition pour IE6
        if (position.y > parPos.y) 
            menuitem.getParent().setStyle("margin-top", (parPos.y - position.y) + "px");
        menuitem.addEvents({
            'mouseenter': function(item){
                var size = item.getSize();
                var position = item.getPosition();
                if (!item.hoverEl) {
                    item.setStyle('position', 'relative');
                    item.hoverEl = new Element('SPAN', {
                        'class': 'hoveritem'
                    }).inject(item.getParent(), "bottom");
                    if (item.getParent().hasClass('first')) 
                        item.hoverEl.addClass('hoverfirstitem');
                }
                item.hoverEl.set({
                    styles: {
                        width: size.x + "px",
                        left: position.x + "px",
                        top: position.y + "px",
                        opacity: 0
                    }
                });
                item.hoverEl.morph({
                    opacity: 1
                });
            }
.pass(menuitem)            ,
            'mouseleave': function(item){
                if (item.hoverEl) {
                    item.hoverEl.morph({
                        opacity: 0
                    });
                }
            }
.pass(menuitem)
        });
    });
    
    document.getElements('.tooltip').each(function(item, i){
        var content_element = item.getElement('.ttip-content');
        content_element.set('styles', {
            display: 'block'
        });
        var content = content_element.get('html');
        content_element.dispose();
        var tooltip = new ToolTip(item, content, {
            mode: 'cursor',
            display: 'block',
            width: 400,
            style: 'default'
        });
    });
    
    
    $$('#header h1 a').addEvents({
        'mouseenter': function(){
            this.morph({
                opacity: 1
            });
        },
        'mouseleave': function(){
            this.morph({
                opacity: 0.01
            });
        }
    }).addClass('active').setStyles({
        'opacity': 0.01
    });
    
    
    $$('#feature .selector li a').each(function(item){
        new Element('SPAN').setStyle("opacity", 0).inject(item, "top");
        item.addEvents({
            'mouseenter': function(){
                this.getElement('span').morph({
                    opacity: .6
                });
            },
            'mouseleave': function(){
                this.getElement('span').morph({
                    opacity: 0
                });
            }
        });
    });
    
    
    $$('#header .rsslink a').each(function(item){
        item.addClass('activated');
        var oldText = item.get('text');
        item.empty();
        hoverSpan = new Element('SPAN', {
            'class': 'hover',
            'styles': {
                'opacity': 0
            }
        }).inject(item);
        textSpan = new Element('SPAN', {
            'class': 'text',
            'text': oldText
        }).inject(item);
        textSpan.origBottom = textSpan.getStyle('bottom');
        textSpan.setStyles({
            'bottom': 0,
            'opacity': 0
        });
        item.addEvents({
            'mouseenter': function(item, hoverSpan, textSpan){
                textSpan.morph({
                    opacity: 1,
                    'bottom': textSpan.origBottom
                });
                hoverSpan.morph({
                    opacity: 1
                });
            }
.pass([item, hoverSpan, textSpan])            ,
            'mouseleave': function(item, hoverSpan, textSpan){
                textSpan.morph({
                    opacity: 0,
                    'bottom': 0
                });
                hoverSpan.morph({
                    opacity: 0
                });
            }
.pass([item, hoverSpan, textSpan])
        });
    });
});*/

