/*Dev. by Anderson Alcantara*/

jQuery(function($){
});


function verificacertificado() {
$("#mostracertificado").html("<center><br><br><br><br>Carregando informações, Aguarde...<br><img src='ajax-loader.gif'> </center><br>");
		$.ajax({
			type: "POST",
			cache: false,
			url:  "php/verificacertificado.php",
			data: "email="+$("#email").attr("value"),
			success: function(mostracertificado){
				if(mostracertificado){
					$("#mostracertificado").html(mostracertificado);
				}else{
					$("#mostracertificado").html("Registros não encontrados!");
				}
			}
		});

}

function carregaProduto() {
		$.ajax({
			type: "POST",
			cache: false,
			url: "busca_produto.php",
			data: "idevento="+$("#eventos").attr("value"),
			success: function(dados){
				if (dados){
					$("#carregaProdutos").html(dados);
			}else {
					alert('Nenhum registro encontrado em Produtos!');
					$("#carregaProdutos").html(dados);
				}
			}
		});

}

function carregaPromocional() {
		$.ajax({
			type: "POST",
			cache: false,
			url: "busca_promocional.php",
			data: "idevento="+$("#eventos").attr("value"),
			success: function(dados){
				if (dados){
					$("#carregaPromocional").html(dados);
			}else {
					alert('Nenhum registro encontrado em código Promocional!');
					$("#carregaPromocional").html(dados);
				}
			}
		});

}


function incluiAlteraPromocional(idcad) {
$("#incluialtera").html("<center><br><br><br><br>Carregando informações, Aguarde...<br><img src='ajax-loader.gif'> </center><br>");

		$.ajax({
			type: "POST",
			cache: false,
			url: "inclui_altera_promocional.php",
			data: "tipocadastro="+idcad + "&idevento=" + $("#eventos").attr("value"),
			success: function(dados){
				if (dados){
					$("#incluialtera").html(dados);
			}else {
					alert('Nenhum registro encontrado em código Promocional!');
					$("#incluialtera").html(dados);
				}
			}
		});



}

function salvaPromocional(idcad) {
$("#msgPromocional").html("Salvando Informações, Aguarde...<img src='ajax-loader.gif'>");

		$.ajax({
			type: "POST",
			cache: false,
			url: "salva_promocional.php",
			data: "tipocadastro=" + idcad + "&codigoP="+$("#codigoP").attr("value") + "&descricaoP="+$("#descricaoP").attr("value") + "&valorP="+$("#valorP").attr("value") + "&percentualP="+$("#percentualP").attr("value") + "&qtdmaximaP="+$("#qtdmaximaP").attr("value") + "&diasP="+$("#diasP").attr("value"),
			success: function(dados){
				if (dados){
					$("#msgPromocional").html(dados);
			}else {
					alert('Nenhum registro encontrado em código Promocional!');
					$("#msgPromocional").html(dados);
				}
			}
		});



}


function habilitabotaoexcel(){
	$("#bt_excel").attr("disabled","");
	
}

// arquivo arquivo para gera nota fiscal
function geranotafiscal(){
$("#mostranota").html("<center>Carregando informações, Aguarde...<br><img src='ajax-loader.gif'> </center>");
		$.ajax({
			type: "POST",
			cache: false,
			url: "mostra_notafiscal.php",
			data: "idevento="+$("#eventos").attr("value"),
			success: function(dados){
				if (dados){
					if(dados != ""){
						$("#mostranota").html(dados);
						$("#bt_notaexcel").attr("disabled","");
						$("#bt_notatexto").attr("disabled","");
					}
			}else {
					alert('Nenhum registro encontrado em Código Promocional!');
					$("#mostranota").html(dados);
				}
			}
		});

}

function mostraCodigoPromocional() {
$("#incluialtera").html(" ");	
$("#exibeCodigoPromocional").html("<center><br><br><br><br>Carregando informações, Aguarde...<br><img src='ajax-loader.gif'> </center><br>");
		$.ajax({
			type: "POST",
			cache: false,
			url: "mostra_codigopromocional.php",
			data: "idevento="+$("#eventos").attr("value"),
			success: function(dados){
				if (dados){
					$("#exibeCodigoPromocional").html(dados);
					$("#bt_incluir").attr("disabled","");
			}else {
					alert('Nenhum registro encontrado em Código Promocional!');
					$("#exibeCodigoPromocional").html(dados);
				}
			}
		});

}


function sobeArquivo() {
	window.open("up.php","upload", "height=130,width=450")
}


startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("menu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}



function mudaStatus(valor1,valor2,valor3,valor4) {
	
	window.open("aStatus.php?id="+valor1+"&nS="+valor3+"&oS="+valor2+"&idEv="+valor4,"novoStatus", "height=250,width=350")


}

function enviaNota(pedido,evento,valor) {
	if(valor!= "selecione"){
		window.open("aNotaEletronica.php?ped="+pedido+"&ev="+evento,"notaEletronica", "location = NO, height=250,width=350")
	}


}


function mostraDados(pedido) {
	
	window.open("mostra_dados.php?ped="+pedido,"Janela", "height=800,width=800,scrollbars=yes")


}

function alteraDados(pedido) {
	window.open("alteradados.php?pedido="+pedido,"Janela", "height=600,width=950,scrollbars=yes")
}
