window.addEvent('domready',function(){

kids = $('inner').getChildren().get('html');
p = kids.length.toInt();
width = 960;
actual = 0;
x = new Fx.Morph($('inner'),{ duration: 500, wait:true, transition:Fx.Transitions.linear })
$('inner').set('html',kids[actual]);
	
	$('nextnews').addEvent('click',function(e){
		e = new Event(e).stop();
			actual++;	
		$clear(myTimer);		
		// increase actual as the first news are shown anyways
		if(actual >= p){
			actual = 0;
		}
			
		$('inner').setStyle('left',-width);
		$('inner').set('html',kids[actual]);
		x.start({ 'left':[-width,5] });
		
	})


	$('prevnews').addEvent('click',function(e){
		e = new Event(e).stop();
		$clear(myTimer);
		
		// increase actual as the first news are shown anyways
		
	
		
		
		
			if(actual <= 0){
			actual = p;
		}
		
		--actual;
		
		
		
		$('inner').setStyle('left',-width);
		$('inner').set('html',kids[actual]);
		x.start({ 'left':[-width,5] });

	})
	
	$('resumed').addEvent('click',function(e){
		e = new Event(e).stop();
		myTimer = addCount.periodical(4500);
	})
	
	$('inner').addEvent('mouseenter',function(e){
		e = new Event(e).stop();
		$clear(myTimer);
	})
	
	$('inner').addEvent('mouseleave',function(e){
		e = new Event(e).stop();
		myTimer = addCount.periodical(4500);
	})

var addCount = function(){ 
		actual++;
	if(actual >= p){
		actual = 0;
	}
	
	$('inner').setStyle('left',-width);
	$('inner').set('html',kids[actual]);

	x.start({ 'left':[-width,5] });
	
}

myTimer = addCount.periodical(4500);

})

