$(function() {

$('ul#portifolio li h1, form.contato').css({'opacity':0.9});

// navegação principal
$('#navegacao ul li:has(ul)').hover(
	function() {
		$(this).children('a').addClass('hover').next().show();
	},
	function() {
		$(this).children('a').removeClass('hover').next().hide();
	}
);

$('.lista-conteudo h2').click(function()
{
	$(this).next().slideToggle();
});


$('#portfolio li.portifa:has(.descricao)').hover( function(){ $(this).children('.descricao').show(); }, function(){ $(this).children('.descricao').hide(); } );



// seleciona todos os checkbox's ao clicar no link
$('form fieldset a[rel=selecionar_todos]').click(function() {
	var checados	= $(this).parent().parent().find('input:checked').length;
	var total		= $(this).parent().parent().find('input:checkbox').length;
	if (checados == total) {
		$(this).html('todas');
		$(this).parent().parent().find('input:checkbox').removeAttr('checked');
	} else {
		$(this).html('nenhuma');
		$(this).parent().parent().find('input:checkbox').attr('checked', 'checked');
	}
});
// altera o texto do link de selecionar checkbox
$('form fieldset:has(a[rel=selecionar_todos]) input:checkbox').click(function() {
	var checados	= $(this).parent().parent().find('input:checked').length;
	var total		= $(this).parent().parent().find('input:checkbox').length;
	if (checados == total) {
		$(this).parent().parent().parent().find('a[rel=selecionar_todos]').html('nenhuma');
	} else {
		$(this).parent().parent().parent().find('a[rel=selecionar_todos]').html('todas');
	}
});
// altera o texto do link ao resetar o formulário
$('form:has(a[rel=selecionar_todos]) input:reset').click(function() {
	$(this).parent().parent().find('a[rel=selecionar_todos]').html('todas');
});




// Auto-esconder as mensagens após 5 segundos
setTimeout(function() {
	$('.msg-aviso, .msg-erro, .msg-sucesso').slideUp('fast', function() {
		$(this).remove();
	});
}, 5000);

// Esconder mensagens após clicar
$('.msg-aviso, .msg-erro, .msg-sucesso').click(function() {
	$(this).slideUp('fast', function() {
		$(this).remove();
	});
});






// Exibe/oculta o formulário de busca
$('#container_busca h2').click(function() {
	$(this).next().slideToggle('fast');
});



// Over nas tr's da tabela
$('table tbody tr').hover(function() {
	$(this).addClass('over');
}, function() {
	$(this).removeClass('over');
});

});

