function abrewin(url,trg, altura, largura) {
	window.open(url,trg, 'height='+altura+', width='+largura);
}


/////////////////////////////////////////////////////////////////////////////////////
//
//          VALIDAÇÃO DO CAMPO E-MAIL
//
////////////////////////////////////////////////////////////////////////////////////

 function emailv(text_) {
  			var invalid;
			invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;			
	
			        if (invalid.test(text_.value) == false) {        						
        				return (false); }
        		  return (true); 
		  
}

///////////////////////////////////
//                               //
//    Bloqueio de Não Numériocs  //
//                               //
///////////////////////////////////
function isNum( caractere )       
{ 
 var strValidos = "0123456789-.,;"
 if ( strValidos.indexOf( caractere ) == -1 )   
    return false;   

    return true;   
} 
  
function validaTecla(campo, event) 
  
{   

var BACKSPACE= 8;   
var key;   
var tecla; 
CheckTAB=true;   

if(navigator.appName.indexOf("Netscape")!= -1) 
        tecla= event.which; 
    else 
        tecla= event.keyCode; 
    key = String.fromCharCode( tecla); 
//alert( 'key: ' + tecla + ' -> campo: ' + campo.value); 
    if ( tecla == 13 )   
        return false;   
    if ( tecla == BACKSPACE ) 
        return true;   
return ( isNum(key)); 

} 

function isNum2( caractere )
{
 var strValidos = "0123456789"
 if ( strValidos.indexOf( caractere ) == -1 )
    return false;

    return true;
}

function isNum3( caractere )
{
 var strValidos = "0123456789-"
 if ( strValidos.indexOf( caractere ) == -1 )
    return false;

    return true;
}

//função semelhante a anterior porém
// que só deixa passar caracteres não numéricos
function valida_alfabeto(campo, event)
{

var BACKSPACE= 8;
var key;
var tecla;
CheckTAB=true;

    if(navigator.appName.indexOf("Netscape")!= -1)
            tecla= event.which;
        else
            tecla= event.keyCode;
        key = String.fromCharCode( tecla);
        if ( tecla == 13 )
            return false;
        if ( tecla == BACKSPACE )
            return true;
    return (!isNum2(key));

}

function moeda(campo, e)
{
   var SeparadorDecimal = ","
   var SeparadorMilesimo = "."
   var sep = 0;
   var key = '';
   var i = j = 0;
   var len = len2 = 0;
   var strCheck = '0123456789';
   var aux = aux2 = '';
   var whichCode = (window.Event) ? e.which : e.keyCode;

   if (whichCode == 13) return true;
   key = String.fromCharCode(whichCode); // Valor para o código da Chave

   if (strCheck.indexOf(key) == -1) return true; // Chave inválida
   len = campo.value.length;
   for(i = 0; i < len; i++)

       if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != SeparadorDecimal)) break;
   aux = '';
   for(; i < len; i++)

       if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
   aux += key;
   len = aux.length;

   if (len == 0) campo.value = '';
   if (len == 1) campo.value = '0'+ SeparadorDecimal + '0' + aux;
   if (len == 2) campo.value = '0'+ SeparadorDecimal + aux;
   if (len > 2) {
       aux2 = '';
       for (j = 0, i = len - 3; i >= 0; i--) {
           if (j == 3) {
               aux2 += SeparadorMilesimo;
               j = 0;
           }
           aux2 += aux.charAt(i);
           j++;
       }
       campo.value = '';
       len2 = aux2.length;
       for (i = len2 - 1; i >= 0; i--)
       campo.value += aux2.charAt(i);
       campo.value += SeparadorDecimal + aux.substr(len - 2, len);
}
   return false;

}

//###################################
// Fone
//

// Valida campos do tipo fone
//Formato: 000-0000-0000
// In: Campo do Tipo Nro (text)
//GDI Multimidia
//Catana Rahmeier
//Em 10/2006
//###################################
function Fone(campo) {
		//cria a regra para o formato de telefone
		//		(000)0000-0000
		// Criamos um objeto chamado regra
		var regra = /^([0-9]{2,3}-){0,1}[0-9]{3,4}-[0-9]{4}$/;
		//exec vai retornar true ou false de acordo com a regra
		var verifica = regra.exec(campo.value);
	
	   if(!verifica && campo.value!=""){
		      alert('O telefone '+campo.value+' não é válido.');
		      return false;
	   }
}





