sponsorsfly = {}; 

(function(){jQuery.noConflict();});

(function(){
    //params
    var shift;
    var nbelt;
    var eltwidth;
    var height;
    var speed;
    var delay;
    var contener;
    
    //internal variables
    var t;
    var sh;
    var elt;
    
     //constructor
     sponsorsfly.init = function(){
         //set params
         nbelt = this.nbelt;
         eltwidth = this.eltwidth;
         height = this.height;
         speed = this.speed;
         delay = this.delay;
         contener = this.contener;
         //set dimensions and position
         jQuery('#sponsors').css({'height' : height});
         jQuery('#sponsors div').css({'width' : eltwidth, 'height' : height});
         posCalc();
         resize();
         //set div in place at right and go left
        for(var i=1; i<=nbelt; i++)
                jQuery('#sponsor'+i).animate({
                                opacity: 0,
                                left: shift - eltwidth*(i-1)
                    }, 1, 'linear');
        elt = 1;
        goleft();
    }
    
     function posCalc(){
        var posleft = jQuery('#'+contener).offset().left + 
            (jQuery('#'+contener).width() - (eltwidth*nbelt))/2;
        shift = jQuery(window).width()-posleft + 100;
        var postop = jQuery('#'+contener).offset().top +
            (jQuery('#'+contener).height() - height)/2;
        jQuery("#sponsors").css({'left' : posleft , 'top' : postop});
    }
    
    function resize(){
        jQuery(window).resize(function() {
            posCalc();
        });
    }


     sponsorsfly.goright = function(){
        jQuery('#sponsor'+elt).css('z-index', elt);
        jQuery('#sponsor'+elt).animate({
                opacity: 0,
                left: sh
                }, speed, 'linear',
                function() {
                    elt++;
                    sh -= eltwidth;
                    if(elt<=nbelt){
                            sponsorsfly.goright();
                    }else{
                            elt = 1;
                            goleft();
                    }
    // Animation complete.
    });
    }

    function goleft(){
        jQuery('#sponsor'+elt).css('z-index', 'auto');
        jQuery('#sponsor'+elt).animate({
    opacity: 1,
    left: 0
    }, speed, 'linear',
    function() {
        elt++;
        if(elt<=nbelt)
                goleft();
        else{
                //alert("all done");
                elt = 1;
                timer();
                //goright(shift);
    }
    });
    }

    function timer(){
        sh = shift;
        t = setTimeout("sponsorsfly.goright()", delay);
    }
    
})();

sponsorspos = {};

(function(){
    
})();
