
	//http://rafaelperrechil.com.br/jobs/DAEG/lib/imagens/site/sprite.png

	function ajax_sis(nomeForm, urlDestino, divRetorno, textoCarregando, callback)
	{
	
		if (textoCarregando == "") { textoCarregando = "Carregando..."; }

		if (callback != '') {
			ajaxGo({
				form: nomeForm,
				url: urlDestino,
				loading: "<div style='width:400px;'><img src='../../LIB/imagens/icones/loading.gif'style='vertical-align:middle;'/> "+textoCarregando+"</div>",
				elem_return: divRetorno,
				callback: callback
			})
		} else {
			ajaxGo({
				form: nomeForm,
				url: urlDestino,
				loading: "<div style='width:400px;'><img src='../../LIB/imagens/icones/loading.gif'style='vertical-align:middle;'/> "+textoCarregando+"</div>",
				elem_return: divRetorno
			})
		}

	}
	

	function abreAtividades(id){
		ajax_sis("", "abreAtividades.php?id="+id, "retornoAtividades", "", "");
	}
	
	
	function validaFormLogin(){
		//variáveis
		var enviar = true;
		var form = document.formLogin;
		
		//validação
		if(form.login.value == '' && enviar == true){
			window.alert("É obrigatório preencher o campo USUÁRIO");
			form.login.focus();
			enviar = false;
		}
		if(form.senha.value == '' && enviar == true){
			window.alert("É obrigatório preencher o campo SENHA");
			form.senha.focus();
			enviar = false;
		}
		
		//enviar
		if(enviar == true) {
			//formSubmit(form,'IframeIndex','login_verifica.asp');
			document.getElementById("carregamento").innerHTML = '';
			//ajax(form, "logar.php?i=2", "carregamento", "Carregando&nbsp", "")
			ajax_sis("", "logar_confirma.php?senha="+form.senha.value+"&login="+form.login.value, "carregamento")
		}
		
	}
	

	
	function abreModulo(nomeModulo){
		 ajax("", nomeModulo+"/"+nomeModulo+"_HTML.php?acao=estrutura_"+nomeModulo, "layout_conteudo", "", "");
	}

	function abreFecha(divID)
	{	
		if ($("#"+divID).is(":hidden")){
			$("#"+divID).slideDown("slow");
		}
		else{
			$("#"+divID).slideUp("slow");

		}
	}

	//TIPO: 0=CADASTRO / 1=EDICAO
	function salvar(nomeModulo,tipo)
	{
		if(tipo){
			acao = "edita_"+nomeModulo;
		}else{
			acao = "cadastra_"+nomeModulo;
		}
		
		 ajax("formSalvar", nomeModulo+"/"+nomeModulo+"_BD.php?acao="+acao, "div_auxiliar", "", "");	
	}


	function editar(id,nomeModulo)
	{
		ajax("", nomeModulo+"/"+nomeModulo+"_HTML.php?acao=edita_"+nomeModulo+"&id="+id, "bloco_adicionarConteudo", "", "");	
		$("#bloco_adicionarConteudo").slideDown("slow");
	}


	function excluir(id,nomeModulo,extras)
	{
		
		iAjax_msg({tempo:0, status:'normal', mensagem:"Você realmente deseja excluir o item selecionado?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onClick=\"javascript:excluir_go("+id+",'"+nomeModulo+"','"+extras+"');\"><span class='txt_verde'>Sim</span></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onClick='javascript:iAjax_msgFechar();'><span class='txt_vermelho'>Não</span></a>", titulo:'' })
	}


	function excluir_go(id,nomeModulo,extras)
	{
		var form = document.formAuxiliar;
		
		//atribuição
		form.id.value = id;
		form.acao.value = "exclui_"+nomeModulo;
		form.action = nomeModulo+"/"+nomeModulo+"_BD.php?"+extras;
		form.submit();	
	}


	function cancelar(divID)
	{
		$("#"+divID).slideUp("slow");
	}



	// MOSTRA DIV COM UMA MENSAGEM TEMPORÁRIA
	//USO: iAjax_msg({tempo:5, status:'ok', mensagem:'mensagem', titulo:'titulo' })
	function iAjax_msg(parametros){

		var tempo = parametros["tempo"];
		var status = parametros["status"];
		var mensagem = parametros["mensagem"];
		var titulo = parametros["titulo"];
		var url = parametros["url"];
		
		var iAjax_msg = document.getElementById("mensagem");
		var iAjax_imagem = document.getElementById("mensagem_imagem");

		//tratamentos
		tempo = parseInt(tempo);
		
		
		// se o tempo nao for passado, padrão de 3 segundos
		if(tempo == "" && tempo == 0){
			tempo = 3000
		}else{
			tempo = tempo*1000
		}
		

		// se o tempo nao for passado, padrão de 3 segundos
		if(status == "ok"){
			corFundo = "#9CC49C";
			corTexto = "#000";
			imagem = "ico_msg_ok.png";
			if(titulo == undefined || titulo == "") titulo = "Sucesso";
		}else if(status == "erro"){
			corFundo = "#D79C9C";
			corTexto = "#000";
			imagem = "ico_msg_erro.png";
			if(titulo == undefined || titulo == "") titulo = "Erro";
		}else if(status == "normal"){
			corFundo = "#D7D7D7";
			corTexto = "#000";
			imagem = "ico_msg_normal.png";
			if(titulo == undefined || titulo == "") titulo = "Alerta";
		}

		$('#mensagem').slideDown();
		iAjax_msg.style.backgroundColor = corFundo;
		iAjax_msg.style.color = corTexto;
		
		$('#mensagem_imagem').slideDown();
		iAjax_imagem.style.background="url('../lib/imagens/"+imagem+"') no-repeat"; 
		
		$('#mensagem_titulo').html(titulo);
		$('#mensagem_texto').html(mensagem);
		

		
		if(url == undefined) {
			url = window.location
		}

		
		if(tempo > 0)
		{
			setTimeout(" $('#mensagem').fadeOut('slow');$('#mensagem_imagem').fadeOut('slow');", tempo);
				if(url.length > 0){ setTimeout(" window.location = '"+url+"'; ", tempo);  }
			
		}

	}

	function iAjax_msgFechar()
	{
		$('#mensagem').fadeOut('slow');
		$('#mensagem_imagem').fadeOut('slow');
	}



