//var $ = document.getElementById;
var scroll = null;
window.addEvent('domready', function(){

	scroll = new Fx.Scroll('CenterImage', {
		wait: false,
		duration: 1500,
		offset: {'x': 0, 'y': 0},
		transition: Fx.Transitions.Quad.easeInOut,
		onComplete: function(){
			//console.log("Slide Completed");
		}
	});

	$('next_img').addEvent('click', function(event) {
		event = new Event(event).stop();
		window.clearInterval(int);

		var _n=_c+1;
		if(_n>_t)_n=1;
		_c=_n;
		scroll.toElement('headerItem'+_n);

	});

	$('prev_img').addEvent('click', function(event) {
		event = new Event(event).stop();
		window.clearInterval(int);
		var _p=_c-1;
		if(_p==0)_p=_t;
		_c=_p;
		scroll.toElement('headerItem'+_p);

	});

	var int=self.setInterval("autoRotation(scroll)",5000);

});

var _c = 1;

function autoRotation(scroll){
	var _n=_c+1;
	if(_n>_t)_n=1;
	_c=_n;
	//console.log("AutoTo: headerItem"+_n);
	scroll.toElement('headerItem'+_n);
}


function initTabs() {
	$('tabMenuList').getElements('a').each(function(el) {
		if(el.rel != 'direct'){
			el.addEvent('click',function(e) {
				var ev = new Event(e).stop();
				tabState(el);
			});
		}
	});
}

function tabState(ael) {
	if(ael.rel != 'direct'){
		$('tabMenuList').getElements('a').each(function(el) {
			if(el.hasClass('active')) {
				el.removeClass('active');
			}
		});
		ael.addClass('active');
		$$('#tabContent div.content').each(function(el) {
			if(el.hasClass('active')) {
				el.removeClass('active');
			}
		});
		var ac = ael.getProperty('href');
		$(ac).addClass('active');
	}
}
