// JavaScript Document
$(function(){
	$(document).ready(function() {
		_resize();
		if($(window).height() > $('#container').height()){
			$('#content').css('height',$(window).height()-($('#top').height() + $('#menu').height()+100));
			$('#container').css('height',$(window).height());
		}
	});
});
function _resize(){
	if($(window).height() > $('#container').height()){
			$('#content').css('height',$(window).height()-($('#top').height()+$('#menu').height()+100));
			$('#container').css('height',$(window).height());
	}
};

function pagina(pg,id){
	$(location).attr('href', 'area.html&pagina='+pg+'&id='+id);
}

function fechar(div){
	$(div).fadeOut();
}

function fec(div){
	$(div).fadeOut();
}

function post(arquivo,form){
	$('#carregando').fadeIn();
	var serializeDados = $('#'+form).serializeArray();
	$.ajax({
		url: arquivo, 
		dataType: 'html',
		data: serializeDados,
		type: 'POST',
		success: function(data, textStatus) {
			var retorno = data.split('|',2);
			if(retorno[0] ==  "I"){
				$('#resposta').html(retorno[1] + '<a href="javascript:fechar(\'#resposta\',\'\');" title="Fechar"><img src="img/fechar.gif" alt="Fechar" border="0" id="fechar"></a>');
				$('#resposta').fadeIn();
				$('#'+form)[0].reset();
			}else{
				$('#resposta').html(retorno[1] + '<a href="javascript:fechar(\'#resposta\',\'\');" title="Fechar"><img src="img/fechar.gif" alt="Fechar" border="0" id="fechar"></a>');
				$('#resposta').fadeIn();
			}
		},
		error: function(xhr,er) {
			$('#resposta').html('<p>Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>'+'<a href="javascript:fechar(\'#erro\');" title="Fechar"><img src="img/fechar.gif" alt="Fechar" border="0" id="fechar"></a>');
			$('#resposta').fadeIn();
		},
		complete: function(){
			$('#carregando').fadeOut();
			$('#divsenha').fadeOut();
			$('#trocasenha').fadeOut();//trocasenha
		}
	});
}

function deletar(arquivo,id){
	if(confirm('Realmente deseja excluir?')){
		$('#carregando').fadeIn();
		var registro = id;
		$.ajax({
			url: arquivo, 
			dataType: 'html',
			data: {id: registro},
			type: 'POST',
			success: function(data, textStatus) {
				var retorno = data.split('|',2);
				if(retorno[0].length >=  1){
					$('#resposta').html(retorno[1] + '<a href="javascript:fechar(\'#resposta\');" title="Fechar"><img src="img/fechar.gif" alt="Fechar" border="0" id="fechar"></a>');
					$('#resposta').fadeIn();
					$('#'+id).hide();
				}
			},
			
			error: function(xhr,er) {
				$('#resposta').html('<p>Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>'+'<a href="javascript:fechar(\'#resposta\');" title="Fechar"><img src="img/fechar.gif" alt="Fechar" border="0" id="fechar"></a>');
				$('#resposta').fadeIn();
			},
			complete: function(){
				$('#carregando').fadeOut();
			}
		});
	}
};
