window.addEvent('domready', function(){
    var totIncrement = 0;
    var increment = 775;
	i_s = i_s != 0 ? (i_s - 1) * -1 : 0 ;
    var maxRightIncrement = increment * (i_s);
	if (maxRightIncrement == 0) {
		$('next').setStyle('display', 'none');
	}
    var fx = new Fx.Morph('slides', {
        duration: 1000,
        transition: Fx.Transitions.Back.easeInOut,
        wait: true
    });
    $('previous').addEvents({
        'click': function(event){
            new Event(event).stop();
            if (totIncrement < 0) {
                totIncrement = totIncrement + increment;
                fx.start({
                    'margin-left': totIncrement
                });
                $('next').setStyle('display', 'block');
            }
            if (totIncrement >= 0) {
                $('previous').setStyle('display', 'none');
            }
        }
    });
    $('next').addEvents({
        'click': function(event){
            new Event(event).stop();
            if (totIncrement > maxRightIncrement) {
                totIncrement = totIncrement - increment;
                fx.start({
                    'margin-left': totIncrement
                });
                $('previous').setStyle('display', 'block');
            }
            if (totIncrement <= maxRightIncrement) {
                $('next').setStyle('display', 'none');
            }
        }
    });
    $('previous').setStyle('display', 'none');
});
