function submitOptionAto() {    
	document.bolete.action="faces/jsp/boletoJudCriminalForm1.jsp";
   	document.bolete.submit();      
}

function outroSacado() {
	if (document.bolete.outro.checked = true){
		document.bolete.submit();
	} else {
		alert("nao funciona");
	}
}

function validate() {
	if(document.bolete.discriminacao.value=="-1" || document.bolete.discriminacao.value == null){
	 	alert("Discriminação do ato deve ser informada!")
	    return false 
	}		 
	if(document.bolete.quantidade.value=="" ||  document.bolete.quantidade.value==null || document.bolete.quantidade.value==0) {	
		alert("Favor preencher a quantidade de atos!" )
		document.bolete.quantidade.focus();
		return false
	} else {	
		for(var i=0;i<document.bolete.quantidade.value.length;i++) {
			proibido = "abcdefghijklmnopqrstuvxzyw;:()<>-+!@$%&*_=§[]ªº^~´`?/°";
			p = document.bolete.quantidade.value.charAt(i);    		
	    	
	    	if(proibido.indexOf(p)>-1) {
				alert("O padrão para a quantidade é número vírgula. Ex.: 3.123,55")				
				document.bolete.quantidade.focus();
				return false
	    	}
		}
	}
	document.bolete.action="faces/jsp/boletoJudCriminalForm2.jsp";
	
}

function gettip() {

	var msg = "Os números de processo agora tem 20 dígitos, dispostos da seguinte maneira:\n" +
		"NNNNNNN-DD.AAAA.JTR.OOOO, onde:  \n"+
        "NNNNNNN = número seqüencial do processo no ano e no órgão da justiça, ou no ano, órgão e unidade da justiça \n"+
		"DD = dígito de verificação \n"+
		"AAAA = ano \n"+
		"JTR = identificação do órgão da justiça \n"+
		"OOOO = identificação da unidade no órgão da justiça \n"+
		"Exemplo: 00944801020048220001"		;		  
		  
		
		  
	alert(msg);
	return false;
}

function Tecla(e) {
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else {
			if (tecla != 8) // backspace
				event.keyCode = 0;
			else
				return true;
		}
}

// retira caracteres invalidos da string 
function Limpar(valor, validos) { 
	var result = ""; 
	var aux; 
	for (var i=0; i < valor.length; i++) { 
		aux = validos.indexOf(valor.substring(i, i+1)); 
		if (aux>=0) { 
			result += aux; 
		} 
	} 
	return result; 
} 
//Formata número tipo moeda usando o evento onKeyDown 
function Formata(campo,tammax,teclapres,decimal) { 
	var tecla = teclapres.keyCode; 
	vr = Limpar(campo.value,"0123456789"); 
	tam = vr.length; 
	dec=decimal 
	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 <= dec ) { 
			campo.value = vr ; 
		} 
		if ( (tam > dec) && (tam <= 5) ) { 
			campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; 
		} 
		if ( (tam >= 6) && (tam <= 8) ){ 
			campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, 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 - dec, 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 - dec, 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 ) ;
		} 
	}  
} 

function boletinhoLindo() {

	if (document.boletinho.numeroprocesso.value=="" || document.boletinho.numeroprocesso.value == null || document.boletinho.numeroprocesso.value==0) {
		alert("Digite o  número do processo")
		document.boletinho.numeroprocesso.focus()
		return false		
	}
	
	var b = document.boletinho.numeroprocesso.value;  
	var t = /-/g;
	
	b = b.replace(t, "");  
	t = /%/g;
	b = b.replace(t, "");  
	t = / /g;
	b = b.replace(t, ""); 
	t = /_/g;
	b = b.replace(t, "");  
	t = /\./g;
	b = b.replace(t, "");  
	t = /\[/g;
	b = b.replace(t, "");  
	t = /\]/g;
	b = b.replace(t, "");    
	
	document.boletinho.numeroprocesso.value = b;
}


function ignoreSpaces(string) {
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	
	for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
		
	return temp;
}

