/*
 * SRZD Scripts
 */

jQuery.fn.fadeIn = function(speed, callback) {
	return this.animate({opacity: 'show'}, speed, function() {
		if (jQuery.browser.msie)
			this.style.removeAttribute('filter');
		if (jQuery.isFunction(callback))
			callback();
	});
};

/*
 * Show/Hide Block
 */
function show(id)
{
	if ($("#" + id).css("display") == 'none')
	{
		$("#" + id).css("display", "block");
	}
	else
	{
		$("#" + id).css("display", "none");
	}
}


/*
 * JavaScript de validação de erros
 */
function checkEmpty(id)
{
	if ($("#" + id).attr("value")=="")
	{
		$("#" + id).addClass("formError");
		$("#" + id + "_msg").css("display", "block");
	}
	else
	{
		$("#" + id).removeClass("formError");
		$("#" + id + "_msg").css("display", "none");
	}
}


/*
 * Mudar as chamadas do tipo alta com jQuery
 */
var posicaoAlta = 1;
var clicked = 0;
var ultimo = 1;
function mudaAlta(pos, auto)
{
	if (ultimo == 1)
	{
		return;
	}
	if (clicked!=0 && auto)
	{
		clicked--;
		return;
	}
	posicaoAlta += pos;
	if (posicaoAlta > ultimo)
	{
		posicaoAlta = 1;
	}
	else if (posicaoAlta < 1)
	{
		posicaoAlta = ultimo;
	}

	previous = $("#blocoalta[atual='true']");
	previous.hide();
	previous.attr("atual", "false");

	next = $("#blocoalta[posicao='" + posicaoAlta + "']");
	next.fadeIn();
	next.attr("atual", "true");
	//alert("posicao=" + pos + " - " + "posicaoAlta=" + posicaoAlta + " - " + next.attr("id") + " - " + next.attr("posicao"));
	
	setTimeout("mudaAlta(1, true)", 8000);
	if (!auto) clicked++;
}


$(document).ready(function() {

	// Mudar ABA
	$("#abas a").click(function() {
		var i = $('a', $('#abas')).index(this) + 1;

		$("#abas a").removeClass("active");
		$(this).addClass("active");

		$(".inAbas").hide();
		$(".inAbas[aba='" + i + "']").fadeIn();

		return false;
	});

});

