/*******************************************************************
Carousel - Mootools domready event to rotate "On the Stanford Web"
********************************************************************/
window.addEvent('domready',function() {
	var scroll = new Fx.Scroll('scroll_container_inner', {
			wait: false,
			duration: 800,
			transition: Fx.Transitions.Cubic.easeInOut
	});
	var arrayScrollingContent = $$('.scroll_section');
	var numberofitems = arrayScrollingContent.length;
	var currentItem = 0;
	for (var i=0; i<numberofitems; i++) {
		var scroll_placement = $('scroll_placement');
		var my_img = new Element('img', {'src': '/images/otsw/scroll_placement_button_off.gif', 'class': 'scroll_button' }).injectInside(scroll_placement);		
	};
	var arrayScrollPlacement = $$('.scroll_button');
	arrayScrollPlacement[0].setProperty('src', '/images/otsw/scroll_placement_button_on.gif');
	$('scroll_right_shift').addEvent('click', function(event) {
		event = new Event(event).stop();
		currentItem = currentItem + 1;
		if (currentItem > arrayScrollingContent.length - 1) { 
			(currentItem = 0) }; 
		arrayScrollPlacement.setProperty('src', '/images/otsw/scroll_placement_button_off.gif');
		arrayScrollPlacement[currentItem].setProperty('src', '/images/otsw/scroll_placement_button_on.gif');
		scroll.toElement(arrayScrollingContent[currentItem]);
	});
	$('scroll_left_shift').addEvent('click', function(event) {
		event = new Event(event).stop();
		currentItem = currentItem - 1;
		if (currentItem < 0) { 
			(currentItem = 0) };
		arrayScrollPlacement.setProperty('src', '/images/otsw/scroll_placement_button_off.gif');
		arrayScrollPlacement[currentItem].setProperty('src', '/images/otsw/scroll_placement_button_on.gif');
		scroll.toElement(arrayScrollingContent[currentItem]);	
	});
});
