//////////////////////////////////////////////////////////////////////////////////
////////			Uinet 1.0 [Update Information Internet ]			//////////
////////				   Webroom Soluções Interativa			        //////////
////////					A internet sob Medida						//////////
////////					http://www.webroom.com.br				    //////////
////////			  	  email:: webroom@webroom.com.br				//////////
////////////////////////////////////////////////////////////////////////////////// 
// Criado por   : Daniel Resende Borges
// Data Criação : 11/10/2004
//
// - Compatível com MSIE e Netscape.
////////////////////////////////////////////////////////////////////////////////// 

// Validação de campos numéricos

function isNumeric(e)
{

	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}

	return isNumericChar(keynum);

}

function isNumericChar(character) {

	if(((character>=0x30)&&(character<=0x39))||(character==8)||(character==13))
	{
		return true;
	}

	return false;
	
}

//Formatação de dados

function moneyFormat(value, decimalSeparator) {

	var result = "";
	var indexOfDecSeparator = value.indexOf(decimalSeparator);

	if (indexOfDecSeparator == -1) {
		result = (value + ".00");
	} else {
		var decimalValue = value.substring(indexOfDecSeparator);

		if (decimalValue.length == 1) {
			result = (value + "00");
		} else if (decimalValue.length == 2) {
			result = (value + "0");
		} else {
			result = value;
		}
	}

	return result;
	
}

//Submit do formulário quando o usuário pressiona <Enter>

function submitEnter(field,event)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (event) keycode = event.which;
else return true;

if (keycode == 13)
   {
		field.form.submit();
		return false;
   }
else
   return true;
}

//Popup Configuravel

	function PopConf(url,nome,tamanho){
		oWindow = window.open(url,nome,tamanho);
		//Posicao da janela no browser.
		oWindow.moveTo(300,80);
	}

//Popup padrão

	function PopPadrao(url,nome){
		window.open(url,nome,'width=600,height=400');
	}


//-------------------------------------------------------------
//Para validar o input da HORA com o evento : onblur

function ValidarHora(obj_hora){ 
//Pega o id do objeto.
var Id_hora = document.getElementById(obj_hora);
//Pega o valor do objeto.
var Hora = Id_hora.value;

	
	if (Hora.length == 5){	

		hrs=Hora.substring(0,2); 
		min=Hora.substring(3,5);
		//seg=Hora.substring(6,9); 
		
	  //alert('hrs '+ hrs); 
	  //alert('min '+ min); 
	  //alert('seg '+ seg); 
	  	  
		if( hrs>23 || min>59 || hrs<0 || min<0 ){ 		
			alert("Atenção, a hora está incorreta!"); 
			document.getElementById(obj_hora).value = '';
			document.getElementById(obj_hora).focus();
			return false; 
		} 
	}else if(Hora.length != 0){
		alert("Atenção, a hora está incorreta!"); 
		document.getElementById(obj_hora).value = '';
		document.getElementById(obj_hora).focus();
		return false; 
	}
	

	return Hora; 
} 


//-------------------------------------------------------------
//Para validar o input da DATA como o evento : onblur

function check_date(field) 
{

var checkstr = "0123456789"; 
var DateField = field; 
var Datevalue = ""; 
var DateTemp = ""; 
var seperator = "/"; 
var day; 
var month; 
var year; 
var leap = 0; 
var err = 0; 
var i; 
err = 0; 
DateValue = DateField.value; 

/* Deletando todos os caracteres exceto o 0..9 */ 
for (i = 0; i < DateValue.length; i++) 
{ 
if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) 
{ 
DateTemp = DateTemp + DateValue.substr(i,1); 
} 
} 
DateValue = DateTemp; 
/* Exectutando a data para 8 digitos - string*/ 
/* if entrada do ano com 2-digitos / exemplo 20xx */ 
if (DateValue.length == 6) 
{ 
DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); 
} 
if (DateValue.length != 8) 
{ 
err = 19; 
} 
/* Se o ano for errado = 0000 */ 
year = DateValue.substr(4,4); 
if (year == 0) 
{ 
err = 20; 
} 
/* Validando o mês*/ 
month = DateValue.substr(2,2); 
if ((month < 1) || (month > 12)) 
{ 
err = 21; 
} 
/* Validando o dia*/ 
day = DateValue.substr(0,2); 
if (day < 1) 
{ 
err = 22; 
} 
/* Validando ano Bissexto / fevereiro / dia */ 
if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) 
{ 
leap = 1; 
} 
if ((month == 2) && (leap == 1) && (day > 29)) 
{ 
err = 23; 
} 
if ((month == 2) && (leap != 1) && (day > 28)) 
{ 
err = 24; 
} 
/* Validando o mês */ 
if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) 
{ 
err = 25; 
} 
if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) 
{ 
err = 26; 
} 
/* if 00 houvendo entrada, sem erros */ 
if ((day == 0) && (month == 0) && (year == 00)) 
{ 
err = 0; day = ""; month = ""; year = ""; seperator = ""; 
} 
/* if sem erros, escrevo a data completa no Input-Field (e.x. 13/12/2001) */ 
if (err == 0) 
{ 
DateField.value = day + seperator + month + seperator + year; 
} 
/* Mensagem de erro if err != 0 */ 
else 
{ 
alert("Atenção, a data está incorreta!"); 
DateField.select(); 
DateField.focus();
} 
}

//-------------------------------------------------------------
//Para validar o input da DATA como o evento : onKeyUp

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

//-------------------------------------------------------------
//Para validar o input da DATA como o evento : onkeypress

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(document.all) { // Internet Explorer
	nTecla = evtKeyPress.keyCode; 
}else{ // Nestcape
	nTecla = evtKeyPress.which;
}

sValue = objForm[strField].value;

// Limpa todos os caracteres de formatação que
// já estiverem no campo.
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
fldLen = sValue.length;
mskLen = sMask.length;

i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;

while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == ":") || (sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if (bolMask) {
sCod += sMask.charAt(i);
mskLen++; }
else {
sCod += sValue.charAt(nCount);
nCount++;
}

i++;
}

objForm[strField].value = sCod;

if (nTecla != 8) { // backspace
if (sMask.charAt(i-1) == "9") { // apenas números...
return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
return true;
} }
else {
return true;
}
}

//---------------------------------------------------------------
//Validacao de senha.
function valida_senha()
{
	campo = document.getElementById("senha_hash");
	if (campo.value == ""){
		return false;
	}
	
	if(campo.value.length<6){
		alert('The password must be 6 or more digits.');
		campo.focus();
		return;
	}

	if (!/^[a-zA-Z]{1}[\w\@\&\%\*\-\.\/\:\!\=]{0,250}$/.test(campo.value)){
		alert('The password contains invalid data or do not begin with a letter.');
		campo.focus();
		return;
	}

	var i; 
	var num = 0, carac = 0;

	for (i = 0; i < campo.value.length; i++){
		var c = campo.value.charAt(i);
		// ha um numero
		if (((c >= "0") && (c <= "9")))
			num++;
		if (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")))
			carac++;
	}

	if (num < 3 || carac == 0){
		alert("The password must be numbers and letters (minimum 3 numbers)"); 
		campo.focus();	
		return;
	}

	if (/(1234|4321)/.test(campo.value)){
		alert("The password cannot have the sequence 1234 or 4321. Please, type a new password.");
		campo.focus();
		return;
	}

	s = campo.value
	hoje = new Date()
	ano = hoje.getYear()

	for (f=-2; f<=2; f++){
		n = s.indexOf(ano + f,0)
		if (n > -1){
			alert('It is not possible type the year as a password.');
			campo.focus();
			return;
		}
	}
}

//--------------------------------------------------------------------
//Validacao de controles.
function ValidarControles()
{
	var b = true;
	for(i=0; i<valida.length; i++)
	{
		var controle = document.getElementById(valida[i].value);
		if(controle.value=="")
		{
			if(b)
			{
				alert(valida[i].text);
				if(controle.type!="hidden")
					controle.focus();
			}

			//if(document.getElementById("v_"+valida[i].value)!=null)
			//	document.getElementById("v_"+valida[i].value).style.display='';
			b = false;
		}
		else
			if(document.getElementById("v_"+valida[i].value)!=null)
				document.getElementById("v_"+valida[i].value).style.display='none';
	}
	return b;
}

function checanumcartao(myCardNo, cartao){

	var myCardType;
	
	if(cartao == 1){
		//alert('Visa');
		myCardType = 'Visa';
	}
	if(cartao == 2){
		//alert('MasterCard');
		myCardType = 'MasterCard';
	}
	if(cartao == 3){
		//alert('AmEx');
		myCardType = 'AmEx';
	}
	if(cartao == 4){
		//alert('DinersClub');
		myCardType = 'DinersClub';
	}
	if(cartao == 5){
		//alert('Discover');
		myCardType = 'Discover';
	}
	//alert(checkCreditCard (myCardNo, myCardType));
	return checkCreditCard (myCardNo,myCardType);
}


function ValidarControlesCartao()
{
	var retorno = true;
	//checanumcartao(document.getElementById('card_number_0').value, document.getElementById('pgto_fk_0').value);
	
	if (!checanumcartao(document.getElementById('card_number_0').value, document.getElementById('pgto_fk_0').value)){
		alert("The number of the card and the card type is not compatible!");
		retorno =  false;
	}
	return retorno;
	
}


//--------------------------------------------------------------------
//Validacao de controles.
function ValidarControlesID(id)
{
	var b = true;
	for(i=0; i<eval('valida_'+id+'.length'); i++)
	{
		var controle = document.getElementById(eval('valida_'+id+'[i].value'));
		if(controle.value=="")
		{
			if(b)
			{
				alert(eval('valida_'+id+'[i].text'));
				if(controle.type!="hidden")
					controle.focus();
			}

			if(document.getElementById("v_"+eval('valida_'+id+'[i].value'))!=null)
				document.getElementById("v_"+eval('valida_'+id+'[i].value')).style.display='';
			b = false;
		}
		else
			if(document.getElementById("v_"+eval('valida_'+id+'[i].value'))!=null)
				document.getElementById("v_"+eval('valida_'+id+'[i].value')).style.display='none';
	}
	return b;
}

//--------------------------------------------------------------------
//Validacao de data.
function ValidaData(valor)
{
/*	alert( "Não tem barra: "+(valor.indexOf("/")<=0) );
	alert( "Tem menos de 2 barras: "+(valor.split("/").length<3) );
	alert( "Tem mais de 31 dias: "+(parseInt(valor.split("/")[0])>31) );
	alert( "Tem menos de 1 dia:"+(parseInt(valor.split("/")[0])<1) )
	alert( "Tem mais de 12 meses: "+(parseInt(valor.split("/")[1])>12) );
	alert( "Tem menos de 1 meses:"+(parseInt(valor.split("/")[1])<1) );
	alert( "O ano tem um número de caracteres diferente de 2 ou 4:"+(valor.split("/")[2].length!=4 && valor.split("/")[2].length!=2) );
	alert( "O ano é numérico:"+ (Inteiro(valor.split("/")[2])) );
*/
	if(valor.indexOf("/")<=0 || valor.split("/").length<3)
		return false;
	else
	{
		if(valor.split("/")[0].charAt(0)=="0")
			valor=valor.split("/")[0].charAt(1)+"/"+valor.split("/")[1]+"/"+valor.split("/")[2];
		if(valor.split("/")[1].charAt(0)=="0")
			valor=valor.split("/")[0]+"/"+valor.split("/")[1].charAt(1)+"/"+valor.split("/")[2];
		if(parseInt(valor.split("/")[0])>31 || parseInt(valor.split("/")[0])<1 || parseInt(valor.split("/")[1])>12 || parseInt(valor.split("/")[1])<1 || (valor.split("/")[2].length!=4 && valor.split("/")[2].length!=2) || !Inteiro(valor.split("/")[2]))
			return false;

		return true;
	}
}

//--------------------------------------------------------------------
//Validacao de inteiros - utilizado na funcao : ValidaData();
function Inteiro(valor)
{
	for(i=0; i<valor.length; i++)
	{
		if(isNaN(parseInt(valor.charAt(i))))
			return false;
	}
	return true;
}

//--------------------------------------------------------------------

//================================================================================================
// Verifica periodo final é menor que inicial.
//================================================================================================	

function IntervaloDatas(obj_data_entrada, obj_hora_entrada, obj_data_saida, obj_hora_saida){
//Pega o id do objeto.
var Id_data_entrada = document.getElementById(obj_data_entrada);
//Pega o valor do objeto.
var data_entrada = Id_data_entrada.value;
//Inicializa hora entrada.
hora_entrada = ''; 

//Pega o id do objeto.
var Id_data_saida = document.getElementById(obj_data_saida);
//Pega o valor do objeto.
var data_saida = Id_data_saida.value;
//Inicializa hora saida.
hora_saida = '';

	//Verifica se e para comparar horas.
	if((obj_hora_entrada != '')&&(obj_hora_saida != '')){
		//Pega o id do objeto.
		var Id_hora_entrada = document.getElementById(obj_hora_entrada);
		//Pega o valor do objeto.
		var hora_entrada = Id_hora_entrada.value;
		//Pega o id do objeto.
		var Id_hora_saida = document.getElementById(obj_hora_saida);
		//Pega o valor do objeto.
		var hora_saida = Id_hora_saida.value;
	}	

	 if ((data_entrada != '') && (data_saida != ''))
	 {
		var str_data_inicial = data_entrada;
		var str_data_final = data_saida;
	
		//Verifica se é uma data com horas ou nao.
		if((hora_entrada != '') && (hora_saida != '')){
			var str_hora_inicial = hora_entrada;
			var str_hora_final = hora_saida;		
			
			data_inicial = new Date(str_data_inicial.substr(6,4),str_data_inicial.substr(3,2)-1,str_data_inicial.substr(0,2),str_hora_inicial.substr(0,2),str_hora_inicial.substr(3,2),str_hora_inicial.substr(6,2));
			data_final = new Date(str_data_final.substr(6,4),str_data_final.substr(3,2)-1,str_data_final.substr(0,2),str_hora_final.substr(0,2),str_hora_final.substr(3,2),str_hora_final.substr(6,2));
		}else{
			data_inicial = new Date(str_data_inicial.substr(6,4),str_data_inicial.substr(3,2)-1,str_data_inicial.substr(0,2));
			data_final = new Date(str_data_final.substr(6,4),str_data_final.substr(3,2)-1,str_data_final.substr(0,2));	
		}
			
	/*	alert(str_data_inicial.substr(6,4));
		alert(str_data_inicial.substr(3,2)-1);
		alert(str_data_inicial.substr(0,2));
		alert(data_inicial);
		alert(str_data_final.substr(6,4));
		alert(str_data_final.substr(3,2)-1);
		alert(str_data_final.substr(0,2));
		alert(data_final);			

		alert(data_inicial);
		alert(data_final);
	*/		
		 //Compara datas.
		 if (data_inicial > data_final)
		  {
			alert('A data de saída não pode ser menor que a data de entrada!');
			//Limpa data de saida.
			document.getElementById(obj_data_saida).value = '';		
			if (hora_saida != ''){
				//Limpa hora de saida.
				document.getElementById(obj_hora_saida).value = '';					
			}
			document.getElementById(obj_data_saida).focus();
			return(false);
		  }     
			
		return(true);
	 }
}	 
//================================================================================================

//================================================================================================
// Mensagem depois do post dos dados.
//================================================================================================	


function espera()
{
	
	document.getElementById("enviar").innerHTML="Processing ...<br><br>";
	document.getElementById("enviar2").style.display='none';
	
	return true;
}
//================================================================================================

//================================================================================================
// Mensagem se o post dos dados obteve algum erro.
//================================================================================================	
function espera_Post()
{
	
	document.getElementById("enviar").style.display='none';
	document.getElementById("enviar2").style.display='';
		
	return false;
}
//================================================================================================

//================================================================================================
//Exibe o codigo do flash caso se o tipo do arquivo for FLASH.
// arquivo : tipo de arquivo imagem ou flash.
// caminho : caminho relativo do arquivo.
// campo_valor : id do campo com o nome do arquivo.
// campo_destino : id do campo onde sera armazenado o codigo html do arquivo flash.
//================================================================================================
function TipoArquivo(arquivo, caminho, campo_valor, campo_destino){
	if (arquivo == "flash"){
		document.getElementById(campo_destino).value = ' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"  width="100%" height="100%"><param name="movie" value="'+caminho+'/'+document.getElementById(campo_valor).value+'"><param name="quality" value="high"><embed src="'+caminho+'/'+document.getElementById(campo_valor).value+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  width="100%" height="100%"></embed></object> '
	}
}	
//================================================================================================


//================================================================================================
//VALIDACAO MOEDA:
//================================================================================================
	function VerificaMoeda(controle, erro) {
		if (controle.value != '' && !ValidaMoeda(controle.value)) {
			alert(erro);
			controle.focus();
			return false;
		}
		return true;			
	}
	
	function ValidaMoeda(valor){
		expr1 = /^[0-9]+,+[0-9]{1,2}$/i;
		if((valor.search(expr1) == -1)&&(!Inteiro(valor)))		
			return false;
		return true;
	}
//================================================================================================

//===========================================================================
// Retorna valores padrão Brasil
function NormalizeMoneyBR(text) {
  var i, a, strFinal, dec;
  i = 0;
  strFinal = '';
  dec = true;

  for (i = text.length; i >= 0; i--) {
    a = text.charCodeAt(i);

    if ((a >= 48 && a <= 57) || (i == 0 && a == 45) || (dec && a == 44))
      strFinal = text.charAt(i) + strFinal;

    if (a == 44)
      dec = false

  }
  return strFinal;
}

//===========================================================================
// Retorna valores padrão US
function NormalizeMoneyUS(text) {
  var i, a, strFinal, dec;
  i = 0;
  strFinal = '';
  dec = true;

  for (i = text.length; i >= 0; i--) {
    a = text.charCodeAt(i);

    if ((a >= 48 && a <= 57) || (i == 0 && a == 45) || (dec && a == 46))
      strFinal = text.charAt(i) + strFinal;

    if (a == 46)
      dec = false

  }
  return strFinal;
}

//Caracteres permitidos para Money US como . (ponto), - (menos) e + (mais)
function MoneyUSChar()
{

if(document.all) { // Internet Explorer
	if(((event.keyCode>=0x30)&&(event.keyCode<=0x39))||(event.keyCode==8)||(event.keyCode==13)||(event.keyCode==46)||(event.keyCode==45)||(event.keyCode==43))
	{
	return true;
	}
	event.keyCode=0;
}
}
//===========================================================================

//===========================================================================
//Para validar um campo inteiro como o evento : onkeypress

function JavaInteiro()
{

if(document.all) { // Internet Explorer
	if(((event.keyCode>=0x30)&&(event.keyCode<=0x39))||(event.keyCode==8)||(event.keyCode==13))
	{
	return true;
	}
	event.keyCode=0;
}
else{ // Nestcape
	if(((event.which>=0x30)&&(event.which<=0x39))||(event.which==8)||(event.which==13))
	{
	return true;
	}
	event.which=0;
}
}

//===========================================================================
//===========================================================================
// NormalizeNumber - Retorna somente 0-9 ou - se tiver = true ou 1 
function NormalizeNumber(text,minus) {
  var i, a, strFinal;
  i = 0;
  strFinal = '';

  for (i = 0; i < text.length; i++) {
    a = text.charCodeAt(i);

    if ((a >= 48 && a <= 57) || (minus.length > 0 && i == 0 && a == 45))
      strFinal = strFinal + text.charAt(i);

  }
  return strFinal;
}	

//===========================================================================
//APAGA O REGISTRO CORRESPONDENTE.
//===========================================================================
function DeleteReg(){
	var confirma = confirm("Do you want delete this data ?"); 
	return(confirma);
}

//===========================================================================
//ESVAZIA O CARRINHO.
//===========================================================================
function EmptyCart(){
	var confirma = confirm("Do you want empty cart ?"); 
	return(confirma);
}
//===========================================================================
//EXIBE E OCULTA OS ID´s
//===========================================================================
function ExibeOculta(exibe, oculta, total_pedido, vlr_debito, want_split, ind_atual){

	//alert("pedido: "+total_pedido);
	//alert("total debito: "+document.getElementById(vlr_debito).value);
	if (vlr_debito != "" && want_split != ""){
		if (parseFloat(document.getElementById(vlr_debito).value) == parseFloat(total_pedido)){
			alert('Please, it diminishes the value of the payment in this cartao of credit!');
			document.getElementById(want_split).value = "0";
			return false;	
		}else{

			if (want_split != 'want_split_0'){
				
				//Verifica os valores dos debitos ate o indice atual.
				vlr_tot_debito = 0;
				for(i=0; i<=ind_atual; i++){
					if(document.getElementById('vlr_debito_cartao_'+i).value != null){
						//alert("cartao "+i+" "+document.getElementById('vlr_debito_cartao_'+i).value);
						vlr_tot_debito += parseInt(document.getElementById('vlr_debito_cartao_'+i).value);	
					}
				}
				//alert("pedido: "+total_pedido);
				//alert("total vlr_tot_debito: "+vlr_tot_debito);					
				
				//Verifica se os debitos ate o indice atual e igual ao total do pedido.
				if (parseFloat(total_pedido) == parseFloat(vlr_tot_debito)){
					alert('Please, it diminishes the value of the payment in this cartao of credit!');
					document.getElementById(want_split).value = "0";
					return false;	
				}
			}
		}
	}
	

	if (exibe != ""){
		document.getElementById(exibe).style.display='';
	}
	if (oculta != ""){
		var soma_deb = 0;
		for(i=oculta; i<4; i++){
			
			//Desmarca o drop down da tabela a ser oculta.
			if(i < 3){
				document.getElementById('want_split_'+i).options[0].selected = true;
			}
			
			//Soma os debitos das tabelas que serao ocultas.
			if(document.getElementById('vlr_debito_cartao_'+i).value != null){
				soma_deb += parseInt(document.getElementById('vlr_debito_cartao_'+i).value);
			}
		
			//Oculta tabela.
			document.getElementById('tab_'+i).style.display='none';
		}
		
		//Atualiza valores.	
		document.getElementById(vlr_debito).value = parseInt(document.getElementById(vlr_debito).value) + parseInt(soma_deb);
	}

	return true;
}
//===========================================================================

