function Bloqueia_Caracteres(evnt) {
	//Função permite digitação de números
	if (navigator.appName == "Microsoft Internet Explorer"){
 		if (evnt.keyCode < 48 || evnt.keyCode > 57) {
 			return false;
 		}
	}
	else {
 		if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0) {
 			return false;
 		}
	}
}

function Ajusta_Data(input, evnt) {
	//Ajusta máscara de Data e só permite digitação de números
 	if (input.value.length == 2 || input.value.length == 5) {
 		if(navigator.appName == "Microsoft Internet Explorer") {
 			input.value += "/";
 		}
 	}
 	else {
 		if(evnt.keyCode == 0) {
 			input.value += "/";
 		}
 	}
 	
		//Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
}

function NextControl(campo,prox,tammax,teclapres){
	//alert(document.frmCadastro(prox).type);
	//var tecla = teclapres.keyCode;
	var tecla = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	vr = document.frmCadastro(campo).value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.frmCadastro(campo).value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	tam = vr.length;
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 && tecla != 144 ){
	 		//alert(tecla);
			if (tam == tammax){
				document.frmCadastro(prox).focus();
			}
		}
	}
}

function NextRadio(campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.frmCadastro(campo).value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.frmCadastro(campo).value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	tam = vr.length;
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 && tecla != 144 ){
	 		//alert(tecla);
			if (tam == tammax){
				document.frmCadastro(prox)(0).focus();
			}
		}
	}
}

function NextLink(campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.frmCadastro(campo).value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.frmCadastro	.value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	tam = vr.length;
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 && tecla != 144 ){
	 		//alert(tecla);
			if (tam == tammax){
				document.links(prox).focus();
			}
		}
	}
}

function abre_pop( vsize, turl )
{
	vpos = (screen.availHeight / 2) - (vsize / 2);
	hpos = (screen.availWidth / 2) - (500 / 2);
	nome = "popupnosb"+vsize;

	ne4 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4);
	jan_padrao_nosb = window.open(turl,nome,"maximized=no,status=no,history=no,scrollbars=no,width=510,height="+vsize+",left="+hpos+",top="+vpos);
	//jan_padrao_nosb = window.open(turl,nome,"maximized=no,status=no,history=no,scrollbars=no,resizable=1");
	jan_padrao_nosb.focus();
}

function exibe_imagem( pwidth, pheight, turl )
{
	//vpos = (screen.availHeight / 2) - (pheight / 2);
	//hpos = (screen.availWidth / 2) - (pwidth / 2);

	vpos = 1;
	hpos = 1;
	
	nome = "popupnosb"+pheight;

	ne4 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4);
	jan_padrao_nosb = window.open(turl,nome,"maximized=no,status=no,history=no,scrollbars=no,width=" + pwidth + ",height=" + pheight + ",left="+hpos+",top="+vpos);
	jan_padrao_nosb.focus();
}

function ShowDialog() 
{
	var retorno="";
	var data="";
	vpos = (screen.availHeight / 2) - (176 / 2);
	hpos = (screen.availWidth / 2) - (240 / 2);

	if (window.showModalDialog) {		
	    if (navigator.userAgent.indexOf("MSIE 7.0") != -1)
			retorno = showModalDialog("calendario.aspx","window",'toolbar:no;help:no;status:no;scroll:no;edge:raised;dialogWidth:240px;dialogHeight:176px');
		else
			retorno = showModalDialog("calendario.aspx","window",'toolbar:no;help:no;status:no;scroll:no;edge:raised;dialogWidth:249px;dialogHeight:225px');

		if(retorno!="" && retorno!=null) {
			document.getElementById("txtData").value=retorno;
        }
	} 
	else {
		window.open("calendario.aspx",'calendario',"dialog=no,scrollbars=no,status=no,maximized=no,location=no,width=240,height=176,left="+hpos+",top="+vpos);
	}
 }

// Autor: Martin Webb (martin@irt.org)
// Script gratuito postado pelo
// The JavaScript Source!! http://javascript.internet.com
function right(e)
{
if (navigator.appName == "Netscape" && (e.which == 2 || e.which == 3)) 
{
	alert("Desculpe. Conteudo protegido.");
	return false;
}
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 ||  event.button == 3))
{
	alert("Desculpe. Conteudo protegido.");
	return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers)
window.captureEvents(Event.MOUSEDOWN);
if (document.layers)
window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

