window.addEvent('domready', function(){ var totIncrement = 0; var increment = 171; if(totIncrement == 0){ document.getElementById('previous').style.display = "none"; } var maxRightIncrement = increment*(-41); var fx = new Fx.Style('myList', 'margin-left', { duration: 1000, transition: Fx.Transitions.Back.easeInOut, wait: true }); //------------------------------------- // EVENTS for the button "previous" $('previous').addEvents({ 'click' : function(event){ if(totIncrement<0){ totIncrement = totIncrement+increment; fx.stop() fx.start(totIncrement); display(totIncrement, maxRightIncrement); } } }); //------------------------------------- // EVENTS for the button "next" $('next').addEvents({ 'click' : function(event){ if(totIncrement>maxRightIncrement){ totIncrement = totIncrement-increment; fx.stop() fx.start(totIncrement); display(totIncrement, maxRightIncrement); } } }) function display(totIncrement, maxRightIncrement){ if(totIncrement== 0){ document.getElementById('previous').style.display = "none"; } else { document.getElementById('next').style.display = "block"; document.getElementById('previous').style.display = "block"; } if(totIncrement == maxRightIncrement){ document.getElementById('next').style.display = "none"; //document.getElementById('previous').style.display = "block"; } else { //document.getElementById('previous').style.display = "block"; document.getElementById('next').style.display = "block"; } } });