

function slideSwitch() {
    var $active = $('#slideshow img.active');

    if ( $active.length == 0 ) $active = $('#slideshow img:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function formUser_onClick(elemento_nome, texto) {
	elemento = document.getElementById(elemento_nome);
	if (elemento.value == texto) {
		elemento.value = "";
		if (elemento.id == 'password') 
			elemento.type = 'password';
	}
}

function formUser_onBlur(elemento_nome, texto) {
	elemento = document.getElementById(elemento_nome);
	if (elemento.value == "") {
		elemento.value = texto;
		if (elemento.id == 'password') 
			elemento.type = 'text';
	}
}

function userLogin() {
	if (document.getElementById('llogin').value == "Usuário" || document.getElementById('lpassword').value == "Password") {
		alert("Por favor preencha todos os campos.");
		return false;
	}
	$("#loginLoad").removeClass("hide");
	$("#loginBut").addClass("hide");
	$.post("/ajaxLogin", 
		   { user: document.getElementById('llogin').value, 
		     password: document.getElementById('lpassword').value, 
		   },
		function(data) {
			if (data == "aceite")
				location.reload();
			else {
				alert("Username/password inválidos.\nPor favor tente de novo");
				$("#loginBut").removeClass("hide");
				$("#loginLoad").addClass("hide");
			}
	});
}

$(document).ready(function() {
   $("#loginBut").click(function() {
		userLogin();
	});
});
