function MessageDlg(Mensagem,Botoes){
 rv = window.showModalDialog("http://svraplic/sistemas/medpoint/Paginas/mensagem.asp?Mensagem="+Mensagem+"&Botoes="+Botoes,"","dialogWidth:360px;dialogHeight:217px;help:0;scroll:0;status:0;");
 event.returnValue = true;
 if (rv == "no"){
  event.returnValue = false
 }
}

function AvisoDlg(){
 rv = window.showModalDialog("../Paginas/Aviso.asp","","dialogWidth:500px;dialogHeight:217px;help:0;scroll:0;status:0;");
 event.returnValue = true;
 if (rv == "no"){
  event.returnValue = false
 }
}

function my_win(url)
{
window.open("Ls_Termo_Internacao.aspx?p1="+url,"NewWindow","toolbar=no,location=no,resizable=yes,directories=no,status=no,menubar=no,scrollbars=yes,,copyhistory=no,width=790,height=550");
}

function my_win_Dec(url)
{
window.open("Ls_Termo_Declaracao.aspx?p1="+url,"NewWindow","toolbar=no,location=no,resizable=yes,directories=no,status=no,menubar=no,scrollbars=yes,,copyhistory=no,width=790,height=550");
}

function my_win_FIP(url)
{
window.open("Ls_Termo_FIP.aspx?p1="+url,"NewWindow","toolbar=no,location=no,resizable=yes,directories=no,status=no,menubar=no,scrollbars=yes,,copyhistory=no,width=790,height=550");
}

function my_winDDH(url)
{
window.open("Ls_Termo_DDH.aspx?p1="+url,"NewWindow","toolbar=no,location=no,resizable=yes,directories=no,status=no,menubar=no,scrollbars=yes,,copyhistory=no,width=790,height=550");
}

function my_win2(url)
{
window.open('Ls_Evo_Uti_Adu.aspx?p1='+url,'mywindow','width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=yes,resizable=yes,left=0,top=0');
}

function my_win3(url)
{
window.open(url,'mywindow','width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=yes,resizable=yes,left=0,top=0');
}

function my_win4(url)
{
window.open('Ls_Internacao_Presc.aspx?p1='+url,'mywindow','width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=yes,resizable=yes,left=0,top=0');
}

function my_win5(url)
{
window.open('Ls_Internacao_Presc_Enf.aspx?p1='+url,'mywindow','width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=yes,resizable=yes,left=0,top=0');
}

function my_win6(url)
{
window.open('Ls_Cadastro_AIH.aspx?p1='+url,'mywindow','width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=yes,resizable=yes,left=0,top=0');
}

function newwindow(url) 
{
window.open(url,"NewWindow","toolbar=no,location=no,resizable=yes,directories=no,status=no,menubar=no,scrollbars=no,,copyhistory=no,width=790,height=550");
}

function eumesmo()
{
window.open("http://svraplic/sistemas/seguranca/paginas/login.aspx","NewWindow","toolbar=no,location=no,resizable=yes,directories=no,status=no,menubar=no,scrollbars=no,,copyhistory=no,width=790,height=550");
}

function WindowsModal(pagina,Botoes){
 rv = window.showModalDialog("../Paginas/"+pagina,"dialogWidth:560px;dialogHeight:317px;");
 event.returnValue = true;
 if (rv == "no"){
  event.returnValue = false
 }
}

	function DivDinamico(myDiv){
		if (myDiv.style.display == "none"){
			myDiv.style.display = "";
			event.srcElement.src = "../Imagens/menos.gif"
		}else{
			myDiv.style.display = "none";
			event.srcElement.src = "../Imagens/mais.gif"
		}
	}

function isEmail(who) {
	function isEmpty(who) {
		var testArr=who.split("");
		if(testArr.length==0)
			return true;
		var toggle=0;
		for(var i=0; i<testArr.length; i++) {
			if(testArr[i]==" ") {
				toggle=1;
				break;
			}
		}
		if(toggle)
			return true;
		return false;
	}

	function isValid(who) {
		var invalidChars=new Array("~","!","@","#","$","%","^","&","*","(",")","+","=","[","]",":",";",",","\"","'","|","{","}","\\","/","<",">","?");
		var testArr=who.split("");
		for(var i=0; i<testArr.length; i++) {
			for(var j=0; j<invalidChars.length; j++) {
				if(testArr[i]==invalidChars[j]) {
					return false;
				}
			}
		}
		return true;
	}

	function isfl(who) {
		var invalidChars=new Array("-","_",".");
		var testArr=who.split("");
		which=0;
		for(var i=0; i<2; i++) {
			for(var j=0; j<invalidChars.length; j++) {
				if(testArr[which]==invalidChars[j]) {
					return false;
				}
			}
			which=testArr.length-1;
		}
		return true;
	}

	function isDomain(who) {
		var invalidChars=new Array("-","_",".");
		var testArr=who.split("");
		if(testArr.length<2||testArr.length>4) {
			return false;
		}
		for(var i=0; i<testArr.length; i++) {
			for(var j=0; j<invalidChars.length; j++) {
				if(testArr[i]==invalidChars[j]) {
					return false;
				}
			}
		}
		return true;
	}


	var testArr=who.split("@");
	if(testArr.length<=1||testArr.length>2) {
		return false;
	}
	else {
		if(isValid(testArr[0])&&isfl(testArr[0])&&isValid(testArr[1])) {
			if(!isEmpty(testArr[testArr.length-1])&&!isEmpty(testArr[0])) {
				var testArr2=testArr[testArr.length-1].split(".");
				if(testArr2.length>=2) {
					var toggle=1;
					for(var i=0; i<testArr2.length; i++) {
						if(isEmpty(testArr2[i])||!isfl(testArr2[i])) {
							toggle=0;
							break;
						}
					}
					if(toggle&&isDomain(testArr2[testArr2.length-1]))
						return true;
					return false;
				}
				return false;
			}
		}
	}
}
function isEmail2(who) {
	var email=/^[A-Za-z0-9][\w-.]+[A-Za-z0-9]@[A-Za-z0-9]([\w-.]+[A-Za-z0-9]\.)+([A-Za-z]){2,4}$/i;
	return(email.test(who));
}
function MM_preloadImages(){
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function change()	{
	if(!document.all)
		return
	if(event.srcElement.id=="ListaHeader"){
		var srcIndex = event.srcElement.sourceIndex
    var nested = document.all[srcIndex+1]
    if(nested.style.display=="none"){
			nested.style.display=''
      event.srcElement.style.listStyleImage="url(../Imagens/menos.gif)"
		}else{
			nested.style.display="none"
			event.srcElement.style.listStyleImage="url(../Imagens/mais.gif)"
    }
	}
}

// Código para o teclado 
function tecladown (digito){
	if (digito == ''){
		document.form.senha.value = '';
		return;	
	}
	var pass = document.form.senha.value;
	if (pass.length >= 8){
		return;
	}
	document.form.senha.value = document.form.senha.value + digito;
}
function teclaclick(tecla){
	return false;
}
function teclaup(tecla){
	tecladown(tecla);
}
// --


// -- Contador para objeto TextArea.
function limita(campo){
	var tamanho = document.form[campo].value.length;
	var tex=document.form[campo].value;
	if (tamanho>=1539) {
		document.form[campo].value=tex.substring(0,1539); 
	}
	return true;
}

function contacampo(campo, tamtxt) {
document.form[tamtxt].value =  1540-document.form[campo].value.length;
}
// --



function SetHelp(txt) { help.innerText = txt ; }

function main(campofoco) { 
	if ( campofoco == '' || document.form.elements.length == 0 ) 
		return false;
			
	var num = parseInt(campofoco);

	if ( num || num == 0 )
	{
		if ( document.form[num] )
			document.form[num].focus();
	}
	else 
	{
		if ( (campofoco == "senhaConta" || campofoco == "senhaAtual") && document.applets["tclJava"] ) 
			document.applets["tclJava"].setFocus();
		else if ( document.form[campofoco] )
			document.form[campofoco].focus();
	}
}

function Apaga(){
	if (document.form.elements.length != 0)
		for (i = 0; i < document.form.elements.length; i++)
		{
			if( document.form[i].type != "hidden" )
				document.form[i].value="";
		}
}


function printPage()
{
  if (pr) // NS4, IE5
    window.print()
  else if (da && !mac) // IE4 (Windows)
    vbPrintPage()
  else // other browsers
    alert("Desculpe seu browser não suporta esta função. Por favor utilize a barra de trabalho para imprimir a página.");
  return false;
}

function FormataDado(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		document.form[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.form[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
	}
	//alert("campo: " + document.form[campo+1].name);
	if ( !teclapres.shiftKey && tecla == 9 && document.form[campo+1].name == "senhaConta" && document.applets['tclJava'] ){
		//alert("aki 1");
			document.applets['tclJava'].setFocus();
	}
}


function FormataCodigoSubpa(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = tam + 1; }

	if (tecla == 8 ){tam = tam - 1; }
		
	if (  tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105){
		if ( tam == 2 ){ 
	 		document.form[campo].value = vr+'.' ; }
	 	if (tam == 3){
	 		document.form[campo].value = document.form[campo].value + vr.substr( 2, 1 ) +'.'; }
	 	if  (tam == 4 ){
	 		document.form[campo].value = document.form[campo].value + vr.substr( 3, 1 )+'.' ; }
	 	if  (tam == 5 ){
	 		document.form[campo].value = document.form[campo].value + vr.substr( 5, 2 )+'-'; }
	 	if ( (tam==7)){
	 		document.form[campo].value = document.form[campo].value + vr.substr( 6, 4 ) ; }
	}
		
/*	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 SaltaCampo (campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.form[campo].value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	vr = vr.replace( "-", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( ",", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	tam = vr.length;	
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 ){
		
			if ( tam == tammax ){
				if ( prox == "senhaConta" || (document.form.elements[prox] && document.form.elements[prox].name == "senhaConta"))
				{
					if ( document.applets['tclJava'] )
						document.applets['tclJava'].setFocus();
					else if ( document.form.senhaConta )
						document.form.senhaConta.focus();
				}
				else if ( document.form[prox] )
					document.form[prox].focus();
			}
		}
	}
}
function FormataHora(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( ":", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			document.form[campo].value = vr.substr( 0, tam - 2  ) + ':' + 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[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
				document.applets['tclJava'].setFocus();
			}	
		}
	}
}

function FormataData(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			document.form[campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			document.form[campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}
	
	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[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
				document.applets['tclJava'].setFocus();
			}	
		}
	}
}

function FormataMesAno(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[Campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 7 )
			document.form[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam ); }
}

function FormataPercentual(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	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 <= 3 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		document.form[campo].value = vr.substr( 0, tam - 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
	}		
	
}


function VerificaJava()
 	{
	if (navigator.javaEnabled())
		document.form.javas.value="sim"
	}

function FormataCpf(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	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 <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.form[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) ){
	 		document.form[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) ){
	 		document.form[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 ) ;}
	}		
}

function FormataCartaoCredito(campo, teclapres) {
    var tammax = 16;
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;

	if ( tecla == 8 || (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) )
	{
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( ",", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		tam = vr.length;

		if (tam < tammax && tecla != 8)
		   {tam = vr.length + 1 ; }

		if (tecla == 8 ) {tam = tam - 1 ; }

		if ( tam < 5 )
		   { document.form[campo].value = vr ; }
	 	if ( ( tam >  4 ) && ( tam < 9 ) )
		   { document.form[campo].value = vr.substr( 0, 4 ) + '.' + vr.substr( 4, tam-4 ) ; }
	 	if ( ( tam >  8 ) && ( tam < 13 ) )
		   { document.form[campo].value = vr.substr( 0, 4 ) + '.' + vr.substr( 4, 4 ) + '.' + vr.substr( 8, tam-4 ) ; }
	 	if ( tam > 12 )
		   { document.form[campo].value = vr.substr( 0, 4 ) + '.' + vr.substr( 4, 4 ) + '.' + vr.substr( 8, 4 ) + '.' + vr.substr( 12, tam-4 ); }
	}	
}

function FormataCgc(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	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 <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 6) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 7) && (tam <= 9) ){
	 		document.form[campo].value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 10) && (tam <= 12) ){
	 		document.form[campo].value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 13) && (tam <= 14) ){
	 		document.form[campo].value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.form[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 ) ;}
	}		
}

function FormataTelefone(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	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 <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 4) ){
	 		document.form[campo].value = vr.substr( 0, tam - 4 ) + '-' + vr.substr( tam - 4, tam ) ; }
	}		
}

function getSenha() {
	if ( document.applets['tclJava'] ){
		var senha = document.applets['tclJava'].getSenha();
		document.form['senhaConta'].value = senha;
	}
}

function enviaSub() {
	document.form.submit();
	return false;
}


function mudaFoco(campo)
{
	if(campo == "98") {
		//var nb = document.form.elements[document.form.elements.length - 1].name;
		//if(nb.indexOf(".x"))
		//	nb = nb.substring(0,nb.length-2);
		//document.form.elements[nb].focus();
		return;
	}
	if( (campo == "senhaConta" || (document.form.elements[campo] && document.form.elements[campo].name == "senhaConta")) && document.applets['tclJava'] )
		document.applets.tclJava.setFocus();
	else if (document.form.elements[campo])
		document.form.elements[campo].focus();
}

function mostraBalao(mst) {
	if (mst) {
		document.all["balaoApplet"].style.visibility="visible";
	}
	else {
		document.all["balaoApplet"].style.visibility="hidden";
	}
}

function teclaTab(teclaPress) {
	if(teclaPress.keyCode == 9)
		focaApplet();
}

function focaApplet() {
	if (document.applets['tclJava'] ) {
		document.applets.tclJava.setFocus();
	}
}
	
function focaApplet2(nomeApplet) {
	if (document.applets[nomeApplet] ) {
		document.applets[nomeApplet].setFocus();
	}
}

function focaApplet3(prox,teclapres) {
	var tecla = teclapres.keyCode;
	if ( !teclapres.shiftKey && tecla == 9 && document.form.elements[prox] && document.form.elements[prox].name == "senhaConta" && document.applets['tclJava'] )
		document.applets['tclJava'].setFocus();
}

function setaCod(numCod) {
	if (document.form.elements['numCod'])
		document.form.elements['numCod'].value = numCod;
}

function setaQW(strT) {
	if (document.form.elements['texto'])
		document.form.elements['texto'].value = strT;
}

function executarLogin() {
	getSenha();
	enviaSub();
}
//-->

function FormataProjeto(campo,teclapres, tammax){
		var tecla = teclapres.keyCode;
			vr = document.FrmCadastro.txt_Cod_Subpa.value;
			vr = vr.replace( "-", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( "/", "" );
			tam = vr.length ;
// OnKeyUp="FormataProjeto(2,event, 10)"			
		if (tam < tammax && tecla != 8)
			{ tam = vr.length + 1 ; }

		if (tecla == 8 )
			{ tam = tam - 1 ; }
			
		if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
			{
				if ( tam <= 2 )	{document.FrmCadastro.txt_Cod_Subpa.value = vr; } else
				if ( tam <= 3 )	{document.FrmCadastro.txt_Cod_Subpa.value = vr.substr(0,2)+'.'+vr.substr(2,3);} else
				if ( tam <= 6 )	{document.FrmCadastro.txt_Cod_Subpa.value = vr.substr(0,2)+'.'+vr.substr(2,3)+'.'+vr.substr(3,6);} else
					            {document.FrmCadastro.txt_Cod_Subpa.value = vr.substr(0,2)+'.'+vr.substr(2,3)+'.'+vr.substr(3,6)+'-'+vr.substr(6,10); }
			}
		}
function f_qtd_total(){
		document.FrmCadastro.txt_QtdTotal.value = document.FrmCadastro.txt_QtdPrevisto.value*1 + document.FrmCadastro.txt_QtdRealizado.value*1 + document.FrmCadastro.txt_QtdFuturo.value*1
	}

	var sPlainText 
	var iTick = 2000
	var j = 0
	var sOffID

	function doOnload() {
		idDynaText.style.display='';
		sPlainText = idDynaText.innerText
		idDynaText.innerHTML = replaceChars(idDynaText.innerText," ","&nbsp;")
		getString()
	}
	
	function getString() {
		sDynaText = ""
		for (i=0;i<sPlainText.length;i++){
			sDynaText += "<SPAN ID=idDynaChar" + i + " CLASS=clsNormal>" + sPlainText.substring(i,i+1) + "</SPAN>"
		}
		idDynaText.innerHTML = sDynaText
		j=0
		window.setTimeout("doDynaText()",iTick)
	}

	function doDynaText() {
		if (null != sOffID) {
		}
		sOnID = "idDynaChar" + (j)
		document.all(sOnID).className = "clsDynaText"
		sOffID = sOnID
		j++
		if (j < sPlainText.length	) {
			window.setTimeout("doDynaText()",iTick)
		}
		else {
			if (null != sOffID) {
			}
		sPlainText='';
		}
	}

	function replaceChars(sString,sOld,sNew) {
		for (i = 0; i < sString.length; i++) {
			if (sString.substring(i, i + sOld.length) == sOld) {
				sString = sString.substring(0, i) + sNew + sString.substring(i + sOld.length, sString.length)
			}
		}
		return sString
	}

		var progressEnd = 9;		
		var progressColor = '#006655';	
		var progressInterval = 500;

		var progressAt = progressEnd;
		var progressTimer;
		function progress_clear() {
			for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
			progressAt = 0;
		}
		function progress_update() {
			idDynaText.style.display='';
			progressAt++;
			if (progressAt > progressEnd) progress_clear();
			else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
			progressTimer = setTimeout('progress_update()',progressInterval);
		}
		function progress_stop() {
			clearTimeout(progressTimer);
			progress_clear();
		}

		function progress_update2() {
			idDynaText.style.display='';
		}


//mascara para valor 


function FormataValor(obj,tammax,teclapres) {
 var tecla = event.keyCode;
 vr = obj.value;
 vr = vr.replace( "/", "" );
 vr = vr.replace( "/", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 //Replaces adicionais
 vr = vr.replace( "-", "" );
 vr = vr.replace( "+", "" );
 vr = vr.replace( "*", "" );
 var tam = vr.length;
 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 <= 2 ){ 
   obj.value = vr ; }
  if ( (tam > 2) && (tam <= 5) ){
   obj.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
  if ( (tam >= 6) && (tam <= 8) ){
   obj.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
  if ( (tam >= 9) && (tam <= 11) ){
   obj.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) ){
   obj.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) ){
   obj.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 ) ;}
 }
}


function FormataValor3(obj,tammax,teclapres) {
 var tecla = event.keyCode;
 vr = obj.value;
 vr = vr.replace( "/", "" );
 vr = vr.replace( "/", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 //Replaces adicionais
 vr = vr.replace( "-", "" );
 vr = vr.replace( "+", "" );
 vr = vr.replace( "*", "" );
 var tam = vr.length;
 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 <= 3 ){ 
   obj.value = vr ; }
  if ( (tam > 3) && (tam <= 6) ){
   obj.value = vr.substr( 0, tam - 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
  if ( (tam >= 7) && (tam <= 9) ){
   obj.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
  if ( (tam >= 10) && (tam <= 12) ){
   obj.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
  if ( (tam >= 13) && (tam <= 15) ){
   obj.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
  if ( (tam >= 16) && (tam <= 18) ){
   obj.value = vr.substr( 0, tam - 15 ) + '.' + vr.substr( tam - 15, 3 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + ',' + vr.substr( tam - 3, tam ) ;}
 }
}


function FormataValor5(obj,tammax,teclapres) {
 var tecla = event.keyCode;
 vr = obj.value;
 vr = vr.replace( "/", "" );
 vr = vr.replace( "/", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 //Replaces adicionais
 vr = vr.replace( "-", "" );
 vr = vr.replace( "+", "" );
 vr = vr.replace( "*", "" );
 var tam = vr.length;
 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 <= 5 ){ 
   obj.value = vr ; }
  if ( (tam > 5) && (tam <= 8) ){
   obj.value = vr.substr( 0, tam - 5 ) + ',' + vr.substr( tam - 5, tam ) ; }
  if ( (tam >= 9) && (tam <= 11) ){
   obj.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + ',' + vr.substr( tam - 5, tam ) ; }
  if ( (tam >= 12) && (tam <= 14) ){
   obj.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + ',' + vr.substr( tam - 5, tam ) ; }
  if ( (tam >= 15) && (tam <= 17) ){
   obj.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, tam ) ; }
  if ( (tam >= 18) && (tam <= 20) ){
   obj.value = vr.substr( 0, tam - 17 ) + '.' + vr.substr( tam - 17, 3 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + ',' + vr.substr( tam - 5, tam ) ;}
 }
}