// Cadastrar 
function cadastrarCliente(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?cadastro=cadOK', callbackResultadoClientes, postData);
}

// Salvar Clientes 
function salvarClientes(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?salvar=cadOK', callbackResultadoClientes, postData);
}

// Alterar 
function alterarCliente(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?alterar=cadOK', callbackResultadoClientes, postData);
}

// remover passageiros 
function removePassag(formCadastroNovoCliente,codigo){
	idPag=codigo;
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?removerPass=cadOK', callbackResultadoClientes, postData);
}

// remover clientes 
function removeClientes(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?removerClientes=cadOK', callbackResultadoClientes, postData);
}

//Paginação
function paginacao(pagina){
	LayoutAguarde.showDialog();
	idPag=pagina;
	YAHOO.util.Connect.asyncRequest('GET','clientes/operacoes.php?paginar=OK&pg='+idPag, callbackResultadoClientes);								
}
//Paginação Destino Excursão
function paginacaoEx(paginaEx){
	LayoutAguarde.showDialog();
	idPagEx=paginaEx;
	YAHOO.util.Connect.asyncRequest('GET','clientes/excursao.php?pg='+idPagEx, callbacklstClientes);								
}

// Cadastrar Excursões 
function salvarExcursao(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?excursao=cadOK', callbackResultadoClientes, postData);
}


// Remover Excursões 
function removeExcursao(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?excursaoRemover=cadOK', callbackResultadoClientes, postData);
}

// Buscar Clientes 
function contratoBusca(formCadastroNovoCliente){
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/listar.php', callbacklstClientes);
}

// Enviar contrato pelo e-mail 
function enviarEmailfacil(codigo){
	idContrato=codigo;
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(codigo); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?enviarEmailFacinho=cadOK&id='+codigo, callbackResultadoClientes, postData);
}

// Alterar Pagamento
function alterarPagamento(formCadastroNovoCliente,codigoID){
	idID=codigoID;
	LayoutAguarde.showDialog();
	YAHOO.util.Connect.setForm(formCadastroNovoCliente); 
	var transaction = YAHOO.util.Connect.asyncRequest('POST', 'clientes/operacoes.php?alterarPag=cadOK', callbackResultadoClientes, postData);
}
//***********************************************************************************************************


var postData;
	var successResultadoClientes = function(o){
		if(o.responseText !== undefined){
			
			// Cadastro.
			if (o.responseText=='cadastro_feito'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Cadastro feito com sucesso!');
			 var sUrl = 'clientes/visualizar.php';
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
				// Salvo.
			if (o.responseText=='salvo_feito'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Salvo!');
			 var sUrl = 'clientes/visualizarImprimir.php';
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
			//alterar todos
			if (o.responseText=='alterado_todos'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Alterado com sucesso!');
			 var sUrl = 'clientes/visualizar.php';
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
		
					//Remover Passageiros
			if (o.responseText=='remover_passageiros_ok'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Passageiro removido!');
			 var sUrl = 'clientes/alterar.php?id='+idPag;
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
					//Remover Clientes
			if (o.responseText=='remover_clientes_ok'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Clientes removido!');
			 var sUrl = 'clientes/listar.php';
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
				// paginar
			 else if (o.responseText=='paginar_a_pagina'){
				 
					LayoutAguarde.fechar();
					var sUrl = 'clientes/listar.php?pg='+idPag;
					var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbacklstClientes);		
			 }
			 
			//Cadastrar Excursao
			if (o.responseText=='cadastro_excursao'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Periodo salvo com sucesso!');
			 var sUrl = 'clientes/popup.php';
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
			//Busca Rapida
			if (o.responseText=='rapidao'){
			 //LayoutAguarde.fechar();
			 //Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Periodo salvo com sucesso!');
			 var sUrl = 'clientes/buscarAntes.php';
			 var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbacklstClientes);
				}
			 
			//Remover Excursao
			if (o.responseText=='remover_excursao_ok'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Removido!');
			 var sUrl = 'clientes/excursao.php';
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
							//Email facil
			if (o.responseText=='contrato_enviado'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'E-mail enviado com sucesso!');
			 //var sUrl = 'clientes/excursao.php';
			 //var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}
				
				//ALterar Pagamentos
			if (o.responseText=='alterar_pagamento'){
			 LayoutAguarde.fechar();
			 Ext.example.msg('Resultado da opera&ccedil;&atilde;o:', 'Alterado com sucesso!');
			 var sUrl = 'clientes/visualizarPagamentos.php?id='+idID;
			 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callbacklstClientes);
				}		
	
	
				
		}//fechamento if(responseText !==
		
	}// fechamento successResultadoAdmin


//==========================================================================================
// CALLBACK Atualiza lista  E-MAILS:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//==========================================================================================


	var handleSuccesslst = function(o){
		if(o.responseText !== undefined){
			div = document.getElementById('central');
				  document.getElementById('central').innerHTML = '';
				   LayoutAguarde.fechar();
  				  
			div.innerHTML = o.responseText;

		}
	}
	 
	 var handleFailurelst = function(o){
	  if(o.responseText !== undefined){
		 
	  }
	 }
	 
	 var callbacklstClientes =
	 {
	   success:handleSuccesslst,
	   failure:handleFailurelst,
	   argument:['foo','bar']
	 };


//==========================================================================================
// BUSCA ANTES :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//==========================================================================================


	var handleSuccesslst = function(o){
		if(o.responseText !== undefined){
			div = document.getElementById('alterarBusca');
				  document.getElementById('alterarBusca').innerHTML = '';
  				  
			div.innerHTML = o.responseText;

		}
	}
	 
	 var handleFailurelst = function(o){
	  if(o.responseText !== undefined){
		 
	  }
	 }
	 
	 var callbacklstBuscaAntes =
	 {
	   success:handleSuccesslst,
	   failure:handleFailurelst,
	   argument:['foo','bar']
	 };

//==========================================================================================
// CALLBACK cadastrar conta :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//==========================================================================================

var failureResultadoClientes = function(o){
		if(o.responseText !== undefined){
		 
		}
	}

	var callbackResultadoClientes = {
		success:successResultadoClientes,
		failure:failureResultadoClientes,
		argument:['foo','bar']
	};
	
	
//-------------+++++++++++++++++++++-------------+++++++++++++++++++++-------------++++++++++

// Buscar rapido demais

	function lookup(inputString) {
		if(inputString.length == 0) {

		} else {
			$.post("clientes/departamentos.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {

					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
//-------------+++++++++++++++++++++-------------+++++++++++++++++++++-------------++++++++++
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-------------+++++++++++++++++++++-------------+++++++++++++++++++++-------------++++++++++

//Cadastrar Loop
function addElement() {
  var id=1;
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = '<table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td width="28%">Nome:</td><td width="16%">Rg:</td><td width="18%">Data Nasc.</td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td width="28%"><input name="nomePassageiro[]" type="text" /></td><td width="16%"><input name="rgPassageiro[]"type="text" size="10" /></td><td width="18%"><input name="dataNascPassagerio[]" type="text" size="10"/></td></tr></table>';
  ni.appendChild(newdiv);
}
//-------------+++++++++++++++++++++-------------+++++++++++++++++++++-------------++++++++++

//Cadastrar pagamentos Cheques
function addElementPag() {
  
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2; 
  numi.value = num;
  id=num;
  
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = '<table width="100%" cellpadding="1" cellspacing="3"><tr><td width="21"><input name="n[]" type="text"  size="1" value="'+id+'"/></td><td width="92"><input name="banco[]" type="text" id="banco[]" size="15" /></td><td width="92"><input name="cheque[]" type="text" id="cheque[]" size="15" /></td><td width="94"><input name="valorPg[]" type="text" value="R$" size="15" /></td><td width="366"><input name="vencimento[]" type="text" id="vencimento[]" size="15" /></td></tr></table>';
  ni.appendChild(newdiv);
}
//-------------+++++++++++++++++++++-------------+++++++++++++++++++++-------------++++++++++





