/**************************************************************
 *** Arquivo JavaScript secundário da área do candidato     ***
 ***                                                        ***
 *** Contém funções de controle de apresentação             ***
 *** - Controla exibição/ocultação de itens                 ***
 *** - Controla apresentação de menus                       ***
 *** - Controla downloads de segmentos de páginas           ***
 ***                                                        ***
 **************************************************************/

var checkClosing=true;
var isExiting = false;
var msgErrorExecuting = "Erro ao executar! \n\n Erro:";




        var xmlhttp = getXmlHttpRequest();

        function getXmlHttpRequest() 
        {
            if (window.XMLHttpRequest) 
            {
                return new XMLHttpRequest();
            }
            else if (window.ActiveXObject) 
            {
                return new ActiveXObject("Microsoft.XMLHTTP");
            }
        }


        function alteraURL(url,div,object)
        {
            alert(object.value);
            if(object.value.length>4)
            {
                xmlhttp.open("POST", url, true);
                xmlhttp.onreadystatechange = function(){
                                                    if (xmlhttp.readyState==4)
                                                    {
                                                        document.getElementById(div.id).innerHTML = xmlhttp.responseText;
                                                    }
                                            }
               xmlhttp.send(null);
           }
           else
               document.getElementById(div.id).innerHTML = "";
            
            
        }


// Função de carga inicial da HomePage do Candidato
function loadMain(){
	var query = "HomeCandidato.aspx";
	var div = document.getElementById("bodyMain");
	pageDownload(query, div);
}

// Função de carga inicial da página de cadastro de empresas parceiras
// - usada somente quando chamada através da área da empresa
// (verifica se recebeu algum parametro via query string e repassa-o)
function loadCadastroEmpresa(url){
	var query = "../Candidato/divCadastroEmpresaSimplificado.aspx";
	var div = document.getElementById("divWorkCadastroEmpresa");
	var pos = url.indexOf("?");
	if(pos != -1) query += url.substr(pos); 
	pageDownload(query, div);
}

// Função de inicialização da HomePage
// Obs.: faz o download de vários segmentos logo após a carga da HomePage
function initialize(){
    loadAndDisplay("divCurriculum_MeuCurriculo.aspx", divWorkCurriculum, divWorkSpace);
    document.body.onkeydown = checkF5;
    window.onbeforeunload = beforeClosingWindow;
}

function checkF5(){
	if(window.event.keyCode == 116) isExiting = true;
}

function beforeClosingWindow(){
	if(!isExiting){
		doLogoff();
	}
}

function doLogoff(){
	var confirmacao=true;
	
	if(isCurriculoIncompleto()) confirmacao=confirmaCurriculoIncompleto();

	if(confirmacao){
		checkClosing=false;
		isExiting = true;

		var obj;
		// Cria IFRAME com o FORM dinâmico
		oIfr = createForm("frmLogoff", "HomeCandidato.aspx");
		oDoc = document.frames(oIfr.id).document;
		oFrm = oDoc.forms("frmLogoff");
		
		// Cria os campos e seta os valores para o submit
		oInput = oDoc.createElement("input");
		oInput.type = "hidden";
		oInput.name = "action";
		oInput.value = "logoff";
		oFrm.appendChild(oInput);

		// Registra a função de tratamento da resposta
		oIfr.onreadystatechange = responseLogoff;

		// Faz o submit
		oFrm.submit();
	}
}

// Função que trata a resposta da validacao do login
// disparada pelo evento onreadystatechange do iframe de controle
function responseLogoff(){
	var oIfr, oDoc, oXML, oNode, msg, url;
	oIfr = window.event.srcElement;
	if(oIfr.readyState == "complete"){
		try {
			oDoc = parseResponse(oIfr.id);
			oXML = oDoc.getElementById("responseLogoff").XMLDocument;
			msg = oXML.selectSingleNode("//mensagem").text;
			url = oXML.selectSingleNode("//url").text;
		} catch(e) {
			msg = msgErrorExecuting + e.message;
		} finally {
			oIfr.onreadystatechange = null;
			document.body.removeChild(oIfr);
			if(msg != ""){ 
				isExiting = false;
				alert(msg);
			} else {
				if(url != ""){
					document.location.replace(url);
				} else {
					isExiting = false;
				}
			}
		}
	}
}

// Função de configuração do menu de seções de preenchimento do currículo
// Recebe:
// - menuSelected (opcional) = objeto com a referência do LI da opção que deve vir pré-selecionada
// - subMenuSelected (opcional) = objeto com a referência do LI da sub-opção que deve vir pré-selecionada
function configMenu(menuSelected, subMenuSelected){
	configMenus(menuSelected, subMenuSelected, divCurChangeMenu, divCurChangeSubMenu);
}

// Função de configuração do menu de contratos de estágio
// Recebe:
// - menuSelected (opcional) = objeto com a referência do LI da opção que deve vir pré-selecionada
// - subMenuSelected (opcional) = objeto com a referência do LI da sub-opção que deve vir pré-selecionada
function configMenuEstagio(menuSelected, subMenuSelected){
	configMenus(menuSelected, subMenuSelected, divSubMenuContratos, divSubMenuContratos);
}

// Função de configuração dos menus
// Recebe:
// - menuSelected (opcional) = objeto com a referência do LI da opção que deve vir pré-selecionada
// - subMenuSelected (opcional) = objeto com a referência do LI da sub-opção que deve vir pré-selecionada
// - divMenu = objeto referenciando o div que contém os menus
// - divSubMenu = objeto referenciando o div que contém os sub-menus
function configMenus(menuSelected, subMenuSelected, divMenu, divSubMenu){
    var menuLinks;
    var subMenus;
    var leftMenu;
    var classname;

    // Se recebeu o parâmetro, configura as classes dos links
    if(menuSelected){
		menuLinks = divMenu.getElementsByTagName("LI");
		for(i=0; i<menuLinks.length; i++){
			// configura a classe "clsSubMenuSelected" para o elemento selecionado
			if(menuLinks[i].id == menuSelected.id){
				if(menuSelected.firstChild.className != "clsSubMenuSelected"){
					if(menuLinks[i].id=="liCurChangeSubMenuDadosPessoais"){
						menuSelected.firstChild.className = "clsSubMenuSelected";
					}else if(menuLinks[i].id=="liCurChangeSubMenuDadosProfissionais"){
						menuSelected.firstChild.className = "clsSubMenuSelected2";
					}else{
						menuSelected.firstChild.className = "clsSubMenuSelected3";
					}
				}
			} else {
			// configura a classe "clsSubMenuUnselected" 
			// para todos os outros elementos do tipo "subMenuLink"
				if(menuLinks[i].firstChild.name == "subMenuLink" && menuLinks[i].firstChild.className != "clsSubMenuUnselected"){
					if(menuLinks[i].id=="liCurChangeSubMenuDadosPessoais"){
						menuLinks[i].firstChild.className = "clsSubMenuUnselected";
					}else if(menuLinks[i].id=="liCurChangeSubMenuDadosProfissionais"){
						menuLinks[i].firstChild.className = "clsSubMenuUnselected2";
					}else{
						menuLinks[i].firstChild.className = "clsSubMenuUnselected3";
					}
					
				}
			}
		}
    }
    
    // Se recebeu o parâmetro, configura as classes dos links
    if(subMenuSelected){
		menuLinks = divSubMenu.getElementsByTagName("LI");
		for(i=0; i<menuLinks.length; i++){
			// configura a classe "selectedChildLink" para o elemento selecionado
			if(menuLinks[i].id == subMenuSelected.id){
				classname = "selectedChildLink" + subMenuSelected.lastChild.innerText;
				if(subMenuSelected.firstChild.className != classname)
					subMenuSelected.firstChild.className = classname;
			} else { 
			// configura a classe "unselectedChildLink" 
			// para todos os outros elementos do tipo "subMenuChildLink"
				if(menuLinks[i].firstChild.name == "subMenuChildLink"){
					classname = "unselectedChildLink" + menuLinks[i].lastChild.innerText;
					if(menuLinks[i].firstChild.className != classname)
						menuLinks[i].firstChild.className = classname;
				}
			}
		}

		// configura a classe "leftUnselectedChildLink" para o elemento à esquerda
		// do elemento selecionado
		leftMenu = subMenuSelected.previousSibling;
		if(leftMenu != null && leftMenu.hasChildNodes && leftMenu.firstChild.name == "subMenuChildLink"){
			classname = "leftUnselectedChildLink" + leftMenu.lastChild.innerText;
			if(leftMenu.firstChild.className != classname)
				leftMenu.firstChild.className = classname;
		}
		
		// oculta todos os sub-menus, exceto aquele que possui o LI selecionado
		subMenus = divSubMenu.getElementsByTagName("DIV");
		for(i=0; i<subMenus.length; i++){
			subMenus[i].style.display = (subMenuSelected.parentElement.parentElement.id == subMenus[i].id ? "block" : "none");
		}
		
		// executa a chamada do código JavaScript do atributo href
		if(menuSelected)
			subMenuSelected.firstChild.click();
    }
}

// Função que inicializa o menu de seções do currículo
// somente se ainda não foi inicializado
function initMenu(){
	if(liCurChangeSubMenuDadosPessoais.firstChild.className != "clsSubMenuSelected"
	   && liCurChangeSubMenuDadosPessoais.firstChild.className != "clsSubMenuUnselected") {
		configMenu(liCurChangeSubMenuDadosPessoais, liCurChangeSubMenuChildDadosPessoais);
	}
}

// Função que inicializa o menu de contratos de estágio
// somente se ainda não foi inicializado
function initMenuContratoEstagio(){
	if(liSubMenuChildCompromisso.firstChild.className != "subMenuChildLink"
	   && liSubMenuChildCompromisso.firstChild.className != "unselectedChildLink") {
		configMenuEstagio(liSubMenuChildCompromisso, liSubMenuChildCompromisso);
	}
}

// Função que carrega uma seção do currículo diretamente
function loadSecao(menuSelected, subMenuSelected){
	toggleWorkspace(divWorkCurriculum, divCurChange);
	configMenu(menuSelected, subMenuSelected);
}

// Função que exibe/oculta o div de espera de processamento
// funciona como forma de impedir que ocorram outros clicks do usuário
function toggleWaitingMode(){
	if(divWait.style.display != "block"){
		divWait.style.top = bodyMain.offsetTop;
		divWait.style.height = divPage.offsetHeight;
		divWait.style.display = "block";
	} else {
		divWait.style.display = "none";
	}
}

// Função que apresenta/esconde o quadro de candidatura expressa
function toggleExpressa(){
	if(window.event.srcElement.name == "toggleCandidaturaExpressa"){
		toggleDisplay(divCandidaturaExpressa);
	} else {
		txtCodigoVagaExpressa.value="";
		divCandidaturaExpressa.style.display = "none";
	}
}

// Função que limpa o conteúdo do DIV de trabalho do currículo
// e refaz o download do mesmo
function reloadCurriculum(){
    divWorkCurriculum.innerHTML = "";
    loadAndDisplay("divCurriculum_MeuCurriculo.aspx", divWorkCurriculum, divWorkSpace);
}

//Função que altera a propriedade display
function changeDivVisibility(n,v){
	var names=n.split(",");
	var obj;
	
	for(i=0;i<names.length;i++){
		obj=document.getElementById(names[i]);
		obj.style.display=v;
	}
}

//Função que altera a propriedade display
function changeLabelTermino(obj){
	if(obj.value<3){
		divLabelFormacaoTermino.style.display="none";
		divLabelFormacaoPrevisaoTermino.style.display="block";
	}else{
		divLabelFormacaoTermino.style.display="block";
		divLabelFormacaoPrevisaoTermino.style.display="none";
	}
}

//Controle de seleção de tipos de deficiência
function changeTipoDeficiencia(obj){
	if((obj.value=="1")||(obj.value=="2")||(obj.value=="5")){
		domain_Defisica1.checked=false;
		domain_Defisica2.checked=false;
		domain_Defisica3.checked=false;
		domain_Defisica4.checked=false;
	}else if(obj.value=="3"){
		domain_Defisica2.checked=false;
		domain_Defisica3.checked=false;
		domain_Defisica4.checked=false;
	}else if(obj.value=="4"){
		domain_Defisica1.checked=false;
	}
}

//Controle de seleção de aparelhos
function changeAparelho1(obj){
	if(obj.checked){
		domain_Defisica2.checked=false;
		domain_Defisica3.checked=false;
		domain_Defisica4.checked=false;
		optTipoDeficiencia[2].checked=true;
	}
}

//Controle de seleção de aparelhos
function changeAparelho2(obj){
	if(obj.checked){
		domain_Defisica1.checked=false;
		optTipoDeficiencia[3].checked=true;
	}
}

//--------------------------------------------------------->
//PESQUISA LISTA DE DOMINIOS
//--------------------------------------------------------->
//Exemplo: 
//	Alias=Id|Pais&NomeTabela=pais&CamposExibicao=idpais|nomepais
//	&CamposRetorno=idpais|nomepais&AlvosRetorno=CodigoNacionalidade|Nacionalidade
//	&TituloTela=Nacionalidade&PopUp=Sim&PermitePesquisar=Sim
//	&CampoDePesquisa=Pais&BuscaDadosIniciais=Sim"
function pesquisaLista(path, nome, alias, tabela, exibicao, retorno, alvos, tela, popup, pesquisar, campospesquisa, buscadadosiniciais, filtros, valoresfiltros, CampoOpcional){
	//nomeTela = Converte(tela);
	var url=path + "Pesquisa/PesquisaGenerica.aspx?";
	url += "Alias=" + alias;
	url += "&NomeTabela=" + tabela;
	url += "&CamposExibicao=" + exibicao;
	url += "&CamposRetorno=" + retorno;
	url += "&AlvosRetorno=" + alvos;
	url += "&TituloTela=" + tela;
	url += "&PopUp=" + popup;
	url += "&PermitePesquisar=" + pesquisar;
	url += "&CampoDePesquisa=" + campospesquisa;
	url += "&BuscaDadosIniciais=" + buscadadosiniciais;
	if(CampoOpcional != null)
		url += "&CampoOpcional=" + CampoOpcional;
	
	if((filtros!="")&&(valoresfiltros!="")){
		url += "&Filtros=" + filtros;
		url += "&ValoresFiltros=" + valoresfiltros;
	
	}
	
	var windowHeight = 515;
	var windowWidth = 600;
	
	window.open(url,"PesquisaGenerica","left=" + CalculaLargura(windowWidth) + ",top=" + CalculaAltura(windowHeight) + ",width=" + windowWidth + ",height=" + windowHeight + ",menubar=no,status=no,toolbar=no,scrollbars=yes,");
}
//Converte string para ASCII
function Converte(tela) {

    var str_chr='';

        for(i=0;i<tela.length;i++)
        {

            c = tela.substring(i,i+1);
            str_chr += c.charCodeAt(0) + ',';
        }
     return str_chr;
}

//Usado na busca Pais, Estado, Cidade.
function pesquisaListaAtualizada(path, nome, alias, tabela, exibicao, retorno, alvos, tela, popup, pesquisar, campospesquisa, buscadadosiniciais, filtros, valoresfiltros, CampoOpcional){
	var url=path + "Pesquisa/PesquisaGenerica.aspx?";
	url += "Alias=" + alias;
	url += "&NomeTabela=" + tabela;
	url += "&CamposExibicao=" + exibicao;
	url += "&CamposRetorno=" + retorno;
	url += "&AlvosRetorno=" + alvos;
	url += "&TituloTela=" + tela;
	url += "&PopUp=" + popup;
	url += "&PermitePesquisar=" + pesquisar;
	url += "&CampoDePesquisa=" + campospesquisa;
	url += "&BuscaDadosIniciais=" + buscadadosiniciais;
	if(CampoOpcional != null)
		url += "&CampoOpcional=" + CampoOpcional;
		
	
	if((filtros!="")&&(valoresfiltros!="" && valoresfiltros!=0 && valoresfiltros!="|0")){
		var val = valoresfiltros.split('|');
			if(val[0] == "")
			{
				var fil = filtros.split('|');
				filtros = fil[1];
				valoresfiltros = val[1];
			}
			else
			{
				if(val[1] == ""  || val[1] == 0)
				{
					var fil = filtros.split('|');
					filtros = fil[0];
					valoresfiltros = val[0];
				}
				
			}
		
		url += "&Filtros=" + filtros;
		url += "&ValoresFiltros=" + valoresfiltros;
		
	}
	var windowHeight = 515;
	var windowWidth = 600;
	
	window.open(url,"PesquisaGenerica","left=" + CalculaLargura(windowWidth) + ",top=" + CalculaAltura(windowHeight) + ",width=" + windowWidth + ",height=" + windowHeight + ",menubar=no,status=no,toolbar=no,scrollbars=yes,");
}

function CalculaLargura(windowWidth) {
		var screenWidth = self.screen.width;
		screenWidth = ((screenWidth - windowWidth)/2);
		return screenWidth;
	}

function CalculaAltura(windowHeight) {
		var screenHeight = self.screen.height;
		screenHeight = ((screenHeight - windowHeight)/2);
		return screenHeight;
	}

//--------------------------------------------------------->


//--------------------------------------------------------->
//AJUSTA OS MESES DA SECAO OBJETIVOS PROFISSIONAIS
//--------------------------------------------------------->
function verificaMeses(){
  if(Experiencia_Meses.value>11){
	var xmlMsg=validation_messages_objetivos.XMLDocument;
	alert(xmlMsg.selectSingleNode("//mensagem_experiencia_meses_ajuste").text);
    refexpanos="0123456789";
    anos=Experiencia_Anos.value;
    for(cg=0;cg<anos.length;cg++){
      if(refexpanos.indexOf(anos.charAt(cg))==-1) anos=0;
    }
    if(anos!=0) anos=parseInt(Experiencia_Anos.value);
    meses=parseInt(Experiencia_Meses.value);
    anos=anos+((meses-(meses%12))/12);
    meses=meses%12;
    Experiencia_Anos.value=Math.abs(anos)
    Experiencia_Meses.value=meses;
    
    return false;
  }
}
//--------------------------------------------------------->


//--------------------------------------------------------->
//FUNCOES DE MANIPULACAO DOS GRIDS DO CURRICULO
//--------------------------------------------------------->
//LIMPA O FORMULARIO
function clearData(n){
	if(n=="DataObjetivo"){
		clearObjetivo();
	}else if(n=="DataFormacao"){
		clearFormacao();
	}else if(n=="DataIdioma"){
		clearIdioma();
	}else if(n=="DataInformatica"){
		clearInformatica();
	}else if(n=="DataExperiencia"){
		clearExperiencia();
	}else if(n=="DataCarta"){
		clearCarta();
	}else if(n=="DataLocal"){
		clearLocal();
	}
}

//ADICIONA UM ITEM NO GRID
function addData(n){
	var newData=document.getElementById("new" + n);
	var data=document.getElementById(n);
	
	if(n=="DataObjetivo"){
		if(consisteObjetivo()){
			addObjetivo(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}else if(n=="DataFormacao"){
		if(consisteFormacao()){
			addFormacao(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}else if(n=="DataIdioma"){
		if(consisteIdioma()){
			addIdioma(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}else if(n=="DataInformatica"){
		if(consisteInformatica()){
			addInformatica(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}else if(n=="DataExperiencia"){
		if(consisteExperiencia()){
			addExperiencia(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}else if(n=="DataCarta"){
		if(consisteCarta()){
			addCarta(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}else if(n=="DataLocal"){
		if(consisteLocal()){
			addLocal(getNextSectionId(n),newData,data);
			clearData(n);
		}
	}
}

//REMOVE OS ITENS SELECIONADOS NO GRID
function removeData(c,n){
	//OBTEM AS MENSAGENS DE VALIDACAO
	var xmlMsg;
	if(n=="DataAgente"){
		xmlMsg=validation_messages_agente.XMLDocument;
		if(codigoAgenteSelecionados.value==""){
			alert(xmlMsg.selectSingleNode("//mensagem_selecione_agente").text);
			return false;
		}
	}else if(n=="DataObjetivo"){
		xmlMsg=validation_messages_objetivos;
	}else if(n=="DataFormacao"){
		xmlMsg=validation_messages_formacao.XMLDocument;
	}else if(n=="DataIdioma"){
		xmlMsg=validation_messages_idioma.XMLDocument;
	}else if(n=="DataInformatica"){
		xmlMsg=validation_messages_informatica.XMLDocument;
	}else if(n=="DataExperiencia"){
		xmlMsg=validation_messages_experiencia.XMLDocument;
	}else if(n=="DataCarta"){
		xmlMsg=validation_messages_carta.XMLDocument;
	}else if(n=="DataLocal"){
		xmlMsg=validation_messages_local.XMLDocument;
	}
	
	//CONFIRMA A EXCLUSAO DOS ITENS SELECIONADOS
	
		var hiddenField=document.getElementById(c + "Selecionados");
		if(hiddenField.value!=""){
			var nome="";
			var arr=hiddenField.value.split(",");
			var data=document.getElementById(n);
			var node;
			var delRecord;
			
			if(n=="DataObjetivo"){
				nome="objetivo";
				actionGravaObjetivos.value="true";
			    if(data.XMLDocument.selectSingleNode("//objetivos").childNodes.length == arr.length)
			    {
			       alert(xmlMsg.selectSingleNode("//mensagem_item_lista_obrigatorio1").text + '\n' + xmlMsg.selectSingleNode("//mensagem_item_lista_obrigatorio2").text);
			       return;
			    }
			}else if(n=="DataFormacao"){
				nome="formacao";
				actionGravaFormacoes.value="true";
				if(data.XMLDocument.selectSingleNode("//formacoes").childNodes.length == arr.length)
			    {
			       alert(xmlMsg.selectSingleNode("//mensagem_item_lista_obrigatorio1").text + '\n' + xmlMsg.selectSingleNode("//mensagem_item_lista_obrigatorio2").text);
			       return;
			    }
			}else if(n=="DataIdioma"){
				nome="idioma";
				actionGravaIdiomas.value="true";
			}else if(n=="DataInformatica"){
				nome="informatica";
				actionGravaInformatica.value="true";
			}else if(n=="DataExperiencia"){
				nome="experiencia";
				actionGravaExperiencias.value="true";
			}else if(n=="DataCarta"){
				nome="carta";
				actionGravaCartas.value="true";
			}else if(n=="DataLocal"){
				nome="local";
				actionGravaLocais.value="true";
			}else if(n=="DataAgente"){
				nome="agente";
				if(codigoAgenteExcluidos.value!="") codigoAgenteExcluidos.value+=",";
				codigoAgenteExcluidos.value+=hiddenField.value;
			}
			
			//LIMPA ITENS SELECIONADOS
			hiddenField.value="";
			
			
			if(confirm(xmlMsg.selectSingleNode("//mensagem_confirma_exclusao").text)){
			//EXCLUI OS ITENS SELECIONADOS
			var contador=0;
			var values="";
			for(i=0;i<arr.length;i++){
				if(n=="DataAgente"){
					//EXCLUI APENAS OS AGENTES CRIADOS A PARTIR DA PESQUISA DE VAGAS
					if(data.XMLDocument.selectSingleNode("//" + nome + "[@codigo='" + arr[i] + "']/codigoobjetivo").text=="0"){
						data.documentElement.removeChild(data.XMLDocument.selectSingleNode("//" + nome + "[@codigo='" + arr[i] + "']"));
						contador++;
					}else{
						if(values==""){
							values+=arr[i];
						}else{
							values+=","+arr[i];
						}
					}
				}else{
					data.documentElement.removeChild(data.XMLDocument.selectSingleNode("//" + nome + "[@codigo='" + arr[i] + "']"));
				}
			}

			//CONCLUIA EXCLUSAO DOS AGENTES SELECIONADOS
			if(n=="DataAgente"){
				if(contador>0) gravaAgenteVagas();
				if((contador==0)||((contador>0)&&(contador!=arr.length))){
					alert(xmlMsg.selectSingleNode("//mensagem_informa_resultado_exclusao").text);
					hiddenField.value=values;
				}
			}
		}
	}
}

//SELECIONA UM ITEM DO GRID PARA ALTERACAO
function selectData(obj,n){
	var value=obj.parentElement.parentElement.lastChild.innerHTML;
	var data=document.getElementById(n).XMLDocument;
	
	if(n=="DataObjetivo"){
		selectObjetivo(data,value);
	}else if(n=="DataFormacao"){
		selectFormacao(data,value);
	}else if(n=="DataIdioma"){
		selectIdioma(data,value);
	}else if(n=="DataInformatica"){
		selectInformatica(data,value);
	}else if(n=="DataExperiencia"){
		selectExperiencia(data,value);
	}else if(n=="DataCarta"){
		selectCarta(data,value);
	}else if(n=="DataLocal"){
		selectLocal(data,value);
	}

	updateMode(n);
}

//ATUALIZA OS DADOS DE UM ITEM DO GRID
function updateData(n){
	var data=document.getElementById(n).XMLDocument;
	if(n=="DataObjetivo"){
		if(consisteObjetivo()){
			value=itemObjetivo.value;
			updateObjetivo(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataFormacao"){
		if(consisteFormacao()){
			value=itemFormacao.value;
			updateFormacao(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataIdioma"){
		if(consisteIdioma()){
			value=itemIdioma.value;
			updateIdioma(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataInformatica"){
		if(consisteInformatica()){
			value=itemInformatica.value;
			updateInformatica(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataExperiencia"){
		if(consisteExperiencia()){
			value=itemExperiencia.value;
			updateExperiencia(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataCarta"){
		if(consisteCarta()){
			value=itemCarta.value;
			updateCarta(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataLocal"){
		if(consisteLocal()){
			value=itemLocal.value;
			updateLocal(data,value);
			clearData(n);
			insertMode(n);
		}
	}else if(n=="DataAgente"){
		updateAgente(data);
	}
}

//CANCELA A ALTERACAO DE UM ITEM
function cancelData(n){
	clearData(n);	
	insertMode(n);
}

//MANTEM A LISTA DE ITENS SELECIONADOS
function addSelectedItem(obj){
	var hiddenField=document.getElementById(obj.name + "Selecionados");
	var values=hiddenField.value;
	var value=obj.parentElement.lastChild.innerHTML;
	var arr;

	if(values==""){
		if(obj.checked) values=value;
	}else{
		if(obj.checked){
			values += "," + value;
		}else{
			if(values.indexOf(",")!=-1){
				arr=values.split(",");
				values="";
				for(i=0;i<arr.length;i++){
					if(arr[i]!=value){
						if(values!="") values+=",";
						values+=arr[i];
					}
				}
			}else{
				if(values!=value){
					values+=value;
				}else{
					values="";
				}
			}
		}
	}
	
	hiddenField.value=values;
}

//MANTEM A LISTA DE ITENS SELECIONADOS EM UM DETERMINADO CAMPO
function addSelectedItemInTarget(obj,target){
	var hiddenField=document.getElementById(target);
	var values=hiddenField.value;
	var value=obj.parentElement.lastChild.innerHTML;
	var arr;

	if(values==""){
		if(obj.checked) values=value;
	}else{
		if(obj.checked){
			values += "," + value;
		}else{
			if(values.indexOf(",")!=-1){
				arr=values.split(",");
				values="";
				for(i=0;i<arr.length;i++){
					if(arr[i]!=value){
						if(values!="") values+=",";
						values+=arr[i];
					}
				}
			}else{
				if(values!=value){
					values+=value;
				}else{
					values="";
				}
			}
		}
	}
	
	hiddenField.value=values;
}

//LIMPA O FORMULARIO DE OBJETIVOS PROFISSIONAIS
function clearObjetivo(){
	itemObjetivo.value="";
	Cargo_Pretendido.value="";
	Codigo_Cargo_Pretendido.value="";
	Area.value="";
	Codigo_Area.value="";
	Periodo_Trabalho.selectedIndex=0;
	Forma_Contratacao.selectedIndex=0;
	TempoExperiencia.selectedIndex=0;
	FaixaSalarial.selectedIndex=0;
	Periodicidade.selectedIndex=0;
}

//LIMPA O FORMULARIO DE FORMACAO ACADEMICA
function clearFormacao(){
	itemFormacao.value="";
	Tipo_Curso.selectedIndex=0;
	Codigo_Nome_Instituicao.value="";
	Nome_Instituicao.value="";
	Codigo_Nome_Curso.value="";
	Nome_Curso.value="";
	Duracao_Curso.selectedIndex=0;
	Periodo_Curso.selectedIndex=0;
	for(i=0;i<Status_Curso.length;i++){
		Status_Curso[i].checked=false;
	}
	Data_Inicio.value="";	
	Data_Fim.value="";
}

//LIMPA O FORMULARIO DE IDIOMAS
function clearIdioma(){
	Idioma.selectedIndex=0;
	Leitura.selectedIndex=0;
	Escrita.selectedIndex=0;
	Conversacao.selectedIndex=0;
}

//LIMPA O FORMULARIO DE INFORMATICA
function clearInformatica(){
	Nome_Software.selectedIndex=0;
	Nivel_Conhecimento.selectedIndex=0;
}

//LIMPA O FORMULARIO DE EXPERIENCIAS PROFISSIONAIS
function clearExperiencia(){
	itemExperiencia.value="";
	Empresa.value="";
	Codigo_Area_Empresa.value="";
	Area_Empresa.value="";
	DataAdmissao.value="";
	DataSaida.value="";
	Codigo_CargoInicial.value="";
	CargoInicial.value="";
	NivelHierarquicoInicial.selectedIndex=0;
	Codigo_CargoFinal.value="";
	CargoFinal.value="";
	NivelHierarquicoFinal.selectedIndex=0;
	Atividades.value="";
}

//LIMPA O FORMULARIO DE CARTAS DE APRESENTACAO
function clearCarta(){
	itemCarta.value="";
	Nome_Carta.value="";
	Descricao_Carta.value="";
}

//LIMPA O FORMULARIO DE LOCAIS DE TRABALHO
function clearLocal(){
	itemLocal.value="";
	for(i=0;i<Tipo_Local.length;i++){
		Tipo_Local[i].disabled=false;
		Tipo_Local[i].checked=false;
	}
	Pais_Local.disabled=false;
	Pais_Local.selectedIndex=0;
	btnPesquisaEstado.disabled=false;
	Codigo_Estado_Local.value="";
	Estado_Local.value="";
	btnPesquisaCidade.disabled=false;
	Codigo_Cidade_Local.value="";
	Cidade_Local.value="";
}

//INSERE UM OBJETIVO PROFISSIONAL
function addObjetivo(c,n,d){
	checkRows('DataObjetivo');
	var node=n.XMLDocument.documentElement.cloneNode(true);
	node.selectSingleNode("@codigo").text=c;
	node.selectSingleNode("//codigo").text=c;
	node.selectSingleNode("//codigocargo").text=Codigo_Cargo_Pretendido.value;
	node.selectSingleNode("//cargo").text=Cargo_Pretendido.value;
	node.selectSingleNode("//codigoarea").text=Codigo_Area.value;
	node.selectSingleNode("//area").text=Area.value;
	node.selectSingleNode("//periodo").text=Periodo_Trabalho.options[Periodo_Trabalho.selectedIndex].innerText;
	node.selectSingleNode("//codigoperiodo").text=Periodo_Trabalho.options[Periodo_Trabalho.selectedIndex].value;
	node.selectSingleNode("//indiceperiodo").text=Periodo_Trabalho.selectedIndex;
	node.selectSingleNode("//formacontratacao").text=Forma_Contratacao.options[Forma_Contratacao.selectedIndex].innerText;
	node.selectSingleNode("//codigoformacontratacao").text=Forma_Contratacao.options[Forma_Contratacao.selectedIndex].value;
	node.selectSingleNode("//indiceformacontratacao").text=Forma_Contratacao.selectedIndex;
	node.selectSingleNode("//tempoexperiencia").text=TempoExperiencia.options[TempoExperiencia.selectedIndex].innerText;
	node.selectSingleNode("//codigotempoexperiencia").text=TempoExperiencia.options[TempoExperiencia.selectedIndex].value;
	node.selectSingleNode("//indicetempoexperiencia").text=TempoExperiencia.selectedIndex;
	node.selectSingleNode("//faixasalarial").text=FaixaSalarial.options[FaixaSalarial.selectedIndex].innerText;
	node.selectSingleNode("//codigofaixasalarial").text=FaixaSalarial.options[FaixaSalarial.selectedIndex].value;
	node.selectSingleNode("//indicefaixasalarial").text=FaixaSalarial.selectedIndex;
	node.selectSingleNode("//periodicidade").text=Periodicidade.options[Periodicidade.selectedIndex].innerText;
	node.selectSingleNode("//codigoperiodicidade").text=Periodicidade.options[Periodicidade.selectedIndex].value;
	node.selectSingleNode("//indiceperiodicidade").text=Periodicidade.selectedIndex;
	d.XMLDocument.documentElement.appendChild(node);
	actionGravaObjetivos.value="true";
}

//LIMPA O FORMULARIO DE CARTA DE APRESENTACAO
function clearInformatica(){
	Nome_Software.selectedIndex=0;
	Nivel_Conhecimento.selectedIndex=0;
}

//INSERE UMA FORMACAO ACADEMICA
function addFormacao(c,n,d){
	checkRows('DataFormacao');
	var node=n.XMLDocument.documentElement.cloneNode(true);
	node.selectSingleNode("@codigo").text=c;
	node.selectSingleNode("//codigo").text=c;
	node.selectSingleNode("//tipo").text=Tipo_Curso.options[Tipo_Curso.selectedIndex].innerText;
	node.selectSingleNode("//codigotipo").text=Tipo_Curso.options[Tipo_Curso.selectedIndex].value;
	node.selectSingleNode("//indicetipo").text=Tipo_Curso.selectedIndex;
	node.selectSingleNode("//codigoinstituicao").text=Codigo_Nome_Instituicao.value;
	node.selectSingleNode("//instituicao").text=Nome_Instituicao.value;
	node.selectSingleNode("//codigocurso").text=Codigo_Nome_Curso.value;
	node.selectSingleNode("//curso").text=Nome_Curso.value;
	node.selectSingleNode("//duracao").text=Duracao_Curso.options[Duracao_Curso.selectedIndex].innerText;
	node.selectSingleNode("//codigoduracao").text=Duracao_Curso.options[Duracao_Curso.selectedIndex].value;
	node.selectSingleNode("//indiceduracao").text=Duracao_Curso.selectedIndex;
	node.selectSingleNode("//periodo").text=Periodo_Curso.options[Periodo_Curso.selectedIndex].innerText;
	node.selectSingleNode("//codigoperiodo").text=Periodo_Curso.options[Periodo_Curso.selectedIndex].value;
	node.selectSingleNode("//indiceperiodo").text=Periodo_Curso.selectedIndex;
	for(i=0;i<Status_Curso.length;i++){
		if(Status_Curso[i].checked){
			node.selectSingleNode("//status").text=divStatus_Curso[i].innerText;
			node.selectSingleNode("//codigostatus").text=Status_Curso[i].value;
		}
	}
	node.selectSingleNode("//datainicio").text=Data_Inicio.value;
	node.selectSingleNode("//datafim").text=Data_Fim.value;
	d.XMLDocument.documentElement.appendChild(node);
	actionGravaFormacoes.value="true";
}

//INSERE UM IDIOMA
function addIdioma(c,n,d){
	checkRows('DataIdioma');
	var node=n.XMLDocument.documentElement.cloneNode(true);
	node.selectSingleNode("@codigo").text=c;
	node.selectSingleNode("//codigo").text=c;
	node.selectSingleNode("//nomeidioma").text=Idioma.options[Idioma.selectedIndex].innerText;
	node.selectSingleNode("//codigoidioma").text=Idioma.options[Idioma.selectedIndex].value;
	node.selectSingleNode("//indiceidioma").text=Idioma.selectedIndex;
	node.selectSingleNode("//leitura").text=Leitura.options[Leitura.selectedIndex].innerText;
	node.selectSingleNode("//codigoleitura").text=Leitura.options[Leitura.selectedIndex].value;
	node.selectSingleNode("//indiceleitura").text=Leitura.selectedIndex;
	node.selectSingleNode("//escrita").text=Escrita.options[Escrita.selectedIndex].innerText;
	node.selectSingleNode("//codigoescrita").text=Escrita.options[Escrita.selectedIndex].value;
	node.selectSingleNode("//indiceescrita").text=Escrita.selectedIndex;
	node.selectSingleNode("//conversacao").text=Conversacao.options[Conversacao.selectedIndex].innerText;
	node.selectSingleNode("//codigoconversacao").text=Conversacao.options[Conversacao.selectedIndex].value;
	node.selectSingleNode("//indiceconversacao").text=Conversacao.selectedIndex;
	d.XMLDocument.documentElement.appendChild(node);
	actionGravaIdiomas.value="true";
}

//INSERE UM CONHECIMENTO EM INFORMATICA
function addInformatica(c,n,d){
	checkRows('DataInformatica');
	var node=n.XMLDocument.documentElement.cloneNode(true);
	node.selectSingleNode("@codigo").text=c;
	node.selectSingleNode("//codigo").text=c;
	node.selectSingleNode("//software").text=Nome_Software.options[Nome_Software.selectedIndex].innerText;
	node.selectSingleNode("//codigosoftware").text=Nome_Software.options[Nome_Software.selectedIndex].value;
	node.selectSingleNode("//indicesoftware").text=Nome_Software.selectedIndex;
	node.selectSingleNode("//nivelconhecimento").text=Nivel_Conhecimento.options[Nivel_Conhecimento.selectedIndex].innerText;
	node.selectSingleNode("//codigonivelconhecimento").text=Nivel_Conhecimento.options[Nivel_Conhecimento.selectedIndex].value;
	node.selectSingleNode("//indicenivelconhecimento").text=Nivel_Conhecimento.selectedIndex;
	d.XMLDocument.documentElement.appendChild(node);
	actionGravaInformatica.value="true";
}

//INSERE UMA EXPERIENCIA PROFISSIONAL
function addExperiencia(c,n,d){
	checkRows('DataExperiencia');
	var node=n.XMLDocument.documentElement.cloneNode(true);
	node.selectSingleNode("@codigo").text=c;
	node.selectSingleNode("//empresa").text=Empresa.value;
	node.selectSingleNode("//area").text=Area_Empresa.value;
	node.selectSingleNode("//codigoarea").text=Codigo_Area_Empresa.value;
	node.selectSingleNode("//dataadmissao").text=DataAdmissao.value;
	node.selectSingleNode("//datasaida").text=DataSaida.value;
	node.selectSingleNode("//cargoinicial").text=CargoInicial.value;
	node.selectSingleNode("//codigocargoinicial").text=Codigo_CargoInicial.value;
	node.selectSingleNode("//nivelhierarquicoinicial").text=NivelHierarquicoInicial.options[NivelHierarquicoInicial.selectedIndex].innerText;
	node.selectSingleNode("//codigonivelhierarquicoinicial").text=NivelHierarquicoInicial.options[NivelHierarquicoInicial.selectedIndex].value;
	node.selectSingleNode("//indicenivelhierarquicoinicial").text=NivelHierarquicoInicial.selectedIndex;
	node.selectSingleNode("//cargofinal").text=CargoFinal.value;
	node.selectSingleNode("//codigocargofinal").text=Codigo_CargoFinal.value;
	node.selectSingleNode("//nivelhierarquicofinal").text=NivelHierarquicoFinal.options[NivelHierarquicoFinal.selectedIndex].innerText;
	node.selectSingleNode("//codigonivelhierarquicofinal").text=NivelHierarquicoFinal.options[NivelHierarquicoFinal.selectedIndex].value;
	node.selectSingleNode("//indicenivelhierarquicofinal").text=NivelHierarquicoFinal.selectedIndex;
	node.selectSingleNode("//atividades").text=Atividades.value;
	d.XMLDocument.documentElement.appendChild(node);
	actionGravaExperiencias.value="true";
}

//INSERE UMA CARTA DE APRESENTACAO
function addCarta(c,n,d){
	checkRows('DataCarta');
	var node=n.XMLDocument.documentElement.cloneNode(true);
	node.selectSingleNode("@codigo").text=c;
	node.selectSingleNode("//codigo").text=c;
	node.selectSingleNode("//nomecarta").text=Trim(Nome_Carta.value);
	node.selectSingleNode("//descricaocarta").text=Trim(Descricao_Carta.value);
	var descricaoResumida=Trim(Descricao_Carta.value);
	if(descricaoResumida.length>50) descricaoResumida=descricaoResumida.substring(0,50) + "...";
	node.selectSingleNode("//descricaocartaresumida").text=descricaoResumida;
	d.XMLDocument.documentElement.appendChild(node);
	actionGravaCartas.value="true";
}

//INSERE UMA CARTA DE APRESENTACAO
function addLocal(c,n,d){
	var cod=c;
	for(i=0;i<Tipo_Local.length;i++){
		if(Tipo_Local[i].checked){
			checkRows('DataLocal');
			var node=n.XMLDocument.documentElement.cloneNode(true);
			node.selectSingleNode("@codigo").text=cod;
			node.selectSingleNode("//codigo").text=cod;
			node.selectSingleNode("//tipo").text=divTipo_Local[i].innerText;
			node.selectSingleNode("//codigotipo").text=Tipo_Local[i].value;
			if(Tipo_Local[i].value=="1"){
				node.selectSingleNode("//codigodescricao").text=Pais_Local.options[Pais_Local.selectedIndex].value;
				node.selectSingleNode("//descricao").text=Pais_Local.options[Pais_Local.selectedIndex].innerText;
				node.selectSingleNode("//indice").text=Pais_Local.selectedIndex;
			}else if(Tipo_Local[i].value=="2"){
				node.selectSingleNode("//codigodescricao").text=Codigo_Estado_Local.value;
				node.selectSingleNode("//descricao").text=Estado_Local.value;
			}else if(Tipo_Local[i].value=="3"){
				node.selectSingleNode("//codigodescricao").text=Codigo_Cidade_Local.value;
				node.selectSingleNode("//descricao").text=Cidade_Local.value;
			}
			
			d.XMLDocument.documentElement.appendChild(node);
			cod=getNextSectionId("DataLocal");
		}
	}
	actionGravaLocais.value="true";
}

//SELECIONA UM OBJETIVO PROFISSIONAL PARA ALTERACAO
function selectObjetivo(d,v){
	itemObjetivo.value=v;
	Codigo_Cargo_Pretendido.value=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigocargo").text;
	Cargo_Pretendido.value=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/cargo").text;
	Codigo_Area.value=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigoarea").text;
	Area.value=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/area").text;
	Periodo_Trabalho.selectedIndex=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indiceperiodo").text;
	Forma_Contratacao.selectedIndex=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indiceformacontratacao").text;
	TempoExperiencia.selectedIndex=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indicetempoexperiencia").text;
	FaixaSalarial.selectedIndex=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indicefaixasalarial").text;
	Periodicidade.selectedIndex=d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indiceperiodicidade").text;
}

//SELECIONA UMA FORMACAO ACADEMICA PARA ALTERACAO
function selectFormacao(d,v){
	itemFormacao.value=v;
	Tipo_Curso.selectedIndex=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/indicetipo").text;
	Codigo_Nome_Instituicao.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigoinstituicao").text;
	Nome_Instituicao.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/instituicao").text;
	Codigo_Nome_Curso.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigocurso").text;
	Nome_Curso.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/curso").text;
	Duracao_Curso.selectedIndex=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/indiceduracao").text;
	Periodo_Curso.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/indiceperiodo").text;
	for(i=0;i<Status_Curso.length;i++){
		if(Status_Curso[i].value==d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigostatus").text) Status_Curso[i].checked=true;
	}
	Data_Inicio.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/datainicio").text;
	Data_Fim.value=d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/datafim").text;
}

//SELECIONA UM IDIOMA PARA ALTERACAO
function selectIdioma(d,v){
	itemIdioma.value=v;
	Idioma.selectedIndex=d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceidioma").text;
	Leitura.selectedIndex=d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceleitura").text;
	Escrita.selectedIndex=d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceescrita").text;
	Conversacao.selectedIndex=d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceconversacao").text;
}

//SELECIONA UM CONHECIMENTO EM INFORMATICA
function selectInformatica(d,v){
	itemInformatica.value=v;
	Nome_Software.selectedIndex=d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/indicesoftware").text;
	Nivel_Conhecimento.selectedIndex=d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/indicenivelconhecimento").text;
}

//SELECIONA UMA EXPERIENCIA PROFISSIONAL PARA ALTERACAO
function selectExperiencia(d,v){
	itemExperiencia.value=v;
	Empresa.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/empresa").text;
	Area_Empresa.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/area").text;
	Codigo_Area_Empresa.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigoarea").text;
	DataAdmissao.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/dataadmissao").text;
	DataSaida.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/datasaida").text;
	Codigo_CargoInicial.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigocargoinicial").text;
	CargoInicial.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/cargoinicial").text;
	NivelHierarquicoInicial.selectedIndex=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/indicenivelhierarquicoinicial").text;
	Codigo_CargoFinal.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigocargofinal").text;
	CargoFinal.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/cargofinal").text;
	NivelHierarquicoFinal.selectedIndex=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/indicenivelhierarquicofinal").text;
	Atividades.value=d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/atividades").text;
}

//SELECIONA UMA CARTA DE APRESENTACAO
function selectCarta(d,v){
	itemCarta.value=v;
	Nome_Carta.value=d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/nomecarta").text;
	Descricao_Carta.value=d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/descricaocarta").text;
}

//SELECIONA UM LOCAL DE TRABALHO
function selectLocal(d,v){
	clearData("DataLocal");
	itemLocal.value=v;
	var value="";
	for(i=0;i<Tipo_Local.length;i++){
		value=d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigotipo").text;
		if(Tipo_Local[i].value==value){
			Tipo_Local[i].checked=true;
			if(value=="1"){
				Pais_Local.selectedIndex=d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/indice").text;
			}else if(value=="2"){
				Codigo_Estado_Local.value=d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigodescricao").text;
				Estado_Local.value=d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/descricao").text;
			}else if(value=="3"){
				Codigo_Cidade_Local.value=d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigodescricao").text;
				Cidade_Local.value=d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/descricao").text;
			}
		}else{
			if(value=="1"){
				btnPesquisaEstado.disabled=true;
				btnPesquisaCidade.disabled=true;
			}else if(value=="2"){
				Pais_Local.disabled=true;
				btnPesquisaCidade.disabled=true;
			}else if(value=="3"){
				Pais_Local.disabled=true;
				btnPesquisaEstado.disabled=true;
			}
			Tipo_Local[i].disabled=true;
		}
	}
}

//ATUALIZA UM OBJETIVO PROFISSIONAL
function updateObjetivo(d,v){
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigo").text=v;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigocargo").text=Codigo_Cargo_Pretendido.value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/cargo").text=Cargo_Pretendido.value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigoarea").text=Codigo_Area.value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/area").text=Area.value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/periodo").text=Periodo_Trabalho.options[Periodo_Trabalho.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigoperiodo").text=Periodo_Trabalho.options[Periodo_Trabalho.selectedIndex].value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indiceperiodo").text=Periodo_Trabalho.selectedIndex;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/formacontratacao").text=Forma_Contratacao.options[Forma_Contratacao.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigoformacontratacao").text=Forma_Contratacao.options[Forma_Contratacao.selectedIndex].value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indiceformacontratacao").text=Forma_Contratacao.selectedIndex;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/tempoexperiencia").text=TempoExperiencia.options[TempoExperiencia.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigotempoexperiencia").text=TempoExperiencia.options[TempoExperiencia.selectedIndex].value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indicetempoexperiencia").text=TempoExperiencia.selectedIndex;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/faixasalarial").text=FaixaSalarial.options[FaixaSalarial.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigofaixasalarial").text=FaixaSalarial.options[FaixaSalarial.selectedIndex].value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indicefaixasalarial").text=FaixaSalarial.selectedIndex;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/periodicidade").text=Periodicidade.options[Periodicidade.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/codigoperiodicidade").text=Periodicidade.options[Periodicidade.selectedIndex].value;
	d.documentElement.selectSingleNode("//objetivo[@codigo='" + v + "']/indiceperiodicidade").text=Periodicidade.selectedIndex;
	actionGravaObjetivos.value="true";
}

//ATUALIZA UMA FORMACAO ACADEMICA
function updateFormacao(d,v){
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigo").text=v;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/tipo").text=Tipo_Curso.options[Tipo_Curso.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigotipo").text=Tipo_Curso.options[Tipo_Curso.selectedIndex].value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/indicetipo").text=Tipo_Curso.selectedIndex;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigoinstituicao").text=Codigo_Nome_Instituicao.value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/instituicao").text=Nome_Instituicao.value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigocurso").text=Codigo_Nome_Curso.value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/curso").text=Nome_Curso.value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/duracao").text=Duracao_Curso.options[Duracao_Curso.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigoduracao").text=Duracao_Curso.options[Duracao_Curso.selectedIndex].value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/indiceduracao").text=Duracao_Curso.selectedIndex;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/periodo").text=Periodo_Curso.options[Periodo_Curso.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigoperiodo").text=Periodo_Curso.options[Periodo_Curso.selectedIndex].value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/indiceperiodo").text=Periodo_Curso.selectedIndex;
	for(i=0;i<Status_Curso.length;i++){
		if(Status_Curso[i].checked){
			d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/status").text=divStatus_Curso[i].innerText;
			d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/codigostatus").text=Status_Curso[i].value;
		}
	}
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/datainicio").text=Data_Inicio.value;
	d.documentElement.selectSingleNode("//formacao[@codigo='" + v + "']/datafim").text=Data_Fim.value;
	actionGravaFormacoes.value="true";
}

//ATUALIZA UM IDIOMA
function updateIdioma(d,v){
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/codigo").text=v;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/nomeidioma").text=Idioma.options[Idioma.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/codigoidioma").text=Idioma.options[Idioma.selectedIndex].value;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceidioma").text=Idioma.selectedIndex;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/leitura").text=Leitura.options[Leitura.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/codigoleitura").text=Leitura.options[Leitura.selectedIndex].value;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceleitura").text=Leitura.selectedIndex;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/escrita").text=Escrita.options[Escrita.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/codigoescrita").text=Escrita.options[Escrita.selectedIndex].value;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceescrita").text=Escrita.selectedIndex;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/conversacao").text=Conversacao.options[Conversacao.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/codigoconversacao").text=Conversacao.options[Conversacao.selectedIndex].value;
	d.documentElement.selectSingleNode("//idioma[@codigo='" + v + "']/indiceconversacao").text=Conversacao.selectedIndex;
	actionGravaIdiomas.value="true";
}

//ATUALIZA UM CONHECIMENTO EM INFORMATICA
function updateInformatica(d,v){
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/codigo").text=v;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/software").text=Nome_Software.options[Nome_Software.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/codigosoftware").text=Nome_Software.options[Nome_Software.selectedIndex].value;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/indicesoftware").text=Nome_Software.selectedIndex;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/nivelconhecimento").text=Nivel_Conhecimento.options[Nivel_Conhecimento.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/codigonivelconhecimento").text=Nivel_Conhecimento.options[Nivel_Conhecimento.selectedIndex].value;
	d.documentElement.selectSingleNode("//informatica[@codigo='" + v + "']/indicenivelconhecimento").text=Nivel_Conhecimento.selectedIndex;
	actionGravaInformatica.value="true";
}

//ATUALIZA UMA EXPERIENCIA PROFISSIONAL
function updateExperiencia(d,v){
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigo").text=v;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/empresa").text=Empresa.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigoarea").text=Codigo_Area_Empresa.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/area").text=Area_Empresa.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/dataadmissao").text=DataAdmissao.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/datasaida").text=DataSaida.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigocargoinicial").text=Codigo_CargoInicial.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/cargoinicial").text=CargoInicial.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/nivelhierarquicoinicial").text=NivelHierarquicoInicial.options[NivelHierarquicoInicial.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigonivelhierarquicoinicial").text=NivelHierarquicoInicial.options[NivelHierarquicoInicial.selectedIndex].value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/indicenivelhierarquicoinicial").text=NivelHierarquicoInicial.selectedIndex;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigocargofinal").text=Codigo_CargoFinal.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/cargofinal").text=CargoFinal.value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/nivelhierarquicofinal").text=NivelHierarquicoFinal.options[NivelHierarquicoFinal.selectedIndex].innerText;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/codigonivelhierarquicofinal").text=NivelHierarquicoFinal.options[NivelHierarquicoFinal.selectedIndex].value;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/indicenivelhierarquicofinal").text=NivelHierarquicoFinal.selectedIndex;
	d.documentElement.selectSingleNode("//experiencia[@codigo='" + v + "']/atividades").text=Atividades.value;
	actionGravaExperiencias.value="true";
}

//ATUALIZA UMA CARTA DE APRESENTACAO
function updateCarta(d,v){
	d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/codigo").text=v;
	d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/nomecarta").text=Trim(Nome_Carta.value);
	d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/descricaocarta").text=Trim(Descricao_Carta.value);
	var descricaoResumida=Trim(Descricao_Carta.value);
	if(descricaoResumida.length>50) descricaoResumida=descricaoResumida.substring(0,50) + "...";
	d.documentElement.selectSingleNode("//carta[@codigo='" + v + "']/descricaocartaresumida").text=descricaoResumida;
	actionGravaCartas.value="true";
}

//ATUALIZA UM LOCAL DE TRABALHO
function updateLocal(d,v){
	d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/@codigo").text=v;
	d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigo").text=v;
	for(i=0;i<Tipo_Local.length;i++){
		if((Tipo_Local[i].value=="1")&&(Tipo_Local[i].checked)){
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigodescricao").text=Pais_Local.options[Pais_Local.selectedIndex].value;
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/descricao").text=Pais_Local.options[Pais_Local.selectedIndex].innerText;
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/indice").text=Pais_Local.selectedIndex;
		}else if((Tipo_Local[i].value=="2")&&(Tipo_Local[i].checked)){
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigodescricao").text=Codigo_Estado_Local.value;
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/descricao").text=Estado_Local.value;
		}else if((Tipo_Local[i].value=="3")&&(Tipo_Local[i].checked)){
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/codigodescricao").text=Codigo_Cidade_Local.value;
			d.documentElement.selectSingleNode("//local[@codigo='" + v + "']/descricao").text=Cidade_Local.value;
		}
	}
	actionGravaLocais.value="true";
}

//ATUALIZA O CAMPO MONITORACAO AGENTES DE VAGA
function updateAgente(d){
	var status;
	var selecionados=document.getElementById("codigoAgenteSelecionados");
	var monitoradosA=document.getElementById("codigoAgenteMonitoradosA");
	var monitoradosI=document.getElementById("codigoAgenteMonitoradosI");
	if(selecionados.value!=""){
		var arr=selecionados.value.split(",");
		for(i=0;i<arr.length;i++){
			status=d.documentElement.selectSingleNode("//agente[@codigo='" + arr[i] + "']/monitorar").text;
			if(status=="Sim"){
				if(monitoradosI.value==""){
					monitoradosI.value=arr[i];
				}else{
					monitoradosI.value+=","+arr[i];
				}
				d.documentElement.selectSingleNode("//agente[@codigo='" + arr[i] + "']/monitorar").text="N&#227;o";
			}else{
				if(monitoradosA.value==""){
					monitoradosA.value=arr[i];
				}else{
					monitoradosA.value+=","+arr[i];
				}
				d.documentElement.selectSingleNode("//agente[@codigo='" + arr[i] + "']/monitorar").text="Sim";
			}
		}
	}else{
		alert("Por favor, selecione pelo menos um agente.");
		return false;
	}
	
	gravaAgenteVagas();
	
	codigoAgenteMonitoradosA.value="";
	codigoAgenteMonitoradosI.value="";
	codigoAgenteExcluidos.value="";
}

//COLOCA A TELA EM MODO DE ALTERACAO
function updateMode(n){
	var divIncluir=document.getElementById("div" + n + "Incluir");
	var divAlterar=document.getElementById("div" + n + "Alterar");
	divIncluir.style.display="none";
	divAlterar.style.display="block";
}

//COLOCA A TELA EM MODO DE ALTERACAO
function insertMode(n){
	var divIncluir=document.getElementById("div" + n + "Incluir");
	var divAlterar=document.getElementById("div" + n + "Alterar");
	divIncluir.style.display="block";
	divAlterar.style.display="none";
}

//RETORN A O PROXIMO ID DA SECAO
function getNextSectionId(n){
	var id=1;
	var data=document.getElementById(n).XMLDocument;
	var elem;
	
	if(n=="DataObjetivo"){
		elem="objetivo";
	}else if(n=="DataFormacao"){
		elem="formacao";
	}else if(n=="DataIdioma"){
		elem="idioma";
	}else if(n=="DataInformatica"){
		elem="informatica";
	}else if(n=="DataExperiencia"){
		elem="experiencia";
	}else if(n=="DataCarta"){
		elem="carta";
	}else if(n=="DataLocal"){
		elem="local";
	}
	
	var rows=data.selectNodes("*/" + elem).length;
	if(rows>0){
		var codigo=data.selectSingleNode("//" + elem + "[" + (rows-1) + "]/@codigo").text;
		if(codigo!="") id=++codigo;
	}
	
	return id;
}

//VERIFICA A EXISTENCIA DE LINHAS E REMOVE O ITEM EM BRANCO
function checkRows(n){
	var data=document.getElementById(n).XMLDocument;
	var elem="";
	if(n=="DataObjetivo"){
		elem="objetivo";
	}else if(n=="DataFormacao"){
		elem="formacao";
	}else if(n=="DataIdioma"){
		elem="idioma";
	}else if(n=="DataInformatica"){
		elem="informatica";
	}else if(n=="DataExperiencia"){
		elem="experiencia";
	}else if(n=="DataCarta"){
		elem="carta";
	}else if(n=="DataLocal"){
		elem="local";
	}
	
	var rows = data.selectNodes("*/" + elem).length;
	if(rows==1){
		if(data.selectSingleNode("//" + elem + "/@codigo").text == ""){
			var ele = document.getElementById(n);
			var node = data.selectSingleNode("//" + elem);
			ele.documentElement.removeChild(node);
			var tbody=document.getElementById("tbody" + n + "Aux");
			tbody.style.display="none";
			var tbody=document.getElementById("tbody" + n);
			tbody.style.display="block";
		}
	}
}
//--------------------------------------------------------->


//HABILITA E DESABILITA O CAMPO NATURALIDADE
//DE ACORDO COM A SELECAO DA NACIONALIDADE
function alteraStatusNaturalidade(obj,nome){
	var campo=document.getElementById(nome);
	if(obj.options[obj.selectedIndex].innerText.toLowerCase()=="brasileiro"){
		campo.disabled=true;
	}else{
		campo.disabled=false;
	}
	campo.value="";
}

//HABILITA E DESABILITA O CAMPO NATURALIDADE e o CAMPO BOTAO
//DE ACORDO COM A SELECAO DA NACIONALIDADE
function alteraStatusNaturalidadeBotao(obj,nome,botaoPesquisa){
	var campo=document.getElementById(nome);
	var botao=document.getElementById(botaoPesquisa);
	
	if(obj.selectedIndex != null)
	{
		if(obj.options[obj.selectedIndex].innerText.toLowerCase()=="brasileiro")
		{
			campo.disabled=true;
			botao.disabled = false;
		}
		else
		{
			campo.disabled=false;
			botao.disabled=true;
		}
		
		campo.value = "";
	}
			
	
}

//Sempre seleciona a opçãp Pais = Brasil
function SelecionaBrasil(combo)
{
    var i;
    
    for(i=0; i<combo.options.length; i++ )
    {
        if(combo.options[i].innerText.toLowerCase()=="brasil")
            combo.options[i].selected = true;           
    }
}

//HABILITA E DESABILITA O CAMPO cidade e o campo Estado
//DE ACORDO COM A SELECAO do país
function alteraStatusEstadoCidadeBotao(obj,nome,botaoPesquisa,bLimpaCampo){
	var campo=document.getElementById(nome);
	var botao=document.getElementById(botaoPesquisa);
	
	if(obj.selectedIndex != null)
	{
	    if(obj.selectedIndex == 0)
	        SelecionaBrasil(obj);
	        
		if(obj.options[obj.selectedIndex].innerText.toLowerCase()=="brasil")
		{
			campo.disabled=true;
			botao.disabled = false;
		}			
		else
		{
			campo.disabled=false;
			botao.disabled=true;
		}
		if(bLimpaCampo)
	        campo.value = "";
	}
}

//EXIBE E OCULTA TOOLTIP
function controleTooltip(ifrName, divName, displayProperty, evnt){
	var divObj=document.getElementById(divName);
	var ifrObj=document.getElementById(ifrName);
	if(displayProperty=="block"){
		ifrObj.style.left=evnt.x+document.documentElement.scrollLeft;
		ifrObj.style.top=evnt.y+document.documentElement.scrollTop;
		window.frames[ifrName].document.body.innerHTML=divObj.innerHTML;
		window.frames[ifrName].document.body.style.backgroundColor="#ffffdd";
		window.frames[ifrName].document.body.style.borderStyle="solid";
		window.frames[ifrName].document.body.style.borderColor="#000000";
		window.frames[ifrName].document.body.style.borderWidth="1px";
	}
	ifrObj.style.display=displayProperty;
}

function controleTooltip1(ifrName, divName, displayProperty, evnt){
	var divObj=document.getElementById(divName);
	var ifrObj=document.getElementById(ifrName);

	ifrObj.style.display=displayProperty;

	if(displayProperty=="block"){
		if(window.screen.availWidth==800){
			ifrObj.style.left=evnt.x-ifrObj.offsetWidth;
		}else{
			ifrObj.style.left=evnt.x-ifrObj.offsetWidth-ifrObj.offsetParent.offsetLeft;
		}
		
		ifrObj.style.top=(evnt.y+document.documentElement.scrollTop)-ifrObj.offsetHeight;
		var objImg=document.getElementById("imgvisibilidade");
		window.frames[ifrName].document.body.innerHTML=divObj.innerHTML;
		window.frames[ifrName].document.body.style.backgroundColor="#ffffdd";
		window.frames[ifrName].document.body.style.borderStyle="solid";
		window.frames[ifrName].document.body.style.borderColor="#000000";
		window.frames[ifrName].document.body.style.borderWidth="1px";
	}
}

function controleTooltip2(ifrName, divName, displayProperty, evnt){
	var divObj=document.getElementById(divName);
	var ifrObj=document.getElementById(ifrName);

	ifrObj.style.display=displayProperty;

	if(displayProperty=="block"){
		if(window.screen.availWidth==800){
			ifrObj.style.left=evnt.x-ifrObj.offsetWidth;
		}else{
			ifrObj.style.left=evnt.x-ifrObj.offsetWidth-ifrObj.offsetParent.offsetLeft;
		}
		
		ifrObj.style.top=(evnt.y+document.documentElement.scrollTop)-ifrObj.offsetHeight;
		//ifrObj.style.top = "260px"
		var objImg=document.getElementById("imgvisibilidade");
		window.frames[ifrName].document.body.innerHTML=divObj.innerHTML;
		window.frames[ifrName].document.body.style.backgroundColor="#ffffdd";
		window.frames[ifrName].document.body.style.borderStyle="solid";
		window.frames[ifrName].document.body.style.borderColor="#000000";
		window.frames[ifrName].document.body.style.borderWidth="1px";
	}
}
function LimpaDeficiencia()
{
	optTipoDeficiencia[0].checked=false;
	optTipoDeficiencia[1].checked=false;
	optTipoDeficiencia[2].checked=false;
	optTipoDeficiencia[3].checked=false;
	optTipoDeficiencia[4].checked=false;
	domain_Defisica1.checked=false;
	domain_Defisica2.checked=false;
	domain_Defisica3.checked=false;
	domain_Defisica4.checked=false;

}
