// JavaScript Document
function IniMenu(){
	$("#menu li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	if (document.all) {
		$("#menu li").hoverClass ("sfHover");
	}
}
	
function IniLista(alt){
	if (alt != '')
		$('td[@id*=cod_]').click(function(){ window.location = alt+"?cod="+this.id.substr(4); });
	
	IniMenu();
	
	$("img[@id*=exc_]").click(function(){ return ExcluirCadastro(this.id); });
}

function Excluir(id, perg, php){
	if (confirm(perg)){
		var cod = id.substr(4);

		$.get(php, { cod: cod}, 
			function(resposta){
			var tr = document.getElementById("tr_"+cod);
			tr.parentNode.removeChild(tr);
			var t = $('#total').val() -1;			
			$('#dtotal').html(t);
			$('#total').val(t);
			$("#msg").html('');	
		});
	}
}

function Excluir2(id, perg, php){
	if (confirm(perg))
		window.location = php+"?cod="+id.substr(4);
}

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

function Abrir(arq, larg, alt){	
	var topo = (screen.height - alt)/2;
	var esq  = (screen.width - larg)/2;

	window.open(arq,'Busca','height='+alt+',width='+larg+',top='+topo+',left='+esq+',resizable=yes,scrollbars=yes');
}
