// Mensagem de Error Geral e Mensagem de Carregamento
var msg_Error = "Ops....Cruze os dedos e tente novamente....Houve um problema ao obter os dados:\n";
var msg_Loading = 
				'<div id="loading" style="text-align: center; width:200px; height:25px; border: 1px solid #000000; background: #ffffff; top:50px; left:550px; position: absolute; z-index: 1000">'+
				'	<img src="img/c_loading.gif" alt="Carregando" title="Carregando" style="vertical-align:middle;" />'+
				'	<b class="textoblack">Carregando...</b>'+
				'</div>';
var msg_LoadingBlue = 
				'<div id="loading" style="text-align: center; width:200px; height:25px; border: 1px solid #000000; background: #ffffff; top:50px; left:550px; position: absolute; z-index: 1000">'+
				'	<img src="img/loading_blue.gif" alt="Carregando" title="Carregando" style="vertical-align:middle;" />'+
				'	<b class="textoblack">Carregando...</b>'+
				'</div>';
				
var msg_Loading_Find_File = 
				'<div id="loading" style="text-align: center; width:200px; height:25px; border: 1px solid #000000; background: #ffffff; top:50px; left:550px; position: absolute; z-index: 1000">'+
				'	<img src="img/c_loading.gif" alt="Carregando" title="Carregando" style="vertical-align:middle;" />'+
				'	<b class="textoblack">Carregando...</b>'+
				'</div>';
var  msg_LoadingInfo = 
					'<center><img src="img/c_loading.gif" alt="Carregando" title="Carregando" style="vertical-align:middle;" />'+
					'	<b class="textoblack">Carregando...</b></center>';
var msg_Loading_2 = 
				'<div id="loading" style="text-align: center; width:200px; height:25px; border: 1px solid #000000; background: #ffffff; top:50px; left:550px; position: absolute; z-index: 1000">'+
				'	<img src="img/c_loading.gif" alt="Carregando" title="Carregando" style="vertical-align:middle;" />'+
				'	<b class="textoblack">Carregando...</b>'+
				'</div>';
function Online(){
	AjaxRequest.get({
			'url':'online.php',
			'onSuccess':function(req){
				document.getElementById('online').innerHTML = req.responseText;
				setTimeout("Online()",5500);
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}


//Marca Voto ENquete
function marca_voto(valor){
	document.enquete.valor_voto.value = valor;
	//alert(valor);
	
}
//
//Vota enquete
function vota_enquete(id_enquete,voto){
	//enquete_votar.php
	AjaxRequest.get({
			'url':'enquete_votar.php?cod_enquete='+id_enquete+'&voto='+voto,
			'onLoading':function(){
				document.getElementById('enquete').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
				document.getElementById('enquete').innerHTML = req.responseText;
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
	
}
//


function verifica_enquete(id_enquete,voto){
	if(voto == '') {
		 alert('Você deve selecionar uma das respostas.');
	}
	else {
		vota_enquete(id_enquete,voto);
	}
}

function grava_newsletter(nome, email){
	AjaxRequest.get({
			'url':'newsletter_enviar.php?nome='+nome+'&email='+email,
			'onLoading':function(){
				document.getElementById('newsletter').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
				document.getElementById('newsletter').style.padding = "30px";
				document.getElementById('newsletter').innerHTML = req.responseText;
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}


function deleta_unidade(vlr_quary){
	AjaxRequest.get({
			'url':'_admin_/delete_unidade.php?dados='+vlr_quary,
			'onLoading':function(){
				document.getElementById('deletando').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
					document.getElementById('lista_'+vlr_quary).style.display = "none";
				//	document.getElementById('miolo').innerHTML = req.responseText;
					document.getElementById('deletando').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}


//
//Deleta Categoria do Cardapio

function deleta_cat_card(vlr_quary){
	AjaxRequest.get({
			'url':'_admin_/delete_cat_card.php?dados='+vlr_quary,
			'onLoading':function(){
				document.getElementById('deletando').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
					document.getElementById('lista_'+vlr_quary).style.display = "none";
				//	document.getElementById('miolo').innerHTML = req.responseText;
					document.getElementById('deletando').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}
//

// Deleta Acompanhamentos

function deleta_acompanhamento(vlr_quary){
	AjaxRequest.get({
			'url':'_admin_/delete_acompanhamento.php?dados='+vlr_quary,
			'onLoading':function(){
				document.getElementById('deletando').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
					document.getElementById('lista_'+vlr_quary).style.display = "none";
				//	document.getElementById('miolo').innerHTML = req.responseText;
					document.getElementById('deletando').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}
//

//deleta_receita
function deleta_receita(vlr_quary){
	AjaxRequest.get({
			'url':'_admin_/delete_receitas.php?dados='+vlr_quary,
			'onLoading':function(){
				document.getElementById('deletando').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
					document.getElementById('lista_'+vlr_quary).style.display = "none";
				//	document.getElementById('miolo').innerHTML = req.responseText;
					document.getElementById('deletando').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}
//


//
function deleta_cardapio(vlr_quary){
	AjaxRequest.get({
			'url':'_admin_/delete_cardapio.php?dados='+vlr_quary,
			'onLoading':function(){
				document.getElementById('deletando').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
					document.getElementById('lista_'+vlr_quary).style.display = "none";
				//	document.getElementById('miolo').innerHTML = req.responseText;
					document.getElementById('deletando').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}
//
//

//insere acompanhamento para o intem
function grava_acomp_cardapio(item_card, acomp, situacao){	
	AjaxRequest.get({
			
			'url':"_admin_/gravar_acompanhamentos_itens.php?item="+item_card+"&acomp="+acomp+"&situacao="+situacao,
					
			'onLoading':function(){
				document.getElementById('processando').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
	           document.getElementById('processando').innerHTML = req.responseText;
			   //document.getElementById('processando').style.display = "none";
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}
//
///////////////////////////////////////////////////////

// Pagina grava_emp.php
function grava_emp(vlr_quary){
	AjaxRequest.get({
			'url':'clientes/gravar_empresa.php?dados='+vlr_quary,
			'onLoading':function(){
				document.getElementById('miolo').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
				document.getElementById('miolo').innerHTML = req.responseText;
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}


//Pagina Valida_login de empresa

function valida_login(email_empres,senha_empres){
	AjaxRequest.get({
			'url':'includes/valida_login.php?email='+email_empres+'&senha='+senha_empres,
			'onLoading':function(){
				document.getElementById('miolo').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
				document.getElementById('miolo').innerHTML = req.responseText;
				document.getElementById('msg').innerHTML = document.getElementById('result').innerHTML;
				document.getElementById('result').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}

// Valida login de Noivos
function valida_login_noivos(email_empres,senha_empres){
	AjaxRequest.get({
			'url':'noivos/valida_login.php?email='+email_empres+'&senha='+senha_empres,
			'onLoading':function(){
				document.getElementById('miolo').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
				document.getElementById('miolo').innerHTML = req.responseText;
				document.getElementById('msg').innerHTML = document.getElementById('result').innerHTML;
				document.getElementById('result').style.display = "none";
				
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}



function chama_link(vlr_link){	
	AjaxRequest.get({
			
			'url':vlr_link,
					
			'onLoading':function(){
				document.getElementById('miolo').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
	            document.getElementById('miolo').innerHTML = req.responseText;
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}


function getValues(frm){
var result = AjaxRequest.submit(frm, {
			'onLoading':function(){
				document.getElementById('msgloading').innerHTML = msg_Loading;
			},
			'onSuccess':function(req){
				document.getElementById('Change').innerHTML = req.responseText;
 	            document.getElementById('msgloading').style.display = "none";
			},
			'onError':function(req){
				alert('Mensagem de Error...!!!!!!' + req.statusText);
			}
		});
		return result;
}

// Utilizado pra preencher o campo cidade nos cadastros  q utiliza estado e cidade
function atualiza(vlr,nome){	
	alert(vlr+"-"+nome);
	AjaxRequest.get({
			
			'url':"includes/cidades.php?ID="+vlr+"&nome="+nome,
					
			'onLoading':function(){
				document.getElementById('atualiza_'+nome).innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
	            document.getElementById('atualiza_'+nome).innerHTML = req.responseText;
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}

function atualiza_tipo_empres(vlr){	
	AjaxRequest.get({
			
			'url':"includes/tipo_empres.php?desc="+vlr,
					
			'onLoading':function(){
				document.getElementById('tipo_empres').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
	            document.getElementById('tipo_empres').innerHTML = req.responseText;
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}


function verifica_email(vlr){	
	AjaxRequest.get({
			
			'url':"includes/verifica_email.php?email="+vlr,
					
			'onLoading':function(){
				document.getElementById('valida_email').innerHTML = msg_LoadingInfo;
			},
			'onSuccess':function(req){
	            var i = 0
				var aux = ""
				
				vlr = req.responseText;
				
				for($i = 0;  i <= vlr.length; i++){
					if(vlr.substr(i,1)!=" "){
				       aux = aux + vlr.substr(i,1);
					}
				}
			
			if(aux=="OK"){
					document.getElementById('valida_email').innerHTML = "E-mail é Valido";
					document.getElementById('cadastro').style.display = "block";
				}else{
					document.getElementById('valida_email').innerHTML = req.responseText;
					document.getElementById('cadastro').style.display = "none";
				}	
			},
			'onError':function(req){
				alert(msg_Error + req.statusText);
			}
		});
}