img1 = new Image();
img1.src = "img/menu-home-on.png";
img2 = new Image();
img2.src = "img/menu-empresa-on.png";
img3 = new Image();
img3.src = "img/menu-fotos-on.png";
img4 = new Image();
img4.src = "img/menu-contato-on.png";
img31 = new Image();
img31.src = "img/menu-danca-on.png";
img32 = new Image();
img32.src = "img/menu-teatro-on.png";
img33 = new Image();
img33.src = "img/menu-book-on.png";
img34 = new Image();
img34.src = "img/menu-musica-on.png";
img35 = new Image();
img35.src = "img/menu-publicidade-on.png";
img36 = new Image();
img36.src = "img/menu-externas-on.png";
img37 = new Image();
img37.src = "img/menu-social-on.png";

function fotoRotativa(fotos, div, tempo, intervalo) {
	var html = "", timer = "", index = 0, i = 0, intervaloTotal = 0;
	clearTimeout(timer);
	if (fotos.constructor == Array) {
		for (i = 0; i < fotos.length; i++) {
			index = 999 - i;
			html += "<div id='foto-rotativa" + i + "' style='position:absolute; top:0; left:0; z-index:" + index + ";'>";
			html += "<img src='" + fotos[i][0] + "' title='" + fotos[i][1] + "' alt='" + fotos[i][2] + "' />";
			html += "</div>";
		}
		index = 999 - i;
		html += "<div id='foto-rotativa" + i + "' style='position:absolute; top:0; left:0; z-index:" + index + ";'>";
		html += "<img src='" + fotos[0][0] + "' title='" + fotos[0][1] + "' alt='" + fotos[0][2] + "' />";
		html += "</div>";
		$("#" + div).html(html);
	} else {
		fotos = new Array(fotos);
	}
	$("#" + div + " div").css('opacity', 1);
	for (i = 0; i < fotos.length; i++) {
		intervaloTotal = (intervalo * (i + 1)) + (tempo * i);
		timer = setTimeout("$('#foto-rotativa" + i + "').animate({opacity: 0}, " + tempo + ")", intervaloTotal);
	}
	intervaloTotal = intervaloTotal + tempo + 500;
	timer = setTimeout("fotoRotativa(" + fotos.length + ", '" + div + "', " + tempo + ", " + intervalo + ")", intervaloTotal);
}

$(document).ready(function(){
	$("#menu ul li a img, #menu-lateral ul li a img").mouseover(function(){
		if (!$(this).hasClass("ativo")) {
			imagem = $(this).attr("src");
			tamanho = imagem.length - 4;
			imagem = imagem.substr(0, tamanho);
			$(this).attr("src", imagem + "-on.png");
		}
	}).mouseout(function(){
		if (!$(this).hasClass("ativo")) {
			imagem = $(this).attr("src");
			tamanho = imagem.length - 7;
			imagem = imagem.substr(0, tamanho);
			$(this).attr("src", imagem + ".png");
		}
	});
});
