function formataMoeda(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0) return true;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    if (obj.value.length == 0) {
    	obj.value = '0.0';
    } else {
    	valor = parseFloat(obj.value);
    	if (valor < 1) {
    		obj.value = obj.value.substr(2,1) + "." + obj.value.substr(3,1);
    	} else {
    		var partes = obj.value.split(".");
    		if (partes.length != 2) obj.value = '0.0';
    		else obj.value = partes[0] + partes[1].substr(0,1) + "." + partes[1].substr(1,1);
    	}
    }
   	return true;
}

function formataPeriodo(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    if (obj.value.length == 2) obj.value += '/';
   	return true;
}


function formataAgencia(obj,e) {
    var strCheck = '0123456789-';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0) return true;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
   	return true;
}

function formataConta(obj,e) {
    var strCheck = '0123456789Xx-';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0) return true;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
   	return true;
}

function formataBanco(obj,e) {
    var strCheck = 'BCXbcx';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0) return true;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
   	return true;
}

function formataConta(obj,e) {
    var strCheck = '0123456789Xx-';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0) return true;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
   	return true;
}

function soNumero(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0) return true;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
   	return true;
}

function resetaNumeros(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    switch (whichCode) {
    	case 8:	case 37: case 46: case 39:
    		obj.value = '';
    	break;
    }
}

function pular(obj, prox, tam, action, handler) {
	if (obj.value.length == tam) {
		if (prox != null) document.getElementById(prox).focus();
		ajaxOpen('http1', action, handler ,null);
	}

}

function formataData(obj,e) {
    var strCheck = '0123456789';
    var tam = obj.length;
    
    var whichCode = (window.Event) ? e.which : e.keyCode;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    if (obj.value.length == 2) obj.value += '/';
    if (obj.value.length == 5) obj.value += '/';
    
    if (tam == 10) alert('teste');
    
   	return true;

}

// funcao auxiliar - cadastro de menu principal
function showHide(valor) {
	switch (valor) {
		case "C":
			document.getElementById('divtexto').style.display = 'block';
			document.getElementById('divlink').style.display = 'none';
		break;
		case "L":
			document.getElementById('divtexto').style.display = 'none';
			document.getElementById('divlink').style.display = 'block';
		break;
	}
}

function pular2(obj, prox, tam) {
	if (obj.value.length == tam) {
		if (prox != null) document.getElementById(prox).focus();		
	}

}

function showHide2(valor) {
	switch (valor) {
		case "0":
			document.getElementById('divTexto').style.display = 'none';
			document.getElementById('divArquivo').style.display = 'block';
			document.getElementById('divArquivo2').style.display = 'none';
		break;
		case "1":
			document.getElementById('divTexto').style.display = 'block';
			document.getElementById('divArquivo').style.display = 'none';
			document.getElementById('divArquivo2').style.display = 'none';
		break;	
		case "2":
			document.getElementById('divTexto').style.display = 'none';
			document.getElementById('divArquivo').style.display = 'none';
			document.getElementById('divArquivo2').style.display = 'block';
		break;	
	}
}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

// funcao auxiliar - cadastro de menu principal
function showHide(valor) {
	switch (valor) {
		case "0":
			document.getElementById('divtexto').style.display = 'none';
			document.getElementById('divlink').style.display = 'none';
		break;
		case "1":
			document.getElementById('divtexto').style.display = 'block';
			document.getElementById('divlink').style.display = 'none';
		break;
		case "2":
			document.getElementById('divtexto').style.display = 'none';
			document.getElementById('divlink').style.display = 'block';
		break;
	}
}
