//<script>

function valida(form)
{
	x = form.elements.length -1
	for (i = 0; i <= x; i++)
	{
 		tipo = form.elements[i].name
		tipo = tipo.substring(0, 5)
		tipo = tipo.toUpperCase()
		campo = form.elements[i].name
		campo = campo.substring(5)
		switch (tipo)
		{
			case 'V_REQ': //REQUERIDO
				if (!isNotEmpty(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_NUL': //NULO
				if (!isEmpty(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_INT': //INTEIRO - NÃO REQUERIDO
				if (!isInteger(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_CEP':
				if (!isCEP(form.elements[campo],form.elements[i].value))
					return false;
				break;
			case 'V_DBL': //DOUBLE (numérico) - NÃO REQUERIDO
				if (!isDouble(form.elements[campo], form.elements[i].value))
					return false;				
				break;			
			case 'V_EMA': //EMAIL - NÃO REQUERIDO
				if (!isEmail(form.elements[campo], form.elements[i].value))
					return false;
				break;			
			case 'V_CPF': //CPF - NÃO REQUERIDO
				if (!isCPF(form.elements[campo], form.elements[i].value))
					return false;
				break;			
			case 'V_CNPJ': //CNPJ - NÃO REQUERIDO
				if (!isCNPJ(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_CAR': //CARACTERES INVÁLIDOS
				if (!isCarac(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_DTA': //DATA
				if (!CheckDate(form.elements[campo],form.elements[i].value))
					return false;
				break;
			case 'V_DT2': //DATA
				sDia = campo + '_dd'
				sMes = campo + '_mm'
				sAno = campo + '_aaaa'
				if (!isDate_Ind(form.elements[sDia], form.elements[sMes], form.elements[sAno], form.elements[i].value))
					return false;
				break;
			case 'V_HOR': //HORA
				if (!isHour(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_LIM': //LIMITA TEXT
				if (!LimitaText(form.elements[campo], form.elements[i].value))
					return false;
				break;
			case 'V_ANU': //ALFANUMERICO
				if (!isAlphaNumeric(form.elements[campo], form.elements[i].value))
					return false;
				break;
		}				
	}
	return true;
}

function isNotEmpty(campo, mensagem)
{
	if (campo.type == 'select-one')
	{
		if (campo.selectedIndex == 0)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
	}
	else
	{
		if (campo.value == '')
		{
			alert(mensagem);
			if (campo.type != 'hidden') {
				campo.focus();	
			}
			return false;
		}
	}
	return true;
}

function isEmpty(campo, mensagem){
	if (campo.type == 'select-one'){
		if (campo.selectedIndex != 0)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
	}
	else{
		if (campo.value != ''){
			alert(mensagem);
			if (campo.type != 'hidden') {
				campo.focus();	
			}
			return false;
		}
	}
	return true;
}

function isDouble(campo, mensagem)
{
	sValor = campo.value;
	sValor = sValor.toString();
	sValor = sValor.replace(',','.');
	if (isNaN(sValor) && sValor != '')
	{
		alert(mensagem);
		campo.focus();	
		return false;
	}
	return true;
}

function isInteger(campo,mensagem)
{
	sValor = campo.value;
	sValor = sValor.toString();
	xpqp = sValor.length
	for (iputo = 0; iputo < xpqp; iputo++)
	{
		sAux = sValor.charAt(iputo);
		if (sAux < '0' || sAux > '9')
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
	}
	return true;
}

function isEmail(campo,mensagem)
{
	if (campo.value != '')
	{
		var i = 1;
		sValor = campo.value
		sLength = sValor.length;

		while ((i < sLength) && (sValor.charAt(i) != '@'))
			i++
			
		if ((i >= sLength) || (sValor.charAt(i) != '@')) 
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
		else
			i += 2;
		while ((i < sLength) && (sValor.charAt(i) != '.'))
			i++
		if ((i >= sLength - 1) || (sValor.charAt(i) != '.')) 
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
	}
	return true;
}

function isCPF(campo,mensagem)
{
	sValor1 = campo.value;
	sValor1 = sValor1.toString();
	sValor = '';
	xpqp = sValor1.length
	for (iputo = 0; iputo < xpqp; iputo++)
	{
		sAux = sValor1.charAt(iputo);
		if (sAux < '0' || sAux > '9')
		{
			if (sAux != '.' && sAux != '-' && sAux != '/')
			{
				alert(mensagem);
				campo.focus();
				return false;
			}
		}
		else
		{
			sAux = sAux.toString();
			sValor = sValor + '' + sAux;
		}
	}
	if (sValor != '')
	{
		if (isNaN(sValor) || sValor.length != 11)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
		soma = (sValor.substr(0,1) * 10) + (sValor.substr(1,1) * 9) + (sValor.substr(2,1) * 8) + (sValor.substr(3,1) * 7) + (sValor.substr(4,1) * 6) + (sValor.substr(5,1) * 5) + (sValor.substr(6,1) * 4) + (sValor.substr(7,1) * 3) + (sValor.substr(8,1) * 2);
		dv1 = (soma % 11);
		if (dv1 == 0 || dv1 == 1) 
			dv1 = 0;
		else
			dv1 = 11 - dv1;
		soma = (sValor.substr(0,1) * 11) + (sValor.substr(1,1) * 10) + (sValor.substr(2,1) * 9) + (sValor.substr(3,1) * 8) + (sValor.substr(4,1) * 7) + (sValor.substr(5,1) * 6) + (sValor.substr(6,1) * 5) + (sValor.substr(7,1) * 4) + (sValor.substr(8,1) * 3) + (dv1 * 2);
		dv2 = (soma % 11);
		if (dv2 == 0 || dv2 == 1) 
			dv2 = 0;
		else
			dv2 = 11 - dv2;
		if (sValor.substr(9,1) != dv1 || sValor.substr(10,1) != dv2)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
	}
	return true;
}

function isCNPJ(campo,mensagem)
{
	sValor1 = campo.value;
	sValor1 = sValor1.toString();
	sValor = '';
	xpqp = sValor1.length
	for (iputo = 0; iputo < xpqp; iputo++)
	{
		sAux = sValor1.charAt(iputo);
		if (sAux < '0' || sAux > '9')
		{
			if (sAux != '.' && sAux != '-' && sAux != '/')
			{
				alert(mensagem);
				campo.focus();
				return false;
			}
		}
		else
			sValor = sValor + sAux
	}
	if (sValor != '')
	{
		if (isNaN(sValor) || sValor.length != 14)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
		soma = (sValor.substr(0,1) * 5) + (sValor.substr(1,1) * 4) + (sValor.substr(2,1) * 3) + (sValor.substr(3,1) * 2) + (sValor.substr(4,1) * 9) + (sValor.substr(5,1) * 8) + (sValor.substr(6,1) * 7) + (sValor.substr(7,1) * 6) + (sValor.substr(8,1) * 5) + (sValor.substr(9,1) * 4) + (sValor.substr(10,1) * 3) + (sValor.substr(11,1) * 2)
		dv1 = (soma % 11);
		if (dv1 == 0 || dv1 == 1) 
			dv1 = 0;
		else
			dv1 = 11 - dv1;
		soma = (sValor.substr(0,1) * 6) + (sValor.substr(1,1) * 5) + (sValor.substr(2,1) * 4) + (sValor.substr(3,1) * 3) + (sValor.substr(4,1) * 2) + (sValor.substr(5,1) * 9) + (sValor.substr(6,1) * 8) + (sValor.substr(7,1) * 7) + (sValor.substr(8,1) * 6) + (sValor.substr(9,1) * 5) + (sValor.substr(10,1) * 4) + (sValor.substr(11,1) * 3)  + (dv1 * 2)
		dv2 = (soma % 11);
		if (dv2 == 0 || dv2 == 1) 
			dv2 = 0;
		else
			dv2 = 11 - dv2;
		if (sValor.substr(12,1) != dv1 || sValor.substr(13,1) != dv2)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}
	}
	return true;
}

function isCarac(campo, mensagem)
{ if (!/^[a-zA-Z0-9\-\.\_]{0,250}$/.test(campo.value)){
	alert(mensagem);
	campo.focus();
	return false;
	}
return true;
}

function isDate_Ind(objDia, objMes, objAno, mensagem)
{
	if (objDia.type == 'select-one')
		dia = objDia.options[objDia.selectedIndex].value;
	else
		dia = objDia.value;
	
	if (objMes.type == 'select-one')
		mes = objMes.options[objMes.selectedIndex].value;
	else
		mes = objMes.value;

	if (objAno.type == 'select-one')
		ano = objAno.options[objAno.selectedIndex].value;
	else
		ano = objAno.value;
	
	if (isNaN(dia) || isNaN(mes) || isNaN(ano) || dia == '' || mes == '' || ano == '')
	{
		alert(mensagem);
		objDia.focus();
		return false;
	}
	diaAux = 0;
	dia = parseInt(dia,10)
	mes = parseInt(mes,10)
	ano = parseInt(ano,10)
		
	switch (mes)
	{
		case 2 :
			if (((ano % 400) == 0) || ((ano % 4) == 0 && (ano % 100) != 0))
				diaAux = 29;
			else
				diaAux = 28;
			break;
		case 1  :
		case 3  :
		case 5  :
		case 7  :
		case 8  :
		case 10 :
		case 12 :
			diaAux = 31;
			break;
		case 4 :
		case 6 :
		case 9 :
		case 11:
			diaAux = 30;
			break;
		default:
			diaAux = 0;
	} 
	if (dia > diaAux || dia < 1)
	{
		alert(mensagem);
		objDia.focus();
		return false;
	}
	else
		return true;
}

function isCEP(campo, mensagem)
{
		
	if (campo.value != '')
	{
		var CEPPat = /^(\d{5})(\-)?(\d{3})$/;
		var strAux = campo.value;
		strAux = strAux.toString();
			
		if (strAux.match(CEPPat) == null)
		{
			alert(mensagem);
			campo.focus();
			return false;
		}		
	}	
		
     var s;
     s = document.Cadastro.Senha;
     var i; 
     var num = 0, carac = 0;
     for (i = 0; i < s.value.length; i++)
{
	var c = s.value.charAt(i);
        // ha um numero
	if (((c >= "0") && (c <= "9")))
 	{
		num++;
	}
	if (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")))
 	{
		carac++;
	}
	if (c == "'" || c == "`" || c == '"' || c == '<' || c == '>')
	{
		alert("Campo com caractere inválido!!");
          	document.Cadastro.Senha.focus();	
		return false;		
	}
     }

     if (document.Cadastro.Senha.value.length == 0 || document.Cadastro.Senha2.value.length == 0) {
	alert("As senhas são obrigatórias !");
        document.Cadastro.Senha.focus();
        return false;
     }

     if (document.Cadastro.Senha.value.length < 1) {
	alert("A senha deve ter no mínimo 1 caractere !");
        document.Cadastro.Senha.focus();
        return false;
     }

     if (document.Cadastro.Senha.value.length > 14) {
	alert("A senha deve ter no máximo 14 caracteres !");
        document.Cadastro.Senha.focus();
        return false;
     }

     if (document.Cadastro.Senha.value != document.Cadastro.Senha2.value) {
	alert("As senhas não são iguais !");
        document.Cadastro.Senha.focus();
        return false;
     }
	 s = document.Cadastro.Senha.value
	 hoje = new Date()
	 ano = hoje.getYear()
	 for (f=-2; f<=2; f++){
	 	n = s.indexOf(ano + f,0)
		if (n > -1){
			alert('Não é permitido colocar o ano como senha.');
			document.Cadastro.Senha.focus();
	        return false;
		}

    return true;
       }
}

function isHour(campo, mensagem) {
	// Verifica se horário está no formato HH:MM:SS.
	
	sValor = campo.value
	
	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?$/;
	
	var matchArray = sValor.match(timePat);
	
	if (matchArray == null) {
		alert(mensagem);
		campo.focus();
		return false;
	}

	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	
	if (second=="") { second = null; }
	
	if (hour < 0  || hour > 23) {
		alert("As horas devem estar entre 0 e 23.");
		//campo.focus();
		return false;
	}
	if (minute<0 || minute > 59) {
		alert ("Os minutos devem estar entre 0 and 59.");
		//campo.focus();
		return false;
	}
	if (second != null && (second < 0 || second > 59)) {
		alert ("Os segundos devem estar entre 0 and 59.");
		//campo.focus();
		return false;
	}
	return true;
}

function isAlphaNumeric(campo, msg){
	var re = /[^a-zA-Z0-9]/g
	if (re.test(campo.value)) {
		alert(msg);
		return false;
	}
	return true;
}

function formata_telefone(campo) {
   var valor='';
   var digito = false;
   a = campo.value;
   if (a) {
   num = a.length;
   for (f=0;f<num;f++)
     {
     if (parseInt(a.substr(f,1)) || a.substr(f,1)=='0') 
        if ((a.substr(f,1) != '0') || digito) valor = valor + '' + a.substr(f,1);
        if (parseInt(a.substr(f,1)) && a.substr(f,1) != '0') digito = true;
     };
   num = valor.length;
   if (num < 9 || num > 10)
      {
      alert ('O Número de telefone não é válido. \nUtilize o padrão (99) 9999-9999');
      campo.value = '';
      campo.focus();
      }
	  else
	  {
	  if (num == 9) valor = '(' + valor.substr(0, 2) + ') ' + valor.substr(num-7, 3) + '-' + valor.substr(num-4, 4);
	  if (num == 10) valor = '(' + valor.substr(0, 2) + ') ' + valor.substr(num-8, 4) + '-' + valor.substr(num-4, 4);
	  campo.value = valor;
	  }
   }
}
function formata_cep(campo) 
{
   var valor='';
   a = campo.value;
   if (a) {
   num = a.length;
   
   for (f=0;f<num;f++)
     {
     if (parseInt(a.substr(f,1)) || a.substr(f,1)=='0') 
        valor = valor + '' + a.substr(f,1);
     };
   num = valor.length;
   if (num != 5 && num != 8)
	  {
      alert ('O Campo CEP inválido. \nUtilize o padrão 99.999-999');
      campo.value = '';
      campo.focus();
	  }
      else
	  {	
      if (num == 5) valor = valor.substr(0, 2) + '.' + valor.substr(num-3, 3) + '-000';
      if (num == 8) valor = valor.substr(0, 2) + '.' + valor.substr(num-6, 3) + '-' + valor.substr(num-3, 3);
      campo.value = valor;
	  }
   }
}

function formata_data(campo) 
{
if (window.event.keyCode < 44 || window.event.keyCode > 57 || window.event.keyCode == 45 || window.event.keyCode == 47 ) 
    {
    window.event.keyCode=0;
    return false;
	}
else
    {
   var valor=campo.value;
   switch (valor.length)
       {
	case 2 :
		valor = valor + '/';
		break;
	case 5 :
		valor = valor + '/'
		break;
	   }	
   campo.value = valor;   
   }
}

function formata_hora(campo) 
{
//FORMATA HH:MM

if (window.event.keyCode < 44 || window.event.keyCode > 57 || window.event.keyCode == 45 || window.event.keyCode == 47 ) 
    {
    window.event.keyCode=0;
    return false;
	}
else
    {
   var valor=campo.value;
   switch (valor.length)
       {
	case 2 :
		valor = valor + ':';
		break;
	   }	
   campo.value = valor;   
   }
}

function SomenteNumero(){
	if ((window.event.keyCode < 48 || window.event.keyCode > 57 ) && (window.event.keyCode != 13) )  {
			window.event.keyCode=0;
			return false;
	}
}

function SomenteMoeda(){
	if ((window.event.keyCode < 44 || window.event.keyCode > 57 || window.event.keyCode == 45 || window.event.keyCode == 47) && (window.event.keyCode != 13) )  {
			window.event.keyCode=0;
			return false;
	}
}

function SomenteNumeroVirgula(){
	if ((window.event.keyCode < 48 || window.event.keyCode > 57) && (window.event.keyCode != 13) && (window.event.keyCode != 44))  {
			window.event.keyCode=0;
			return false;
	}
}

function conta_caracteres(pMax,campo,conta){
	  var maxSize = pMax
      var minSize = 0;
	  var vCampo=campo;
	  var vConta=conta;
	  
      minSize = vCampo.value.length;
      if (minSize > maxSize){
	      	//window.alert ("O campo não pode conter mais que " + maxSize + " caracteres.")	
			vCampo.value = vCampo.value.substring(0,maxSize);
	  }
      else {
		  vConta.value = maxSize - vCampo.value.length;
      }
}

function liap(pCampo, pTexto){
	if(pCampo.value==pTexto){
		pCampo.value='';
	}
}

function CheckDate(campo,mensagem){ 
	if(!isDate(campo.value)){ 
		alert(mensagem);
		campo.focus();
		return false; 
	} 
	campo.value = FormatDate(campo.value,"dd/mm/yyyy"); 
	return true;
} 

function isDate(DateToCheck){
	if(DateToCheck==""){return true;}
	var m_strDate = FormatDate(DateToCheck);
	if(m_strDate==""){
		return false;
	}
	var m_arrDate = m_strDate.split("/");
	var m_DAY = m_arrDate[0];
	var m_MONTH = m_arrDate[1];
	var m_YEAR = m_arrDate[2];
	if(m_YEAR.length > 4){return false;}
	m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;
	var testDate=new Date(m_strDate);
	if(testDate.getMonth()+1==m_MONTH){
		return true;
	} 
	else{
		return false;
	}
}//end function

function FormatDate(DateToFormat,FormatAs){
	if(DateToFormat==""){return"";}
	if(!FormatAs){FormatAs="dd/mm/yyyy";}
	
	var strReturnDate;
	FormatAs = FormatAs.toLowerCase();
	DateToFormat = DateToFormat.toLowerCase();
	var arrDate
	var arrMonths = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro");
	var strMONTH;
	var Separator;
	
	while(DateToFormat.indexOf("st")>-1){
	DateToFormat = DateToFormat.replace("st","");
	}
	
	while(DateToFormat.indexOf("nd")>-1){
	DateToFormat = DateToFormat.replace("nd","");
	}
	
	while(DateToFormat.indexOf("rd")>-1){
	DateToFormat = DateToFormat.replace("rd","");
	}
	
	while(DateToFormat.indexOf("th")>-1){
	DateToFormat = DateToFormat.replace("th","");
	}
	
	if(DateToFormat.indexOf(".")>-1){
	Separator = ".";
	}
	
	if(DateToFormat.indexOf("-")>-1){
	Separator = "-";
	}
	
	
	if(DateToFormat.indexOf("/")>-1){
	Separator = "/";
	}
	
	if(DateToFormat.indexOf(" ")>-1){
	Separator = " ";
	}
	
	arrDate = DateToFormat.split(Separator);
	DateToFormat = "";
		for(var iSD = 0;iSD < arrDate.length;iSD++){
			if(arrDate[iSD]!=""){
			DateToFormat += arrDate[iSD] + Separator;
			}
		}
	DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
	arrDate = DateToFormat.split(Separator);
	
	if(arrDate.length < 3){
	return "";
	}
	
	var DAY = arrDate[0];
	var MONTH = arrDate[1];
	var YEAR = arrDate[2];
	
	
	
	
	if(parseFloat(arrDate[1]) > 12){
	DAY = arrDate[1];
	MONTH = arrDate[0];
	}
	
	if(parseFloat(DAY) && DAY.toString().length==4){
	YEAR = arrDate[0];
	DAY = arrDate[2];
	MONTH = arrDate[1];
	}
	
	
	for(var iSD = 0;iSD < arrMonths.length;iSD++){
	var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
	var MonthPosition = DateToFormat.indexOf(ShortMonth);
		if(MonthPosition > -1){
		MONTH = iSD + 1;
			if(MonthPosition == 0){
			DAY = arrDate[1];
			YEAR = arrDate[2];
			}
		break;
		}
	}
	
	var strTemp = YEAR.toString();
	if(strTemp.length==2){
	
		if(parseFloat(YEAR)>40){
		YEAR = "19" + YEAR;
		}
		else{
		YEAR = "20" + YEAR;
		}
	
	}
		if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){
		MONTH = "0" + MONTH;
		}
		if(parseInt(DAY)< 10 && DAY.toString().length < 2){
		DAY = "0" + DAY;
		}
		switch (FormatAs){
		case "dd/mm/yyyy":
		return DAY + "/" + MONTH + "/" + YEAR;
		case "mm/dd/yyyy":
		return MONTH + "/" + DAY + "/" + YEAR;
		case "dd/mmm/yyyy":
		return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
		case "mmm/dd/yyyy":
		return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
		case "dd/mmmm/yyyy":
		return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
		case "mmmm/dd/yyyy":
		return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
		}
	
	return DAY + "/" + strMONTH + "/" + YEAR;;

} //End Function

function InStr(n, s1, s2){
	var numargs=InStr.arguments.length;	
	if(numargs<3)
		return n.indexOf(s1)+1;
	else
		return s1.indexOf(s2, n)+1;
}

function abrePop(pURL,pNome,pFeatures) { //v2.0
  window.open(pURL,pNome,pFeatures);
}

function LimitaText(pCampo, pLimite){
	editor_setmode('TextoSite', '');
	setTimeout("editor_setmode('TextoSite','init');",100);
	
	var Limite = pLimite;
	var TamCampo = pCampo.value.length;
	
	if (TamCampo > Limite){
		alert("O campo " + pCampo.name + " não pode conter mais de " + Limite + " caracteres.\nVocê digitou " + TamCampo + " caracteres.");
		return false;
	}
	else{
		return true;
	}
}

function SelAll (pForm){
	var nb;
	var chk;
	if (pForm.SEL_ALL.value == 0){
		chk=1;
	}
	else{
		chk=0;
	}

	nb = pForm.elements.length;
	for (var i=0;i<nb;i++){
		var e = pForm.elements[i];
		e.checked = chk;
	}
	pForm.SEL_ALL.value = chk;

}

function SaltaCampo(pCampo,pLen,pCampoDestino){
	if(pCampo.length == pLen){
		pCampoDestino.focus();
	}	
}

function RemoveHttp(pCampo){
	if(pCampo.value != ""){
		var vValorCampo;
		vValorCampo = pCampo.value;
		vValorCampo = vValorCampo.replace('http://','');
		vValorCampo = vValorCampo.replace('http:/','');
		vValorCampo = vValorCampo.replace('http:','');
		vValorCampo = vValorCampo.replace('http:\\','');
		vValorCampo = vValorCampo.replace('https://','');
		vValorCampo = vValorCampo.replace('https:/','');
		vValorCampo = vValorCampo.replace('https:','');
		
		pCampo.value = vValorCampo;
	}	
}

function MascaraCEP (pCampo){
	if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) {
			event.returnValue = false;
	}
	campo = eval (pCampo);
	caracteres = '01234567890';
	separacoes = 1;
	separacao1 = '-';
	conjuntos = 2;
	conjunto1 = 5;
	conjunto2 = 3;
	if ((caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto1 + conjunto2 + 1)) {
		if (campo.value.length == conjunto1) 
			campo.value = campo.value + separacao1;
	}else 
		event.returnValue = false;

}