		var Page_ConfirmationVer = "2.0";
		var MaxMes = new Array(31,31,29,31,30,31,30,31,31,30,31,30,31)
		netscape = "";
		ver = navigator.appVersion; len = ver.length;
		for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
		netscape = (ver.charAt(iln+1).toUpperCase() != "C");

		function keyDown(DnEvents) { // handles keypress
		
			try { 
				// determines whether Netscape or Internet Explorer
				k = (netscape) ? DnEvents.which : window.event.keyCode;
			
				if (k == 13) { // enter key pressed
					if (nextfield == 'done' ) {
						return true; // submit, we finished all fields
						}
					else  { // we're not done yet, send focus to next box
						eval('document.frm.' + nextfield + '.focus()');
						//eval('document.frm.' + nextfield + '.select()');
						return false;
						
					}
				}
				
				
			}
			catch(e){
				return false;
			}	
			
		}
		
		//Critica data no formato "MM/yyyy"
      function CriticaDtMMYYYY(campo) {

		var bolOK
		var dtData = new Date()
		var strMes,strAno
		var strData
		
		strData = campo.value;
		
		bolOK = true;
		
		//alert(strdata);
		
		if (strData.length > 0 ) {
		
			strMes = strData.substr(0,2);
			strAno = strData.substr(3,4);
			
			//alert(strmes);
			//alert(strano);

			//if (strMes == '') { strMes = dtData.getMonth()+1  ;}
			if (strAno == '') { strAno = dtData.getFullYear() ;}

			if (strAno.length < 4 ) {
				strAno = 2000 + parseInt(strAno);
				strAno = "" + strAno
			}
							
			
			if (strMes < 1 || strMes > 12 ) {
				bolOK = false;
			}

			if (bolOK == false){
				
				alert("Data invalida !");
				campo.value = "";
	   		eval('document.frm.' + campo.id + '.focus()');
	   		eval('document.frm.' + campo.id + '.select()');
		   	
	   	}
	   	else
	   		campo.value = strMes + "/" + strAno;
	   	
		}
			
		}

                
		
   function ValidaData(campo,mascara) { 
		var bolOK,intPos
		var j
		var dtData = new Date()
		var strDia,strMes,strAno,strHora,strMin,strSeg
		var strData,strDataTmp

		
		strData = campo.value;
		
		strDia = "";
		strMes = "";
		strAno = "";
		
		bolOK = true;
		
		if (strData.length > 0 ) {
			//Verifica Ano
			intPos = mascara.indexOf('y');

			if (intPos >=0 ) {
				strAno = strData.substr(intPos,4);	
				if (strAno == '') {
					strAno = dtData.getFullYear() ;
				}
				else {
					if (strAno.length < 4 ) {
						strAno = 2000 + parseInt(strAno);
						strAno = "" + strAno
					}
					else {
						if ( strAno < 1800 || strAno > 2999) {
							bolOK = false;
						}
					}
				}

			}

			//Verifica Mes
			intPos = mascara.indexOf('M');

                        if (intPos >=0 && bolOK == true) {
				strMes = strData.substr(intPos,2);
				if (strMes == '') { 
					strMes =  dtData.getMonth()+1 + "" ;
					if (strMes.length ==1) { strMes = "0" + strMes;}
				}	
				else {
					if (strMes < 1 || strMes > 12 ) {
						bolOK = false;	
					}
				
				}
			}

			//Verifica Dia
			intPos = mascara.indexOf('d');

                        if (intPos >=0 && bolOK == true) {
				strDia = strData.substr(intPos,2);
				if (strDia < 1 || strDia > MaxMes[parseInt(strMes)]) {
					bolOK = false;		
				}	
			}
				

			
			if (bolOK == false){
				
				alert("Data invalida !");
				campo.value = "";
	   			eval('document.frm.' + campo.id + '.focus()');
	   			eval('document.frm.' + campo.id + '.select()');
		   	
	   		}
	   		else { 
	   			strDataTmp="";
	   			strData ="";
	   			j = -1;
	   			strData += strDia;
	   			strData += strMes;
	   			strData += strAno;
	   			
	   			for(var i=0; i < mascara.length;i++) {
						if (mascara.substr(i,1) != '#' &&
							mascara.substr(i,1) != 'd' &&
							mascara.substr(i,1) != 'M' &&
							mascara.substr(i,1) != 'y' &&
							strDataTmp.length == mascara.substr(0,i).length ) {
							strDataTmp = strDataTmp + mascara.substr(i,1);
						}	
						else {
							j++;
							strDataTmp = strDataTmp + strData.substr(j,1);
						}
					campo.value = strDataTmp;
				}	
	   	
		}
			
}

		function ValidaData_OLD(campo) { 
		var bolOK
		var dtData = new Date()
		var strDia,strMes,strAno
		var strData,strDataTmp

		
		strData = campo.value;
		
		bolOK = false;
		
		if (strData.length > 0 ) {
	
	
			strDia = strData.substr(0,2);
			strMes = strData.substr(3,2);
			strAno = strData.substr(6,4);

			//Caso o usuário não informe o mês ou o ano, a função
			// o fará.	
			if (strMes == '') { strMes = dtData.getMonth()+1  ;}
			if (strAno == '') { strAno = dtData.getFullYear() ;}



			if (strAno.length < 4 ) {
				strAno = 2000 + parseInt(strAno);
				strAno = "" + strAno
			}
							
			
			if (strMes >= 1 && strMes <= 12 ) {
				
				if (strDia >= 1 && strDia <= MaxMes[parseInt(strMes)]) {
				
					if ( strAno >= 1800 && strAno <= 2999) {
					
						bolOK = true;
					}
				}
			}
					
			
			
			if (bolOK == false){
				
				alert("Data invalida !");
				campo.value = "";
	   			eval('document.frm.' + campo.id + '.focus()');
	   			eval('document.frm.' + campo.id + '.select()');
		   	
	   		}
	   		else
	   			campo.value = strDia + "/" + strMes + "/" + strAno;
	   				
					
			}
	   	
		}
			
		}
		
		function ValidaValor(campo) { 
		
		//????????????????
		
		}
		
		function ValidaCNPJ(campo){
		var ret,texto
		
		texto = campo.value;
		
		texto = RemoveMascara(texto);	
		
		
		ret = Calc_CNPJ(texto);
		
		if ( ret == false) { alert('CNPJ inválido !');}
				
		}
		
		function ValidaCPF(campo){
		var ret,texto
		
		texto = campo.value;
		
		texto = RemoveMascara(texto);	
		
		ret = Calc_CPF(texto);
		
		if ( ret == false) { alert('CPF inválido !');}
				
		}
		
		function Calc_CNPJ(Valor) { 
		var Mult1,Mult2,dig1,dig2,x
		
		if (Valor == '') { return true; }
		
		dig1 = 0 ;
		
		Mult1 = "543298765432";
		Mult2 = "6543298765432";
		
		for (x=1 ; x<=12 ; x++) {
			dig1 = dig1 + (Valor.substring(x,1) * Mult1.substring( x, 1));
		}
		
		
		for (x=1 ; x<=13 ; x++) {
			dig1 = dig1 + (Valor.substring(x,1) * Mult2.substring( x, 1));
		}
				
		dig1 = Mod((dig1 * 10), 11);
		
		dig2 = Mod((dig2 * 10), 11);
		
		if (dig1 == 10) { dig1 = 0; }
		if (dig2 == 10) { dig2 = 0; }
		
		
		if (dig1 != Valor.substring(13, 1)) { 
			return false;
		}
		
		if (dig2 != Valor.substring(14, 1)) { return false;}


		return true	;
		
		}
		
		function Calc_CPF(Valor) { 
		var dig1,dig2,x,Mult1,Mult2
		
		if (Valor == '') { return; }
		
		
		dig1 = 0;
		
		Mult1 = 10;
		Mult2 = 11;
		
		for (x=1 ; x<=9 ; x++) {
			 dig1 = dig1 + (Valor.substring(x,1) * Mult1);
			 Mult1 = Mult1 - 1;
		}
		
		for (x=1 ; x<=10 ; x++) {
			 dig2 = dig2 + (Valor.substring(x,1) * Mult2);
			 Mult2 = Mult2 - 1;
		}
   
		dig1 =  Mod((dig1 * 10),11);
		dig2 = Mod((dig2 * 10),11);
		
		if (dig1 == 10) { dig1 = 0; }
		if (dig2 == 10) {dig2 = 0;}
   
		
		
		if (Valor.substring(10,1)!= dig1) {
			 return false;
		}
		if (Valor.substring(11,1) != dig2 ) {
			return false;
		}
		
		return true;
					
		}
		/*
		Calcula o resto de uma divisão
		*/
		function Mod(num1,num2) {
		var resto
		var div
		
		div = (num1 / num2)
		
		resto = num1 - (div * num2)
		
		return resto
				
		}
		
		
		function FormataValor(campo,tammax,teclapres) { 
		var tecla = teclapres.keyCode;
		vr = campo.value;
		
		
		if (((tecla < 44) || 
			 (tecla > 57)) || 
			 tecla == 47 || 
			 (vr.indexOf(',') >=0 && 
			 (tecla == 44 || 
			 tecla == 46 )) || 
			 (vr.indexOf('-') >=0 && 
			 tecla == 45 ) ) {
			if (netscape) 
				DnEvents.which = 0 ;
			else
				window.event.keyCode = 0;
			return;	
		}
		
		
		
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( ",", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		tam = vr.length;
	
		var nrocasadec = 2;	
		var agrupa = ".";
		
		
		
		if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	
		if (tecla == 8 ){	tam = tam - 1 ; }
			
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
			if ( tam <= nrocasadec ){ 
		 		campo.value = vr ; }
	 		if ( (tam >nrocasadec) && (tam <= 5) ){
		 		campo.value = vr.substr( 0, tam - nrocasadec ) + ',' + vr.substr( tam - nrocasadec, tam ) ; }
	 		if ( (tam >= 6) && (tam <= 8) ){
		 		campo.value = vr.substr( 0, tam - 5 ) + agrupa + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - nrocasadec, tam ) ; }
	 		if ( (tam >= 9) && (tam <= 11) ){
		 		campo.value = vr.substr( 0, tam - 8 ) + agrupa + vr.substr( tam - 8, 3 ) + agrupa + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - nrocasadec, tam ) ; }
	 		if ( (tam >= 12) && (tam <= 14) ){
		 		campo.value = vr.substr( 0, tam - 11 ) + agrupa + vr.substr( tam - 11, 3 ) + agrupa + vr.substr( tam - 8, 3 ) + agrupa + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - nrocasadec, tam ) ; }
	 		if ( (tam >= 15) && (tam <= 17) ){
		 		campo.value = vr.substr( 0, tam - 14 ) + agrupa + vr.substr( tam - 14, 3 ) + agrupa + vr.substr( tam - 11, 3 ) + agrupa + vr.substr( tam - 8, 3 ) + agrupa + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - nrocasadec, tam ) ;}
		}
		
		/*
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
			if ( tam <= 2 ){ 
		 		campo.value = vr ; }
	 		if ( (tam > 2) && (tam <= 5) ){
		 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 		if ( (tam >= 6) && (tam <= 8) ){
		 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 		if ( (tam >= 9) && (tam <= 11) ){
		 		campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 		if ( (tam >= 12) && (tam <= 14) ){
		 		campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 		if ( (tam >= 15) && (tam <= 17) ){
		 		campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
		}

		*/
		
		/*	
		for (var ct = 0; ct < document.form.elements.length; ct++) {
			if (document.form.elements[ct].name == document.form.elements[campo].name) {
				if ( !teclapres.shiftKey && tecla == 9 && document.form.elements[ct+1] && document.form.elements[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
					document.applets['tclJava'].setFocus();
				}	
			}
		}	
		*/	
		}
			
		function FormataCampo(campo,mascara) { 
			var Texto,OldValue,j
			
			Texto = '';
			OldValue = campo.value;
			
			OldValue = RemoveMascara(OldValue);
			
			// Determina quando é Netscape ou Internet Explorer
			k = (netscape) ? DnEvents.which : window.event.keyCode;
						
			if (mascara.length == OldValue.length  ||  ((k < 48) || (k > 57)) ) {
				if (netscape) 
					DnEvents.which = 0 ;
				else
					window.event.keyCode = 0;
				return;	
			}
			
			campo.value = "";
			Texto = "";
			j = -1;
			
			for(var i=0; i < mascara.length;i++) {
					if (mascara.substr(i,1) != '#' &&
					   mascara.substr(i,1) != 'd' &&
					   mascara.substr(i,1) != 'M' &&
					   mascara.substr(i,1) != 'y' &&
					   Texto.length == mascara.substr(0,i).length ) {
							Texto = Texto + mascara.substr(i,1);
						}	
					else {
						j++;
						Texto = Texto + OldValue.substr(j,1);
					}
						
					
			}
			campo.value = Texto;

		}
						
		function RemoveMascara(Texto){
		var j,Car
		
		j = 0;
		//
		//Remove caracteres especiais da mascara
		//
		while (j < Texto.length) {
			Car = Texto.substr(j,1)
			if (Car >= 0 && Car <= 9) {
			   j++;
			}
			else {
				Texto = Texto.replace(Car, "" );
			}
		}
		
		return Texto;
		}
				




function ConfirmationOnLoad() {
    if ( !ConfirmationBrowserCapable() ) return;
    if (typeof(Page_Confirmations) == "undefined") return;
    var i, confirmButton;
    for (i = 0; i < Page_Confirmations.length; i++) {
        confirmButton = Page_Confirmations[i];
        if (typeof(confirmButton) == "string") {
            confirmButton = document.getElementById( confirmButton );
        }
        if ( typeof(confirmButton.confirmationmessage ) == "undefined" ) {
            if ( typeof( confirmButton.attributes ) != "undefined" ) {
                confirmButton.confirmationmessage = confirmButton.attributes["confirmationmessage"].value;
            } else {
                confirmButton.confirmationmessage = "Are you sure you want to do this?";
            }
        }
        ConfirmationHookupControl(confirmButton);
    }
}

function ConfirmationBrowserCapable() {
    if ( typeof( document.getElementById ) == "undefined" ) {
        if( typeof( document.all ) != "undefined" ) {
            document.getElementById = function( elementId ) { return document.all[elementId]; };
            return true;
        }
        return false;
    }
    return true;
}

function ConfirmationHookupControl( confirmButton ) {
    var ev = confirmButton.onclick;
    if (typeof(ev) == "function" ) {            
        ev = ev.toString();
        ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
    }
    else {
        ev = "";
    }
    var func = new Function("if ( !ConfirmationOnClick( this ) ){return false;} " + ev);
    confirmButton.onclick = func;
}

function ConfirmationOnClick( confirmButton ) {
	 return confirm( confirmButton.confirmationmessage );
}

function RetornaValores( LinkButton ) {
var achou		
var valorCol
	achou = 0;

	 for (var i = 0;i < NomeObjeto.length;i++) { 
	   
	   if (achou == 0) {
	   
			for (var j = 0;j < window["Col" + i].length;j++) { 
				if (window["Col" + i][j] == LinkButton.id) {
					achou = 1;
					break;
				}	
			}
			if (achou) { break };
	   }
	 }
	 for (var i = 0;i < NomeObjeto.length;i++) {   
		valorCol = window[window["Col" + i][j]].innerHTML;	
		opener.document.frm[NomeObjeto[i]].value = valorCol;
    }
	 opener.document.frm[NomeObjetoFoco[0]].focus();
	 opener.document.frm[NomeObjetoFoco[0]].select();
	 window.close();
		
 		
}
