
function setMascara(mascara, documento){
	var i = documento.value.length;
	var saida = mascara.substring(0,1);
	var texto = mascara.substring(i);
	
	if (texto.substring(0,1) != saida){
		documento.value += texto.substring(0,1);
	}
}

function mascara_data(data){ 
	var mydata = ''; 
	mydata = mydata + data; 
	if (mydata.length == 2){ 
		mydata = mydata + '/'; 
		document.forms[0].data.value = mydata; 
	} 
	if (mydata.length == 5){ 
		mydata = mydata + '/'; 
		document.forms[0].data.value = mydata; 
	} 
	if (mydata.length == 10){ 
		verifica_data(); 
	} 
} 
           
function verifica_data () { 
	dia = (document.forms[0].data.value.substring(0,2)); 
	mes = (document.forms[0].data.value.substring(3,5)); 
	ano = (document.forms[0].data.value.substring(6,10)); 
	
	situacao = ""; 
	// verifica o dia valido para cada mes 
	if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
		situacao = "falsa"; 
	} 
	
	// verifica se o mes e valido 
	if (mes < 01 || mes > 12 ) { 
		situacao = "falsa"; 
	} 
	
	// verifica se e ano bissexto 
	if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
		situacao = "falsa"; 
	} 
	
	if (document.forms[0].data.value == "") { 
		situacao = "falsa"; 
	} 
	
	if (situacao == "falsa") { 
		alert("Data inválida!"); 
		document.forms[0].data.focus(); 
	} 
} 

function doMudaTag(obAtual, cod) {

	areaCurriculo(cod);

	var vItensMenu = 5;
	var	stImg  = "brr_noticia_esq_off.gif";
	var midImg = "brr_noticia_meio_off.gif";
	var lstImg = "brr_noticia_dir_off.gif";
	
	var	stImgOn  = "brr_noticia_esq_on.gif";
	var midImgOn = "brr_noticia_meio_on.gif";
	var lstImgOn = "img_tab_in_fundo.gif";
	
	for (a = 1; a <= vItensMenu; a++) {
		
		retornaObj('lyrNoticia'+a).className = "tabOut";
		
		if (a == vItensMenu) {
			retornaObj('lyrNoticia'+a+''+a).className = "tabOutImage";
		}
		else {
			retornaObj('lyrNoticia'+a+''+a).className = "tabOutImage1";
		}
	}
	
	retornaObj('lyrNoticia'+cod).className = "tabIn";
	
	if (cod > 1) {
		retornaObj('lyrNoticia'+(cod-1)+''+(cod-1)).className = "tabInImage1";
	}
	
	if (cod == vItensMenu) {
		retornaObj('lyrNoticia'+cod+''+cod).className = "tabInImage";
	}
	else {
		retornaObj('lyrNoticia'+cod+''+cod).className = "tabInImage2";
	}
}

function verFoto(COD_FOTO){
	NewWindow("produto_foto.php?COD_FOTO="+COD_FOTO,"fotos",400,350,"no");
}

//função para o sub menu
function AbrirSubMenu(COD_CATEGORIA) {
	var i;
	categoria_item = "linha_"+COD_CATEGORIA;
	path = document.getElementById(categoria_item);
	var menu	= document.getElementsByTagName('div');
	for (i=0;i<menu.length;i++)
	{
		if (menu[i].getAttribute('lang') != null && menu[i].getAttribute('lang') != "")
			menu[i].style.display = 'none';
	}
	

	if(path.style.display=='') {
		path.style.display='none';
	} else {
		path.style.display='';
	}
}

var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var ns6=document.getElementById&&!document.all;
var ns4=document.layers;

//funcção  para abrir janela popup
function NewWindow(mypage,myname,w,h,bars) {

	
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='status=yes,';		
	settings +='left='+winl+',';
	settings +='resizable=no,';
	settings +='scrollbars='+bars;

	win=window.open(mypage,myname,settings);
	
	if(parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function retornaObj(obj) {
	
	if (ie4){
		
		if (obj.indexOf(".") == -1) {
			//alert(obj);
			return document.all[obj];
		}
		else {
			obj = obj.split(".");
			i = obj.length - 1;
			//alert(obj[i]);
			return document.all[obj[i]];
		}
		
	} else if (ns6) {
		
		if (obj.indexOf(".") == -1) {
			return document.getElementById(""+obj+"");
		}
		else {
			return eval("document."+obj);
		}
		
	} else if (ns4) {
		
		if (obj.indexOf(".") == -1) {
			return document[obj];
		}
		else {
			obj = obj.split(".");
			i = obj.length - 1;
			return document[obj[i]];
		}
		
	} else {
		
		if (obj.indexOf(".") == -1) {
			return document.getElementById(""+obj+"");
		}
		else {
			return eval("document."+obj);
		}
		
	}
	
}

function doValidarCampo(campo, msg) {

	if(campo.value == "" || campo.value.length == 0) {
		alert(msg);
		campo.focus();
		return false;
	}
	return true;
}

function doValidarCampoLength(campo, tam, msg) {

	if(campo.value == "" || campo.value.length < tam) {
		alert(msg);
		campo.focus();
		return false;
	}
	return true;
}

function doValidarCampoNoFocus(campo, msg) {

	if(campo.value == "" || campo.value.length == 0) {
		alert(msg);
		return false;
	}
	return true;
}

function formataValor(Obj) {
	var data = new String(Obj.value);
	var dataok = '';
	var cont = 0;
	var contPonto = 0;
	
	for (i = 0; i < data.length; i++) {
		if ( ( (data.charAt(i) >= '0') && (data.charAt(i) <= '9') ) || (data.charAt(i) == "." || data.charAt(i) == ",") ) {
			if (data.charAt(i) == "," || data.charAt(i) == ".") {
				if (contPonto == 0) {
					dataok += ".";
					contPonto = 1;
				}
			}
			else {
				dataok += data.charAt(i);
			}
		}
		else 
			cont++;
	} 
	Obj.value = dataok;
}

function doFormatarCampo(field, mask, e) {
	if (navigator.appName == "Netscape")
		key = e.which;
	else
		key = e.keyCode;

	string = field.value;
	i = string.length;

	keys = (key == 8 || key == 9 || key == 13 || key == 46 || (key > 36 && key < 41));

	if (i < mask.length) {
		if (mask.charAt(i) == '§')
			return (keys || key > 47 && key < 58);
		else {
			if (mask.charAt(i) == '!')
				return true; 
		
			for (c = i; c < mask.length; c++) {
				if (mask.charAt(c) != '§' && mask.charAt(c) != '!')
					field.value = field.value + mask.charAt(c);
				else if (mask.charAt(c) == '!')
					return true;
				else
					return (key > 47 && key < 58);
			}
		}
	} else 
		return keys;
}
function doValidarCEP(obj) {

 var data = new String(obj.value);
 var dataok = '';
 var cont = 0;

 
	 for (i = 0; i < data.length; i++) {
		  if ((data.charAt(i) >= '0') && (data.charAt(i) <= '9') || (data.charAt(i) == '-') && i==5) {
			dataok += data.charAt(i);
		  }
		  else cont++;
	 }
		
	 if (cont > 0) {  
		obj.value = dataok;
	 }

	if (obj.value.indexOf("-") == -1 && obj.value.length > 5){ 
		obj.value = ""; 
	}
	if (obj.value.length == 5){
		obj.value += "-";
	}
}

function setNumberOnly(Obj) {
	
	var data = new String(Obj.value);
	var dataok = '';
	var cont = 0;
 
	for (i = 0; i < data.length; i++) {
		if ((data.charAt(i) >= '0') && (data.charAt(i) <= '9')) {
			dataok += data.charAt(i);
		}
		else {
			cont++;
		}
	}
	
	if (cont > 0) {  
		Obj.value = dataok;
	}
	
}

/* 
  power by djony 
  jmene@proway.com.br
  [ 25/10/2006 ] 
  validação de e-mail 
*/
  
function doValidarEmail(obj) 
{
	
	var mail = obj.value;
	if (obj.value.length > 0)
	if ((mail.indexOf('@') < 3) || ((mail.lastIndexOf('.') < (mail.indexOf('@') + 3)) || (mail.indexOf('.') == -1)))
		alert('O e-mail digitado não é um e-mail válido');
}

function MascaraCPF (formato, objeto)
{
	campo = eval (objeto);
	if (formato=='CPF')
	{
		caracteres = '01234567890';
		separacoes = 3;
		separacao1 = '.';
		separacao2 = '-';
		conjuntos = 4;
		conjunto1 = 3;
		conjunto2 = 7;
		conjunto3 = 11;
		conjunto4 = 14;
	if ((caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto4))
	{
		if (campo.value.length == conjunto1) 
			campo.value = campo.value + separacao1;
		else if (campo.value.length == conjunto2) 
			campo.value = campo.value + separacao1;
		else if (campo.value.length == conjunto3) 
			campo.value = campo.value + separacao2;
	}
	else 
		event.returnValue = false;
	} 
}
function isData(obj) {
	
	var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;

	if (!(reDate.test(obj.value)) && (obj.value.length == 10)) {
		alert('A data digitada não é uma data válida');
		obj.value = '';
	}

}

function nextC(obj,tm,prox)
{
	if (obj.value.length == tm)
		prox.focus();
}
function exibDescLang(desc)
{
		document.getElementById('exibeDesc').innerHTML = '<span class="textoNormal">'+desc+'</span>';
}
function escoDescLang()
{	
document.getElementById('exibeDesc').innerHTML = '&nbsp;';
}
function Validar_Email(email)
{
	if(email.length < 6) {
		return false;
	}
	var x = 0;
	for (var c=0;c<email.length;c++) {
		if (email.substring(c,c+1) == '@') {
			x = c;
		}
	}
	var y = 0;
	if (x > 0) {
		for (c=x;c<email.length;c++) {
			if (email.substring(c,c+1)=='.') {
				y = c;
				var valida = 1;
			}
		}
		if (y > 0) {
			var dominio = '';
			for (c=x;c<y;c++) {
				dominio = dominio + email.substring(1,c);
			}
		}
	}
	else {
		return false;
	}					
	if (y <= x+2){
		return false;
	}				
	if (valida == 1){
		return true;
	}
}
function areaCurriculo(AREA) {
	if(AREA == 1) {
		document.getElementById("dadosPessoais").style.display = '';
		document.getElementById("escolaridade").style.display = 'none';
		document.getElementById("experiencia").style.display = 'none';
		document.getElementById("pretencoes").style.display = 'none';
		document.getElementById("observacoes").style.display = 'none';
	}
	if(AREA == 2) {
		document.getElementById("dadosPessoais").style.display = 'none';
		document.getElementById("escolaridade").style.display = '';
		document.getElementById("experiencia").style.display = 'none';
		document.getElementById("pretencoes").style.display = 'none';
		document.getElementById("observacoes").style.display = 'none';
	}
	if(AREA == 3) {
		document.getElementById("dadosPessoais").style.display = 'none';
		document.getElementById("escolaridade").style.display = 'none';
		document.getElementById("experiencia").style.display = '';
		document.getElementById("pretencoes").style.display = 'none';
		document.getElementById("observacoes").style.display = 'none';
	}
	if(AREA == 4) {
		document.getElementById("dadosPessoais").style.display = 'none';
		document.getElementById("escolaridade").style.display = 'none';
		document.getElementById("experiencia").style.display = 'none';
		document.getElementById("pretencoes").style.display = '';
		document.getElementById("observacoes").style.display = 'none';
	}
	if(AREA == 5) {
		document.getElementById("dadosPessoais").style.display = 'none';
		document.getElementById("escolaridade").style.display = 'none';
		document.getElementById("experiencia").style.display = 'none';
		document.getElementById("pretencoes").style.display = 'none';
		document.getElementById("observacoes").style.display = '';
	}
}
function doRetiraAcento(obj) {

	var valor = obj.value;
	
	valor = valor.toLowerCase();
	
	valor = valor.replace(/á/g, "a");
	valor = valor.replace(/ã/g, "a");
	valor = valor.replace(/â/g, "a");
	valor = valor.replace(/à/g, "a");
	valor = valor.replace(/Á/g, "a");
	valor = valor.replace(/Ã/g, "a");
	valor = valor.replace(/Â/g, "a");
	valor = valor.replace(/À/g, "a");
	valor = valor.replace(/é/g, "e");
	valor = valor.replace(/ê/g, "e");
	valor = valor.replace(/è/g, "e");
	valor = valor.replace(/É/g, "e");
	valor = valor.replace(/Ê/g, "e");
	valor = valor.replace(/È/g, "e");
	valor = valor.replace(/í/g, "i");
	valor = valor.replace(/ì/g, "i");
	valor = valor.replace(/î/g, "i");
	valor = valor.replace(/Í/g, "i");
	valor = valor.replace(/Î/g, "i");
	valor = valor.replace(/Ì/g, "i");
	valor = valor.replace(/ó/g, "o");
	valor = valor.replace(/ò/g, "o");
	valor = valor.replace(/ô/g, "o");
	valor = valor.replace(/õ/g, "o");
	valor = valor.replace(/Ó/g, "o");
	valor = valor.replace(/Ò/g, "o");
	valor = valor.replace(/Ô/g, "o");
	valor = valor.replace(/Õ/g, "o");
	valor = valor.replace(/ú/g, "u");
	valor = valor.replace(/ù/g, "u");
	valor = valor.replace(/û/g, "u");
	valor = valor.replace(/Ú/g, "u");
	valor = valor.replace(/Ù/g, "u");
	valor = valor.replace(/Û/g, "u");
	valor = valor.replace(/ç/g, "c");
	valor = valor.replace(/Ç/g, "c");
	
	return valor;
}