window.addEvent('domready', function() {

    var  mc= $('maincontainer');
	var count =2;
	mc.tween('height',300);
 	var scroll = new Fx.Scroll('demo-wrapper', {
	wait: false,
	duration: 500,
	offset: {'x': -305, 'y': -50},
	transition: Fx.Transitions.Quad.easeInOut});
	scroll.toElement('flashintro');

	var gotoflash = function()
	{
		scroll.toElement('news3');
		mc.tween('height',300);
	};
//gotoflash.delay();

	

	var slideforward = function()
	{
	
	if( count ==1)
	{
		scroll.toElement('flashintro');
		mc.tween('height',300);
		count=count+1;
	}
	else if (count == 2)
	{
		scroll.toElement('news2');
		mc.tween('height',400);
		count = count+1;
	}
	else if (count == 3)
	{
		scroll.toElement('news3');
		mc.tween('height',560);
		count = 1;
	}
	else if (count == 4)
	{
		scroll.toElement('news1');
		mc.tween('height',890);
		count = 1;
	}	
		
	}

//	var myTimer = slideforward.periodical(15000,this);
$('left').addEvent('click', function(event) {
	event = new Event(event).stop();
	if( count ==1)
	{
		scroll.toElement('news2');
		mc.tween('height',300);
		count = 4;
		
	}
	else if (count == 2)
	{
		scroll.toElement('news1');
		mc.tween('height',890);
		count = count-1;
	}
	else if (count == 3)
	{
		scroll.toElement('news3');
		mc.tween('height',560);
		count = count-1;
		
	}
	else if (count == 4)
	{
		scroll.toElement('flashintro');
		mc.tween('height',300);
		count = count-1;
	}
	
	});

$('right').addEvent('click', function(event) {
	event = new Event(event).stop();
	if( count ==1)
	{   
		scroll.toElement('news3');
		mc.tween('height',560);
		count=count+1;
		
	}
	else if (count == 2)
	{
		scroll.toElement('flashintro');
		mc.tween('height',300);
		count=count+1;
		
	}
	else if (count == 3)
	{
		scroll.toElement('news2');
		mc.tween('height',400);
		count=count+1;
	}
	else if (count == 4)
	{
		scroll.toElement('news1');
		mc.tween('height',890);
		count = 1;
	}	
	});

 

});