var total_promoboxes; var current_promobox = 0; var interval_promobox; var links_promoboxes; function promoInit() { if ($('promoboxlist')) { links_promoboxes = $('promoboxlist').getElementsByTagName('li'); total_promoboxes = links_promoboxes.length; enable(links_promoboxes[0]); // links[0].removeClassName('active'); // links[0].addClassName('active'); $A(links_promoboxes).each(function(e){ e.observe('mouseover', function(f){enable(e);}) }); $('promoboxlist').observe('mouseover', stopSlideshow); $('promoboxlist').observe('mouseout', startSlideshow); startSlideshow(); } // alert(link.nextSibling()); // $(links[2]).addClassName('active'); } function enableNext() { next = current_promobox + 1; if( next >= total_promoboxes ) next = 0; // alert(next)s; enable(links_promoboxes[next]); current_promobox = next; } function startSlideshow() { interval = setInterval(enableNext, 4000); } function stopSlideshow() { clearInterval(interval); } function disableAll() { $A($$('#promoboxlist li')).each(function(e){ e.removeClassName('active'); }); } function enable(element) { disableAll(); $(element).addClassName('active'); } document.observe('dom:loaded', function(e){ promoInit(); }); /* var interval; var active; var prevactive; var promo; var nextactive; function Promo( ) { this.active = false; this.interval = false; this.init = function() { this.startSlideshow(); } this.startSlideshow = function() { interval = setInterval('promo.appearNext();', 2000); } this.stopSlideshow = function() { // clearInterval(interval); // active = promo.getActive(); // // if( active ) // promo.appear(active); } this.appearNext = function() { // active = promo.getActive(); // // if( active ) // { // // nextelm = $(active).next(); // if ( !nextelm ) // { // nextelm = $(active).up().firstChild; // // } // // nextid = nextelm.id.match(/(\d+)/)[1]; // promo.appear(nextid); // } // alert('a'); } this.getActive = function() { // if( promo.active == false ) // promo.active = $('promoslider').firstChild.id; // // return this.active; } this.appear = function( promoboxes_id ) { // active = this.getActive(); // nextactive = 'box' + promoboxes_id; // // if( nextactive != active ) // { // prevactive = active; // // promo.active = nextactive; // // active = promo.getActive(); // // if( $('link' + prevactive) ) // $('link' + prevactive).morph('background:#1f313d;', {duration: 0.1}); // // if($('link' + active)) // $('link' + active).morph('background:#283c4a;', {duration: 0.5}); // // // // if( $(active) ) // $(active).appear({duration:0.1}); // if( $(prevactive) ) // $(prevactive).fade({duration:0.5}); // } } } promo = new Promo(); document.observe('dom:loaded', function(e){ if( $('promoselector') ) { if( promo ) { promo.init(); // $A($$('#promoselector li')).each(function(e){ // e.observe('mouseover', promo.stopSlideshow); // e.observe('mouseout', promo.startSlideshow); // }); } } }); */