function Numero(e) //campo apenas numérico ... ativação: (onKeyPress="return Numero(event);")
{ 
	navegador = /msie/i.test(navigator.userAgent); 
	if (navegador) {
		var tecla = event.keyCode;
	} else {
		var tecla = e.which; 
	}
	if(tecla > 47 && tecla < 58) { // numeros de 0 a 9 
		return true;
	} else {
		if (tecla != 8) { // backspace 
		return false;
		} else {
			return true;
		}
	}
} 

function cpf(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	
	if ( tecla != 9 && tecla != 8 ){
		if ( tam == 11 )
			document.cadastro[campo].value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr( 6, 3 ) + '-' + vr.substr( 9, 2 );
	}
}

function cnpjs(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	
	if ( tecla != 9 && tecla != 8 ){
		if ( tam == 14 )
			document.cadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8, 4 ) + '-' + vr.substr( 12, 2 );
	}
}

function inscEst(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	
	if ( tecla != 9 && tecla != 8 ){
		if ( tam == 9 )
			document.cadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '-' + vr.substr( 8, 2 );
	}
}

function ceps(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	
	if ( tecla != 9 && tecla != 8 ){
		if ( tam == 8 )
			document.cadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '-' + vr.substr( 5, 3 );
	}
}

function fone(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam >= 5 && tam <= 9 ){
			document.cadastro[campo].value = vr.substr( 0, 4 ) + '-' + vr.substr( 5, 4 ); 
		}
	}
}

function data(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[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.cadastro[campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			document.cadastro[campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}
}

function bancario(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.cadastro[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.cadastro[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.cadastro[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
	}
}

function valor(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.cadastro[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 <= 2 ){ 
	 		document.cadastro[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.cadastro[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.cadastro[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.cadastro[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.cadastro[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.cadastro[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.cadastro.elements.length; ct++) {
		if (document.cadastro.elements[ct].name == document.cadastro.elements[campo].name) {
			if ( !teclapres.shiftKey && tecla == 9 && document.cadastro.elements[ct+1] && document.cadastro.elements[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
				document.applets['tclJava'].setFocus();
			}	
		}
	}
}

function salta(campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.emails[campo].value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.emails[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.emails.elements[prox] && document.emails.elements[prox].name == "senhaConta"))
				{
					if ( document.applets['tclJava'] )
						document.applets['tclJava'].setFocus();
					else if ( document.emails.senhaConta )
						document.emails.senhaConta.focus();
				}
				else if ( document.emails[prox] )
					document.emails[prox].focus();
			}
		}
	}
}


//-------------------------------------------------------------------------------------------------------------------------



function Fechar(){
	document.getElementById('edit_menu').style.display='none';
	window.Menu.location='blank.htm';
	//window.location="";
}
function MovLayer() //colocar no body onscroll="MovLayer()"
{
	if (document.body.scrollTop >= 0)
	{
		//document.getElementById('edit_menu').style.top = document.body.scrollTop
	}
	else
	{
		//document.getElementById('edit_menu').style.top = 0
	}
}
function flutuante(caminho, largura, altura)
{
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	window.Menu.location=caminho;
	/*if(navigator.appName=='Microsoft Internet Explorer'){
		posicaoX = event.clientX;
		posicaoY = event.clientY;
		if(altura + posicaoY > winH){ //screen.width;
			var diferenca = altura - document.body.scrollTop;
		} else{
			var diferenca = 0;
		}
		document.getElementById("edit_menu").style.top  = posicaoY - diferenca;
		if(largura + posicaoX > winW){ //screen.width;
			var diferenca = largura/2;
		} else{
			var diferenca = -largura/2;
		}
		document.getElementById("edit_menu").style.left = posicaoX - diferenca;
	}*/
	document.getElementById('edit_menu').style.display='block';
	document.getElementById('fechar').style.width=largura;
	document.getElementById('Menu').width=largura;
	document.getElementById('Menu').height=altura;
	document.body.scrollTop=0;
	//window.open(caminho, 'Menu', 'width='+largura+', height='+altura);
}

//arrastar e soltar janelas////////////////////////////////
function drag_drop(){
	document.getElementById('edit_menu').style.top = event.y;
	document.getElementById('edit_menu').style.left = event.x;
}
/////////////////////////////////////////////////////////



//---------------------------------------------------------------------------------------------------------------------


var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";
	
	
	
	
//----------------------------------------------------------------------------------------------------------------



function addSWF (URL, WIDTH, HEIGHT, TRANSPARENTE, SEMMENU)
{
document.write (' <embed src="'+ URL +'" quality="high" ');

if ( TRANSPARENTE ) {
	document.write (' wmode = "transparent" ');
}
if ( SEMMENU ) {
	document.write (' menu = "false" ');
}
document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
}

/*<script language='JavaScript' src='addswf.js'></script>*/
/*<script>addSWF('exemplo.swf', 125, 100, true, true);</script>*/

function confirmar(campo_id, form_name) {
	var pergunta = confirm("Tem certeza que deseja excluir?")
	if (pergunta){
		document.getElementById(form_name).id.value=campo_id;
		document.getElementById('excluir'+form_name).value='1';
		document.getElementById(form_name).submit();
	}
}

function replicar(objeto) {
	campo=objeto.name.split('_');
	if(objeto.checked==true){
		document.getElementById(campo[1]+"2").value=document.getElementById(campo[1]).value;
		document.getElementById(campo[1]+"2").disabled=true;
	}else{
		document.getElementById(campo[1]+"2").disabled=false;
	}
}

function replicar2(objeto) {
		document.getElementById(objeto.name+"2").value=document.getElementById(objeto.name).value;
}