function formatar(src, mask) {
	var i = src.value.length;
	var saida = mask.substring(0,1);
	var texto = mask.substring(i)
	
	if (texto.substring(0,1) != saida) {
		src.value += texto.substring(0,1);
	}
}

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");
}

//funo 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;

//funco  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=yes,';
	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) {
			return document.all[obj];
		}
		else {
			obj = obj.split(".");
			i = obj.length - 1;
			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 ] 
  validao 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 no  um e-mail vlido');
}

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 CheckCPF (thisCPF) {
	
				thisCPF = thisCPF.replace(".","");
				thisCPF = thisCPF.replace(".","");
				thisCPF = thisCPF.replace("-","");				

                 cpf = thisCPF;
                 erro = new String;
                 if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
                 var nonNumbers = /\D/;
                 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n"; 
                 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
                         erro += "Numero de CPF invalido!"
               }
               var a = [];
               var b = new Number;
               var c = 11;
               for (i=0; i<11; i++){
                       a[i] = cpf.charAt(i);
                       if (i < 9) b += (a[i] * --c);
               }
               if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
               b = 0;
               c = 11;
               for (y=0; y<10; y++) b += (a[y] * c--); 
               if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
               if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
                       erro +="Digito verificador com problema!";
               }
               if (erro.length > 0){
                       alert(erro);
                       return false;
               }
               return true;


}

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 no  uma data vlida');
		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;

	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;
}
	/* Abre janela centralizada */
	function openCenterWin(url,nome,largura,altura, propriedades){
		var Top=(screen.height/2)-(altura/2);
		var Left=(screen.width/2)-(largura/2);
		var features='height='+altura+',width='+largura+',top='+Top+',left='+Left+','+propriedades;	
		
		janela=window.open(url,nome,features);

		return janela;
	}