function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features+",resizable=1");
}

function Limita(Nome,Limite) { //v2.0
	if(Limite>0){
  	if(document.getElementById(Nome).value.length>Limite){
  		document.getElementById(Nome).value=document.getElementById(Nome).value.substr(0,Limite);
  	}
	}	
}

function IsEmail(Email){
 if(Email != ''){
    if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(Email)){
			return false;
    }else{
		  return true;
	  }
 }else{
 		return true;
 }	
}

function IsNumeric(sText){
  var ValidChars2 = "0123456789,";
  var Status=true;
  var Char;
	var Arr=sText.split(",")
	if(Arr.length>2){
		Status = false;
	}else{
    for (i = 0; i < sText.length && Status == true; i++){ 
       Char = sText.charAt(i); 
       if (ValidChars2.indexOf(Char) == -1){
         Status = false;
       }
		}		 
 	}
 return Status; 
}

function IsTelefone(sText){
  var ValidChars2 = "+() 0123456789\/.";
  var Status=true;
  var Char;
  for (i = 0; i < sText.length && Status == true; i++){ 
     Char = sText.charAt(i); 
     if (ValidChars2.indexOf(Char) == -1){
       Status = false;
     }
 }
 return Status; 
}

function getkey(e){
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}

function goodchars(e, goods)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;

// get character
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
	return true;

// control keys
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
   return true;

// else return false
return false;
}
