
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

//var campos = new Array('estcivil','fonte','tipotel1','uf','tipo_def','grauesc', 'areas', 'nivel', 'experiencia');
var campos = new Array('estcivil','fonte','tipotel1','tipotel2', 'uf', 'tipo_def', 'areas', 'experiencia', 'nivel', 'atividade', 'experiencia', 'nivel', 'nivel', 'atividade', 'experiencia_ramo', 'tipo_def', 'grauesc', 'cursosup', 'situacaocurso', 'tipocurso', 'cursosup', 'periodo', 'idioma', 'nivelidioma', 'outroscursos', 'informatica', 'habilitacao', 'digitacao', 'nivelinicial', 'nivelfinal', 'atividade', 'periodo');

function valida_num(e) { 
	var validos = new String("0123456789");
	if (document.layers) Key = e.which; 
	else { Key = window.event.keyCode; }
	var keychar = String.fromCharCode(Key);
	if (Key != 0) { 
		if (validos.indexOf(keychar) == -1) return false;
		return true; 
	} 
}

function enter() {
	if (document.layers) Key = e.which; else { Key = window.event.keyCode; }
	alert(Key);
	xajax_login()
}

function getvalue(campo) {
	if(obj = document.getElementById(campo)) return obj.value;
	else alert('Erro ao pegar valor do campo: '+campo);
}

function getcheckvalue(campo) {
	if(obj = document.getElementById(campo)) {
		if (obj.checked == true) return obj.value;
		else return '';
	}
	else alert('Erro ao pegar valor do campo: '+campo);
}


function get_datanasc(){
		var data;
		if(data = document.getElementById('dianasc').value+'/'+document.getElementById('mesnasc').value+'/'+document.getElementById('anonasc').value) return data;
		else return false;
}

function fade_in(obj, num) {
	var desc = obj;
	//if(obj = document.getElementById(obj)) alert('encontrou obj');
	//else if(obj = parent.document.getElementById(obj)) alert('encontrou no parent');
	var obj = parent.document.getElementById(obj);
	var interval;
	num = parseInt(num);
	var cor = new Array('#FFFFFF','#FFF0F0','#FFE1E1','#FFD2D2','#FFBFBF','#FFB3B3','#FF9F9F', '#FF8C8C', '#FF7575', '#FF5E5E','#FF3E3E', '#FF2B2B', '#FF0000');
//		alert(cor[num]);
	if(campos.inArray(desc)) {
		obj.style.color = '#ffffff';
		obj.style.background = cor[num];
	}
	else
		obj.style.border = '1px solid '+cor[num];
	if(num < 12) {
		num++;
		//alert('fade(\''+obj.name+'\','+ num +')');
		setTimeout('fade_in(\''+obj.name+'\','+ num +')', 50);
	}
}

function show_cv_incompleto(display){
	if (display)
		parent.document.getElementById('cv_incompleto').style.display = "block";
	else parent.document.getElementById('cv_incompleto').style.display = "none";
}

	function fade_out(obj, num) {
		var desc = obj;
		var obj = parent.document.getElementById(obj);
		num = parseInt(num);
		var cor = new Array('#FFFFFF','#FFF0F0','#FFE1E1','#FFD2D2','#FFBFBF','#FFB3B3','#FF9F9F', '#FF8C8C', '#FF7575', '#FF5E5E','#FF3E3E', '#FF2B2B', '#FF0000');
		if(campos.inArray(desc)){
			obj.style.color = '#000000';
			obj.style.background = cor[num];
		}
		else
			obj.style.border = '1px solid '+cor[num];
		if(num >= 1) {
			num--;
			//alert('fade(\''+obj.name+'\','+ num +')');
			setTimeout('fade_out(\''+obj.name+'\','+ num +')', 50);
		}
		else {
			if(campos.inArray(desc)) obj.style.background = '#FFFFF4';
			else obj.style.border = '1px solid #000000';
		}
	}
	
	function disable(desc){
		var obj = document.getElementById(desc);
		if(div = document.getElementById('div'+desc)) div.innerHTML = '';
		obj.style.background = '#F0F0F0';
		obj.style.border = '1px solid #CCCCCC';
		obj.value = '';
		obj.disabled = true;
		
	}

	function enable(desc){
		var obj = document.getElementById(desc);
		obj.style.background = '#FFFFF4';
		obj.style.border = '1px solid #000000';
		obj.disabled = false;
	}

	
function trans() {
	if (document.all) 
		document.getElementById('janela').className = 'trans';
	else if (document.layers) {
		setInterval ( 'document.layers.Layer1.top=window.pageYOffset;', 100 );
		document.getElementById('janela').className = 'transmz';
	}
	else if (document.getElementById) {
		setInterval ( 'document.layers.Layer1.top=window.pageYOffset;', 100 );
		document.getElementById('janela').className = 'transmz';
	}
}
function travatela() {
	var obj;
	if(obj = parent.document.getElementById('janela'))	obj.style.visibility = 'visible';
	if(obj = parent.document.getElementById('Layer1')) obj.style.visibility = 'visible';
	for (i=0; i < campos.length; i++) {
		if(obj = document.getElementById(campos[i])) obj.style.visibility = 'hidden';
		else if(obj = parent.document.getElementById(campos[i])) obj.style.visibility = 'hidden';
	}
}

function travatelanew(name, show) {
	frame = document.getElementById('fundovagas');
	if(show) {
		if(obj = document.getElementById('janela')) obj.style.visibility = 'visible';
		else if(obj = parent.document.getElementById('janela')) obj.style.visibility = 'visible';
		if(obj = document.getElementById(name)) {
			obj.style.visibility = 'visible';
			//frame.style.width = (obj.offsetWidth)+'px';
			//frame.style.height = (obj.offsetHeight)+'px';
			//frame.style.left = (obj.offsetLeft)+'px';
			//frame.style.top = (obj.offsetTop)+'px';
			frame.style.visibility = 'visible';

		}
		else if(obj = parent.document.getElementById(name)) obj.style.visibility = 'visible';
	}
	else {
		if(obj = document.getElementById('janela')) obj.style.visibility = 'hidden';
		else if(obj = parent.getElementById('janela')) obj.style.visibility = 'hidden';
		if(obj = document.getElementById(name)) {
			obj.style.visibility = 'hidden';
			frame.style.visibility = 'hidden';
		}
		else if(obj = parent.getElementById(name)) obj.style.visibility = 'hidden';
	}
}

function travacpf() {
	var obj;
	parent.document.getElementById('janela').style.visibility = 'visible';
	parent.document.getElementById('cpfcad').style.visibility = 'visible';
	for (i=0; i < campos.length; i++) {
		if(obj = document.getElementById(campos[i])) obj.style.visibility = 'hidden';
		else if(obj = parent.document.getElementById(campos[i])) obj.style.visibility = 'hidden';
	}
}

function destravacpf() {
	parent.document.getElementById('janela').style.visibility = 'hidden';
	parent.document.getElementById('cpfcad').style.visibility = 'hidden';
	for (i=0; i < campos.length; i++) {
		if(obj = document.getElementById(campos[i])) obj.style.visibility = 'visible';
		else if (obj = parent.document.getElementById(campos[i])) obj.style.visibility = 'visible';
	}
}

function destravatela() {
	if(obj = parent.document.getElementById('janela')) obj.style.visibility = 'hidden';
	if(obj = parent.document.getElementById('Layer1')) obj.style.visibility = 'hidden';
	for (i=0; i < campos.length; i++) {
		if(obj = document.getElementById(campos[i])) obj.style.visibility = 'visible';
		else if (obj = parent.document.getElementById(campos[i])) obj.style.visibility = 'visible';
	}
}


var count = 10;

function addline(area, cargo, nivel, experiencia) {
	var table = document.getElementById('tbareas');
	var linha = document.createElement("tr");
	var celula = document.createElement("td");
	var areavalue = document.getElementById('areas').value;
//	celula.style.background = cores[count];
	celula.innerHTML = '<img src="../figuras/del.gif" width="16" height="16" style="cursor:pointer" onclick="xajax_delArea(\''+areavalue+'\', \''+cargo+'\','+count+')">';
	celula.height = 27;
	celula.align = 'center';
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = area;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = cargo;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = nivel;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = experiencia;
	linha.appendChild(celula);
	linha.id = count;
	linha.onmouseover = function() { this.style.background = '#E9EAE5'; }
	linha.onmouseout  = function() { this.style.background = ''; }
	table.appendChild(linha);
	count++;
}

function addVinculos(empresa, cidade, uf, cargoinicial, nivelinicial, cargofinal, nivelfinal, dataadmissao, trabalha, datademissao, ramodeatividade, produtos, empid) {
	var table = document.getElementById('tbvinculos');
	var linha = document.createElement('tr');
	var celula = document.createElement('td');
	celula.align = "center";
	celula.innerHTML = '<img src="../figuras/del.gif" width="16" height="16" style="cursor:pointer" onclick="xajax_delVinculo('+empid+')">';
	linha.appendChild(celula);
	var celula = document.createElement('td');
	//celula.innerHTML = '<img src="../figuras/edit.gif" width="16" height="16"/>';
	celula.align = "center";
	linha.appendChild(celula);
	var conteudo = '';
	conteudo += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	conteudo += '<tr>';
	conteudo += '<td width="22%" align="right">Empresa:&nbsp;</td>';
	conteudo += '<td colspan="3">'+empresa+'</td>';
	conteudo += '</tr>';
	conteudo += '<tr>';
	conteudo += '<td align="right">Cidade:&nbsp;</td>';
	conteudo += '<td width="30%">'+cidade+'</td>';
	conteudo += '<td width="22%" align="right">Uf:&nbsp;</td>';
	conteudo += '<td width="26%">'+uf+'</td>';
	conteudo += '</tr>';
	conteudo += '<tr>';
	conteudo += '<td align="right">Cargo Inicial:&nbsp; </td>';
	conteudo += '<td>'+cargoinicial+'</td>';
	conteudo += '<td align="right">Nivel:&nbsp;</td>';
	conteudo += '<td>'+nivelinicial+'</td>';
	conteudo += '</tr>';
	conteudo += '<tr>';
	conteudo += '<td align="right">Cargo Final:&nbsp; </td>';
	conteudo += '<td>'+cargofinal+'</td>';
	conteudo += '<td align="right">Nivel:&nbsp;</td>';
	conteudo += '<td>'+nivelfinal+'</td>';
	conteudo += '</tr>';
	conteudo += '<tr>';
	conteudo += '<td align="right">Data de Admiss&atilde;o:&nbsp; </td>';
	conteudo += '<td>'+dataadmissao+'</td>';
	conteudo += '<td align="right">Data de Demiss&atilde;o:&nbsp;</td>';
	if(trabalha.length == 0) conteudo += '<td>'+datademissao+'</td>';
	else conteudo += '<td>Trabalha Atualmente</td>';
	conteudo += '</tr>';
	conteudo += '<tr>';
	conteudo += '<td align="right">Ramo de Atividade:&nbsp; </td>';
	conteudo += '<td colspan="3">'+ramodeatividade+'</td>';
	conteudo += '</tr>';
	conteudo += '<tr>';
	conteudo += '<td align="right">Principais Produtos&nbsp;<br> e/ou&nbsp;Servi&ccedil;os&nbsp;</td>';
	conteudo += '<td colspan="3">'+produtos+'</td>';
	conteudo += '</tr>';
	conteudo += '</table>';
	var celula = document.createElement('td');
	celula.innerHTML = conteudo;
	linha.id = empid;
	linha.appendChild(celula);
	table.appendChild(linha);
	var linha = document.createElement('tr');
	linha.id = empid+'-';
	var celula = document.createElement('td');	
	celula.height = 27;
	celula.colSpan = "3";
	celula.align = "center";
	celula.innerHTML = '<font color=\"#E9EAE5\">-----------------------------------------------------------------------------------------------------------------------------------</font>';
	linha.appendChild(celula);
	table.appendChild(linha);
}

function addoutroscursos(curso) {
	var table = document.getElementById('tboutroscursos');
	var linha = document.createElement("tr");
	var celula = document.createElement("td");
	var cursovalue = document.getElementById('outroscursos').value;
//	celula.style.background = cores[count];
	celula.innerHTML = '<img src="../figuras/del.gif" width="16" height="16" style="cursor:pointer" onclick="xajax_delOutroscursos(\''+cursovalue+'\',\'curso_'+count+'\')">';
	celula.height = 27;
	celula.align = 'center';
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = curso;
	linha.appendChild(celula);
	linha.id = 'curso_'+count;
	linha.onmouseover = function() { this.style.background = '#E9EAE5'; }
	linha.onmouseout  = function() { this.style.background = ''; }
	table.appendChild(linha);
	count++;
}

function addramo(ramo, experiencia) {
	var table = document.getElementById('tbramos');
	var linha = document.createElement("tr");
	var celula = document.createElement("td");
	var ramovalue = document.getElementById('atividade').value;
//	celula.style.background = cores[count];
	celula.innerHTML = '<img src="../figuras/del.gif" width="16" height="16" style="cursor:pointer" onclick="xajax_delRamo(\''+ramovalue+'\',\'ramo_'+count+'\')">';
	celula.height = 27;
	celula.align = 'center';
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = ramo;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = experiencia;
	linha.appendChild(celula);
	linha.id = 'ramo_'+count;
	linha.onmouseover = function() { this.style.background = '#E9EAE5'; }
	linha.onmouseout  = function() { this.style.background = ''; }
	table.appendChild(linha);
	count++;
}

function addcurso(curso, tipo, instituicao, situacao, periodo, conclusao) {
	var table = document.getElementById('tbcursos');
	var linha = document.createElement("tr");
	var celula = document.createElement("td");
	var cursovalue = document.getElementById('cursosup').value;
	var situacaovalue = document.getElementById('situacaocurso').value;
	var periodovalue = document.getElementById('periodo').value;
	var tipovalue = document.getElementById('tipocurso').value;
	celula.innerHTML = '<img src="../figuras/del.gif" width="16" height="16" style="cursor:pointer" onclick="xajax_delCurso(\''+cursovalue+'\', \''+tipovalue+'\', \''+instituicao+'\', \''+situacaovalue+'\', \'curso_'+count+'\')">';
	celula.height = 27;
	celula.align = 'center';
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = curso;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = tipo;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = instituicao;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = situacao;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = periodo;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = conclusao;
	linha.appendChild(celula);
	linha.id = 'curso_'+count;
	linha.onmouseover = function() { this.style.background = '#E9EAE5'; }
	linha.onmouseout  = function() { this.style.background = ''; }
	table.appendChild(linha);
	count++;
}

function addidioma(idioma, nivel) {
	var table = document.getElementById('tbidiomas');
	var linha = document.createElement("tr");
	var celula = document.createElement("td");
	var idiomavalue = document.getElementById('idioma').value;
	var nivelvalue = document.getElementById('nivelidioma').value;
	celula.innerHTML = '<img src="../figuras/del.gif" width="16" height="16" style="cursor:pointer" onclick="xajax_delIdioma(\''+idiomavalue+'\', \'idioma_'+count+'\')">';
	celula.height = 27;
	celula.align = 'center';
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = idioma;
	linha.appendChild(celula);
	var celula = document.createElement("td");
	celula.innerHTML = nivel;
	linha.appendChild(celula);
	linha.id = 'idioma_'+count;
	linha.onmouseover = function() { this.style.background = '#E9EAE5'; }
	linha.onmouseout  = function() { this.style.background = ''; }
	table.appendChild(linha);
	count++;
}

function delline(tablename) {
	var table = document.getElementById(tablename);
	table.parentNode.removeChild(table);
}

function getText(objtext) {
	var obj = document.getElementById(objtext);
    var indice = obj.selectedIndex;
    var texto = obj.options[indice].text
	return texto;
}

function carregando(show) {
	if(obj = document.getElementById('carregando')) {} else alert('erro ao carregar div carregando');
	if(obj2 = document.getElementById('janela')) {} else alert('erro ao carregar div janela')
	if(show) {
		obj.style.visibility = 'visible';
		obj2.style.visibility = 'visible';
	}
	else {
		obj.style.visibility = 'hidden';
		obj2.style.visibility = 'hidden';
	}
}

function carregando_interesse() {
	var html = '';
	html =  '<table border="0" cellpadding="0" cellspacing="0">';
	html += '<tr>';
	html += '<td width="10" height="10"><img src="../figuras/canto_esquerdo_sup.gif" width="10" height="10" /></td>';
	html += '<td width="300" colspan="3" bgcolor="#FFFFFF" style="border-top:#2E73AC solid 1px"></td>';
	html += '<td width="10" height="10"><img src="../figuras/canto_direito_sup.gif" width="10" height="10" /></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td bgcolor="#FFFFFF">&nbsp;</td>';
	html += '<td height="25" colspan="3" align="center" bgcolor="#FFFFFF"><font color="#990000" size="2" face="Tahoma, Arial"><strong>Aguarde Carregando Vagas do seu interesse.</strong></font></td>';
	html += '<td bgcolor="#FFFFFF">&nbsp;</td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td width="10" height="10"><img src="../figuras/canto_esquerdo_inf.gif" width="10" height="10" /></td>';
	html += '<td colspan="3" bgcolor="#FFFFFF" style="border-bottom: #2E73AC solid 1px"></td>';
	html += '<td width="10" height="10"><img src="../figuras/canto_direito_inf.gif" width="10" height="10" /></td>';
	html += '</tr>';
	html += '</table>';
	if(obj = document.getElementById('vagasinteresse')) obj.innerHTML = html;
	//alert(html);
}

function focu(name, show) {
	if(show) {
		if(obj = document.getElementById(name+'_esquerdo')) obj.style.backgroundImage="url('../figuras/menu_esquerdo_focu.png')";
		if(obj = document.getElementById(name+'_direito')) obj.style.backgroundImage = "url('../figuras/menu_direito_focu.png')";
		if(obj = document.getElementById(name+'_corpo')) obj.style.backgroundImage = "url('../figuras/menu_corpo_focu.png')";
	}
	else {
		if(obj = document.getElementById(name+'_esquerdo')) obj.style.backgroundImage="url('../figuras/menu_esquerdo.png')";
		if(obj = document.getElementById(name+'_direito')) obj.style.backgroundImage = "url('../figuras/menu_direito.png')";
		if(obj = document.getElementById(name+'_corpo')) obj.style.backgroundImage = "url('../figuras/menu_corpo.png')";
	}
}
function trans() {
	if (document.all) 
		document.getElementById('janela').className = 'trans';
	else if (document.layers) {
		setInterval ( 'document.layers.Layer1.top=window.pageYOffset;', 100 );
		document.getElementById('janela').className = 'transmz';
	}
	else if (document.getElementById) {
		setInterval ( 'document.layers.Layer1.top=window.pageYOffset;', 100 );
		document.getElementById('janela').className = 'transmz';
	}
}

function hidden()
{document.body.style.overflow='hidden';}

function carrega_vaga(vagaid, filialid) {
	document.getElementById('telavagas').innerHTML = '<table width="100%" height="100%" bgcolor="#FFFFFF"><tr><td width="100%" height="100%" align="center" valign="middle"><img src="../figuras/ajax-loader.gif" border="0"><br><br>Aguarde. Carregando....</td></tr></table>';
	travatelanew('telavagas', true);
	xajax_carrega_vaga(vagaid, filialid);
}

function carreg() {
	document.getElementById('telavagas').innerHTML = '<table width="100%" height="100%" bgcolor="#FFFFFF"><tr><td width="100%" height="100%" align="center" valign="middle"><img src="../figuras/ajax-loader.gif" border="0"><br><br>Aguarde. Carregando....</td></tr></table>';
}
