// JavaScript Document
function mostraDepoimento(dep){
	for (i=2;i<=5;i++){
		if(dep!=i)
			document.getElementById('divDepoi_'+i).style.display="none";
		else
			document.getElementById('divDepoi_'+dep).style.display="block";
	}
}
function atualizaDepoimento(){
	var v1 = document.getElementById('divDepoi_2');
	var v2 = document.getElementById('divDepoi_3');
	if(v1.style.display=="block"){
		v1.style.display = "none";
		v2.style.display = "block";
	}else{
		v2.style.display = "none";
		v1.style.display = "block";
	}
	window.setTimeout( atualizaDepoimento, 10000 );
}
scrollStep = 2;
timerLeft = "";
   timerRight = "";
function stopMe() {
            clearTimeout(timerRight)
            clearTimeout(timerLeft)
        }
function MM_swapImgRestore() { //v3.0
            var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
        }
        function scrollDivRight(id) {
            clearTimeout(timerLeft)
            document.getElementById(id).scrollLeft -= scrollStep;
            timerLeft = setTimeout("scrollDivRight('" + id + "')", 10);
        }
        function MM_swapImage() { //v3.0
            var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
                if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
        }
        function scrollDivLeft(id) {
            clearTimeout(timerRight)
            document.getElementById(id).scrollLeft += scrollStep;
            timerRight = setTimeout("scrollDivLeft('" + id + "')", 10);
        }
		function MM_findObj(n, d) { //v4.01
            var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
                d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
            }
            if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
            for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
            if (!x && d.getElementById) x = d.getElementById(n); return x;
        }
		function toTop(id) {
            document.getElementById(id).scrollTop = 0
        }
        function scrollDivTop(id) {
            clearTimeout(timerRight)
            document.getElementById(id).scrollTop += scrollStep;
            timerRight = setTimeout("scrollDivTop('" + id + "')", 20);
        }
        function scrollDivBottom(id) {
            clearTimeout(timerLeft)
            document.getElementById(id).scrollTop -= scrollStep;
            timerLeft = setTimeout("scrollDivBottom('" + id + "')", 20);
        }
        function toBottom(id) {
            document.getElementById(id).scrollTop = document.getElementById(id).scrollWidth
        }
		function abreTela(endereco){
			window.open(endereco,'','width='+(screen.width-10)+',height='+(screen.height-70)+',resizable=yes,scrollbars=yes,toolbar=no, location=no, directories=no, status=no, menubar=no, left=0,top=0');
		}
	function limparCampos(form){
		vForm = document.getElementById(form);
		for( var x = 0; x < vForm.elements.length; x++ ) {
			if(vForm.elements[x].type=="text" || vForm.elements[x].type=="password")
			vForm.elements[x].value = "";
			else
			if(vForm.elements[x].type=="select-one")
			vForm.elements[x].options[0].selected = true;
		}
		vForm.elements[0].focus();
	}
	function validaCadastroEnviado(form){
		vForm = document.getElementById(form);
		for( var x = 0; x < vForm.elements.length; x++ ) {
			if((vForm.elements[x].type=="text")&&(vForm.elements[x].value=="")){
				alert('Informe o '+vForm.elements[x].title);
				vForm.elements[x].focus();
				return false;
			}
		}
		submit();
	}
	function validaCadastro(form){
		vForm = document.getElementById(form);
		for( var x = 0; x < vForm.elements.length; x++ ) {
			if((vForm.elements[x].type=="text" || vForm.elements[x].type=="password")&&(vForm.elements[x].value=="")){
				alert(vForm.elements[x].title);
				vForm.elements[x].focus();
				return false;
			}
			if((vForm.elements[x].alt=="email")){
				if(checkMail(vForm.elements[x].value)==false){
					alert('E-mail inválido, verifique.');
					vForm.elements[x].focus();
					return false;
				}
			}
		}
	}
	function validaMail(campo){
		if(checkMail(document.getElementById(campo).value)==false){
		alert('E-mail inválido, verifique.');
		return false;
		}
	}
	function checkMail(mail){
        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
        if(typeof(mail) == "string"){
                if(er.test(mail)){ return true; }else{
                return false;
                }
        }else if(typeof(mail) == "object"){
                if(er.test(mail.value)){
                   return true;
                }
        }else{
                return false;
                }
	}
function validarAlteraSenha(){
	with(document.frmSenha){
		if(senhaAtual.value == ""){
				alert("Informe a Senha Atual. Campo Obrigatório!");
				senhaAtual.focus();
				return false;
			}
			if(senhaNova.value == ""){
				alert("Informe a Nova Senha. Campo Obrigatório!");
				senhaNova.focus();
				return false;
			}
			if(senhaConfirma.value == ""){
				alert("Confirme a Nova Senha. Campo Obrigatório!");
				senhaConfirma.focus();
				return false;
			}
			if(senhaNova.value != senhaConfirma.value){
				alert("Nova senha é diferente da senha confirmada.");
				senhaConfirma.focus();
				return false;
			}
	}
}
function mostraDivs(valor,numPesq,numEmp){
	if(valor=='beneficio'){
		listarDados('../classes/processaAjax.php?act=meusBeneficios','POST','listagem2');
		document.getElementById('trBeneficio_1').style.display='none';
		document.getElementById('listagem2').style.display='';
		document.getElementById('listagem').style.display='none';
		document.getElementById('tdMeusBeneficios').className='fonteCargosAtivo';
		document.getElementById('tdBeneficiosPesquisa').className='fonteCargosInativo';
	}else{
		if(valor=='beneficioPesquisa'){
			document.getElementById('trBeneficio_1').style.display='';
			document.getElementById('listagem2').style.display='none';
			document.getElementById('listagem').style.display='';
			document.getElementById('tdBeneficiosPesquisa').className='fonteCargosAtivo';
			document.getElementById('tdMeusBeneficios').className='fonteCargosInativo';
		}else{
			if(valor=='minhasFiliais'){
				Loading('divLoading','carregando');
				listarDados('../../classes/processaAjaxNovo.php?act=minhasFiliais','POST','listagem2');
				document.getElementById('listagem2').style.display='';
				document.getElementById('listagem').style.display='none';
				document.getElementById('tdMeusDados').className='fonteCargosAtivo';
				document.getElementById('tdPesquisa').className='fonteCargosInativo';
				Loading('divLoading','limpar');

			}else{
				if(valor=='filialPesquisa'){
					document.getElementById('listagem2').style.display='none';
					document.getElementById('listagem').style.display='';
					document.getElementById('tdPesquisa').className='fonteCargosAtivo';
					document.getElementById('tdMeusDados').className='fonteCargosInativo';
				}
			}
		}
	}
}
function startAjax(){
			try {
				xmlhttp = new XMLHttpRequest();
			}catch(e) {
				try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(ee){
					try {
						xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch(E){
						xmlhttp = false;
					}
				 }
  		    }
			return xmlhttp;
	}
function listarDados(enderecourl,getoupost,divRetorno){
	var ajax = startAjax();
	if (ajax){
		ajax.open(getoupost,enderecourl,true);
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.onreadystatechange = function()
		{
			//após ser processado - chama função processXML que vai varrer os dados
			if (ajax.readyState==4){
			var get = ajax.responseText.replace(/\+/g," ");
			document.getElementById(divRetorno).innerHTML = get;
			}
		}
		ajax.send(null);
	}
}

function Loading(divNome, acao) {
	var divElement = document.getElementById(divNome);
	
	divElement.style.position = 'absolute';
	divElement.style.zIndex = 3000;
	divElement.style.top = ((screen.height/2 - divElement.style.height/2)-100)+"px";
	divElement.style.left = ((screen.width/2 - divElement.style.width/2)-100)+"px";

//	var idFrame = document.getElementById('iFrameMenu');
	//idFrame.style.top = ((screen.height/2 - idFrame.style.height/2)-90)+"px";
//	idFrame.style.left = ((screen.width/2 - idFrame.style.width/2)-100)+"px"; 
	if (acao == "buscar"){
		//idFrame.style.visibility='';
		divElement.innerHTML = "<center><br><b>Aguarde, pesquisando...</b>&nbsp;&nbsp;<img align='absmiddle' src=\"http://www.salariosweb.com.br/img/indicator.gif\" width=\"16\" height=\"16\" vspace=\"2\" /><br><br></center>";
		//tooltipCloneIframeDivNew(divElement); //Funcao para clonar iFrame
	}else{
		if (acao == "carregando"){
			//idFrame.style.visibility='';
			divElement.innerHTML = "<center><br><b>Aguarde, carregando...</b>&nbsp;&nbsp;<img align='absmiddle' src=\"http://www.salariosweb.com.br/img/indicator.gif\" width=\"16\" height=\"16\" vspace=\"2\" /><br><br></center>";
			//tooltipCloneIframeDivNew(divElement); //Funcao para clonar iFrame
		}else{
			if (acao == "limpar"){
				divElement.style.display='none';
				divElement.innerHTML = "";
				//tooltipCloneIframeDivNew(divElement); //Funcao para clonar iFrame
			}else{
				if(acao=="gravando"){
					divElement.innerHTML = "<center><br><b>Aguarde, gravando informação...</b>&nbsp;&nbsp;<img align='absmiddle' src=\"http://www.salariosweb.com.br/img/indicator.gif\" width=\"16\" height=\"16\" vspace=\"2\" /><br><br></center>";					
				}else{
					if(acao=="camposelect"){
						divElement.innerHTML = "<select class='formulario' style='width:75%'><option value=''>Aguarde, carregando...</option></select>";					
					}
				}
			}
		}
	}
}

function confirmaFilial(valor){
		if(confirm("Você tem certeza que deseja excluir essa Filial da sua lista?")){
			var ajax = startAjax();
			if (ajax){
				Loading('divLoading','carregar');
				ajax.open('POST','../../classes/processaAjaxNovo.php?act=excluirFilialEmpresa&valor='+valor,true)
				ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				ajax.onreadystatechange = function()
				{
				//após ser processado - chama função processXML que vai varrer os dados
					if (ajax.readyState==4){
						var get = ajax.responseText.replace(/\+/g," ");
						if(get!="possuiSalario")
						document.getElementById('listagem2').innerHTML = get;
						else
						alert("Não é possível continuar a exclusão, existem salários vinculados a essa Filial.");
						Loading('divLoading','limpar');
					}
				}
				ajax.send();
			}
		}else{
			return false
		}
}

function forcaListaPesquisa(act,divRetorno,numPesq){
	if(act=="listaEmpresasAdicionaPesquisa"){
		if(numPesq==""){
			alert('Selecione a Pesquisa.');
			return false;
		}
		act1 = "&ordenacao="+document.getElementById('ordenar').value;
	}else
		act1 = "";
 	listaPesquisa('../../classes/processaAjaxNovo.php?act='+act+act1,'POST',divRetorno,'listaDados');
}

function listaPesquisa(enderecourl,getoupost,divRetorno,acao){
	if((acao!="listaEdicaoCarta")&&(acao!="listaDados")&&(acao!="geraRelatorio")&&(acao!="listaEdicaoAtualizaSalario")&&(acao!="alteraAcessoUsuario")){
		if(divRetorno!="divGrupoCadQuestao")
			var vcx_texto  = document.getElementById('cx_texto').value;
		else
			var vcx_texto  = document.getElementById('numQuest').value;
	}else
		var vcx_texto="";
	
	Loading('divLoading','buscar');
			var ajax = startAjax();
			if (ajax){

				ajax.open(getoupost,enderecourl+'&cx_texto='+vcx_texto,false);
				ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=ISO-8859-1");
				ajax.send(null);
					if (ajax.status==200){
						var get = ajax.responseText.replace(/\+/g," ")
						document.getElementById(divRetorno).innerHTML = get;
						Loading('divLoading','limpar');
					}
			}
}

function moveDados( srcList, destList, moveAll,cond,nomecampo ) {
 <!-- Aqui não tem controle sobre total de inserção nos campos -->
 if ((srcList.selectedIndex == -1 ) && (moveAll == false)) {
   return;
 }
if(cond=="insere"){
	 newDestList = new Array( destList.options.length );
	 var len = 0;
	 if((destList.options.length==1)&&(destList.options[0].value==0))
		 destList.options[0]=null;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
	   	  //PROCEDIMENTO PARA ATUALIZAR O VALOR.
		  var arrayDados = srcList.options[i].value.split('*');
	/*	  var vSalario = (parseFloat(arrayDados[1]) * (document.getElementById('valor').value/100))+parseFloat(arrayDados[1]);*/
		vVal = document.getElementById('valor').value.replace(",",".");
		atac1 = parseFloat((arrayDados[1] * vVal) / 100);
		v1 = parseFloat(arrayDados[1]) + atac1;
//		v2 = (v1*100);
		v2 = Arredonda(v1,2);
		vSalario = formatFloat2(v2,2);
		vData = new Date();
		dia = vData.getDate();
		if(dia<10)
		dia = "0"+dia;
		mes = vData.getMonth()+1;
		if(mes<10)
		mes = "0"+mes;

		ano = vData.getFullYear();
		vDataF = dia+"/"+mes+"/"+ano;
		  var vTitu = vDataF+" "+arrayDados[2]+" "+vSalario;
		  newDestList[ len ] = new Option( vTitu, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 var R = srcList.options.length;
    var k = 0;
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
		  srcList.options[i] = null;
		  if (k!=1){
		  	R=i;
			k=1;
		  }
	   }
	 }
 	 if(srcList.options.length>0)
	  srcList.options[R].selected = true;
}else{
	if(cond=="volta"){
		newDestList = new Array( destList.options.length );
	 var len = 0;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  var arrayDados = srcList.options[i].value.split('*');
		  vSalario = formatFloat2(arrayDados[1],2);
		   vTitu = arrayDados[3]+" "+arrayDados[2]+" "+vSalario;
		  newDestList[ len ] = new Option( vTitu, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
		  srcList.options[i] = null;
		  var i2 = i;
	   }
	 }
	 if(srcList.options.length>0)
	 srcList.options[i2].selected = true;
	}
}
}

function Arredonda( valor , casas ){
   var novo = Math.round( valor * Math.pow( 10 , casas ) ) / Math.pow( 10 , casas );
   return novo;
}
function isNumber (cp) {
	var er = /[^0-9]/;
	er.lastIndex = 0;
	var campo = document.getElementById(cp);
	if (er.test (campo.value)) {
		campo.value = campo.value.slice(0, (campo.value.length) - 1);
	}
}


function formatFloat2(campo2,decimais)
{
  var posicaoPontoDecimal;
  var campo = '';
  var resultado = '';
  var pos,sep,dec;
  var campooriginal = ''+campo2;
//Retira possiveis separadores de milhar
  for (pos=0; pos < campooriginal.length; pos ++)
  {
    if (campooriginal.charAt(pos)!='.')
        campo = campo + campooriginal.charAt(pos);
	else
	campo = campo + ',';
  }
// valor monetário com decimais
  posicaoPontoDecimal = campo.indexOf(',');
  if (posicaoPontoDecimal != -1)
   {
      sep = 0;
      for (pos=posicaoPontoDecimal-1;pos >= 0;pos--)
      {
        sep ++;
        if (sep > 3)
        {
           resultado = '.' + resultado;
           sep = 1;
        }
        resultado = campo.charAt(pos) + resultado;
      }
      // Trata parte decimal
      if (parseInt(decimais) > 0 )
      {
         resultado = resultado + ',';
         pos=posicaoPontoDecimal+1;
         for (dec = 1;dec <= parseInt(decimais); dec++)
         {
           if (pos < campo.length)
           {
              resultado = resultado + campo.charAt(pos);
              pos++;
           }
           else
              resultado = resultado + '0';
         }
      } // trata decimais
   }
   // Trata valor monetário sem decimais
   else
   {
      sep = 0;
      for (pos=campo.length-1;pos >= 0;pos--)
      {
        sep ++;
        if (sep > 3)
        {
           resultado = '.' + resultado;
           sep = 1;
        }
        resultado = campo.charAt(pos) + resultado;
      }
      // Trata parte decimal
      if (parseInt(decimais) > 0 )
      {
         resultado = resultado + ',';
         for (dec = 1;dec <= parseInt(decimais); dec++)
         {
              resultado = resultado + '0';
         }
      } // trata decimais
   }
   return resultado;
}

////////////////////////////////////////////////////////////////////////////////////////////
function compareOptionValues(a, b) {
 var sA = parseInt( a.value, 36 );
 var sB = parseInt( b.value, 36 );
 return sA - sB;
}
////////////////////////////////////////////////////////////////////////////////////
function compareOptionText(a, b) {
 var sA = parseInt( a.text, 36 );
 var sB = parseInt( b.text, 36 );
 return sA - sB;
}

//////////////////////////////////////////////////////////////////////////////////////////////
function moveDadosRelatorioNovo( srcList, destList, moveAll,cond,nomecampo ) {
 <!-- Aqui não tem controle sobre total de inserção nos campos -->
 if ((srcList.selectedIndex == -1 ) && (moveAll == false)) {
   return;
 }
	var vRel = document.getElementById("relatorio");
if(cond=="insere"){
	 newDestList = new Array( destList.options.length );
	 	 
	if(((vRel.value==2)||(vRel.value==3)||(vRel.value==6)||(vRel.value==9))&&(nomecampo=="empresasSelecionadas")){
		//NO RELATORIO  SÓ USA A EMPRESA SE ESCOLHER ELA SENAO LIBERA O RESTANTE E DEIXA A EMPRESA
			document.getElementById('trFiltros1').style.display = "none";
			document.getElementById('trFiltros11').style.display = "none";
			document.getElementById('trFiltros2').style.display = "none";
			document.getElementById('trFiltros22').style.display = "none";
			document.getElementById('trFiltros3').style.display = "none";
			document.getElementById('trFiltros3').style.display = "none";
			
			document.getElementById('tipoEmpresa').options[0].selected = true;
			document.getElementById('porteEmpresa').options[0].selected = true;
			document.getElementById('selectUFEmpresa').options[0].selected = true;
			document.getElementById('regiaoEstado').options[0].selected = true;
			document.getElementById('origemCapital').options[0].selected = true;
			document.getElementById('faixaFaturamento').options[0].selected = true;
	
			/////////////////TUDO ISSO PARA QUE SE POSSA VOLTAR OS RAMOS E SELECIONAR DEPOIS.
			var b = 0;
			var vRamos = document.getElementById('ramosSelecionados');
			var vRamosPesq = document.getElementById('ramoPesquisa');			
			newDestListCarlos = new Array( destList.options.length );
			 var len = 0;
			 for( len = 0; len < vRamosPesq.options.length; len++ ) {
			   if ( vRamosPesq.options[ len ] != null ) {
				 newDestListCarlos[len] = new Option(vRamosPesq.options[len].text, vRamosPesq.options[len].value, vRamosPesq.options[ len ].defaultSelected, vRamosPesq.options[len].selected);
			   }
			 }
			 for( var i = 0; i < vRamos.options.length; i++ ) {
			   if (vRamos.options[i] != null && ( vRamos.options[i].selected == true || moveAll))
			   {
				  newDestListCarlos[ len ] = new Option( vRamos.options[i].text, vRamos.options[i].value, vRamos.options[i].defaultSelected, vRamos.options[i].selected );
				  len++;
			   }
			 }
		//	 newDestList.sort( compareOptionValues );
			 for ( var j = 0; j < newDestListCarlos.length; j++ ) {
			   if ( newDestListCarlos[ j ] != null ) {
				 vRamosPesq.options[ j ] = newDestListCarlos[ j ];
			   }
			 }
		 	for ( var j = 0; j < vRamos.length; j++ )
				vRamos.options[j] = null;
			vRamos.options[0] = new Option( "Todos os Ramos de Atividades", 0, "", true);
			/////////////////////////////////////////////////////////////////////////////////////////////
			
	}
	 var len = 0; var idx = 0;
	 if((destList.options.length==1)&&(destList.options[0].value==0))
		 destList.options[0]=null;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
		//////////CRIO O ARRAY QUE IRA COMPARAR OS OUTROS CARGOS EELCIONADOS DA PEQSUISA	 	
	if(nomecampo=="cargosSelecionados"){	
		 var cpOutrosCargos = document.getElementById('outrosCargosVer');		
		 newOutrosCargosList = new Array( cpOutrosCargos.options.length );
		  
		 if((cpOutrosCargos.options.length==1)&&(cpOutrosCargos.options[0].value==0))
			 cpOutrosCargos.options[0]=null;
		 for( idx = 0; idx < cpOutrosCargos.options.length; idx++ ) {
		   if ( cpOutrosCargos.options[ idx ] != null ) {
			 newOutrosCargosList[idx] = new Option(cpOutrosCargos.options[idx].text, cpOutrosCargos.options[idx].value, cpOutrosCargos.options[ idx ].defaultSelected, cpOutrosCargos.options[idx].selected);
		   }
		 }
	}
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  
		 /////////////////comparar as empresas para saber se passou o total//////////////////////
		 if(nomecampo=="cargosSelecionados"){
			 var cpMeusCargos = document.getElementById('meusCargosVer');
			 
			 var cargoEstranho = "S";
			 for( car = 0; car < cpMeusCargos.options.length; car++ )
				if ( cpMeusCargos.options[ car ].value == srcList.options[i].value )
					cargoEstranho = "N";	
				if(cargoEstranho=="S"){
					if(((cpOutrosCargos.options.length + 1) > (cpMeusCargos.options.length))||
					((newOutrosCargosList.length+1)>(cpMeusCargos.options.length))){
						alert("Você só pode selecionar outros cargos da pesquisa no mesmo total de cargos que você possuí cadastrado.\n\nExemplo: se você cadastrou 5 cargos, só pode selecionar outros 5 cargos da pesquisa para este relatório.");
						return false;
					}else{						
					    newOutrosCargosList[ idx ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
						idx++;
					}
				}
		 }
		  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
	 ////////GRAVANDO AQUI OS OUTROS CARGOS SELECIONADOS DA PESQUISA////////////
	 newOutrosCargosList.sort( compareOptionValues );	 
	 for ( var j = 0; j < newOutrosCargosList.length; j++ ) {
	   if ( newOutrosCargosList[ j ] != null ) {
		 cpOutrosCargos.options[ j ] = newOutrosCargosList[ j ];
	   }
	 }
	 
	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 var R = srcList.options.length;
    var k = 0;
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
		  srcList.options[i] = null;
		  if (k!=1){
		  	R=i;
			k=1;
		  }
	   }
	 }
	 	 if(srcList.options.length>0)
	  srcList.options[R].selected = true;
}else{
	if(cond=="volta"){
	newDestList = new Array( destList.options.length );
	 var len = 0;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
//	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
	      if(nomecampo=="cargosSelecionados"){	
			 var cpOutrosCargos = document.getElementById('outrosCargosVer');
			 for( var id = 0; id < cpOutrosCargos.options.length; id++ ) {
				 if (cpOutrosCargos.options[id].value == srcList.options[id].value)
					  cpOutrosCargos.options[id] = null;
			 }
		  }
		  
		  
		  srcList.options[i] = null;
		  var i2 = i;

	   }
	 }
	 
	 if(srcList.options.length==0){
	 	if(nomecampo=="ramosSelecionados")
			srcList.options[0] = new Option( "Todos os Ramos de Atividades", 0, "", true);
		else
	 	if(nomecampo=="empresasSelecionadas")
			srcList.options[0] = new Option( "Todas as Empresas da Pesquisa", "", "", true);
	 }
	 if(srcList.options.length>0)
	 srcList.options[i2].selected = true;
	}
	if(((vRel.value==2)||(vRel.value==3)||(vRel.value==6)||(vRel.value==9))&&(nomecampo=="empresasSelecionadas")){
		//NO RELATORIO  SÓ USA A EMPRESA SE ESCOLHER ELA SENAO LIBERA O RESTANTE E DEIXA A EMPRESA
		if(document.getElementById('empresasSelecionadas').options[0]== null || document.getElementById('empresasSelecionadas').options[0].value==""){
			document.getElementById('trFiltros1').style.display = "";
			document.getElementById('trFiltros11').style.display = ""
			document.getElementById('trFiltros2').style.display = ""
			document.getElementById('trFiltros22').style.display = ""
			document.getElementById('trFiltros3').style.display = ""
		}
	}
}
}

function moveDadosRelatorio( srcList, destList, moveAll,cond,nomecampo ) {
 <!-- Aqui não tem controle sobre total de inserção nos campos -->
 if ((srcList.selectedIndex == -1 ) && (moveAll == false)) {
   return;
 }
	var vRel = document.getElementById("relatorio");
if(cond=="insere"){
	 newDestList = new Array( destList.options.length );
	if(((vRel.value==2)||(vRel.value==3)||(vRel.value==6)||(vRel.value==9))&&(nomecampo=="empresasSelecionadas")){
		//NO RELATORIO  SÓ USA A EMPRESA SE ESCOLHER ELA SENAO LIBERA O RESTANTE E DEIXA A EMPRESA
			document.getElementById('trFiltros1').style.display = "none";
			document.getElementById('trFiltros11').style.display = "none";
			document.getElementById('trFiltros2').style.display = "none";
			document.getElementById('trFiltros22').style.display = "none";
			document.getElementById('trFiltros3').style.display = "none";
			document.getElementById('trFiltros3').style.display = "none";
			
			document.getElementById('tipoEmpresa').options[0].selected = true;
			document.getElementById('porteEmpresa').options[0].selected = true;
			document.getElementById('selectUFEmpresa').options[0].selected = true;
			document.getElementById('regiaoEstado').options[0].selected = true;
			document.getElementById('origemCapital').options[0].selected = true;
			document.getElementById('faixaFaturamento').options[0].selected = true;
	
			/////////////////TUDO ISSO PARA QUE SE POSSA VOLTAR OS RAMOS E SELECIONAR DEPOIS.
			var b = 0;
			var vRamos = document.getElementById('ramosSelecionados');
			var vRamosPesq = document.getElementById('ramoPesquisa');			
			newDestListCarlos = new Array( destList.options.length );
			 var len = 0;
			 for( len = 0; len < vRamosPesq.options.length; len++ ) {
			   if ( vRamosPesq.options[ len ] != null ) {
				 newDestListCarlos[len] = new Option(vRamosPesq.options[len].text, vRamosPesq.options[len].value, vRamosPesq.options[ len ].defaultSelected, vRamosPesq.options[len].selected);
			   }
			 }
			 for( var i = 0; i < vRamos.options.length; i++ ) {
			   if (vRamos.options[i] != null && ( vRamos.options[i].selected == true || moveAll))
			   {
				  newDestListCarlos[ len ] = new Option( vRamos.options[i].text, vRamos.options[i].value, vRamos.options[i].defaultSelected, vRamos.options[i].selected );
				  len++;
			   }
			 }
		//	 newDestList.sort( compareOptionValues );
			 for ( var j = 0; j < newDestListCarlos.length; j++ ) {
			   if ( newDestListCarlos[ j ] != null ) {
				 vRamosPesq.options[ j ] = newDestListCarlos[ j ];
			   }
			 }
		 	for ( var j = 0; j < vRamos.length; j++ )
				vRamos.options[j] = null;
			vRamos.options[0] = new Option( "Todos os Ramos de Atividades", 0, "", true);
			/////////////////////////////////////////////////////////////////////////////////////////////
			
	}
	 var len = 0;
	 if((destList.options.length==1)&&(destList.options[0].value==0))
		 destList.options[0]=null;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  
		  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 var R = srcList.options.length;
    var k = 0;
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
		  srcList.options[i] = null;
		  if (k!=1){
		  	R=i;
			k=1;
		  }
	   }
	 }
	 	 if(srcList.options.length>0)
	  srcList.options[R].selected = true;
}else{
	if(cond=="volta"){
	newDestList = new Array( destList.options.length );
	 var len = 0;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
//	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {

		  srcList.options[i] = null;
		  var i2 = i;
	   }
	 }
	 if(srcList.options.length==0){
	 	if(nomecampo=="ramosSelecionados")
			srcList.options[0] = new Option( "Todos os Ramos de Atividades", 0, "", true);
		else
	 	if(nomecampo=="empresasSelecionadas")
			srcList.options[0] = new Option( "Todas as Empresas da Pesquisa", "", "", true);
	 }
	 if(srcList.options.length>0)
	 srcList.options[i2].selected = true;
	}
	if(((vRel.value==2)||(vRel.value==3)||(vRel.value==6)||(vRel.value==9))&&(nomecampo=="empresasSelecionadas")){
		//NO RELATORIO  SÓ USA A EMPRESA SE ESCOLHER ELA SENAO LIBERA O RESTANTE E DEIXA A EMPRESA
		if(document.getElementById('empresasSelecionadas').options[0]== null || document.getElementById('empresasSelecionadas').options[0].value==""){
			document.getElementById('trFiltros1').style.display = "";
			document.getElementById('trFiltros11').style.display = ""
			document.getElementById('trFiltros2').style.display = ""
			document.getElementById('trFiltros22').style.display = ""
			document.getElementById('trFiltros3').style.display = ""
		}
	}
}
}

function moveDualList( srcList, destList, moveAll,cond ) {
 <!-- Aqui não tem controle sobre total de inserção nos campos -->
 if ((srcList.selectedIndex == -1 ) && (moveAll == false)) {
   return;
 }
if(cond=="insere"){
	 newDestList = new Array( destList.options.length );
	 var len = 0;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
		  srcList.options[i] = null;
	   }
	 }
	 if(srcList.options.length>0)
	 srcList.options[i+1].selected = true;
}else{
	if(cond=="volta"){
		newDestList = new Array( destList.options.length );
	 var len = 0;
	 for( len = 0; len < destList.options.length; len++ ) {
	   if ( destList.options[ len ] != null ) {
		 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
	   }
	 }
	 for( var i = 0; i < srcList.options.length; i++ ) {
	   if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
	   {
		  newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
		  len++;
	   }
	 }
	 newDestList.sort( compareOptionValues );
	 for ( var j = 0; j < newDestList.length; j++ ) {
	   if ( newDestList[ j ] != null ) {
		 destList.options[ j ] = newDestList[ j ];
	   }
	 }
	 for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	   if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
		  srcList.options[i] = null;
	   }
	 }
	 if(srcList.options.length>0)
	 srcList.options[i+1].selected = true;
	}
}
}



