function clickNS(e) 
{
	if (document.layers||(document.getElementById&&!document.all)) 
	{
		if (e.which==2||e.which==3) 
		{
			(mensagem);return false;
		}
	}
}
if (document.layers) 
{
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}
else
{
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false")

var mensagem="";
function clickIE() 
{
	if (document.all) 
	{
		(mensagem);return false;
	}
}
    var asciiF2        = 113;
    var asciiF3        = 114;
    var asciiF4        = 115;
    var asciiF5        = 116;
    var asciiF6        = 117;
    var asciiF11       = 122;
    var asciiF12       = 123;
    var asciiF1        = 112;
    if(document.all){
        document.onkeydown = onKeyPress;
    }else if (document.layers || document.getElementById){
        document.onkeypress = onKeyPress;
    }
    function onKeyPress(evt) {
        window.status = '';
        var oEvent = (window.event) ? window.event : evt;
        var nKeyCode =  oEvent.keyCode ? oEvent.keyCode : oEvent.which ? oEvent.which : void 0;
        var bIsFunctionKey = false;
        if(oEvent.charCode == null || oEvent.charCode == 0){
            bIsFunctionKey = (nKeyCode >= asciiF1 && nKeyCode <= asciiF12)
        }
        var sChar = String.fromCharCode(nKeyCode).toUpperCase();
        var oTarget = (oEvent.target) ? oEvent.target : oEvent.srcElement;
        var sTag = oTarget.tagName.toLowerCase();
        var sTagType = oTarget.getAttribute("type");
        var bAltPressed = (oEvent.altKey) ? oEvent.altKey : oEvent.modifiers & 1 > 0;
        var bShiftPressed = (oEvent.shiftKey) ? oEvent.shiftKey : oEvent.modifiers & 4 > 0;
        var bCtrlPressed = (oEvent.ctrlKey) ? oEvent.ctrlKey : oEvent.modifiers & 2 > 0;
        var bRet = true; 
       if(sTagType != null){sTagType = sTagType.toLowerCase();}
        if(bIsFunctionKey){ // Capture and stop these keys
            bRet = false;
        }else if(bCtrlPressed && (sChar == 'R')){ // block Control + R
            bRet = false;
        }   
        if(!bRet){
            try{
                oEvent.returnValue = false;
                oEvent.cancelBubble = true;
                if(document.all){ //IE
                    oEvent.keyCode = 0;
                }else{ //NS
                    oEvent.preventDefault();
                    oEvent.stopPropagation();
                }
            msg='Por favor, procure não utilizar esta tecla';
			alert(msg);
            }
			catch(ex)
			{
                alert(msg);
            }
        }
        return bRet;
    }

//************************************************************************************************************************************************************************

var mensagem="";
function clickIE() {if (document.all) {(mensagem);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(mensagem);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

//************************************************************************************************************************************************************************
function Mascara(tipo, campo, teclaPress) 
{
	if (window.event)
	{
		var tecla = teclaPress.keyCode;
	} 
	else 
	{
		tecla = teclaPress.which;
	}
 	var s = new String(campo.value);
	// Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
	s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');
	tam = s.length + 1;
 	if ( tecla != 9 && tecla != 8 ) 
	{
		switch (tipo)
		{
			case 'CPF' :
				if (tam > 3 && tam < 7)
					campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
				if (tam >= 7 && tam < 10)
					campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
				if (tam >= 10 && tam < 12)
					campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
			break;
			case 'CNPJ' :
				if (tam > 2 && tam < 6)
					campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
				if (tam >= 6 && tam < 9)
					campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
				if (tam >= 9 && tam < 13)
					campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
				if (tam >= 13 && tam < 15)
					campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
			break;
			case 'TEL' :
				if (tam > 2 && tam < 4)
					campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
				if (tam >= 7 && tam < 11)
					campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
			break;
 			case 'DATA' :
				if (tam > 2 && tam < 4)
					campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
				if (tam > 4 && tam < 11)
					campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
			break;
 			case 'HORA' :
				if (tam > 2 && tam < 5)
					campo.value = s.substr(0,2) + ':' + s.substr(2, tam);
			break;
		}
	}
}
//************************************************************************************************************************************************************************  
function testaTeclaNumero(e,msg) 
{	
	var vTecla;
    var vPermitidas = '8,13,48,49,50,51,52,53,54,55,56,57';
		
	//Verifica qual o browser Mozilla, Netescape, IE para direcionar corretamente
	if (document.all) //é IE
	{
	  if (e.keyCode == '13') //Testa se foi digitado Enter
	  {}
	  else if (e.keyCode < '46' || e.keyCode > '58') //Testa se não foram digitados números
	  {
		alert(msg); 
		return(false);
	  }
	}
	else
	{	 	  
	  vTecla = e.which.toString();
	  if (e.which == '13')
	  {}
	  else if (vPermitidas.indexOf(vTecla)==-1) //Testa se foi digitado apenas números ou TAB ou ALT ou Backspace
	  {
		alert(msg); 
		return(false); 
	  }
	}	
}
//************************************************************************************************************************************************************************  
function testaTecla(e,msg) 
{	
	if (document.all) //é IE
	{
	  if (e.keyCode) //Testa se foi digitado Enter
	  {
		alert(msg); 
		return(false);
	  }
	}
	else
	{	 	  
	  vTecla = e.which.toString();
	  if (e.which)
	  {
		alert(msg); 
		return(false); 
	  }
	}
}
//************************************************************************************************************************************************************************  
function validaEmail(vMail) 
{
	if (isEmail2(vMail))
   		return(true)
 	else
 	{
   		alert("Por favor, informe um e-mail válido");
		document.form.f_Mail.value='';
		document.form.f_Mail.focus();
   		return(false);
 	}
}
function isEmail2(who) 
{
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(who));
}
//************************************************************************************************************************************************************************  
function openWindow(url,largura,altura,top,left)
{
	top=((top/2)-(altura/2));
  	left=((left/2)-(largura/2));
  	window.open(url, altura, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, menubar=no, top='+top+', left='+left+', width='+largura+', height='+altura);
}
//javascript:AbreJanela('arquivo.php',400,630,window.screen.availHeight, window.screen.availWidth)
//************************************************************************************************************************************************************************  

