var MENU = {
	time: 0
	,element: '#submenu'
	,out: function () {
		this.time = setTimeout(function () {
			jQuery(MENU.element).hide();
		}, 500);
	}

	,over: function () {
		clearTimeout(this.time);
		jQuery(this.element).show();
	}
}

$(function() {
	/*
	$('#mid_content-index').serialScroll({
		target:'#pane1-index',
		items:'img', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		axis:'x',// The default is 'y' scroll on both ways
		navigation:'.navigation li a',
		duration:800,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		interval:3000, // It's the number of milliseconds to automatically go to the next
		cycle: true,
		constant: false,
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		},
		lazy: false
	});
	*/

	$('#banner1').animate({ opacity: 'show' }, "slow");
	$('#link-banner-index').attr("href", $('#' + ELE[0]).children("a").attr("href"));

	time_evento = setInterval(anima_evento, 6000);
	//time_evento = setTimeout(anima_evento, 6000);
});


var time_evento;
var ELE = new Array("banner1", "banner2", "banner3", "banner4");
var ELE_INDEX = 0;

function anima_evento() {
	var atual = ELE[ELE_INDEX];
	ELE_INDEX++;

	if (ELE_INDEX == ELE.length)
		ELE_INDEX = 0;

	var proximo = ELE[ELE_INDEX];

	for (var i = 0; i < ELE.length; i++) {
		var nn = ELE[i].match(/[0-9]+/);

		var ele = document.getElementById('box-evento-nav' + nn);
	}

	var nn = proximo.match(/[0-9]+/);
	var ele = document.getElementById('box-evento-nav' + nn);
	$('#' + atual).animate({ opacity: 'hide' }, 1000);
	$('#' + proximo).animate({ opacity: 'show' }, 1000);
	$('#link-banner-index').attr("href", $('#' + proximo).children("a").attr("href"));
}

function setBanner(index) {
	clearInterval(time_evento);

	if (index < 0) {
		index = ELE.length - 1;
		ELE_INDEX = ELE.length - 1;
	}

	if (index == 0)
		index = ELE.length - 1;
	else
		index = index - 1;

	//alert(index);

	aux = ELE_INDEX;

	ELE_INDEX = index;

	anima_evento();
	$('#' +  ELE[aux]).animate({ opacity: 'hide' }, 1000);

	time_evento = setInterval(anima_evento, 6000);
	//time_evento = setTimeout(anima_evento, 6000);
}
