<!---// JavaScript Document 

function verificaCheckbox(obj) {

	alert(obj.checked);	
}
		
function openAjax() { 
	
		var objAjax;
		
		try {
			objAjax = new XMLHttpRequest(); // XMLHttpRequest para browsers mais populares, como: Firefox, Safari, dentre outros. 
		}
		catch(ee) { 
			try {	
				objAjax = new ActiveXObject(" Msxml2.XMLHTTP"); // Para o IE da MS 
			}
			catch(e) { 
				try {objAjax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS 
			}catch(e) {
				objAjax = false; 
		} 
	} 
} 
	return objAjax; 
} 

function funResetCombos(ids){

	Objs = ids.split(",");
	
	for(i=0;i < Objs.length;i++){
	
	elemento = eval('document.getElementById("' + Objs[i] + '")');
	elemento.value = '';
	
	}
}

function goAjax(url, metodo, modo, objContainer, parametros, objWait) {

		objWait.className = "";
	
		if (navigator.appName == "Microsoft Internet Explorer") {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
		}
		else{
				xmlhttp = new XMLHttpRequest();
		}
			
		if(metodo == "GET") {
			xmlhttp.open("GET", url, modo);
		} 
		else {
			xmlhttp.open("POST", url, modo);
			xmlhttp.setRequestHeader("Content-Type",	"application/x-www-form-urlencoded; charset=iso-8859-1");
			xmlhttp.setRequestHeader("Cache-Control", "no-store,	no-cache, must-revalidate");
			xmlhttp.setRequestHeader("Cache-Control", "post-check=0,	pre-check=0");
			xmlhttp.setRequestHeader("Pragma", "no-cache");
		}
		
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4) {
			
			
				if (xmlhttp.status==200) {
					retorno=xmlhttp.responseText
					retorno = retorno.replace(/\+/g," ");
					retorno = unescape(retorno);
					
					document.getElementById(objContainer).innerHTML=retorno;
				}
				else if (xmlhttp.status==403) {
					alert("Sua sessão expirou!\nVocê será enviado à tela de acesso ao Sistema.");
					window.location.href = "default.asp";
				}			
				
				objWait.className = "divOculta";
				
			}
		
		}
	
		if(metodo == "GET") {
			xmlhttp.send(null);
		} else {
			xmlhttp.send(parametros);
		}
	
}
	
	
function abrejanela_(url) {
	window.open(url,  "_blank" , "width=200 , height= 300, statusbar=no, scrollsbars=no, top=1 , left=1 , resizable=no") 
}

function abrecentro(url,largura,altura, scr, target){ 
  var w = largura;
  var h = altura;
  var wp = (screen.width / 2)- (w / 2);
  var hp = (screen.height / 2)  - (h / 2);
  
  if (scr == null) {
  	scr='no';
  }
  
  var janela = window.open(url, '' + target + '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scr+',resizable=no,copyhistory=no,width='+w+',height='+h+',left='+wp+', top='+hp+',screenX=100,screenY=200');
  janela.focus()
  janela = null
}

function enter(funcao, e) {
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) {
		eval(funcao)
	}
}

//FUNCOES
function abreform(frm, w, h, t, scr) {
    if (scr == null) {
	  scr = 'no'
	}
	var wp = (screen.width / 2)- (w / 2);
	var hp = (screen.height / 2) - (h / 2);

	var frm = window.open(frm,  t , "width=" + w + "px,height="+ h + "px,resizable=no,scrollbars="+scr+",toolbars=no,titlebar=no,top="+hp+", left="+wp+",status=no,");
    frm.focus();
}

//-----------------------------------------------------
//Funcao: MascaraMoeda
//Sinopse: Mascara de preenchimento de moeda
//Parametro:
//   objTextBox : Objeto (TextBox)
//   SeparadorMilesimo : Caracter separador de milésimos
//   SeparadorDecimal : Caracter separador de decimais
//   e : Evento
//Retorno: Booleano
//Data Criação: 15/02/2005
//-----------------------------------------------------
function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
		
		var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}

function FormataTelefone(campo,e) {
var strDigitos = "1234567890"; //Valores aceitos
	if (FormataDigitos(campo,e,strDigitos) != "OK")
		return FormataDigitos(campo,e,strDigitos);
var separador = '-'; 
var conjunto1 = 4; 
if (campo.value.length == 0){ 
campo.value = "(" + campo.value; 
} 
if (campo.value.length == 3){ 
campo.value = campo.value + ") "; 
} 
if (campo.value.length == conjunto1 + 5){ 
campo.value = campo.value + separador; 
} 
}
//######################################
//# VALIDA TECLAS INVÁLIDAS NOS CAMPOS #
//######################################
function fnValidaCampos(campo,e) {
//	alert("O nº da tecla é: "+e.keyCode);
// Retira Aspas simples, Aspas duplas, Apóstofre, Cerquinha ou jogo da velha, Exclamação e Crase   
   if (e.keyCode > 32 && e.keyCode < 36 || e.keyCode == 39 || e.keyCode == 96) 
	  return false;
	return "OK";
}	
//################ 
//# FORMATA CEP  # 
//################ 
function FormataCep(campo,e) {
	var strDigitos = "1234567890"; //Valores aceitos
	if (FormataDigitos(campo,e,strDigitos) != "OK")
		return FormataDigitos(campo,e,strDigitos);
	var vr = new String(campo.value); //Guarda o valor do campo
	vr = vr.replace(".", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (e.keyCode != 9 && e.keyCode != 8){
		//if (tam > 2 && tam < 5)
			//campo.value = vr.substr(0,2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam <10)
			campo.value = vr.substr(0,2) + '' + vr.substr(2,3) + '-' + vr.substr(5,tam-5);
	}
}
//################ 
//# FORMATA CPF  # 
//################ 
function FormataCPF(campo,e) {
	var strDigitos = "1234567890"; //Valores aceitos
	if (FormataDigitos(campo,e,strDigitos) != "OK")
		return FormataDigitos(campo,e,strDigitos);
	var vr = new String(campo.value); //Guarda o valor do campo
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (e.keyCode != 9 && e.keyCode != 8){
		if (tam > 3 && tam < 7) {
			campo.value = "";
			campo.value = vr.substr(0,3) + '.' + vr.substr(3, tam);
		}
		if (tam >= 7 && tam <10) {
			campo.value = "";
			campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
		}
		if (tam >= 10 && tam < 12) {
			campo.value = "";
			campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
		}
	}
}

//###################################
//# Coloca mascara nos campos datas #
//###################################
function FormataData(campo,e){
  
   var strDigitos = "1234567890"; //Valores aceitos
   if (FormataDigitos(campo,e,strDigitos) != "OK")
	 return FormataDigitos(campo,e,strDigitos);
   var vr = new String(campo.value); //Guarda o valor do campo
   vr = vr.replace("/","");
   vr = vr.replace("/","");
   tam = vr.length + 1;
   if (e.keyCode != 9 && e.keyCode != 8){
     if (tam > 2 && tam < 5) {
	   campo.value = "";
	   campo.value = vr.substr(0,2) + '/' + vr.substr(2, tam);
	 }
	 if (tam >= 5 && tam < 8) {
	   campo.value = "";
	   campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,tam-4);
	 }
   }
  }

//###################################
//# Coloca mascara nos campos datas #
//###################################
function Mascara (formato, keypress, objeto){
   campo = eval (objeto);
   VerifiqueTAB=true;
   if (formato=='DATA'){
     Separador = '/'; 
     conjunto1 = 2;
     conjunto2 = 5;
     if (campo.value.length == conjunto1){
       Dia = campo.value.substring(0,campo.value.indexOf(Separador))
       if (Dia.length == 1) {
         campo.value = 0 + campo.value; }
       else {   
         campo.value = campo.value + Separador; }
     }    
	 else if (campo.value.length == conjunto2){
       Mes = campo.value.substring(eval(campo.value.indexOf(Separador) + 3),campo.value.lastIndexOf(Separador)); 
       //alert(Mes);
       if (Mes.length == 1) {
         campo.value = campo.value.substring(0,campo.value.indexOf(Separador) + 1) + 0 + campo.value.substring(eval(campo.value.indexOf(Separador) + 1),campo.value.lastIndexOf(Separador)) + Separador; }
         //campo.value = campo.value.substring(0,campo.value.indexOf(Separador) + 1) + 0 + campo.value.substring(eval(campo.value.indexOf(Separador) + 1),campo.value.lastIndexOf(Separador)) + Separador;}
       else {   
         campo.value = campo.value + Separador;
       }
     }
   }
}

//################################
//# VERIFICA SE CAMPO É NUMERICO #
//################################
function FormataNumero(campo,e) {
	var strDigitos = "1234567890"; //Valores aceitos
	if (FormataDigitos(campo,e,strDigitos) != "OK")
		return FormataDigitos(campo,e,strDigitos);
}

function FormataNumVirgula(campo,e) {
	var strDigitos = "1234567890,"; //Valores aceitos
	if (FormataDigitos(campo,e,strDigitos) != "OK")
		return FormataDigitos(campo,e,strDigitos);
}

function validaDecimal(valor) {
	var primeira
	valor = replaceChars(valor, "." , ",")
	primeira = valor.indexOf(',')
	if (valor.indexOf(',', primeira + 1) != -1) {
		return false
	}
	else {
		return true
	}
}

//################
//# FORMATA CNPJ #
//################
function FormataCNPJ(campo,e) {
	var strDigitos = "1234567890"; //Valores aceitos
	if (FormataDigitos(campo,e,strDigitos) != "OK")
		return FormataDigitos(campo,e,strDigitos);
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1 ;
	if (e.keyCode == 13) {
	   return true;
	}   
	else if (e.keyCode != 9 && e.keyCode != 8) {
		if (tam >= 3 && tam < 6)
			campo.value = vr.substr(0,2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
	}
}

//###################
//# REPLACE -- SUBSTITUI VALORES #
//###################

function replaceChars(entry, out, add) {
	var pos
	while (entry.indexOf(out)>-1) {
	pos= entry.indexOf(out);
	entry = "" + (entry.substring(0, pos) + add + 
	entry.substring((pos + out.length), entry.length));
	}
return entry
}

//###################
//# FORMATA DIGITOS #
//###################
function FormataDigitos(campo,e,digitos) {
	//Verificação dos digitos:
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13 || whichCode == 8 || whichCode == 0 || whichCode==9)
		return true;
	key = String.fromCharCode(whichCode);
	if (digitos.indexOf(key) == -1)
		return false;  // Chave inválida
	return "OK";
}

//###########################
//# LIMPA CAMPOS CNPJ E CPF #
//###########################
function fnLimpa(theCampo) {
	// elimina .,- e /
	var sCampo;
	
	sCampo = theCampo;
	for (i=0; i<sCampo.length; i++) {
		if (sCampo.charAt(i) == ".")
			sCampo = sCampo.replace(".","");
			
		if (sCampo.charAt(i) == "-")
			sCampo = sCampo.replace("-","");

		if (sCampo.charAt(i) == "/")
			sCampo = sCampo.replace("/","");
	}
	
	return sCampo.toString();
}
//###################################
//# VALIDA DV DOS CAMPOS CNPJ E CPF #
//###################################
function focusNext(campo, proximocampo, situacao,e) {
    var sCampo;
    if (e.keyCode != 37 & e.keyCode != 38 & e.keyCode != 39 & e.keyCode != 40) {
	    if (e.keyCode == 13) {
		   proximocampo.focus();
		}   
		if (campo.value.length == (campo.maxLength)) 
		   proximocampo.focus();
	}	   
	return false;
}  

//###############################
//# VALIDA OS CAMPOS CNPJ E CPF #
//###############################
function fnValida(theForm)
{
	var retCNPJ, retCPF;
	
	retCNPJ = fnValidaCNPJ(theForm.txtCNPJ.value);
	
	if (retCNPJ == 1)
	{
		alert("CNPJ ausente.");
		theForm.txtCNPJ.focus();
		return (false);
	}
	if (retCNPJ == 2) {
		alert("CNPJ inválido.");
		theForm.txtCNPJ.focus();
		return (false);
	}

	if (retCNPJ == 3) {
		alert("CNPJ deve conter apenas números.");
		theForm.txtCNPJ.focus();
		return (false);
	}
	
	if (retCNPJ == 4) {
		alert("CNPJ inválido.");
		theForm.txtCNPJ.focus();
		return (false);
	}

	retCPF = fnValidaCPF(theForm.txtCPF.value);
	
	if (retCPF == 1) {
		alert("CPF do Responsável ausente.");
		theForm.txtCPF.focus();
		return (false);
	}

	if (retCPF == 2) {
		alert("CPF do Responsável inválido.");
		theForm.txtCPF.focus();
		return (false);
	}


	if (retCPF == 3) {
		alert("CPF do Responsável deve conter apenas números.");
		theForm.txtCPF.focus();
		return (false);
	}
	
	if (retCPF == 4) {
		alert("CPF do Responsável inválido.");
		theForm.txtCPF.focus();
		return (false);
	}

    if (theForm.T1.value.length != "")
    {
		if (theForm.T1.value.length != 4) 
		{
		   alert('Código impresso abaixo inválido, digite os 4 caracteres da imagem.');
		   theForm.T1.focus();
		   return false;
		} 
	}
	else
	{ 	
	   alert('Código impresso abaixo inválido, digite os 4 caracteres da imagem.');
	   theForm.T1.focus();
	   return false;
    }

	return (true);
}

//###############
//# VALIDA CNPJ #
//###############
function fnValidaCNPJ(theCNPJ) {

	if (theCNPJ == "")
		return 1;

	if (theCNPJ.length != 18)
		return 2;
    
    var checkOK = "0123456789.-/";
	var checkStr = theCNPJ;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";

	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
		
		allNum += ch;
	}

	if (!allValid)
		return 3;
		
	if (!fnChecaDVCnpj(theCNPJ))
		return 4;

	return 0;
}

//###################
//# CALCULA DV CNPJ #
//###################
function fnChecaDVCnpj(theCNPJ) {
	var sCnpj, i, c, dv, d1;
	
	sCnpj = fnLimpa(theCNPJ);
	
	if (sCnpj == "00000000000000" || sCnpj == "11111111111111" ||
	    sCnpj == "22222222222222" || sCnpj == "33333333333333" ||
	    sCnpj == "44444444444444" || sCnpj == "55555555555555" ||
	    sCnpj == "66666666666666" || sCnpj == "77777777777777" ||
	    sCnpj == "88888888888888" || sCnpj == "99999999999999")
	    return false;
	    
    c = sCnpj.substr(0,12);
	dv = sCnpj.substr(12,2);
	d1 = 0;
	for (i = 0; i < 12; i++) {
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
	if (d1 == 0)
		return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9)
		d1 = 0;
	if (dv.charAt(0) != d1)
		return false;
	d1 *= 2;
	for (i = 0; i < 12; i++) {
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9)
		d1 = 0;
	if (dv.charAt(1) != d1) {
		return false;
	}
	return true;
}

//##############
//# VALIDA CPF #
//##############
function fnValidaCPF(theCPF) {
	if (theCPF == "" || theCPF.length < 1)
		return 1;

	if (theCPF.length != 14)
		return 2;

	var checkOK = "0123456789.-";
	var checkStr = theCPF;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";

	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
		
		allNum += ch;
	}

	if (!allValid)
		return 3;
		
	if (!fnChecaDVCpf(theCPF))
		return 4;

	return 0;
}

//##################
//# CALCULA DV CPF #
//##################
function fnChecaDVCpf(theCPF) {
	var sCpf;
	var iSoma, iResto;
	
	sCpf = fnLimpa(theCPF);
	
	if (sCpf == "00000000000" || sCpf == "11111111111" ||
	    sCpf == "22222222222" || sCpf == "33333333333" ||
	    sCpf == "44444444444" || sCpf == "55555555555" ||
	    sCpf == "66666666666" || sCpf == "77777777777" ||
	    sCpf == "88888888888" || sCpf == "99999999999")
	    return false;
	    
	iSoma = 0;
	
	for (i=0; i<9; i++)
		iSoma += parseInt(sCpf.charAt(i))*(10-i);

	iResto = 11 - (iSoma % 11);
	if (iResto == 10 || iResto == 11)
		iResto = 0;
		
	if (iResto != parseInt(sCpf.charAt(9)))
		return false;
		
	iSoma = 0;
	
	for (i=0; i<10; i++)
		iSoma += parseInt(sCpf.charAt(i))*(11-i);

	iResto = 11 - (iSoma % 11);
	if (iResto == 10 || iResto == 11)
		iResto = 0;
		
	if (iResto != parseInt(sCpf.charAt(10)))
		return false;
	
	return true;
}


//###################################
//# Verifica campo data se é válido #
//###################################
function isDateJS(Data){
   var Dia = Data.substring(0,Data.indexOf("/")); 
   var Mes = Data.substring(eval(Data.indexOf("/") + 1),Data.lastIndexOf("/")); 
   var Ano = Data.substring(eval(Data.lastIndexOf("/") + 1),Data.length); 

   if ((Data == "") || (Data.length != 10)) {
     return false; 
   }
   if (Data.length > 10 || Data.lenght < 6) {
     return false; }
   //Se a Data for apenas números retorna inválido
   else if (!isNaN(Data)) {
     return false;
   }

   for (i=0;i<=Data.length;i++){
     if (isNaN(Data.charAt(i))){
       Separador = Data.charAt(i); 
       //SE O SEPARADOR FOR DIRERENTE DE "/" , RETORNA DATA INVALIDA.
       if (Separador != "/"){
         return false; 
       }
       Dia = Data.substring(0,Data.indexOf(Separador)); 
       Mes = Data.substring(eval(Data.indexOf(Separador) + 1),Data.lastIndexOf(Separador)); 
       Ano = Data.substring(eval(Data.lastIndexOf(Separador) + 1),Data.length); 
     } 
   } 
   if (isNaN(Dia)){
     return false;  }
   else if (Dia.length < 1 || Dia.length > 2) {
     return false;
   }
   if (isNaN(Mes)){
     return false; }
   else if (Mes.length < 1 || Mes.length > 2 ) {
     return false; }
   else if ((Mes==4 || Mes==6 || Mes==9 || Mes==11) && Dia==31) {
     //alert("Este mês não tem 31 dias!");
     return false; 
   }		 
   if (isNaN(Ano)){
     return false; }
   else if (Ano.length < 2 || Ano.length > 4){
     return false;
   } 
   if (Mes == 2){
     var bissexto = (Ano % 4 == 0 && (Ano % 100 != 0 || Ano % 400 == 0));
     if (Dia>29 || (Dia==29 && !bissexto)) {
       //alert("Fevereiro não possue "+Dia+" dias.");
       return false; }
   }
   else if (Dia < 1 || Dia > 31 || Mes < 1 || Mes > 12){
     return false; }

   return true;   
}


//############################
//# Função para retirar aspa #
//############################
function fnRemoveAspa(campo) {
	for (var i = 0; i <= campo.value.length; i++) {
		if (campo.value.substr(i,1) == "'") {
			campo.value = campo.value.substr(0,i) + "" + campo.value.substr(i+1);
		}
	}
}

function fnSair(mensagem,sURL) {
   if (!confirm(mensagem)) 
     return false;
   location.href= sURL + 'default.asp';
   return true;
}


function calculaIdade(data,dataHoje) {

	x = data.split("/");
	h = dataHoje.split("/");

	anosProvisorio = h[2] - x[2];

	if(h[1] < x[1]) {
		anosProvisorio -= 1;
	}
	else if(h[1] == x[1]) {
		if(h[0] < x[0]) {
			anosProvisorio -= 1;
		}
	}

	return anosProvisorio;
}



function funMoveList(MenuOrigem, MenuDestino){
    var arrMenuOrigem = new Array();
    var arrMenuDestino = new Array();
    var arrLookup = new Array();
    var i;
    for (i = 0; i < MenuDestino.options.length; i++){
        arrLookup[MenuDestino.options[i].text] = MenuDestino.options[i].value;
        arrMenuDestino[i] = MenuDestino.options[i].text;
    }
    var fLength = 0;
    var tLength = arrMenuDestino.length;
    for(i = 0; i < MenuOrigem.options.length; i++){
        arrLookup[MenuOrigem.options[i].text] = MenuOrigem.options[i].value;
        if (MenuOrigem.options[i].selected && MenuOrigem.options[i].value != ""){
            arrMenuDestino[tLength] = MenuOrigem.options[i].text;
            tLength++;
        }
        else{
            arrMenuOrigem[fLength] = MenuOrigem.options[i].text;
            fLength++;
        }
    }
    arrMenuOrigem.sort();
    arrMenuDestino.sort();
    MenuOrigem.length = 0;
    MenuDestino.length = 0;
    var c;
    for(c = 0; c < arrMenuOrigem.length; c++){
        var no = new Option();
        no.value = arrLookup[arrMenuOrigem[c]];
        no.text = arrMenuOrigem[c];
        MenuOrigem[c] = no;
    }
    for(c = 0; c < arrMenuDestino.length; c++){
        var no = new Option();
        no.value = arrLookup[arrMenuDestino[c]];
        no.text = arrMenuDestino[c];
        MenuDestino[c] = no;
   }
}

/********************************************************/
/*														*/
/* Author:..................Derek J. Klingman			*/
/*														*/
/* Date Started:............Tuesday, February 26, 2003	*/
/*														*/
/* Date Completed:..........Friday, February 28, 2003	*/
/*														*/
/* Function Name:...........isCurrency(stringValue)		*/
/* 														*/
/* File Name:...............isCurrency.js				*/
/*														*/
/* Version:.................1.0							*/
/*														*/
/* Platform Test Under:.....IE6.0						*/
/*														*/
/* Operating System:........WinXP Pro					*/
/*														*/
/* Description:											*/
/* 		This function will take a string value and 		*/
/*		break it apart and check for valid US currency 	*/
/*		values.  If the string is a valid US currency 	*/
/*		value the function will return true.  If the 	*/
/*		function encounters an error while validation	*/
/*		the function will display a error message to 	*/
/*		the client and return false.					*/
/********************************************************/

function isCurrency(f)
{
	var nNum = 0;			// Total numbers for currency value.
	var nDollarSign = 0;	// Total times a dollar sign occurs.
	var nDecimal = 0;		// Total times a decimal point occurs.
	var nCommas = 0;		// Total times a comma occurs.
	var txtLen;				// Length of string passed.
	var xTxt;				// Assigned object passed.
	var sDollarVal;			// Assigned dollar amount with or without commas.
	var bComma;				
	var decPos;				// Assigned value of numbers or positions after decimal point.
	var nNumCount = 0;		// Total number between commas.
	var i;					// For forloop indexing.
	var x;					// Assigned each indivual character in string.
	
	// Set the xTxt variable to the object passed to this function.
	// Assign the length of the string to txtLen.
	xTxt = f.txt;
	txtLen = xTxt.value.length

	for(i = 0; i < txtLen; i++)
	{
		// Assign charater in substring to x.
		x = xTxt.value.substr(i, 1);
		
		
		if(x == "$")
			nDollarSign = nDollarSign + 1; // Sum total times dollar sign occurs.
		else if(x == ".")
			nDecimal = nDecimal + 1; // Sum total times decimal point occurs.
		else if(x == ",")
			nCommas = nCommas + 1; // Sum total times comma occurs.
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; // If the character is a number sum total times a number occurs.
		else
		{
			// Error occurs if any other character value is in the string
			// othere then the valid characters.
			alert("ERROR! \n\nYou have entered an illegal value!\nPlease enter only: Dollar" +
				  " Signs, Commas, Decimal Points, and numbers between 0...9!");
			return false;
		} // end else
	} // end for

	if(nDollarSign > 1)
	{
		alert("ERROR! \n\nYou have entered more then one dollar sign!\nPlease only enter one!");
		return false;
	} // end if
		
	if(nDecimal > 1)
	{
		alert("ERROR! \n\nYou have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} // end if
		
	if(nDollarSign == 1)
	{
		// Make sure dollar sign in the first character in string
		// if there is a dollar sign present.
		if(xTxt.value.indexOf("$") != 0)
		{
			alert("ERROR!  \n\nThe dollar sign you entered is not in the correct position!");
			return false;
		} // end if
	}// end if
	
	if(nDecimal == 1)
	{
		// Get the number of numbers after the decimal point in
		// the string if there is a decimal point present
		decPos = (txtLen - 1) - xTxt.value.indexOf(".");
		
		// Floating point cannot be more then two.
		// Valid format after decimal point.
		/**********************************/
		/*   $#.##, $#.#, $.#, $#., $.##  */
		/**********************************/
		if(decPos > 2)
		{
			alert("ERROR! \n\nThe decimal point you entered is not in the correct position!");
			return false;
		} // end if
	} // end if
	
	if(nCommas == 0)
	{
		// If no commas are present value is a valid US
		// currency.
		return true;
	}
	else
	{
		// Get total number of dollar number(s), removing
		// floating point numbers or cents.
		nNum = nNum - decPos;
		
		// Determine if dollar sign is in string so to be 
		// removed.
		// After determining dollar sign, assign sDollarVal
		// numbers and comma(s)
		if(xTxt.value.indexOf("$", 0) == 0)
			sDollarVal = xTxt.value.substr(1, (nNum + nCommas));
		else
			sDollarVal = xTxt.value.substr(0, (nNum + nCommas));
		
		
		// Determine if a zero is the first number or if a
		// comma is the first or last character in the string.
		if(sDollarVal.lastIndexOf("0", 0) == 0 )
		{
			alert("ERROR! \n\nYou cannot start the dollar amount out with a zero!");
			return false;
		}
		else if(sDollarVal.lastIndexOf(",", 0) == 0)
		{
			alert("ERROR! \n\nYou cannot start the dollar amount out with a comma!");
			return false;
		}
		else if(sDollarVal.indexOf(",", (sDollarVal.length - 1)) == (sDollarVal.length - 1))
		{
			alert("ERROR! \n\nYou cannot end the dollar amount with a comma!");
			return false;
		}
		else
		{
			// Initialize bComma indicating a comma has not been
			// occured yet.
			bComma = false;
			for(i = 0; i < sDollarVal.length; i++)
			{
				// Assign charater in substring to x.
				x = sDollarVal.substr(i, 1);
				
				if(parseInt(x) >= 0 || parseInt(x) <= 9)
				{
					// If x is a number add one to the number counter.
					nNumCount = nNumCount + 1;
					
					// Sense comma(s) are present number counter cannot
					// be more then three before the first or next comma.
					if(nNumCount > 3)
					{
						alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;
					} // end if
				}
				else
				{
					// If the number counter is less then three and
					// the comma indicator is true the comma is either
					// mis-placed or there are not enough values.
					if(nNumCount != 3 && bComma)
					{
						alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;
					} // end if
					
					// Reset the number counter back to zero.
					nNumCount = 0;
					
					// Set the comma indicator to true indicating
					// that the first comma has been found and that
					// there now MUST be three numbers after each
					// comma until the loop hits the end.
					bComma = true;
				} // end if
			} // end for
			
			// Determine if after the loop ended that there
			// was a total of three final numbers after the
			// last comma.
			if(nNumCount != 3 && bComma)
			{
				alert("ERROR! \n\nYou have a mis-placed comma!");
				return false;
			} // end if
		} // end if
	} // end if
	
	// Return true indicating that the value is a valid
	// currency.
	return true;
}

		function DG_funMarcarTodas(obj) {
			
			DG_TOTAL = document.getElementById("DG_TOTAL_LINHAS").value;
			if (obj.checked) {
					valor = true	
			}
			else {
				valor = false	
			}
				
			for (var i = 1; i <= DG_TOTAL; i++) {
				document.getElementById("DG_CHK_" + i).checked = valor
			}
		}
		
		

-->
