function exibirOutraAreaFormacao( show ){
  var e = document.getElementById("outraAreaFormacao");
  e.style.display = show ? "block" : "none";
  //e.style.visibility = show ? "visible" : "hidden";
  
  if(!show){
	document.forms["pesquisaForm"].elements["P1132"].value = "";
  }
}
function exibirCursosSuperior( show ){
  var e = document.getElementById("cursosSuperior");
  e.style.display = show ? "block" : "none";
  //e.style.visibility = show ? "visible" : "hidden";

}		
function exibirAreaFormacao( show ){
  var e = document.getElementById("areaFormacao");
  e.style.display = show ? "block" : "none";
  //e.style.visibility = show ? "visible" : "hidden";

}	

function exibe(x) {
	var args = exibe.arguments;
	for (var idx=0; idx < args.length; idx++) {
		var el = document.getElementById(args[idx]);
		el.style.display='block';
	}  
}

function exibe2(name, idx, total) {
	idx = parseInt(idx);

		if (idx < 0){idx = 0;}
	total = parseInt(total);
		if(idx>0)
	document.getElementById(name).style.display = 'block';
	if(idx >= 0) {
		for (var i=0; i < idx; i++) {
			exibe(name + (i+1));
		}
		for (var j = idx; j < total; j++) {
			esconde(name + (j+1));
		}
				if(idx==0)
		document.getElementById(name).style.display = 'none';
	}
}	

// Limpa os filhos a partir do indiceº filho ( 0 até 9 )
function limpaFilhos(indice) {

	if (indice <=0) {
		document.getElementsByName("P1043")[0].value = "";
					esconde('osFilho');
					indice = 0;
	}

	for (var i = 1528 + indice; i <= 1538; i++) {
		if(i==1536)i++;
		document.getElementsByName("P" + i)[0].checked = false;
		document.getElementsByName("P" + i)[1].checked = false;
	}
	for (var i = 809 + indice; i <= 818; i++) {
		document.getElementsByName("P" + i)[0].value = "";
	}
	for (var i = 819 + indice; i <= 828; i++) {
		document.getElementsByName("P" + i)[0].checked = false;
		document.getElementsByName("P" + i)[1].checked = false;
	}
}

function esconde(x){
	var args = esconde.arguments;
	for (var idx = 0; idx < args.length; idx++) {
		var al = document.getElementById(args[idx]);
			al.style.display='none';
	}
}	

/*
 * Inicio das funcoes do passo 2. 
 */
function exibirCursos( show ) {
  var e = document.getElementById("cursos");
  e.style.display = show ? "block" : "none";
  //e.style.visibility = show ? "visible" : "hidden";
   
  if(!show){
	document.forms["pesquisaForm"].elements["P1128"].selectedIndex = 0;
	document.forms["pesquisaForm"].elements["P2587"].value = "";
  }
  document.forms["pesquisaForm"].elements["P1128"].disabled = !show;
}

function exibirOutraAreaFormacao( show ){
  var e = document.getElementById("outraAreaFormacao");
  e.style.display = show ? "block" : "none";
  //e.style.visibility = show ? "visible" : "hidden";
  
  if(!show){
	document.forms["pesquisaForm"].elements["P1132"].value = "";
  }
}	

function abreFrequecia(check){
	check.checked ? numCheck2++ : numCheck2--;
	var pergunta = document.getElementsByName(check.name.replace('C','P'));
	for(i=0; i < pergunta.length; i++){
		pergunta[i].disabled = !check.checked;
		pergunta[i].checked = false;
	}
}	

function atualizarAreasAtuacao( check ){
	
	if(check.checked){			
		if(checkeds == 3){
			alert("O número de opções não deve exceder a 3.");
			check.checked = false;
		}else{
			checkeds ++;
		}

	} else {
	checkeds --;
	}

}

function atualizarAreasImportantesLimitar3( check ){
	if(check.checked){			
		if(checkedsPergunta10 == 3){
			alert("O número de opções não deve exceder a 3.");
			check.checked = false;
		}else{
			checkedsPergunta10 ++;
		}

	} else {
	checkedsPergunta10 --;
	}

}

function atualizarAreasImportantes( check ){
		var frm = document.forms["pesquisaForm"];

		/*
		 * Se o "checkbox" for marcado, deve-se inserir a opção nos 
		 * três "select"s.
		*/
		if(check.checked && checkedsPergunta10 < 3){		
				for(var i = 0; i < 3; i++){
						/*
						 * Acessa o atributo "options" a partir do "name" dos "select"s.
						 */ 				
						var options = frm.elements["P" + (1327 + i)].options;

						/*
						 * Adiciona o novo "option".
						 */ 
						options[options.length] = new Option(check.value, check.value);
				}
		}

		/*
		 * Se o "checkbox" for desmarcado, deve-se retirar a opção
		 * de todos os "select"s.
		 */
		else{
				for(var i = 0; i < 3; i++){
						/*
						 * Acessa o atributo "options" a partir do "name" dos "select"s.
						 */ 
						var options = frm.elements["P" + (1327 + i)].options;

						/*
						 * Retira a opção do "options".
						 */ 
						for(var j = 0; j < options.length; j++){
								if(options[j].value == check.value){
										options[j] = null;
										break;
								}
						}

						if (frm.elements["P" + (1327 + i)].value == check.value) {
								frm.elements["P" + (1327 + i)].selectedIndex = 0;
						}
				}
		}
		
}	

function selecionarAreasImportantes( select ) {
	var frm = document.forms["pesquisaForm"];

	for(var i = 0; i < 3; i++){
		var element = frm.elements["P" + (1327 + i)];

		/*
		 * Se o "select" clicado for diferente do que
		 * está sendo percorrido...
		 */
		if(element != select){
			
			/*
			 * ... e se o valor do select for "", então
			 * adicione o valor anterior do "select" no que está sendo
			 * percorrido. Para isto, verifica-se qual opção está presente no
			 * "select" e que não se encontra nos demais.
			 */
			if(select.value == ""){
				
				/*
				 * Percorre-se os elementos do "select"... 
				 */
				for(var j = 1; j < select.options.length; j++){
					var k;

					/*
					 * ... e os elementos do outro "select".
					 */
					for(k = 1; k < element.options.length; k++){
						
						/*
						 * Caso o elemento exista nos dois objetos,
						 * parte-se para outro...
						 */
						if(select.options[j].value == element.options[k].value){
							break;
						}
					}
					
					/*
					 * ... mas se o objeto não foi encontrado, então adiciona-se.
					 */
					if(k == element.options.length){
						element.options[element.options.length] = new Option(select.options[j].text, select.options[j].value);
						break;
					}
				}	
			}
			
			/*
			 * Já se o valor do select não for "", então
			 * deve-se retirar a opção dos demais "select"s.
			 */
			else{
				for(var j = 1; j < element.options.length; j++){
					if(element.options[j].value == select.value){
						element.options[j] = null;
					}
				}
			}
		}
	}	
}	
	
function popjan(objName, objW, objH) {
	window.open(objName, "", "menubar=no, fullscreen=no, toolbar=no, location=no, scrollbars=yes, status=no,resizable=no, width="+objW+", height="+objH+", left="+(screen.width/2 - (objW/2))+", top="+(screen.height/2 - (objH/2)));
}