function telaLogin() {
	document.getElementById("formularioLogin").className="";
	document.getElementById("html").className="semScroll";
}

function fechaTelaLogin() {
	document.getElementById("formularioLogin").className="hidde";
	document.getElementById("html").className="";
}

function salvaClasses() {
	var divs = document.getElementById("vagas").getElementsByTagName("div");
	
	for (var i = 0; i < divs.length; i++) {
		divsAntigas[i] = divs[i].className;
		//alert (divsAntigas[i]);
	}
}

function resetaClasses() {
	var divs = document.getElementById("vagas").getElementsByTagName("div");
	
	for (var i = 0; i < divs.length; i++) {
		//alert (divsAntigas[i]);
		divs[i].className = divsAntigas[i];	
	}
	//alert (divsAntigas[0]);
	
}	

function escondeUnidade(unidade) {	
	if (divsAntigas[0] == "teste") {
		salvaClasses();	
	}
	
	resetaClasses();
			
	if (unidade != "-1") {
		var divs = document.getElementById("vagas").getElementsByTagName("div");
		
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].className != unidade) {
				divsAntigas[i] = divs[i].className;
				divs[i].className = "hidde";	
			}
		}
	}
}

function adicionarExp() {
	empresa = document.getElementById("empresa").value;
	cargo = document.getElementById("cargo").value;
	inicio = document.getElementById("inicio").value;
	fim = document.getElementById("fim").value;
	atividades = document.getElementById("atividades").value;
	contador = parseInt(document.getElementById("contExp").value) + 1;
	
	if (trim(empresa) == "") {
		alert("Verifique o preenchimento do campo Empresa");
		document.getElementById("empresa").focus();
	}else if (trim(cargo) == "") {
		alert("Verifique o preenchimento do campo Cargo");
		document.getElementById("cargo").focus();
	}else if (trim(inicio) == "") {
		alert("Verifique o preenchimento do início da sua experiência");
		document.getElementById("inicio").focus();
	}else if (trim(atividades) == "") {
		alert("Verifique o preenchimento do campo Atividades Desenvolvidas");
		document.getElementById("atividades").focus();
	} else {
		
		document.getElementById("contExp").value = contador;
		
		novaTr = "<tr id=\"exp"+contador+"\"><td>"+empresa+"<input type=\"hidden\" value=\""+empresa+"\" name=\"empresa"+contador+"\" id=\"empresa"+contador+"\" /></td>";
		novaTr += "<td>"+cargo+"<input type=\"hidden\" value=\""+cargo+"\" name=\"cargo"+contador+"\" id=\"cargo"+contador+"\" /></td>";
		novaTr += "<td>"+inicio+" à "+fim+"<input type=\"hidden\" value=\""+inicio+"\" name=\"inicio"+contador+"\" id=\"inicio"+contador+"\" />       <input type=\"hidden\" value=\""+fim+"\" name=\"fim"+contador+"\" id=\"fim"+contador+"\" /></td>";
		novaTr += "<td>"+atividades+"<input type=\"hidden\" value=\""+atividades+"\" name=\"atividades"+contador+"\" id=\"atividades"+contador+"\" /></td>";
		novaTr += "<td><a href=\"#\" onclick=\"return excluiExp("+contador+");\">X</td></tr>";
		
		document.getElementById("empresa").value = "";
		document.getElementById("cargo").value  = "";
		document.getElementById("inicio").value  = "";
		document.getElementById("fim").value  = "";
		document.getElementById("atividades").value  = "";	
		
		//alert(novaTr);
		
		document.getElementById("exp").innerHTML += novaTr;
	}
	
	return false;
}

function excluiExp(numTr) {
	document.getElementById("empresa"+numTr).value = "";
	document.getElementById("cargo"+numTr).value  = "";
	document.getElementById("inicio"+numTr).value  = "";
	document.getElementById("fim"+numTr).value  = "";
	document.getElementById("atividades"+numTr).value  = "";
	
	if (confirm ("Você tem certeza que deseja excluir esta experiência?"))
	{
		document.getElementById("exp"+numTr).className = "hidde";
	}
	
	return false;
}


function adicionarCurso() {
	
	
	var instituicao = document.getElementById("instQuali").value;
	var curso = document.getElementById("cursoQuali").value;
	var conclusao = document.getElementById("anoQuali").value;
	if (trim(instituicao) == "") {
		alert("Verifique o preenchimento do campo Instituição dos Cursos de Qualificação");
		document.getElementById("instQuali").focus();
	}else if (trim(curso) == "") {
		alert("Verifique o preenchimento do campo Curso dos Cursos de Qualificação");
		document.getElementById("cursoQuali").focus();
	}else if (trim(conclusao) == "") {
		alert("Verifique o preenchimento do campo Ano dos Cursos de Qualificação");
		document.getElementById("anoQuali").focus();
	} else {
		contador = parseInt(document.getElementById("contCurso").value) + 1;
		
		
		
		document.getElementById("contCurso").value = contador;
	
		novaTr = "<tr id=\"curso"+contador+"\"><td>"+instituicao+"<input type=\"hidden\" value=\""+instituicao+"\" name=\"instituicao"+contador+"\" id=\"instituicao"+contador+"\" /></td>";
		novaTr += "<td>"+curso+"<input type=\"hidden\" value=\""+curso+"\" name=\"curso"+contador+"\" id=\"curso"+contador+"\" /></td>";
		novaTr += "<td>"+conclusao+"<input type=\"hidden\" value=\""+conclusao+"\" name=\"conclusao"+contador+"\" id=\"conclusao"+contador+"\" /></td>";
		novaTr += "<td><a href=\"#\" onclick=\"return excluiCurso("+contador+");\">X</td></tr>";
		
		document.getElementById("instQuali").value = "";
		document.getElementById("cursoQuali").value  = "";
		document.getElementById("anoQuali").value  = "";
		//alert(novaTr);
		//alert("ok4");
		//el = replaceHtml(document.getElementById("curso2"), novaTr);
		document.getElementById("curso").innerHTML += novaTr;
		//alert("ok5");
	}
	
	return false;
}

function replaceHtml(el, html) {
	var oldEl = typeof el === "string" ? document.getElementById(el) : el;
	/*@cc_on // Pure innerHTML is slightly faster in IE
		oldEl.innerHTML = html;
		return oldEl;
	@*/
	var newEl = oldEl.cloneNode(false);
	newEl.innerHTML = html;
	oldEl.parentNode.replaceChild(newEl, oldEl);
	/* Since we just removed the old element from the DOM, return a reference
	to the new element, which can be used to restore variable references. */
	return newEl;
};

function excluiCurso(numTr) {
	document.getElementById("instituicao"+numTr).value = "";
	document.getElementById("curso"+numTr).value  = "";
	document.getElementById("conclusao"+numTr).value  = "";
	if (confirm ("Você tem certeza que deseja excluir este curso?"))
	{
		document.getElementById("curso"+numTr).className = "hidde";
	}
	
	return false;
}

function adicionarCurso2() {
	var instituicao = document.getElementById("instQuali").value;
	var curso = document.getElementById("cursoQuali").value;
	var conclusao = document.getElementById("anoQuali").value;
	if (trim(instituicao) == "") {
		alert("Verifique o preenchimento do campo Instituição dos Cursos de Qualificação");
		document.getElementById("instQuali").focus();
	}else if (trim(curso) == "") {
		alert("Verifique o preenchimento do campo Curso dos Cursos de Qualificação");
		document.getElementById("cursoQuali").focus();
	}else if (trim(conclusao) == "") {
		alert("Verifique o preenchimento do campo Ano dos Cursos de Qualificação");
		document.getElementById("anoQuali").focus();
	} else {
		contador = parseInt(document.getElementById("contCurso").value) + 1;
		document.getElementById("contCurso").value = contador;
		
		tabela = document.getElementById("curso");
		
		idLinha = "curso"+contador;
		
		linha = tabela.insertRow(0);
		linha.setAttribute("id", idLinha);
		
		contCell0 = instituicao+"<input type=\"hidden\" value=\""+instituicao+"\" name=\"instituicao"+contador+"\" id=\"instituicao"+contador+"\" />";
		contCell1 = curso+"<input type=\"hidden\" value=\""+curso+"\" name=\"curso"+contador+"\" id=\"curso"+contador+"\" />";
		contCell2 = conclusao+"<input type=\"hidden\" value=\""+conclusao+"\" name=\"conclusao"+contador+"\" id=\"conclusao"+contador+"\" />";
		contCell3 = "<a href=\"#\" onclick=\"return excluiCurso("+contador+");\">X</a>";
		
		cell = linha.insertCell(0);
		cell.innerHTML = contCell0;
		
		cell = linha.insertCell(1);
		cell.innerHTML = contCell1;
		
		cell = linha.insertCell(2);
		cell.innerHTML = contCell2;
		
		cell = linha.insertCell(3);
		cell.innerHTML = contCell3;
		
		document.getElementById("instQuali").value = "";
		document.getElementById("cursoQuali").value  = "";
		document.getElementById("anoQuali").value  = "";
	}
	return false;
}


function adicionarExp2() {
	empresa = document.getElementById("empresa").value;
	cargo = document.getElementById("cargo").value;
	inicio = document.getElementById("inicio").value;
	fim = document.getElementById("fim").value;
	atividades = document.getElementById("atividades").value;
	contador = parseInt(document.getElementById("contExp").value) + 1;
	
	if (trim(empresa) == "") {
		alert("Verifique o preenchimento do campo Empresa");
		document.getElementById("empresa").focus();
	}else if (trim(cargo) == "") {
		alert("Verifique o preenchimento do campo Cargo");
		document.getElementById("cargo").focus();
	}else if (trim(inicio) == "") {
		alert("Verifique o preenchimento do início da sua experiência");
		document.getElementById("inicio").focus();
	}else if (trim(atividades) == "") {
		alert("Verifique o preenchimento do campo Atividades Desenvolvidas");
		document.getElementById("atividades").focus();
	} else {
		document.getElementById("contExp").value = contador;
		
		tabela = document.getElementById("exp");
		
		idLinha = "exp"+contador;
		
		linha = tabela.insertRow(0);
		linha.setAttribute("id", idLinha);
		
		contCell0 = empresa+"<input type=\"hidden\" value=\""+empresa+"\" name=\"empresa"+contador+"\" id=\"empresa"+contador+"\" />";
		contCell1 = cargo+"<input type=\"hidden\" value=\""+cargo+"\" name=\"cargo"+contador+"\" id=\"cargo"+contador+"\" />";
		contCell2 = inicio+" à "+fim+"<input type=\"hidden\" value=\""+inicio+"\" name=\"inicio"+contador+"\" id=\"inicio"+contador+"\" />       <input type=\"hidden\" value=\""+fim+"\" name=\"fim"+contador+"\" id=\"fim"+contador+"\" />";
		contCell3 = atividades+"<input type=\"hidden\" value=\""+atividades+"\" name=\"atividades"+contador+"\" id=\"atividades"+contador+"\" />";
		contCell4 = "<a href=\"#\" onclick=\"return excluiExp("+contador+");\">X</a>";
		
		cell = linha.insertCell(0);
		cell.innerHTML = contCell0;
		
		cell = linha.insertCell(1);
		cell.innerHTML = contCell1;
		
		cell = linha.insertCell(2);
		cell.innerHTML = contCell2;
		
		cell = linha.insertCell(3);
		cell.innerHTML = contCell3;
		
		cell = linha.insertCell(4);
		cell.innerHTML = contCell4;
		
		document.getElementById("empresa").value = "";
		document.getElementById("cargo").value  = "";
		document.getElementById("inicio").value  = "";
		document.getElementById("fim").value  = "";
		document.getElementById("atividades").value  = "";	
	}
	
	return false;
}

