//Javascript Document

/*_______________________________________
  |                                      |
  |    IT'S NOT COPY, WAS MADE BY RISSO  |
  | 	   thiago.risso@gmail.comã ? áãç |
  |______________________________________|*/
/*
*Fabio
*Date:	06/12/2007
*Describe:	Funções copiadas para controller.js(ger_new)
*			alterValue(obj,valor,frame)
*/
PPTop = 0;
temp_sess = 60 * 19 * 1000; // 19 minutos
temp_login = 30 * 1000; // 30 segundos
var get = false;
var timeSession = null;
var timeLogin = null;

img_dis = 'image/star_enable.gif';
img_ena = 'image/star_disable.gif';

function branco()
{
	if(parent.topo)
		parent.topo.location.href = "branco.php";
}

function addEvent(obj, evType, fn)
{
    if(obj.addEventListener)
	{
        obj.addEventListener(evType, fn, false);
        return true;
    } 
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent('on'+evType, fn);
		return r;
    } 
	else 
	{
        return false;
    }
}

function removeEvent(obj, type, fn)
{
	if (obj.detachEvent) 
	{
		obj.detachEvent('on'+type, obj[type+fn]);
		obj[type+fn] = null;
	} 
	else 
	{
		obj.removeEventListener(type, fn, false);
	}
}

/******  getWindowHeight and getWindowWidth is copy from http://quirksmode.org *******/
function getWindowHeight()
{
	if (self.innerHeight) 
	{
		// all except Explorer
		return  self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		// Explorer 6 Strict Mode
		return document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		// other Explorers
		return document.body.clientHeight;
	}
}

function getWindowWidth()
{
	if(self.innerWidth) 
	{
		// all except Explorer
		return  self.innerWidth;
	}
	else if(document.documentElement && document.documentElement.clientWidth)
	{
		// Explorer 6 Strict Mode
		return document.documentElement.clientWidth;
	}
	else if(document.body)
	{
		// Explorer 6 Strict Mode
		return document.body.clientWidth;
	}
}
/* ********************************************************************************** */

function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}

function trocaCidade(estado,obj)
{
	if(window.ocupado)
		ocupado();
	parent.topo.location.href = 'troca_cidade.php?cid='+estado+'&func=true&id='+obj;
	var obj = document.getElementById(obj);
	obj.options[0] = new Option('Aguarde...','0');
	obj.selectedIndex = 0;
	obj.disabled=true;
}

function apareceCarregando()
{
	doc = window.document;
	jan = window;

	if(!doc.getElementById('dv_carregando_xml'))
	{
		dv = doc.createElement("DIV");
		
		dv.style.width = '80px';
		dv.style.height = '18px';
		dv.style.paddingTop = '2px';
		dv.style.textAlign = 'center';
		
		dv.style.position = 'absolute';
		dv.style.backgroundColor = '#666666';
		dv.style.color = '#FFFFFF';
		dv.style.fontFamily = 'Arial';
		dv.style.fontSize = '11px';
		dv.style.fontWeight = 'bold';		
		dv.id = 'dv_carregando_xml';
		dv.innerHTML = 'Carregando...';
			
		
		if(doc.body)
			doc.body.appendChild(dv);
		else
			doc.all.appendChild(dv);
	}
	
	div = doc.getElementById('dv_carregando_xml');
	
	div.style.top = '0px';
	lf = jan.innerWidth ? jan.innerWidth : (jan.document.body.clientWidth ? jan.document.body.clientWidth : 800 );
	lf-=82;
	div.style.left = lf+'px';
	div.style.visibility='visible';
}

function someCarregando()
{
	doc = window.document;

	div = doc.getElementById('dv_carregando_xml');
	div.style.visibility='hidden';
}


function trocaInner(objOrig,objTarget,objTarget2,size)
{ 
	objTarget = document.getElementById(objTarget);
	if((document.getElementById(objTarget2))&&(objTarget2))
	{
		objTarget2 = document.getElementById(objTarget2);
		if(size)
		{
			objTarget2.size = size;
			objTarget2.maxLength = size;
		}
	}
	objTarget.innerHTML = objOrig.value;
}

function SetaCandidato(grid)
{
	id = grid.selectedIds[0];
	if(id)
	{
		line = grid.selectedSeqs[0];
		nome = grid.getValueColumn(line,0);
		
		if(parent.opener.document.getElementById('nome'))
		{
			parent.opener.document.getElementById('nome').value = nome;
			
			if(parent.opener.document.getElementById('nome_old'))
				parent.opener.document.getElementById('nome_old').value = nome;
			
			if(parent.opener.document.getElementById('id_candidato'))
				parent.opener.document.getElementById('id_candidato').value = id;
			parent.close();
		}
	}
}

function SetaUsuario(grid)
{
	id = grid.selectedIds[0];
	if(id)
	{
		line = grid.selectedSeqs[0];
		nome = grid.getValueColumn(line,0);
		
		if(parent.opener.document.getElementById('usuario'))
		{
			parent.opener.document.getElementById('usuario').value = nome;
			
			if(parent.opener.document.getElementById('id_usuario'))
				parent.opener.document.getElementById('id_usuario').value = id;
			parent.close();
		}
	}
}

function preencheData(obj)
{
	if(obj.value == "")
	{
		data = new Date();
		hora = data.getHours();
		hora = new String(hora);
		minu = data.getMinutes();
		minu = new String(minu);
				
		if(hora.length == 1)
			hora = '0'+hora;
			
		if(minu.length == 1)
			minu = '0'+minu;
				
		obj.value = hora+":"+minu;
	}
}

function reimprimeContrato(id)
{
	id = (id && id != 0) ? id : false;
	if(id)
	{
		wd_contrato = window.open("emite_contrato_exec.php?id_contrato_emissao="+id,"wd_contrato","width=800,menubar=yes,toolbar=no,status=no,scrollbars=yes");
		wd_contrato.opener = self;
		wd_contrato.focus();
	}
	else
	{
		alert("Selecione um contrato para reimprimir!");
	}
	return;
}

function repetirEnd(tp)
{
	var end = document.getElementById('endereco').value;
	var bairro = document.getElementById('bairro').value;
	var numero = document.getElementById('numero').value;
	var compl = document.getElementById('complemento').value;
	var id_estado = document.getElementById('id_estado');
	var id_cidade = document.getElementById('id_cidade');
	
	if(trim(end)=="")
	{
		alert("Endereço principal não preenchido!");
		return;
	}
	
	if(tp == 'fat')
	{
		document.getElementById("endereco_"+tp).value = end;
		document.getElementById("numero_"+tp).value = numero;
		document.getElementById("complemento_"+tp).value = compl;
		
       /*var html = document.getElementById("state_princ").innerHTML;
	   var new_html = html.replace("id_estado","id_estado_fat");
	   document.getElementById("state_"+tp).innerHTML = new_html;
	  
       html = document.getElementById("dv_cid").innerHTML;
	   new_html = html.replace("id_cidade","id_cidade_fat");
	   document.getElementById("dv_cid_"+tp).innerHTML = new_html;*/
	   
		dv = document.getElementById("state_"+tp);
		sels = dv.getElementsByTagName('select');
		sels[0].selectedIndex = document.getElementById("id_estado").selectedIndex;

		html = document.getElementById("dv_cid").innerHTML;

		dvcids =  document.getElementById("dv_cid_"+tp);
		dvcids.innerHTML = html;

		selcids = dvcids.getElementsByTagName('select');
		selcids[0].id = "id_cidade_"+tp;
		selcids[0].name = "id_cidade_"+tp;
		selcids[0].selectedIndex = document.getElementById("id_cidade").selectedIndex;
	}
	else
	{
		document.getElementById(tp+"_endereco").value = end + ' nº '+ numero;
		document.getElementById(tp+"_bairro").value = bairro;
		
		
       dv = document.getElementById("state_"+tp);
	   sels = dv.getElementsByTagName('select');
	   sels[0].selectedIndex = document.getElementById("id_estado").selectedIndex;
	   
	
	  //alert(document.getElementById("id_estado_enc"));
	   //document.getElementById("id_estado_"+tp).selectedIndex = document.getElementById("id_estado").selectedIndex;
	  
       html = document.getElementById("dv_cid").innerHTML;

	  dvcids =  document.getElementById("dv_cid_"+tp);
	  dvcids.innerHTML = html;
	   
   	   selcids = dvcids.getElementsByTagName('select');
	   selcids[0].id = "id_cidade_"+tp;
   	   selcids[0].name = "id_cidade_"+tp;
	   selcids[0].selectedIndex = document.getElementById("id_cidade").selectedIndex;
	}
}

function ast_obj()
{
	if(parent.corpo.gridObj.Seq == 0)
	{
		parent.corpo.document.getElementById('hier_span').style.display="";
		parent.corpo.document.getElementById('funcao_span').style.display="";
	}
	else
	{
		parent.corpo.document.getElementById('hier_span').style.display="none";
		parent.corpo.document.getElementById('funcao_span').style.display="none";
	}
}

function ast_esc()
{
	if(parent.corpo.gridEsc.Seq == 0)
	{
		parent.corpo.document.getElementById('escol_span').style.display="";
		parent.corpo.document.getElementById('insti_span').style.display="";
		if(parent.corpo.document.getElementById('inicio_span'))
			parent.corpo.document.getElementById('inicio_span').style.display="";
		if (parent.corpo.document.getElementById('term_span'))
			parent.corpo.document.getElementById('term_span').style.display="";
	}
	else
	{
		parent.corpo.document.getElementById('escol_span').style.display="none";
		parent.corpo.document.getElementById('insti_span').style.display="none";
		if (parent.corpo.document.getElementById('inicio_span'))
			parent.corpo.document.getElementById('inicio_span').style.display="none";
		if (parent.corpo.document.getElementById('term_span'))
			parent.corpo.document.getElementById('term_span').style.display="none";
	}
}

function SelecionaCand(id_cand,id_vaga,process)
{
	if(typeof as == 'undefined')
	{
		as = new assyncRequest('as');
	}
	
	as.loadXML('seleciona_candidato_exec.php','GET',['id_vaga','id_candidato','process'],[id_vaga,id_cand,process],'eval');
	
	/*
	if(!parent.ifr_salva)
		parent.corpo.ifr_salva.location.href = 'seleciona_candidato_exec.php'+get;
	else
		parent.ifr_salva.location.href = 'seleciona_candidato_exec.php'+get;
	*/
}

function StatusCand(id_cand,acao)
{
	//var id = "?id_candidato="+id_cand;
	if(acao=='desativar')
		pagina = 'desativa_candidato_exec.php';
	else if (acao=='reativar')
		pagina = 'reativa_candidato_exec.php';
	
	if(typeof as == 'undefined')
	{
		as = new assyncRequest('as');
	}
	
	as.loadXML(pagina,'GET',['id_candidato','topo'],[id_cand,'false'],'eval');
	
	//Open(pagina,'GET',['id_candidato'],[id_cand]);
	//ifr_salva.location.href = pagina+id;trocaIdioma
}


function trocaIdioma()
{
	idioma = parent.corpo.document.getElementById('id_idioma');
	div_idi = parent.corpo.document.getElementById('div_outro_idioma');
	input_idi = parent.corpo.document.getElementById('outro_idioma');
	
	if(idioma.value=="6")
	{
		div_idi.style.display = "";
	}
	else
	{
		div_idi.style.display = "none";
		input_idi.value = "";
	}
}

function validaFiltroFil(form)
{

	dt = document.getElementById('chk_data');
	td = document.getElementById('chk_todas');
	
	if(document.getElementById('chk_razao_social'))
		rs = document.getElementById('chk_razao_social');
	
	if(dt.checked)
	{
		datad = document.getElementById('data_de');
		dataa   = document.getElementById('data_ate');
		
		if(!valida_formato_data(datad.value))
			{
				alert("Data Inicial Inválida!");
				datad.focus();
				return false;
			}
		if(!valida_formato_data(dataa.value))
			{
				alert("Data Final Inválida!");
				dataa.focus();
				return false;
			}
	}	
		
	if(document.getElementById('chk_razao_social'))
	{
		if(rs.checked)
		{
			nome = document.getElementById('razao_social');
			
			if(nome.value=="")
				{
					alert("Preencha o campo Razão Social!");
					nome.focus();
					return false;
				}
		}
	}
	
	panel.submitForm(form.action,form,'GET');
	return false;
}


function validaFiltro(form)
{

	dt = document.getElementById('chk_data');
	cd = document.getElementById('chk_codigo');
	td = document.getElementById('chk_todas');
	tv = document.getElementById('chk_titulo');
	gr = document.getElementById('chk_grupo');
	
	if(document.getElementById('chk_razao_social'))
		rs = document.getElementById('chk_razao_social');

	if(document.getElementById('chk_nome_fantasia'))
		nf = document.getElementById('chk_nome_fantasia');
		
	if(	document.getElementById('chk_cliente'))
		cl = document.getElementById('chk_cliente');
		
	if (document.getElementById('chk_resp_comercial'))
		rc = document.getElementById('chk_resp_comercial');	
	
	if(dt.checked)
	{
		datad = document.getElementById('data_de');
		dataa   = document.getElementById('data_ate');
		
		if(!valida_formato_data(datad.value))
		{
			alert("Data Inicial Inválida!");
			datad.focus();
			return false;
		}
		if(!valida_formato_data(dataa.value))
		{
			alert("Data Final Inválida!");
			dataa.focus();
			return false;
		}
	}
	if(gr.checked)
	{
		grupo = document.getElementById('grupo');
		if(grupo.value == 0)
		{
			alert('Selecione um grupo!');
			grupo.focus();
			return false;			
		}
	}
	if(typeof cl != 'undefined')
	{
		if(cl.checked)
		{
			id_cli = document.getElementById('id_cliente');
			cli    = document.getElementById('cliente');
			
			if((trim(cli.value)=="")||(trim(id_cli.value)==""))
			{
				alert("Selecione o cliente !");
				return false;
			}
		}
	}
	
	
	if(typeof cd != 'undefined')
	{
		if(cd.checked)
		{
			cod = document.getElementById('codigo');
			
			if(trim(cod.value)=="")
				{
					alert("Digite um código !");
					cod.focus();
					return false;
				}
		}
	}
	
	if((typeof tv != 'undefined')&&(tv))
	{
		if (tv.checked)
		{
		   if (trim(document.getElementById("titulo").value) == "")
			  {
				 alert("Digite o titulo da vaga");
				 document.getElementById("titulo").focus();
				 return false;
			  }
		}
	}
	
	if(document.getElementById('chk_razao_social'))
	{
		if(typeof rs != 'undefined')
		{
			if(rs.checked)
			{
				nome = document.getElementById('razao_social');
				
				if(nome.value=="")
					{
						alert("Preencha o campo Razão Social!");
						nome.focus();
						return false;
					}
			}
		}
	}
	
	if(document.getElementById('chk_nome_fantasia'))
	{
		if(typeof nf != 'undefined')
		{
			if(nf.checked)
			{
				nome = document.getElementById('nome_fantasia');
				
				if(nome.value=="")
					{
						alert("Preencha o campo Nome Fantasia!");
						nome.focus();
						return false;
					}
			}
		}
	}	
	
	panel.submitForm(form.action,form,'GET');
	return false;
}

function filtroCliente(valor)
{
	divs = new Array('codigo','razao_social','nome_fantasia','data','filial','grupo','resp_com');
	for(x=0;x<divs.length;x++)
		{
			if(valor!=divs[x])
				document.getElementById('dv_'+divs[x]).style.display = 'none';
			else
				document.getElementById('dv_'+divs[x]).style.display = 'block';
		}
}

function filtroVaga(valor)
{
	divs = new Array('cliente','codigo','data','titulo','grupo','filial','selecionador');
	for(x=0;x<divs.length;x++)
	{
		if(valor!=divs[x])
			document.getElementById('dv_'+divs[x]).style.display = 'none';
		else
			document.getElementById('dv_'+divs[x]).style.display = 'block';
	}
}

function filtroVagaCand(valor)
{
	divs = new Array('funcao');
	for(x=0;x<divs.length;x++)
		{
			if(valor!=divs[x])
				document.getElementById('dv_'+divs[x]).style.display = 'none';
			else
				document.getElementById('dv_'+divs[x]).style.display = 'block';
		}
}


function filtroFilial(valor)
{
	divs = new Array('razao_social','data');
	for(x=0;x<divs.length;x++)
		{
			if(valor!=divs[x])
				document.getElementById('dv_'+divs[x]).style.display = 'none';
			else
				document.getElementById('dv_'+divs[x]).style.display = 'block';
		}
}

function filtroHistorico(valor,filtro)
{
	if(filtro=='data')
		divs = new Array('data','prox_contato');
	else
		divs = new Array('cliente','grupo');
	for(x=0;x<divs.length;x++)
		{
			if(valor!=divs[x])
				document.getElementById('dv_'+divs[x]).style.display = 'none';
			else
				document.getElementById('dv_'+divs[x]).style.display = 'block';
		}
}

function validaFiltroHistorico(form)
{
	td = document.getElementById('chk_todas');
	cl = document.getElementById('chk_cliente');
	dt = document.getElementById('chk_data');
	pc = document.getElementById('chk_prox_contato');
	
	if(cl.checked)
	{
		id_cli = document.getElementById('id_cliente');
		cli    = document.getElementById('cliente');
		
		if((trim(cli.value)=="")||(trim(id_cli.value)==""))
			{
				alert("Selecione o cliente !");
				return false;
			}
	}
	else if(dt.checked)
	{
		data_de = document.getElementById('data_de');
		data_ate   = document.getElementById('data_ate');
		
		if(!valida_formato_data(data_de.value))
			{
				alert("Data Inicial Inválida!");
				data_de.focus();
				return false;
			}
		if(!valida_formato_data(data_ate.value))
			{
				alert("Data Final Inválida!");
				data_ate.focus();
				return false;
			}
	}
	else if (pc.checked)
	{
		prox_inicio = document.getElementById('prox_contato_inicio');
		prox_fim  = document.getElementById('prox_contato_fim');
		
		if(!valida_formato_data(prox_inicio.value))
			{
				alert("Data Inicial Inválida!");
				prox_inicio.focus();
				return false;
			}
		if(!valida_formato_data(prox_fim.value))
			{
				alert("Data Final Inválida!");
				prox_fim.focus();
				return false;
			}
	}
	
	panel.submitForm(form.action,form,'GET');
	return false;
}

function abreCand(id_cand)
{
	if(id_cand)
		{
			vars = new Array('id_candidato');
			vals = new Array(id_cand);
		}
	else
		{
			vars = new Array('');
			vals = new Array('');
		}
		
	openWindow("inclui_curr_emp.php",vars,vals,'candidato',780,560);
}

function trocaOrigemCand(compl)
{
	if(!compl)
		compl="";
	var ori=document.getElementById('origem'+compl);
	var tr=document.getElementById('tr_origem'+compl);
	var ind=document.getElementById('div_indic'+compl);
	var out=document.getElementById('div_outra'+compl);
	var obs=document.getElementById('origem_obs'+compl);
	if(ori.value=='3')
	{
		tr.style.display = "";
		ind.style.display = "";
		out.style.display = "none";
		obs.style.display = "";
	}
	else if(ori.value=='5')
	{
		tr.style.display = "";
		ind.style.display = "none";
		out.style.display = "";
		obs.style.display = "";
	}
	else
	{
		tr.style.display = "none";
		ind.style.display = "none";
		out.style.display = "none";
		obs.style.display = "none";
		obs.value = "";
	}
}

function trocaOrigem()
{
	var ind=parent.corpo.document.getElementById('td_ind');
	var out=parent.corpo.document.getElementById('td_out');
	var obs=parent.corpo.document.getElementById('td_obs');
	var ori=parent.corpo.document.getElementById('origem');
	
	if(ori.value=='3')
	{
		ind.style.display = "";
		out.style.display = "none";
		obs.style.display = "";
	}
	else if(ori.value=='5')
	{
		ind.style.display = "none";
		out.style.display = "";
		obs.style.display = "";
	}
	else
	{
		ind.style.display = "none";
		out.style.display = "none";
		obs.style.display = "none";
		parent.corpo.document.getElementById('origem_obs').value = "";
	}
}

function openWindow(url,campo,val,nome_jan,w,h,tb)
{
	if(!w)
		w=600;
	if(!h)
		h=600;
	altura = h;
	largura = w;
	
	
	if(!tb)
		tb='no';
	
	tbar = tb;
	
	for(x=0;x<campo.length;x++)
	{
		if(x==0)
			get = campo[x]+"="+val[x];
		else
			get+="&"+campo[x]+"="+val[x];
	}

	urlG = url;
	nomeJanela = nome_jan;
	if(get)
	{
		if((!window.showModalDialog)&&(browser()!="Opera")||(tb=='yes')||(tb=='1'))
		{
			//copyhistory=no,directories=no,
			if(document.getElementById("BT"))
			{
				if(document.body)
					document.body.removeChild(document.getElementById("BT"));
				else
					document.all.removeChild(document.getElementById("BT"));
			}
			var BT = document.createElement("button");
			BT.onclick = abreJanela;
			BT.href = '#';
			BT.style.display="none";
			BT.id='BT';
			if(document.body)
				document.body.appendChild(BT);
			else
				document.all.appendChild(BT);
			BT.click();
		}
		else if(browser()=='Opera')
		{
			JANELA=window.open(urlG+"?"+get,nomeJanela,"width="+w+",height="+h+",status=no, toolbar = no, menubar = "+tb+"scrollbars=yes,dependent=yes,mimimize=no")
		}
		else
		{
			parametro = new Object;
			parametro.Janela = self;
			var JANELA = window.showModalDialog(url+"?"+get, parametro, "dialogWidth:"+w+"px; dialogHeight:"+h+"px;");
		}
	}
}
	
function abreJanela()
{
	JANELA=window.open(urlG+"?"+get,nomeJanela,"width="+largura+",height="+altura+",status=no, toolbar = no, menubar="+tbar+",scrollbars=yes,dependent=yes,mimimize=no")
}

function alterValue(obj,valor,frame)
{
	if(!frame)
		frame = self;
		
	if(!frame.document.getElementById(obj))
		return false;
	else
		frame.document.getElementById(obj).value = valor;	
}
	
function Disable(obj,val,frame)
{
	if(!frame)
		frame = self;
	if(!frame.document.getElementById(obj))
		return false;
	else
	{
		frame.document.getElementById(obj).disabled = val;		
	}
}

function checkById(obj,chk,frame)
{
	if(!frame)	
		frame=self;
	if(frame.document.getElementById(obj))
	{
		if(!chk)
			chk = false;
		else
			chk = true;
		frame.document.getElementById(obj).checked = chk;
	}
}

/*function checkById(obj,valor)
{
	check = document.getElementById(obj);
	
	if(!valor)	
		valor = false;
	else
		valor = true;
	
	check.checked = valor;
}*/

function check(obj,valor,frame,form,F)
{
	if(F)
	{
		var CHECK = false;
		var UNCHECK = true;
	}
	else
	{
		var CHECK = true;
		var UNCHECK = false;
	}
		
	if(!frame)
		frame = self;

	if(!(eval("frame.document."+form+"."+obj)))
		return false;
	else
	{
		Els = eval("frame.document."+form+"."+obj);
		if(Els.length)
		{
			nEl = Els.length;
			for(x=0;x<nEl;x++)
			{
				objChk = eval("frame.document."+form+"."+obj+"["+x+"]");
				if(objChk.value == valor)
					objChk.checked = CHECK;
				else if(objChk.type.toLowerCase() == 'radio')
					objChk.checked = UNCHECK;
			}
		}
		else
		{
			if(Els.value == valor)
				Els.checked = CHECK;
		}
	}
}
	
function Select(obj,value,frame)
{
	//VERIFICA SE FOI PASSADO O PARAMETRO FRAME
	if(!frame)
		 frame = self;
		
	//Verifica a existencia do OBJETO	
	//alert(frame.document.getElementById(obj));
	if(!frame.document.getElementById(obj))
		return false;
	else
	{
		var sel=frame.document.getElementById(obj);	
		tipo = sel.type.toUpperCase();
		if(tipo.indexOf("SELECT")==-1)
			return false;
		else
		{
			var selid = sel.id;
			
			var opts = sel.options;
			var index = -1;
			var x=0;
			for(x=0;x<opts.length;x++)
			{
				if(opts[x].value == value)
				{
					index = x;
					break;
				}
			}
			if(index!=-1)
				sel.selectedIndex = index;
		}
	}
}

function LoadSelect(obj,arrValues,arrTexts,ValSelect,frame)
{
	if(!frame)
	  frame = self;
	
	var index;
	
	if(!frame.document.getElementById(obj))
		return false;
	else
	{
		var sel=frame.document.getElementById(obj);	
		tipo = sel.type.toUpperCase();
		if(tipo.indexOf("SELECT")==-1)
			return false;
		else
		{
			var opts = sel.options;
		
			for(x=(opts.length-1);x>=0;x--)
				opts[x]=null;
			
			for(x=0;x<arrValues.length;x++)
			{
				sel.options[x] = new Option(arrTexts[x],arrValues[x]);
				if (arrValues[x]==ValSelect)
					index = x;
			}
			if(index!=-1)
				sel.selectedIndex = index;
		}
	}
}

function Migrar(id_candidato)
{
	if(document.getElementById('D_img_'+id_candidato))
	{
		img = document.getElementById('D_img_'+id_candidato);
		img.src = img_ena;
		img.id = 'E_img_'+id_candidato;
		tp = 'D';
	}
	else
	{
		img = document.getElementById('E_img_'+id_candidato);
		img.src = img_dis;
		img.id = 'D_img_'+id_candidato;
		tp = 'E';
	}

	if(document.getElementById('ifr_seleciona'))
	{
		window.open("pendencia_migracao_auxonline.php?id_candidato="+id_candidato+'&tp='+tp,'seleciona');
	}
	else
	{	
		var seila = new Image();
		seila.src = "pendencia_migracao_auxonline.php?id_candidato="+id_candidato+'&tp='+tp;
	}
}

function verifFormCurrency(valor,obj)
{
	if(!valor)
	{
		if(obj)
			valor=obj.value;
	}
	
	if(valor == "")
		valor = '0';
	
	if(valor.indexOf(".")>-1)
		return true;
	else if(valor.indexOf(",")>-1)
		while(valor.indexOf(",")>-1)
			valor=valor.replace(",",".");
	else if(valor != "")
		valor= valor + '.00'
	
	if(obj)
		obj.value=valor;
		
	return false;
}

function popup(url)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=525,height=560,left =50,top = 20');");
}

function verificaCNPJSubEmp(cnpj)
{
	window.open('verifica_cnpj_sub_emp.php?cnpj='+cnpj,'topo');
}

function carregaContatos(id)
{
	parent.topo.location.href = 'carrega_dados_cliente_exec.php?id='+id;
}

function SetaCli(obj_grid,gets,carregaCli)
{
	grid = obj_grid;
	arr = grid.selectedIds;
	if(arr[0])
	{
		var idO = arr[0];
		
		if(idO!=0)
		{
			if(carregaCli)
			{
				parent.opener.carregaCliente(idO);
			}
			else
			{
				
				if((gets!='') && (gets!=null) && (gets!=false))
				{
					var id_cliente 	= idO;
					var cliente 	= parent.topo.names[idO];
					
					var get 		= "?abre_cliente=true";
					get += "&id_cliente="+id_cliente;
					get += "&cliente="+cliente;
					
					if(document.getElementById('id_status'))
						get += "&id_status="+document.getElementById('id_status').value;
						
					if (parent.opener.document.getElementById('segmento_cliente') && parent.opener.document.getElementById('observacao_cliente'))
						get += "&carrega_seg_obser=carrega";
					
					parent.opener.parent.topo.location.href = 'inclui_vaga_complemento.php'+get;
				}
				else
				{
					var id_cliente = parent.opener.document.getElementById('id_cliente').value = idO;
					var cliente = parent.opener.document.getElementById('cliente').value = parent.topo.names[idO];
					
					if (parent.opener.document.getElementById('filial_contrato'))
						parent.opener.carregaFilial(idO);
					
					if(parent.opener.document.getElementById('contato'))
						parent.opener.carregaContatos(idO);	
					
				}
				// Caso não tenha sido setado  a variável not_close_popup, fecha o popup de busca do cliente
				if(typeof not_close_popup == 'undefined')
					parent.close();
			}
		}
	}
}

function SetaVagaCand(obj_grid)
{
	grid = obj_grid;
	arr = grid.selectedIds;
	
	if(arr[0])
	{
		var idO = arr[0];
		
		if(idO!=0)
		{
			if (parent.opener.document.getElementById('id_vaga') && parent.opener.document.getElementById('vaga'))
			{
				var id_vaga = parent.opener.document.getElementById('id_vaga').value = idO;
				var vaga = parent.opener.document.getElementById('vaga').value = parent.topo.names[idO];
			}
			else
			{
				alert("A janela de Relatório de Candidato Selecionado deve estar selecioando para que este recurso funcione corretamente!");
				return false;
			}
			
			parent.close();
		}
	}
}
	
function carregaCliente(id)
{
	var get = "";
	var loaded = window.aba.loaded;
	var arV = new Array();
	var arR = new Array();
	
	for(x=0;x<loaded.length;x++)
	{
		arV[x]= 'abasLoaded['+x+']';
		arR[x]= loaded[x];
	}
	
	arV[x]= 'id_est_1';
	arR[x]= __idEstadoPrinc;
	
	arV[x+1]= 'id_est_2';
	arR[x+1]=  __idEstadoEnc;
		
	arV[x+2]= 'id_est_3';
	arR[x+2]= __idEstadoFat;
	
	arV[x+3]= 'id_cliente';
	arR[x+3]=  id ;

	url = 'carrega_cliente.php';

	__reqCliente.loadXML(url,"GET",arV,arR,'eval');
}

function SetaEmailContato(obj_grid)
{
	grid = obj_grid;
	arr = grid.selectedIds;
	if(arr[0])
	{
		for(x=0;x<arr.length;x++)
		{
			var idO = arr[x];
			parent.opener.document.getElementById('para').value+= parent.topo.email[idO]+"; ";
		}
		parent.close();
	}
}
	
function SetaContato(obj_grid)
{
	grid = obj_grid;
	arr = grid.selectedIds;
	if(arr[0])
	{
		for(x=0;x<arr.length;x++)
		{
			var idO = arr[x];
			linha = grid.selectedSeqs[0];
			parent.opener.document.getElementById('id_contato_entrev').value= idO;
			parent.opener.document.getElementById('contato_entrev').value= grid.getValueColumn(linha,0);
		}
		parent.close();
	}
}

function FindCliente(pag,taxa,carrega,todos)
{
	if((pag!='') && (pag!=null) && (pag!=false))
		var get ='?pag='+pag;
	else	
		var get='';
		
	if(carrega)
	{
		if(get!="")
			get+="&carrega=true";
		else
			get = "?carrega=true";
	}
	if(todos)
	{
		if(get!="")
			get+="&todos=true";
		else
			get = "?todos=true";
	}
	
	janCliente = window.open("busca_cliente.php"+get,"Cliente","width=320,height=420,statusbar=1, toolbars = no,scrollbars=no");
	janCliente.opener = self;
	janCliente.focus();
}

function FindVagaCand()
{	
	janVaga = window.open("busca_vaga_jan.php","Vaga","width=580,height=435,statusbar=1, toolbars = no,scrollbars=no");
	janVaga.opener = self;
	janVaga.focus();
}

function FindContato(id_vaga,sub_emp)
{
	if((id_vaga) && (id_vaga!='') && (id_vaga!=null))
	{
		var get = '?id_vaga='+id_vaga;
		if(sub_emp==true)
			get+= '&sub_emp=1';
	}
	else
		var get = "";

	Contato = window.open("busca_contato.php"+get,"Contato","width=310,height=400,statusbar=1, toolbars = no,scrollbars=no");
	Contato.opener = self;
	Contato.focus();
}

function listaEsperaCand()
{
	ListaEspera = window.open("agenda_recepcao_espera.php","ListaEspera","width=530,height=210,statusbar=1, toolbars = no,scrollbars=no");
	if(window.parent)
		ListaEspera.opener = window.parent;
	else
		ListaEspera.opener = self;
	ListaEspera.focus();
}

function FindContatoId()
{
	if(document.getElementById("id_cliente"))
		var id_cliente = document.getElementById("id_cliente").value;
	else	
		var id_cliente = '';
	Contato = window.open("busca_contato.php?id_cliente="+id_cliente,"Contato","width=310,height=400,statusbar=1, toolbars = no,scrollbars=no");
	Contato.opener = self;
	Contato.focus();
}

function FindCandidato()
{
	Vaga = window.open("busca_candidato.php","Vaga","width=415,height=490,statusbar=1, toolbars = no,scrollbars=yes");
	Vaga.opener = self;
	Vaga.focus();
}

function FindUser()
{
	WUser = window.open("busca_usuario.php","Vaga","width=415,height=490,statusbar=1, toolbars = no,scrollbars=yes");
	WUser.opener = self;
	WUser.focus();
}

function FindVaga()
{
	Vaga = window.open("busca_vaga.php","Vaga","width=415,height=490,statusbar=1, toolbars = no,scrollbars=yes");
	Vaga.opener = self;
	Vaga.focus();
}

function SetaVaga(obj_grid)
{
	grid = obj_grid;
	arr = grid.selectedIds;
	if(arr && (arr != ''))
	{
		var idO = arr[0];
		if(idO!=0)
		{
			parent.opener.document.getElementById('id_vaga').value = idO;
			parent.opener.document.getElementById('nome_vaga').value = parent.topo.names[idO];
			//parent.opener.carregaContatos(idO);
			if(parent.opener.document.getElementById('id_funcao[]'))
				parent.topo.location.href = 'carrega_busca.php?janela=parent.opener&vaga='+idO;
			else
				top.window.close();
		}
	}
	else
	{
		alert("Informe o título da vaga!");
		document.getElementById("pchave").focus();
	}
}

function validaCNPJ(cnpj,exibAlerta) 
{
	CNPJ = cnpj;
	erro = new String;
	
	if(CNPJ.length < 14)
	{
		erro = "O CNPJ deve conter 14 dígitos!";
		alert(erro);
		return false;
	}
	
	var nonNumbers = /\D/;
	if(nonNumbers.test(CNPJ))
	{
		if(exibAlerta)
		{
			erro = "A verificação de CNPJ suporta apenas números!";
			alert(erro);
		}
		return false;
	}
	
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for(i=0; i<12; i++)
	{
		a[i] = CNPJ.charAt(i);
		b += a[i] * c[i+1];
	}
	if((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	b = 0;
	for(y=0; y<13; y++)
	{
		b += (a[y] * c[y]); 
	}
	if((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	
	//alert(a[13]);
	
	if((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13]))
	{
		if(exibAlerta)
		{
			erro ="Dígito verificador com problema!";
			alert(erro);
		}
		return false;
	}
	return true;
}
/*	
function validaCNPJ(cnpj)
{
if(trim(cnpj)=="")
		{
			return false;
		}
	else
		{
		if ((cnpj.indexOf(".") != -1) || (cnpj.indexOf("/") != -1) || (cnpj.indexOf("-") != -1))
	 		{
				  return false;
    		}
		else if((cnpj.length > 0) && (cnpj.length != 14))
			{
				  return false;
			}
		else
		  	{
			 var i = 0 ; 
			 var cgcstr = new Array();
			 for (i = 0 ; i < 13; i++)
			  {
				cgcstr[i] = cnpj.substr(i,1);
			  }
			  cgcstr[13] = cnpj.substr(12,2);
			  primeiro = (cgcstr[0]*5+cgcstr[1]*4+cgcstr[2]*3+cgcstr[3]*2+cgcstr[4]*9+cgcstr[5]*8+cgcstr[6]*7+cgcstr[7]*6+cgcstr[8]*5+cgcstr[9]*4+cgcstr[10]*3+cgcstr[11]*2)%11;
			  if (primeiro > 1){
				primeiro = 11 - primeiro;
			  }
			  else
			  {
				primeiro = 0;
			  }
			  
			  segundo = (cgcstr[0]*6+cgcstr[1]*5+cgcstr[2]*4+cgcstr[3]*3+cgcstr[4]*2+cgcstr[5]*9+cgcstr[6]*8+cgcstr[7]*7+cgcstr[8]*6+cgcstr[9]*5+cgcstr[10]*4+cgcstr[11]*3+cgcstr[12]*2)%11;
			  if (segundo > 1){
				segundo = 11 - segundo;
			  }
			  else
			  {
				segundo = 0;
			  }
			  controle = (10*primeiro) + segundo;
			   if (cgcstr[13] != controle)
			  {
					return false;
			  }
			  else
			  {
					return true;  
			  }
		   }
		}
}
*/


function Load(tm,ST,cand)
{
	//time_out_session(tm);
	//alert(ST);
	
	if(!cand)
	{
		timeSession=setTimeout('renovaSession()',temp_sess);
		
		atualizaLogin();
		
		if(window.parent)
			window.parent.name = 'gerenciadorMainWindow';
		else
			window.name = 'gerenciadorMainWindow';
		
		if(window.Init_Pag)
			Init_Pag();
		
		if(window.GRIDLoad)
			GRIDLoad();
	}
	
	if(!ST)Inicia_Menu(false,cand);
	
	if(document.getElementById("HiddenMenu"))
		document.getElementById("HiddenMenu").style.display='block';
	
	if(document.getElementById("Dv_Ag"))
	{
		document.getElementById("Dv_Ag").style.display = 'none';
		if(document.getElementById("Moldura"))
			document.getElementById("Moldura").style.display = 'block';
	}

	if((document.getElementById("Dv_Aguarde")))
	{
		document.getElementById("Dv_Aguarde").style.top = PPTop + 150 + 'px';
	}
}

function ImprimeCurr(id_cand,omitir,laudo)
{
	get = '?id_candidato='+id_cand;
	if(omitir)
		get+='&omitir=1';
	
	if(laudo)
		get+='&laudo=1';
		
	h = window.screen.height-60;
	janPrintCurr = window.open('exibe_curr_impressao.php'+get,'printCurr','width=600,height='+h+',toolbar=no,scrollbars=yes');
	janPrintCurr.focus();
}

function PrintVaga(id_vaga)
{
	jan_vaga = window.open("exibe_vaga_impressao.php?id_vaga="+id_vaga,'jan_vaga','top=10, left=10, width=800, height=600, toolbar=no,location=no,menubar=yes,personalbar=no,status=no,scrollbars=yes,resizable=yes');
	jan_vaga.focus();
}

function PrintEst(tipo,ano,mes,data_de,data_ate,id_filial,id_empresa,tipo_est,val,usuario,id_forma)
{
	if (!usuario)
	  usuario = 0;
	
	if (!id_filial || id_filial=='')
	  id_filial = 0;
	  
	jan = window.open("print_est.php?tipo="+tipo+"&ano="+ano+"&mes="+mes+"&data_de="+data_de+"&data_ate="+data_ate+"&id_empresa="+id_empresa+"&tipo_est="+tipo_est+'&val='+val+'&usuario='+usuario+'&id_filial='+id_filial+'&id_forma='+id_forma,'jan','top=10, left=10, width=600, height=500, toolbar=no,location=no,menubar=yes,personalbar=no,status=no,scrollbars=yes,resizable=no');
	jan.focus();
}

var __scrToLoad = 0;
var __scrLoaded = 0;

function refreshScripts()
{
	__scrToLoad = 0;
	__scrLoaded = 0;
	assyncXMLScript = new assyncRequest('assyncXMLScript');
	scr = document.getElementsByTagName("SCRIPT");
	for(s=0;s<scr.length;s++)
	{
		if(scr[s].src)
		{
			__scrToLoad++;
			assyncXMLScript.loadXML('reload_script_js.php','GET',['url'],[scr[s].src],'loadScript')
		}
	}
	alert('script to load:' + __scrToLoad);
}

function loadScript(content)
{
	eval(content);
	__scrLoaded++;
	alert('scripts loaded:' + __scrLoaded);
	if(__scrLoaded == __scrToLoad)
	{
		alert('SCRIPTS recarregados com sucesso!');
	}
}

function openCadCand(id_cand)
{
	//alert(id_cand);
	var compl;
	var arrGet =new Array();
	var arrVal =new Array();
	

	for(x=0;x<aba.loaded.length;x++)
	{	
		arrGet[x] = 'aba[]';
		arrVal[x] =  aba.loaded[x];
	}
	
	arrGet[x] = 'id_candidato';
	arrVal[x] =  id_cand;


	arrGet[x+1] = 'id_estado';
	arrVal[x+1] =  __IdEstadoLoaded;

	compl="&"+compl;
	assync = new  assyncRequest('assync');
	assync.loadXML('verifica_curr_emp.php','GET',arrGet,arrVal,'loadDataCand');
}

function loadDataCand(data)
{
	//abreErro(data);
	//alert(data);
	eval(data);
}

function verifCad(cpf)
{
	if(trim(cpf)!="")
	{
		if(valida_cpf(cpf))
		{
			document.getElementById("Dv_Aguarde").style.visibility='visible';
			window.open("verifica_cadastro.php?cpf="+cpf,'topo');
		}
		else
		{
			alert('CPF Inválido.');
			parent.corpo.document.getElementById("cpf").value="";
			//parent.corpo.document.getElementById("cpf").focus();
		}
	}
}

function CursoCompleto(N,V)
{
	mes_t=document.getElementById("mes_conc_curso["+N+"]");
	ano_t=document.getElementById("ano_conc_curso["+N+"]");
	if(V)
	{
		mes_t.value = '';
		ano_t.value = '';
		mes_t.disabled=true;
		ano_t.disabled=true;
	}
	else
	{
		mes_t.disabled=false;
		ano_t.disabled=false;
		mes_t.focus();
	}
}

function AstHist(tipo)//USADA PARA HISTORICO PROFISSIONAL
{
	if(tipo)
	{
		for(x=1;x<=6;x++)
		{
			document.getElementById('ast0'+x).innerHTML='*';
		}
	}
	else
	{
		for(x=1;x<=6;x++)
		{
			document.getElementById('ast0'+x).innerHTML='';
		}
	}
}

function AsteriscoCurso(tipo) //USADA PARA CURSOS
{
	if(tipo)
	{
		document.getElementById('astC00').innerHTML='*';
		document.getElementById('astC01').innerHTML='*';
	}
	else
	{
		document.getElementById('astC00').innerHTML='';
		document.getElementById('astC01').innerHTML='';
	}
}

function AsteriscoIdioma(nARR,idOutros,valor) //USADA PARA IDIOMAS
{
	dvid = document.getElementById("dv_outros_id_"+	nARR);
	if(valor!=0)
	{
		document.getElementById('astI'+nARR+'0').innerHTML='*';
		document.getElementById('astI'+nARR+'1').innerHTML='*';
		if(valor==idOutros)
		{
			dvid.style.display='block';
			document.getElementById("idioma_outros["+nARR+"]").focus();
		}
		else
		{
			if(dvid.style.display=='block')
			{
				dvid.style.display='none';
			}
		}
	}
	else
	{
		if(dvid.style.display=='block')
			{
				dvid.style.display='none';
			}
		document.getElementById('astI'+nARR+'0').innerHTML='';
		document.getElementById('astI'+nARR+'1').innerHTML='';
	}
}

function Submete(url,target,form)
{
	document.getElementById(form).action = url;
	document.getElementById(form).target = target;
	document.getElementById(form).submit();
}

function VerVis()
{
	var N=0;
	for(x=0;x<LinksDropId.length;x++)
	{
		if(document.getElementById(LinksDropId[x]))
			N++;
	}
	alert("N="+N);
	if(N==0)
		return false;
	else	
		return true;
}

//Funcao para Confirmar exclusao de usuario da empresa	
function ExcluiSub(id,orig)
{
	var ret = confirm("Confirma a exclusão ?","Confirmação");
	if(ret)	
		window.open(orig+"excluir_sub_emp_exec.php?id_sub="+id,"_top");
}

function ExcluiCliente(id,orig)
{
	var ret = confirm("Confirma a exclusão ?","Confirmação");
	if(ret)	
		window.open(orig+"excluir_sub_emp_exec.php?id_sub="+id,"_top");
}

function ExcluiUsuario(id,orig)
{
	var ret = confirm("Confirma a exclusão do Usuário?","Confirmação");
	if(ret)	
		Open(orig+"excluir_usuario_emp_exec.php",'GET',['id_usuario'],[id]);
}

function SetaNovo(id_cand,id_vaga)
{
	spn=document.getElementById("span_nv_"+id_cand);
	vl=spn.innerHTML;
	if(trim(vl)=='*')
	{
		window.open('gerenciador_seta_cand_novo_exec.php?novo=f&id_cand='+id_cand+'&id_vaga='+id_vaga,'topo');
	}
	else
	{
		window.open('gerenciador_seta_cand_novo_exec.php?novo=t&id_cand='+id_cand+'&id_vaga='+id_vaga,'topo');
	}
}

var mvtmp;

function EstatVagaRec(tipo, cliente)
{
	if(tipo=='mes')
	{
		tp='mes';
		document.getElementById("Est_Periodo").style.display = 'none';
		document.getElementById("Est_Ano").style.display = 'block';
		document.getElementById("Est_Mes").style.display = 'block';
		if(cliente)
		{
			document.getElementById("Div_Todos").style.display = 'block';		
			document.getElementById("Div_Cliente").style.display = 'block';
		}
	}
	else if(tipo == 'ano')
	{
		tp='ano';
		document.getElementById("Est_Periodo").style.display = 'none';
		document.getElementById("Est_Ano").style.display = 'block';
		document.getElementById("Est_Mes").style.display = 'none';
		if(cliente)
		{
			document.getElementById("Div_Todos").style.display = 'none';
			document.getElementById("Div_Cliente").style.display = 'block';
			document.getElementById("tipo_cliente_c").checked = 'true';
		}
	}
	else if(tipo =='periodo')
	{
		tp='periodo';
		document.getElementById("Est_Periodo").style.display = 'block';
		document.getElementById("Est_Ano").style.display = 'none';
		document.getElementById("Est_Mes").style.display = 'none';
		if(cliente)
		{		
			document.getElementById("Div_Todos").style.display = 'block';				
			document.getElementById("Div_Cliente").style.display = 'block';
		}
	}
	else if(tipo =='todos')
	{
		document.getElementById("Div_Todos").style.display = 'block';
		document.getElementById("Div_Cliente").style.display = 'none';
		document.getElementById("id_cliente").value = '';
		document.getElementById("cliente").value = '';
	}
	else if(tipo =='cliente')
	{
		document.getElementById("Div_Todos").style.display = 'block';
		document.getElementById("Div_Cliente").style.display = 'block';
	}
}

function movemrq_down()
{
	if(browser()=="IE")
		tMrq= 50;
	else
		tMrq= 20;

	if(document.getElementById('mrq').style.marginTop.indexOf('px')>-1)
	{
		h = document.getElementById('mrq').style.marginTop.substr(0,document.getElementById('mrq').style.marginTop.length -2);
	}
	else
	{
		h = document.getElementById('mrq').style.marginTop;
	}
	
	if(h=='')
		h = 0;
	
	if(document.getElementById('Conteudo_1'))
	{
		HC = document.getElementById('Conteudo_1').clientHeight;
		if((HC==0)||(HC=='undefined'))
			HC = document.getElementById('Conteudo_1').offsetHeight;
	}
	else
	{
		HC=document.getElementById('Conteudo_Login').clientHeight;
		if((HC==0)||(HC=='undefined'))
			HC = document.getElementById('Conteudo_Login').offsetHeight;
	}

	HM = document.getElementById('mrq_t').clientHeight;
	if((HM==0)||(HM=='undefined'))
		HM=document.getElementById('mrq_t').offsetHeight;

	if((-h) + HC < HM )
	{
		document.getElementById('mrq').style.marginTop = h - 2 +'px' ;
		mvtmp = setTimeout('movemrq_down()',tMrq);
	}
	else
	{
		clearTimeout(mvtmp);
	}
}

function movemrq_up()
{
	if(browser()=="IE")
		tMrq= 50;
	else
		tMrq= 20;
	if(document.getElementById('mrq').style.marginTop.indexOf('px')>-1)
	{
		h = document.getElementById('mrq').style.marginTop.substr(0,document.getElementById('mrq').style.marginTop.length -2);
	}
	else
	{
		h = document.getElementById('mrq').style.marginTop;
	}
	
	if(h < 0)
	{
		y=new Number(h);
		y+=2;
		if(y>0)
			y=0;
		document.getElementById('mrq').style.marginTop = y +'px' ;
		mvtmp = setTimeout('movemrq_up()',tMrq);
	}
	else
	{
		clearTimeout(mvtmp);
	}
}

function IsIE()
{
	Brw = navigator.appName;
	if(Brw.indexOf("Microsoft") > -1)
		return true;
	else
		return false;
}

function browser()
{
	B = navigator.userAgent;
	if((B.indexOf("Mac")> -1)&&(B.indexOf("MSIE") > -1))
	{
		bw = "MacIE";
	}
	else if(B.indexOf("Netscape") > -1)
	{
		bw = "Netscape";
	}
	else if(B.indexOf("Opera") > -1)
	{
		bw = "Opera";
	}
	else if((B.indexOf("MSIE") > -1) && (B.indexOf("Opera") == -1))
	{
		bw = "IE";
	}
	else if((B.indexOf("Mozilla") > -1)&& (B.indexOf("MSIE") == -1)&&(B.indexOf("Opera") == -1))
	{
		bw= "Mozilla";
	}
	return bw;
}

function Centralizar(obj)
{
	obj = document.getElementById(obj);
	if((document.body.offSetHeight)&&(browser() != 'IE'))
	{
		wHeight = document.body.offSetHeight;
		wWidth  = document.body.offSetWidth;
	}
	else if(window.innerHeight)
	{
		wHeight = window.innerHeight;
		wWidth  = window.innerWidth;
	}
	else if(document.body.clientHeight)
	{
		wHeight = document.body.clientHeight;
		wWidth  = document.body.clientWidth;
	}
	else if(document.documentElement.clientHeight)
	{
		wHeight = document.documentElement.clientHeight;
		wWidth  = document.documentElement.clientWidth;
	}
	
	if(obj.style.width != 0)
	{
		clHeight = obj.style.height;
		if(clHeight == "auto")
		{
			if ((obj.offSetHeight)&&(browser() != 'IE'))
				clHeight = obj.offSetHeight;
			else
				clHeight = obj.clientHeight;
		}
		clWidth  = obj.style.width;
	}
	else if((obj.offSetHeight)&&(browser() != 'IE'))
	{
		clHeight = obj.offSetHeight;
		clWidth  = obj.offSetWidth;
	}
	else
	{
		clHeight = obj.clientHeight;	
		clWidth  = obj.clientWidth;
	}

	if(isNaN(clHeight))
		if(clHeight.indexOf("px") > -1)
		{
			clHeight = clHeight.substr(0,clHeight.length -2);
		}
	
	if(isNaN(clWidth))
		if(clWidth.indexOf("px") > -1)
		{
			clWidth = clWidth.substr(0,clWidth.length -2);
		}
		
	if(isNaN(wHeight))
		if(wHeight.indexOf("px") > -1)
		{
			wHeight = wHeight.substr(0,wHeight.length -2);
		}
	if(isNaN(wWidth))
		if(wWidth.indexOf("px") > -1)
		{
			wWidth = wWidth.substr(0,wWidth.length -2);
		}
	
	obj.style.top = (wHeight/2) - (clHeight/2) + 'px';
	obj.style.left = (wWidth/2) - (clWidth/2) + 'px';
}

function maxL(obj,m,s) 
{
	if(m!='')
	{
		document.getElementById(obj).maxLength = m;
		if(document.getElementById(obj).value!='')
		{
			document.getElementById(obj).value = document.getElementById(obj).value.substr(0,2);
		}
	}
	if(s!='')
		document.getElementById(obj).size = s;
}

function troca_texto(texto,obj)
{
	document.getElementById(obj).innerHTML = texto;
	if(document.getElementById('pchave'))
		document.getElementById('pchave').focus();
}

function mostra_data()
{
	data = new Date();
	dia = data.getDay();
	
	if(dia==0)
		week = "Domingo";
	if(dia ==1)
		week = "Segunda-Feira";
	if(dia ==2)
		week = "Terça-Feira";
	if(dia ==3)
		week = "Quarta-Feira";
	if(dia ==4)
		week = "Quinta-Feira";
	if(dia ==5)
		week = "Sexta-Feira";
	if(dia ==6)
		week = "Sábado";
	
	dia = data.getDate();
	mes = data.getMonth()+1;
	

	if(mes == 1)
		mes = "Janeiro";
	if(mes == 2)
		mes = "Fevereiro";
	if(mes == 3)
		mes = "Março";
	if(mes == 4)
		mes = "Abril";
	if(mes == 5)
		mes = "Maio";
	if(mes == 6)
		mes = "Junho";
	if(mes == 7)
		mes = "Julho";
	if(mes == 8)
		mes = "Agosto";
	if(mes == 9)
		mes = "Setembro";
	if(mes == 10)
		mes = "Outubro";
	if(mes == 11)
		mes = "Novembro";
	if(mes == 12)
		mes = "Dezembro";
	
	ano = data.getFullYear();
	//data_tot = week + ", " + dia + " de " + mes + " de " + ano;
	document.write(week + ", " + dia + " de " + mes + " de " + ano);
}

function troca_hierarquia(hie,id,size,name,sel,targ,n)
{
	if(size=="")
		size=3;
		
	if(id=="")
		id="td0_hierarquia";
	
	if(name=="")
		name="id_hierarquia";
	
	if(sel==0)
	sel=0;
	else if(sel =='undefined')
		sel='-1';
	else if(sel =='')
		sel='-1';
		
	//alert('sel='+sel);
	if(! targ)
		targ="topo";
		
	if(n)
		n='true';
	else if(n =='undefined')
		n='false';
	else if(n =='')
		n='false';
	else if(!n)
		n= 'false';

	window.open("troca_hierarquia.php?hie="+hie+"&size="+size+"&id="+id+"&name="+name+'&selected='+ sel+'&n='+n,targ);
}

function textarea(campo,maxi,label,falta)
{
	campo=document.getElementById(campo);
	if(falta != "")
		document.getElementById(falta).value=maxi-campo.value.length;

	if(campo.value.length >= maxi)
	{
		if (IsIE())
			window.event.key=0;
		
		alert("O campo " + label + "deve ter no máximo " + maxi + " caracteres!");
		
		a=campo.value.substring(0,maxi);
		campo.value=a;
		
		if(falta != "")
			document.getElementById(falta).value=maxi-campo.value.length;
		
		campo.focus();
		return false;
	}
}


function trim(valor)
{	
	while(valor.indexOf(" ")==0)
	{
		valor=valor.substr(1,valor.length);
		if(valor.length==0)break;
	}
	while(valor.lastIndexOf(" ")==(valor.length-1))
	{
		valor=valor.substr(0,valor.length-1);
		if(valor.length==0)break;
	}
	return valor;
}

function valida_formato_data(data,previsao,previsao_atual)
{
	// Variavel de Erro - true(ñ há erros);
	var erro = true;
	
	// Extrai as partes da string de data
	var diav=data.substr(0,2);
	var mesv=data.substr(3,2);
	var anov=data.substr(6,4);
	
	barra1=data.substr(2,1);
	barra2=data.substr(5,1);
	
	if((barra1!="/")||(barra2!="/"))
		erro=false;
	
	var ano=new Number;
	var mes=new Number;
	var dia=new Number;
	
	ano=Math.abs(anov);
	mes=Math.abs(mesv);
	dia=Math.abs(diav);
			
	
	// data de hoje
	var data1=new Date();
	
	var tmStH = data1.getTime();
	var dateA = new Date(ano,mes,dia);
	var tmStD = dateA.getTime();
	
	if(previsao_atual) //Data futura ou data autal
		dataMenor=(tmStD < tmStH)?true:false;
	else //SOMENTE DATA FUTURA
		dataMenor=(tmStD <= tmStH)?true:false;
	
	if(previsao==true)
	{
		if((ano.toString()=='NaN')||(dataMenor))
			erro=false;
	}
	else if((ano.toString()=='NaN'))
	{   
	   erro=false;
	}
	
	if(ano < 1900)
	{
		 erro=false;
	}
		
	if((mes.toString()=='NaN')||(mes<1)||(mes > 12))
	{
		erro=false;
	}
		
	if((dia.toString()=="NaN")||(dia<1)||(dia > 31))
	{
		erro=false;
	}
		
	if (mes==1 || mes==3 || mes==5 || mes==7 || mes==8 || mes==10 || mes==12)
	{
		if (dia>31)
		  {
				erro=false;
		  }
	}
	
	if(mes==2)
	{
		if((ano%4)==0)
		{
			if(dia>29)
			{
				erro=false;
			}
		}
		if((ano%4)!=0)
		{
			if(dia>28)
			{
				erro=false;
			}
		}                  
	}
	
	if(mes==4 || mes==6 || mes==9 || mes==11)
	{
		if(dia>30)
		{
			erro=false;
		}
	}
	
	return erro;
}

function verifica_numero(num)
{
	a = new Number;
	a=Math.abs(num);
	if(a.toString()=='NaN')
		return false;
	else
		return true;
}

function valida_email(email)
{
	var erEmail = /^[\w-]+(\.[\w-]+)*(\.@|@)(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	if(! (erEmail.test(email)))
		return false;
	else
		return true;
}

function valida_site(site)
{
   var erSite = /^([a-z0-9]{2,20}\.)(([a-z0-9]{2,20}\.)+)([a-z]{3}|[a-z]{1,3}\.[a-z]{2})$/;
   if(!(erSite.test(site)))
      return false;
   else
      return true;
}

function valida_rg(rg)
{
	var erRG = /^[0-9\.]{6,12}[\-]{0,1}[0-9x]{0,1}$/;
	if(!(erRG.test(rg)))
		return false;
	else
		return true;
}

function validaMoeda(valor)
{
	var erMoeda = /^[0-9]{1,5}\.[0-9]{2}$/;
	if(erMoeda.test(valor))
		return true;
	else
		return false;
}

function valida_cpf(cpf)
{
  	soma1=0;
	soma2=0;
	igual=0;

	for(x=1;x<=10;x++) 
	{
		if (cpf.charAt(x-1) != cpf.charAt(x))
			break;
		else
			igual++;
	}
	if(igual == 10)
		return false;
   
	for(i=0;i<9;i++)
	{
	   numero1=parseInt(cpf.charAt(i))*(i+1);
	   soma1=soma1+numero1;
	}
	for(i=1;i<10;i++)
	{
	   numero2=parseInt(cpf.charAt(i))*i;
	   soma2=soma2+numero2;
	}
	v1=soma1%11;
	v2=soma2%11;
	
	if(v1 == 10) v1=0;
	if(v2 == 10) v2=0;
	if(!(v1 == parseInt(cpf.charAt(9)) && v2 == parseInt(cpf.charAt(10))))
	{
		return false;
	}
	else
		return true;
}

function STRReplace(oq,pq,onde)
{
	var lastOcur = -1;
	contat = "";

	while(onde.indexOf(oq)>-1 && onde.indexOf(oq)>lastOcur)
	{
		pos = onde.indexOf(oq);
		inicio = onde.substr(0,pos);
		
		fim = onde.substr(pos+oq.length,onde.length);
		
		inicio+=pq;
		onde = fim;
		contat+=inicio;
	}
	return ""+contat+fim;
}

function ShowDiv(div)
{
	if(document.getElementById(div).style.display == "block")
	{
		document.getElementById(div).style.display = "none";
	}
	else
	{
		document.getElementById(div).style.display = "block";
	}
}
	
function SpanSwap(spn,oq,pq)
{
	if(document.getElementById(spn).innerHTML.indexOf(oq)>-1)
		document.getElementById(spn).innerHTML=document.getElementById(spn).innerHTML.replace(oq,pq);
	else if (document.getElementById(spn).innerHTML.indexOf(pq)>-1)
		document.getElementById(spn).innerHTML=document.getElementById(spn).innerHTML.replace(pq,oq);
}
	
function progress(y,tot,arquivo,Label,Label2,size)
{
	var x = 0;
	var saida_tabela;
	if(y<=tot)
	{
		x = (y / tot) * size; 
		saida_tabela =  '<table border="0" width="100%" style=" border-width: 1px; border-color:#000000; border-style:solid ; font-family:arial,verdana; font-size:12px;" cellpadding="0" cellspacing="0">'
		saida_tabela += '	<tr>';
		saida_tabela += '<td height="18">';
		saida_tabela += '<table width='+x+' cellpadding="0" cellspacing="0">';
		saida_tabela += '<tr>';
		saida_tabela += '<td height="20" class="frm_label"></td>';
		saida_tabela += '</tr>';
		saida_tabela += '</table>';
		saida_tabela += '</td>';
		saida_tabela += '</tr>';
		saida_tabela += '</table>';
		saida_tabela += '<font style=\"font-family:arial,verdana; font-size:12px;\>"<b>'+parseInt((y / tot) * 100)+'%</b><br><b>'+Label2+'</b>'+y+'/'+tot+'<br><b>'+Label +'</b>'+arquivo+"</font><br>";
		saida_tabela += '<span id=\"spn_falha\"></span>';
		//saida_tabela = '<b>a</b>';
		//alert(document.getElementById('progress_bar'));
		document.getElementById('progress_bar').innerHTML = saida_tabela;
		//y = y + 1; 
		//setTimeout("progress("+y+")",100);
	}
}
   
function preload(img)
{
	teste=new Image();
	this.teste.src=img;
}

function change()
{
	x = document.frm_cancela_vaga.id_motivo.value;
	
	if(x == 3)
	{
		document.getElementById("outros_motivos").style.display = 'none';
		document.getElementById("fechamento").style.display = 'block';
	}
	else
	{
		document.getElementById("fechamento").style.display = 'none';
		document.getElementById("outros_motivos").style.display = 'block';		  
	}
}

function valida_cancel_vaga(form)
{
	var n_vagas = parseInt(document.getElementById("n_vagas").innerHTML);
	var qtdes = 0;
	var num = 0;
	var array_mot = document.getElementById("est_motiv").getElementsByTagName("INPUT");
	var name = new String();
	for(x=0;x<array_mot.length;x++)
	{
		name = array_mot[x].name;
		//alert("Nome:"+name);
		//alert("Indice"+name.indexOf("motivo_"));
		if(name.indexOf("motivo_") > -1)
		{
			if(array_mot[x].value == '')
			   num = 0;
			else
			   num = parseInt(array_mot[x].value); 
			qtdes = qtdes + num;
		}
	}
   
	if(document.getElementById('id_motivo').value == 0)
	{
		alert("Motivo não Selecionado"); 
		document.getElementById('id_motivo').focus();
	}
	/*else if (document.getElementById('id_motivo').value == 3)
	{
		if (document.getElementById('id_fonte').value == 0)
		{
			alert("Selecione uma fonte"); 
			document.getElementById('id_fonte').focus();
		}
	}*/
	else if(qtdes > n_vagas)
		alert("A soma dos números para fechamento ultrapassaram a quantidade de vaga!.");
	else if(qtdes != n_vagas)
		alert("A soma dos números para fechamento tem que ser igual a quantidade de vagas!.");
	else
	{
		panel.submitForm('cancela_vaga_exec.php',form,'POST');
		HiddenAll();
	}
	
	return false;
}

//validacao para o campo dias de trabalho
function valida_cancel_vaga_seg(form)
{
	var n_vagas = parseInt(document.getElementById("n_vagas").innerHTML);
	var qtdes = 0;
	var num = 0;
	var array_mot = document.getElementById("est_motiv").getElementsByTagName("INPUT");
	var name = new String();
	var dias_trabalho = document.getElementById("dias_trabalho");
	var horas_trabalho = document.getElementById("horas_trabalho");
	var expr_vlr = /^\d{1,3}\.\d{2}$/;
	var taxa_cliente = document.getElementById("taxa_cliente");
	var taxa_admin = document.getElementById("taxa_admin");
	var taxa_comissao = document.getElementById("taxa_comissao");
	var id_motivo = document.getElementById("id_motivo");
	
	for(x=0;x<array_mot.length;x++)
	{
		name = array_mot[x].name;
		//alert("Nome:"+name);
		//alert("Indice"+name.indexOf("motivo_"));
		if(name.indexOf("motivo_") > -1)
		{
			if(array_mot[x].value == '')
			   num = 0;
			else
			   num = parseInt(array_mot[x].value); 
			qtdes = qtdes + num;
		}
	}
	//alert("Final"+qtdes);
   
	if(document.getElementById('id_motivo').value == 0)
	{
		alert("Motivo não Selecionado"); 
		document.getElementById('id_motivo').focus();
	}
	else if ((document.getElementById('id_fonte') && document.getElementById('id_fonte').value == 0 && document.getElementById('id_motivo').value == 3))
	{
		 alert("Selecione uma fonte"); 
		 document.getElementById('id_fonte').focus();
	}
	else if(qtdes > n_vagas)
		alert("A soma dos números para fechamento ultrapassaram a quantidade de vaga!");
	else if(qtdes != n_vagas)
		alert("A soma dos números para fechamento tem que ser igual a quantidade de vagas!");
	else if(dias_trabalho && (dias_trabalho.value == '' || dias_trabalho.value <= 6) && id_motivo.value != 3)
	{
		alert("Dias de trabalho Inválido.");
		dias_trabalho.focus();
	}
	else if(horas_trabalho && (horas_trabalho.value == '' || !validaHora(horas_trabalho.value,'H:M')) && id_motivo.value != 3)
	{
		alert("Horas de trabalho inválida.");
		horas_trabalho.focus();
	}
	else if(taxa_admin.disabled && !taxa_cliente.disabled && !expr_vlr.test(taxa_comissao.value) && id_motivo.value != 3)
	{
		alert("A taxa de comissao é inválida.");
		return false;
	}
	else if(taxa_admin.disabled && !taxa_cliente.disabled && !taxa_comissao.disabled && !expr_vlr.test(taxa_cliente.value) && id_motivo.value != 3)
	{
		alert("A taxa de cliente é inválida.");
		return false;
	}
	else if(taxa_admin.disabled && !taxa_cliente.disabled && !taxa_comissao.disabled && !expr_vlr.test(taxa_comissao.value) && id_motivo.value != 3)
	{
		alert("Inválida a taxa de comissão.");
		return false;
	}
	else if(taxa_cliente.disabled && taxa_comissao.readOnly && (taxa_comissao.value != '') && !taxa_admin.disabled && !validaMoeda(taxa_admin.value) && id_motivo.value != 3)
	{
		alert("Inválida a taxa de adm.");
		return false;
	}
	else
	{
		panel.submitForm('cancela_vaga_exec.php',form,'POST');
		HiddenAll();
	}
	
	return false;
}

function HidenCancel()
{
	document.getElementById('Div_Motivo_Cancel').style.visibility='hidden';
	
	if(document.frm_cancela_vaga.id_motivo.value == 3)
	{
		if(document.getElementById("fechamento") && document.getElementById("outros_motivos"))
	    {
			document.getElementById("fechamento").style.display = 'none';
			document.getElementById("outros_motivos").style.display = 'block';	
		}
	}
	
	document.frm_cancela_vaga.id_motivo.value = 0;
	
	someMolduraIE();
}

function HiddenDiv(div)
{
	if(document.getElementById(div))
		document.getElementById(div).style.visibility='hidden';
	
	if(div == "Div_Pesquisa")
	{
		someMolduraIE();
	}
}

function AlteraCurrEmp(id,orig,id_vaga)
{
	var get ="id_candidato="+id;
	
	if(id_vaga)
		get +="&id_vaga="+id_vaga;
	
	print_curr=window.open(orig+"inclui_curr_emp.php?"+get,"print_curr","toolbar=no , scrollbars=no, width = 800 , height = 600, top = 0 , left = 0, status = yes");
	print_curr.opener = self;
}

function observacao(id)
{	 
	document.getElementById("titulo_candidato").innerHTML = document.getElementById("A_titulo_cand_"+id).innerHTML;
	document.getElementById("id_candidato").value = id;
	document.getElementById("obs").value = document.getElementById("A_observacao_"+id).value;
	if((lIMove==0) || (tIMove == 0))
	{
		Centralizar("Div_Observacao");
	}
	document.getElementById("Div_Observacao").style.visibility = "visible";
	//alert(document.getElementById("id_vaga").value);
}

function VerifEsc(val,v)
{
	verifEscHorario(val,v);
	if((val != 1)&&(val != 201)&&(val !=202)&&(val !=401)&&(val !=402)&&(val !=403))
	{
		document.getElementById("spn_esc_ast"+v).innerHTML='*';
	}
	else
	{
		document.getElementById("spn_esc_ast"+v).innerHTML='';
	}
	
	var ids = [212,213,214,404,405,406,407,408,409,410,411,412];
	
	for(x=0;x<ids.length;x++)
	{	
		if (ids[x] == val)
		{
			incrInstCurso(v);
			return false;
		}
	}
	
	decrInstCurso(v);
}

function incrInstCurso(v)
{
	objTextInst = document.getElementById("inst_esc["+v+"]");
	objTextCurso = document.getElementById("curso_esc["+v+"]");
	objImgInst = document.getElementById("img_inst_esc["+v+"]");
	objInpInst = document.getElementById("inp_inst_esc["+v+"]");
	objImgCurso = document.getElementById("img_curso_esc["+v+"]");
	objInpCurso = document.getElementById("inp_curso_esc["+v+"]");
	
	
	if(objImgInst && objInpInst && objImgCurso && objInpCurso)
	{
		 objImgInst.style.visibility = 'visible';
		 objInpInst.value = '';
		 objImgCurso.style.visibility = 'visible';
		 objInpCurso.value = '';
		 objTextInst.disabled = true;
		 objTextCurso.disabled = true;
	}
}

function decrInstCurso(v,type)
{
	objTextInst = document.getElementById("inst_esc["+v+"]");
	objTextCurso = document.getElementById("curso_esc["+v+"]");
	objImgInst = document.getElementById("img_inst_esc["+v+"]");
	objInpInst = document.getElementById("inp_inst_esc["+v+"]");
	objImgCurso = document.getElementById("img_curso_esc["+v+"]");
	objInpCurso = document.getElementById("inp_curso_esc["+v+"]");

	if(objImgInst && objInpInst && objImgCurso && objInpCurso)
	{
		if(type == 'void_inst')
		{
			//objImgInst.style.visibility = 'hidden';
			objTextInst.value = '';
			objInpInst.value = '';
			objTextInst.disabled = false;
			objTextInst.focus();
		}
		else if(type == 'void_curso')
		{
			//objImgCurso.style.visibility = 'hidden';
			objTextCurso.value = '';
			objInpCurso.value = '';
			objTextCurso.disabled = false;
			objTextCurso.focus();
		}	
		else
		{
			objImgInst.style.visibility = 'hidden';
			objInpInst.value = '';
			objImgCurso.style.visibility = 'hidden';
			objInpCurso.value = '';
			objTextInst.disabled = false;
			objTextCurso.disabled = false;
		}
	}
}
	
function VerifTel(valor,T)
{
	var TF=document.getElementById('id_tipo_fone['+T+']');
	var DDD=document.getElementById('ddd['+T+']');
	var FONE=document.getElementById('fone['+T+']');
	var COMP=document.getElementById('compl_fone['+T+']');
	var spn0 = document.getElementById('spn_ast_tel0'+T);
	var spn1 = document.getElementById('spn_ast_tel1'+T);
	var spn2 = document.getElementById('spn_ast_tel2'+T);
	if(((trim(TF.value)!='')&&(trim(TF.value)!=0))||(trim(DDD.value)!='')||(trim(FONE.value)!='')||(trim(COMP.value)!=''))
	{
		spn0.innerHTML = "*";
		spn1.innerHTML = "*";
		spn2.innerHTML = "*";				
	}
	else
	{
		spn0.innerHTML = "";
		spn1.innerHTML = "";
		spn2.innerHTML = "";
	}
}

function renovaSession()
{
	clearTimeout(timeSession);
	timeSession = setTimeout('renovaSession()',temp_sess);
	if(!document.getElementById('ifr_renova_sessao'))
	{
		if(browser()=='IE')
			var ifr = document.createElement("<iframe name='ifr_renova_sessao'>");
		else
			var ifr = document.createElement("iframe");
		ifr.style.display = 'none';
		ifr.id = 'ifr_renova_sessao';
		ifr.setAttribute("name","ifr_renova_sessao");
		ifr.name = 'ifr_renova_sessao';
		if(document.body)
			document.body.appendChild(ifr);
		else
			document.all.appendChild(ifr); 
		//alert(document.body.innerHTML);
	}
	
	window.open('renova_session.php','ifr_renova_sessao');
}

function atualizaLogin()
{
	clearTimeout(timeLogin);
		timeLogin = setTimeout('atualizaLogin()',temp_login);
	
	if(typeof loginConn == 'undefined')
		loginConn = new assyncRequest("loginConn");
	
	loginConn.loadXML('renova_login.php','GET',[],[],'loginRet');
}

function loginRet(text)
{
	eval(text);
}

function getLineNumber(id,id_vaga)
{
	tb= document.getElementById('Lista');
	Rows = tb.rows;
	alert("ID"+id);
	for(x=0;x<Rows.length;x++)
	{
		id_cand = Rows[x].id.substr(Rows[x].id.lastIndexOf("_")+1,Rows[x].id.length);
		alert("Candidato"+id_cand);
		alert(id_vaga);
		if(id_cand == id )
		{
			LineSel = x; 
		}	
	}
   window.open("encaminhar_candidato.php?line="+LineSel+"&id_candidato="+id+"&id_vaga="+id_vaga,"topo");
}

function getValues(form,pagina,retorna,tipo_ret,Tid,method,nQuebra)	
{
	nQuebra = nQuebra ? nQuebra :false;
	if(!method)
		method = 'GET';
	var campos = new Array;
	var values = new Array;
	var ids = new Array;
	var y = 0;
	
	nElement = form.elements.length;
	for(x=0;x<nElement;x++)
	{
		if((form.elements[x].tagName.toUpperCase()!='FIELDSET')&&(form.elements[x].tagName.toUpperCase()!='LEGEND'))
		{
			if((form.elements[x].type.indexOf('text') > -1)||(form.elements[x].type.indexOf('select') > -1)||(form.elements[x].type.indexOf('hidden') > -1)||(form.elements[x].type.indexOf('password') > -1)||(form.elements[x].tagName.toUpperCase()=='TEXTAREA'))
			{
				if(form.elements[x].type.indexOf('select-multiple') > -1)
				{
					for(z=0;z<form.elements[x].options.length;z++)
					{
						if(form.elements[x].options[z].selected)
						{
							campos[campos.length]=form.elements[x].name;	
							values[values.length]=form.elements[x].options[z].value;
							ids[ids.length]=form.elements[x].id;
						}
					}
				}
				else
				{
					if(form.elements[x].tagName.toUpperCase()=='TEXTAREA')
					{
						var val = form.elements[x].value;
						var z=0;
						if(!nQuebra)
						{
							while(val.indexOf("\n") > -1 || z > val.length)
							{
								val = val.replace("\n","%0A");
								z++;
							}
						}
						
						var z=0;
						
						while(val.indexOf("\r") > -1  || z > val.length)
						{
							val = val.replace("\r","");
							z++;
						}
						
						values[values.length]=val;
					}
					else
					{
						values[values.length]=form.elements[x].value;
					}

					campos[campos.length]=form.elements[x].name;
					ids[ids.length]=form.elements[x].id;
				}
			}
			else if(((form.elements[x].type.indexOf('checkbox') > -1) && (form.elements[x].checked))||((form.elements[x].type.indexOf('radio') > -1) && (form.elements[x].checked)))
			{
				campos[campos.length]=form.elements[x].name;	
				values[values.length]=form.elements[x].value;
				ids[ids.length]=form.elements[x].id;
			}
		}
	}
	
	if(!retorna)
		loadXML(pagina,true,'',method,campos,values);
	else
		if(tipo_ret == 'campos')
			return campos;
		else if(tipo_ret == 'values')
			return values;
	return true;
}

function montaGet(arrVars,arrValues)
{
	var arg = "";
	if((arrVars))
	{
		if((arrVars.constructor==Array)&&(arrValues))
		{
			for(x=0;x<arrVars.length;x++)
			{
				arrValues[x] = arrValues[x].replace("&","%26");
				
				if(arrValues[x])
					if(x==0)
						arg+=arrVars[x]+'='+arrValues[x];
					else
						arg+="&"+arrVars[x]+'='+arrValues[x];
				else
					if(x==0)
						arg+=arrVars[x]+'=';
					else
						arg+="&"+arrVars[x]+'=';
			}
		}
		
		return "?"+arg;
	}
	else
	{
		return false;
	}
}
	
function limpaCampos(campos,excecao,form,janela)
{
	if(!janela)
		janela = self;
	//alert(campos.constructor);
	if(campos)
	{
		for(w=0;w=campos.length;w++)
		{
			ultimo = campos.pop();
			cp = janela.document.getElementById(ultimo);
			
			if (cp.name != excecao)
			{	
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase().indexOf('SELECT')>-1)))
					cp.selectedIndex = 0;
				else if(cp.type)
					cp.value='';
			}
		}
	}
	else
	{
		frm = janela.document.getElementById(form);
		for(x=0;x<frm.elements.length; x++)
		{
			if((frm.elements[x].tagName.toUpperCase()!='FIELDSET')&&(frm.elements[x].tagName.toUpperCase()!='LEGEND'))
			{
				cp = frm.elements[x];
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase().indexOf('SELECT')>-1)))
					cp.selectedIndex = 0;
				else if((cp.type)&&(cp.type.toLowerCase()!="button")&&(cp.type.toLowerCase()!="submit"))
					cp.value='';
			}
		}
	}
}

function limpaTudo(janela,excessao)
{
	if(!janela)
		janela=self;
	
	if(janela.objGrid)
	{
		for(ab=0;ab<janela.objGrid.length;ab++)
		{
			if(janela.objGrid[ab])
				janela.objGrid[ab].clearRows();
		}
	}
	
	ipts = janela.document.getElementsByTagName('input');
	for(x=0;x<ipts.length;x++)
	{
		cp = ipts[x];
		if(cp.name != excessao)
		{
			if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
				cp.checked = false;
			else if((cp.type)&&((cp.type.toUpperCase() !='BUTTON')&&(cp.type.toUpperCase() !='FILE')&&(cp.type.toUpperCase() !='SUBMIT')))
				cp.value='';
		}
	}

	sel = document.getElementsByTagName('select');
	for(x=0;x<sel.length;x++)
	{
		cp = sel[x];
		if(cp.name != excessao)
		{
			cp.selectedIndex = 0;
		}
	}

	txt = document.getElementsByTagName('textarea');
	for(x=0;x<txt.length;x++)
	{
		cp = txt[x];
		if(cp.name != excessao)
		{
			cp.value = "";
		}
	}
}

function validaMes(mes)
{
	if(isNaN(mes))
		return false;
	
	if(mes == "")
		return false;

	if((mes < 1)||(mes > 12))
		return false;
	
	return true;
}

function validaAno(ano)
{
	if(isNaN(ano))
		return false;
	
	if(ano == "")
		return false;

	if((ano < 1900 )||(ano > 2100))
		return false;
	
	return true;
}
	
function loadFromGrid(grid,seq,campos,campoId)
{
	id = grid.selectedIds[0];
	ln = grid.selectedSeqs[0]
	
	for(x=0;x<seq.length;x++)
	{
		var valor = grid.getValueColumn(ln,seq[x]);
		if(document.getElementById(campos[x]))
			document.getElementById(campos[x]).value = valor;
	}
		
	if(document.getElementById(campoId))
		document.getElementById(campos[x]).value = id;
}

function validaHora(hora,tipo)
{
	if(tipo=='H:M')
	{
		var expR = /^(([0-1]{1}[0-9]{1})||([2]{1}[0-3]{1})):([0-5]{1}[0-9]{1})$/
	}
	else if(tipo == 'H:M:S')
	{
		var expR = /^(([0-1]{1}[0-9]{1})||([2]{1}[0-3]{1})):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})$/
	}
	else
	{
		alert('Tipo de hora invalida :'+tipo+'!!\n Coloque H:M  ou H:M:S ');
		return false;
	}
	
	if(expR.test(hora))
		return true;
	else
		return false;
}

function hoje()
{
	data = new Date();
	dia = data.getDate();
	month = data.getMonth() + 1;
	ano = data.getFullYear();

	if (dia < 10)
	dia = "0"+dia.toString();
	else
	dia = dia.toString(); 

	if (month < 10)
	mes = "0"+month.toString();
	else	 
	mes = month.toString(); 

	ano = ano.toString();

	data = dia+"/"+mes+"/"+ano;	

	return data;
}

function limpaForm(form,janela)
{
	if(!janela)
		janela = self;
	//alert(campos.constructor);
		frm = janela.document.getElementById(form);
		for(x=0;x<frm.elements.length; x++)
		{
			if((frm.elements[x].tagName.toUpperCase()!='FIELDSET')&&(frm.elements[x].tagName.toUpperCase()!='LEGEND'))
			{
				cp = frm.elements[x];
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase().indexOf('SELECT')>-1)))
					cp.selectedIndex = 0;
				else if((cp.type)&&(cp.type.toLowerCase()!="button")&&(cp.type.toLowerCase()!="submit"))
					cp.value='';
			}
		}
}

function getForm(form)
{
	frm = document.getElementById(form);
	arrCampos = getValues(frm,'',true,'campos');
	arrValores = getValues(frm,'',true,'values');
	var get = montaGet(arrCampos,arrValores);
	return get;
}

function cadCliente(id)
{
	var get = "";
	if(id)
		get+="id_sub_emp="+id;
	
	cadCli=window.open("inclui_cliente.php?"+get,"cadCli","toolbar=no , status = yes , scroll=yes,  title = no , width = 800 , height = 600, top = 1 , left = 1");
	cadCli.opener = self;
	cadCli.focus();
}

function relGrupo()
{
	relGrup=window.open('rel_grupo_exec.php','RelGrupo','menubar=yes,left=0,top=0,statusbar=no,width=800,scrollbars=yes,toolbar=no');
	relGrup.focus();
}

function escolha_tipo(tipo_ent)
{
   total_tr = document.getElementById("table_entre").getElementsByTagName("TR");
   
	for (x=0;x<total_tr.length;x++)
	{
		if ((total_tr[x].lang != '' ) && (total_tr[x].id != ''))
		{
			if (tipo_ent != "todos")
			{
				if (total_tr[x].lang != tipo_ent)
				{
					if (document.getElementById(total_tr[x].id).style.display == 'none')
					{
						document.getElementById(total_tr[x].id).sytle.display = '';
					}
					else
					{
						document.getElementById(total_tr[x].id).style.display = 'none';
					}	 
				}
				else
				{
				  document.getElementById(total_tr[x].id).style.display = '';
				}	   
			}
			else
			{
				document.getElementById(total_tr[x].id).style.display = '';
			} 	 
		}	 
	}
}
/*Deixa um select sem nenhum item selecionado*/
function desselect(obj)
{
	obj.selectedIndex = -1;
}
/*
@Author:Fabio Soares
@Date:24/04/2008
@Describe:Seleciona todos os itens de um Select
*/
function selecionaItensSelect(obj)
{
	for(var i=0;i<obj.options.length;i++)
		obj.options[i].selected = true;
}

function trocaEsc(vlr,esconde)
{
	if(vlr == "grupo")
	{
		if(esconde)
			document.getElementById("div_compl_busca").style.display = "none";
		
		document.getElementById("filgrupo").style.display = '';
		
		if (document.getElementById("filstat"))
			document.getElementById("filstat").style.display = 'none';
		
		if (document.getElementById("filgrup"))
			document.getElementById("filgrup").style.display = 'none';
		
		if (document.getElementById("filclien"))
			document.getElementById("filclien").style.display = 'none';
		
		if (document.getElementById("escfilial"))
			document.getElementById("escfilial").style.display = 'none';
		
		if (document.getElementById("escgrup"))
			document.getElementById("escgrup").style.display = 'none';
	}
	else if(vlr == "cliente")
    {
		if(esconde)
			document.getElementById("div_compl_busca").style.display = "none";
		 
		document.getElementById("filclien").style.display = '';
		 
		if(document.getElementById("filstat"))
		    document.getElementById("filstat").style.display = 'none';
			
	    if(document.getElementById("filgrup"))
		    document.getElementById("filgrup").style.display = 'none';
			
	    if(document.getElementById("filgrupo"))
		    document.getElementById("filgrupo").style.display = 'none';
		
		if(document.getElementById("escfilial"))
			document.getElementById("escfilial").style.display = 'none';
		
	 	if (document.getElementById("escgrup"))
			document.getElementById("escgrup").style.display = 'none';
	}
	else if(vlr == "status")
    {
		document.getElementById("filclien").style.display = 'none';
		document.getElementById("filstat").style.display = '';
		
		if(document.getElementById("id_cliente"))
			document.getElementById("id_cliente").value = '';
		
		if(document.getElementById("cliente"))
		    document.getElementById("cliente").value = '';
			
		if(document.getElementById("escfilial"))
			document.getElementById("escfilial").style.display = '';
			 
	 	if(document.getElementById("escgrup"))
		    document.getElementById("escgrup").style.display = '';
		
		if(document.getElementById("filgrup"))
		    document.getElementById("filgrup").style.display = 'none';
		
	    if(document.getElementById("filgrupo"))
			document.getElementById("filgrupo").style.display = 'none';
	}
	else if(vlr == "todos")	 
    {
		if(document.getElementById("div_compl_busca"))
			document.getElementById("div_compl_busca").style.display = "";
			
		if(document.getElementById("id_cliente"))
			document.getElementById("id_cliente").value = '';
		   
		if (document.getElementById("cliente"))
		    document.getElementById("cliente").value = '';
        
        if (document.getElementById("filgrup"))
		    document.getElementById("filgrup").style.display = '';
			
        if (document.getElementById("filgrupo"))
		    document.getElementById("filgrupo").style.display = 'none';
			
		if(document.getElementById("filclien"))
			document.getElementById("filclien").style.display = 'none';
		
	    if (document.getElementById("filstat"))
		    document.getElementById("filstat").style.display = '';
		
		if (document.getElementById("escfilial"))
			document.getElementById("escfilial").style.display = '';	    
	}
	
	if(document.getElementById("escolha"))
		document.getElementById("escolha").value = vlr;
}

function viewpass(arg)
{
	if (arg == "sim")
	{
		document.getElementById('vpass_senha').style.display = '';
		document.getElementById('vpass_conf').style.display = '';
		document.getElementById('vpass_dica').style.display = '';
	}
	else if (arg == "nao")
	{
		document.getElementById('vpass_senha').style.display = 'none';
		document.getElementById('vpass_conf').style.display = 'none';
		document.getElementById('vpass_dica').style.display = 'none';
	}
}

function getResp(fiid,tipo)
{
	if (tipo)
	var compl = "&tipo="+tipo;
	else
	var compl = "&tipo=filial";

	jan = window.open("troca_resp.php?fiid="+fiid+compl,"ifrrsel");
}

function isUndefined(a) 
{
    return typeof a == 'undefined';
}

function verifEscHorarioEmp(id_esc,n)
{
	var idsCursando = new Array;
	idsCursando = [202,402,207,213,405,408,411];
	
	// Se não tiver permissão para remover obrigatoriedade das datas da escolaridade adiciona a obrigatoriedade.
	if(typeof removeObrDatEsc == 'undefined')
		for(x=0;x<idsCursando.length;x++)
		{
			if(id_esc==idsCursando[x])
			{
				document.getElementById('dv_inicio_obr'+n).innerHTML = '*';
				document.getElementById('dv_final_obr'+n).innerHTML = '*';
				document.getElementById('dv_horario_obr'+n).innerHTML = "*";
				validaEscHorario = true;
				validaDat = true;
				return false;
			}
		}
	
	validaEscHorario = false;
	validaDat = false;
	document.getElementById('dv_inicio_obr'+n).innerHTML = '';
	document.getElementById('dv_final_obr'+n).innerHTML = '';	
	document.getElementById('dv_horario_obr'+n).innerHTML = '';
}

function verifEscHorario(id_esc,n)
{
	var idsCursando = new Array;
	idsCursando = [202,402,207,213,405,408,411];
	
	for(x=0;x<idsCursando.length;x++)
	{
		if(id_esc==idsCursando[x])
		{
			document.getElementById('dv_horario_obr'+n).innerHTML = "*";
			validaEscHorario[n] = true;
			return false;
		}
	}
	validaEscHorario[n] = false;
	document.getElementById('dv_horario_obr'+n).innerHTML = '';
}

function Open(url,methodO,arrVarO,arrValO,force)
{
	var methodO = methodO ? methodO : 'GET';
	var arrVarO = arrVarO ? arrVarO : [];
	var arrValO =  arrValO ? arrValO : [];
	var force = force ? force : force;
	
	if(typeof panel == 'undefined')
	{
		document.getElementById('Corpo').innerHTML = '';
		panel = new ajaxPanel('panel');
		panel.onload = 'panelLoad()';
		panel.onunload = 'panelUnload()';
		panel.Render("Corpo");
	}
	
	if(url)
	{
		panel.open(url,methodO,arrVarO,arrValO,force);
	}
}

function panelLoad()
{
	if(window.GRIDLoad)
	{
		GRIDLoad();
	}
	
	if(window.Inicia_Menu)
		Inicia_Menu();
	
	if(window.Load)
		Load();
	
	if(window.DropStart)
	{
		DropStart();
	}
}

function panelUnload()
{
	if(window.zeraGrid)
		zeraGrid();
	
	if(window.zeraTabs)
		zeraTabs();
		
	if(typeof tabs != "undefined")
		for(var x=0;x<tabs.length;x++)
			eval(tabs[x]+"=null;");
	
	if(window.Tabs)		
		Tabs = null;
	
	if(typeof ac != "undefined")
	{
		ac.abort();
		ac = null;
	}
	
	var xmlConnect = null;
	
	var __autoCompletarIndex = 0;
	var __autoCompletarResource = new Array();		
		
	if(typeof grids != "undefined")	
		for(var x=0;x<grids.length;x++)
		{
			if(eval(grids[x]))
				eval(grids[x]+"=null;");
		}
		
	/* SUPORTE ON LINE 	
	if(window.Live)
		Live = null;
	if(window.Aardvark)
		Aardvark=null;
	if(window.Misc)
		Misc = null;
	/* -----------------*/
	
	if(window.Grid)
		Grid = null;
	
	Inicia_Drop = null;
	DropStart = null;
	ClassDrop=null;
	classDropOut=null;
	classDropOver=null;
	classDisable = null;
	classDisable = 'td_over disable';	
	lastDisable = false;
	DropMenuType = null;
	DropDivId = null;
	divmove=null;
	
	if(parent.topo)
		parent.topo.location.href = 'branco.php';
	
	if(dv=document.getElementById("ifrJanMoldura"))
	{
		dv.style.display = 'none';
		dv.style.visibility = 'hidden';
		dv.style.top = '-1000px';
		dv.style.left = '-1000px';
	}
}

function voltar(url,getVar,getVal)
{
	connVoltar = new assyncRequest('connVoltar');
	connVoltar.loadXML(url,'GET',['&notag'],['true'],'eval');
}

function abreFotoCorpo(id_candidato)
{
	window.open("display_foto_cand.php?id_candidato="+id_candidato+"&type=2");
}

function valida_encaminhar()
{
	salario = document.getElementById("salario");
	
	if(trim(salario.value)!="")
	{
		if(!validaMoeda(salario.value))
		{
			alert('Salário Inválido! Dica: não utilize virgula, mas sim ponto!\nExemplo : 585.68');
			salario.focus();
			return false;
		}
	}
    else
    {
		alert("Salário Inválido!");
		return false;
	}
}

function trocaNaturalidade(id)
{
	document.getElementById("naturalidade_text").value = '';
	document.getElementById("naturalidade_uf_text").value = '';
	
	if(id != 31 || id == 0)
	{
		document.getElementById("div_naturalidade_sel").style.display = 'none';
		document.getElementById("div_naturalidade_uf_sel").style.display = 'none';
		document.getElementById("div_naturalidade_text").style.display = '';
		document.getElementById("div_naturalidade_uf_text").style.display = '';
	}
	else
	{
		document.getElementById("div_naturalidade_sel").style.display = '';
		document.getElementById("div_naturalidade_uf_sel").style.display = '';
		document.getElementById("div_naturalidade_text").style.display = 'none';
		document.getElementById("div_naturalidade_uf_text").style.display = 'none';
	}	
}

var janInstCur;
function openWindowInstCur(index,type)
{
	janInstCur = window.open("searchInstCur.php?type="+type+"&index="+index,"searchInstCurso","height=310,width=450,statusbar=no,menubar=no");
	janInstCur.focus();
}

function print_r(array,name_array)
{
	var print_array = new String();
	var last_array = new Array();
	
	print_array += "( ";
	
	for(x=0;x<array.length;x++)
	{
		if(array[x].constructor == Array)
		{
		   last_array[last_array.length] = x;
		   print_array += print_r(array[x],"SubArray");
		   x = last_array[last_array.length - x];
		}
		else
		{
			print_array += name_array+"["+x+"]=>"+array[x];
			if ((parseInt(array.length) - parseInt(1)) != x)
				print_array += ",  ";  						  
		} 
	}
	
	print_array += ")";
	return print_array;
}

function filtraGrid(id_vaga,filtro)
{
	// Altera o filtro de pesquisa
	// Richard 02/06/2008

	if(!window.assyncRequest)
	{
		alert("Deve importar a classe asyncRequest!");
	}
	else
	{
		xmlFiltro = new window.assyncRequest('xmlFiltro');
		gridSelec.clearRows();
		xmlFiltro.loadXML('forms/processo_seletivo.php','POST',['id_vaga','filtro'],[id_vaga,filtro],'eval');
	}
	//parent.topo.location = processo_seletivo.php;
}
