var curTab = 0;
var curTabVaga = 0;
var idxIncrement = 1;
var d = document;

/* tab menu */
function selectTab(idx) {
	
	deselectTab(curTab);
	  
	d.getElementById("imgNo_" + idx).style.display = "block";
	d.getElementById("imgNo_" + idx).style.display = "inline";
	d.getElementById("imgOn_" + idx).style.display = "none";
	d.getElementById("divBody_" + idx).style.display = "block";

	curTab = idx;
	
}

function deselectTab(idx) {
	
	d.getElementById("imgOn_" + idx).style.display = "block";
	d.getElementById("imgOn_" + idx).style.display = "inline";
	d.getElementById("imgNo_" + idx).style.display = "none";
	d.getElementById("divBody_" + idx).style.display = "none";
	
	curTab = idx;
	  
}
/* tab menu */

/* tab vaga - DEPRECIADO */
function selectTabVaga(idv) {
	
	deselectTabVaga(curTabVaga);
	  
	d.getElementById("imgVagaNo_" + idv).style.display = "block";
	d.getElementById("imgVagaNo_" + idv).style.display = "inline";
	d.getElementById("imgVagaOn_" + idv).style.display = "none";
	d.getElementById("divBodyVaga_" + idv).style.display = "block";

	curTabVaga = idv;
	
}

function deselectTabVaga(idv) {
	
	d.getElementById("imgVagaOn_" + idv).style.display = "block";
	d.getElementById("imgVagaOn_" + idv).style.display = "inline";
	d.getElementById("imgVagaNo_" + idv).style.display = "none";
	d.getElementById("divBodyVaga_" + idv).style.display = "none";
	
	curTabVaga = idv;
	  
}
/* tab vaga */

function camadaSelect(idCamada, Campo, Foco, Valor, Tipo){ // <select>
	
	if (Tipo == "!=") {
		if (d.getElementById(Campo).value != Valor) {
			Ativo = true;
			d.getElementById(idCamada).style.display = "block" 
		} else {
			Ativo = false;
			d.getElementById(idCamada).style.display = "none" 
		}
	} else {
		if (d.getElementById(Campo).value == Valor) {
			Ativo = true;
			d.getElementById(idCamada).style.display = "block"
		} else {
			Ativo = false;
			d.getElementById(idCamada).style.display = "none"
		}
	}
	if (Foco && Ativo) {
		d.getElementById(Foco).focus();
	}
	
	return;
	
}

function contador(Campo, idContador, Limite) {
	
	var Maximo = Limite ? Limite : 500;
	var field = d.getElementById(Campo);
	var txtField = d.getElementById(idContador);
	
	if (field && field.value.length > Maximo) {
		field.value = field.value.substring(0, Maximo);
		alert("Limite de "+Maximo+" letras.");
	}
	
	if (txtField) {  
		txtField.innerHTML = Maximo - field.value.length;
	}
	
}

function clickFuncao(origem, destino) {
	indice = d.getElementById(origem).selectedIndex;
	texto  = d.getElementById(origem).options[indice].text;
	d.getElementById(destino).value = texto; 
}

function limpaCampo (form,botao,id) {
	d.getElementById(form).reset();
	d.getElementById(botao).value = 'Inserir';
	d.getElementById(id).value = '';
}

function limpaSelect(destino) {
	var obj = d.getElementById(destino);
	obj.options.length = 0;
	eval(obj.options[obj.options.length] = new Option('Função não encontrada!',''));
	d.getElementById('nomeFuncao').value = '';
	d.getElementById('divArea').innerHTML = 'Seleciona a função';
}

function limpaSpan(span) {
	d.getElementById(span).innerHTML = '';
}

function abreJanela(linkJanela, lag, alt){
	LeftPosition = (screen.width) ? (screen.width-lag)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alt)/2 : 0;
	if(navigator.appName=="Microsoft Internet Explorer") {
		var janela = window.open(linkJanela,'','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,scrollbars=yes,resizable=yes,menubar=0,width=' + lag + ',height=' + alt + ',left='+LeftPosition+',top='+TopPosition+'');
		//janela.focus();
	} else {
		var janela = window.open(linkJanela,'','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,width=' + lag + ',height=' + alt + ',left='+LeftPosition+',top='+TopPosition+'');
	}
	if (janela == null || janela.closed == null){
		document.getElementById('bloqueio').innerHTML = "<font color='#FF0000'><strong>ATENÇÃO!</strong></font><br>Seu navegador está com Bloqueador de popup ativado!!<br>Para o funcionamento correto por favor desbloquei nosso site!<br>Obrigado!";
		alert("ATENÇÃO!\nSeu navegador está com Bloqueador de popup ativado!!\nPara o funcionamento correto por favor desbloquei nosso site!\nObrigado!");
	}
}

function aceitar (confirma, url, linkJanela, lag, alt) {
	if (confirma) {
		var pergunta = confirm(confirma)
		if (pergunta == true){
			window.location = url;
			if (linkJanela) {
				abreJanela(linkJanela, lag, alt);			
			}
		} 
	}
}

function fecha(form,valida) {
	document.getElementById(valida).value = 'fechou';
    document.getElementById(form).submit();
}

function verificaCampos(campos) {
	opcao = campos.split("|")
	var teste = 0
	for (i=0; i <= opcao.length; i++) {
		if (document.getElementById(opcao[i]).value == '') {
			//alert('Preencha corretamente o campos marcados com *');
			document.getElementById('form_mensagem').innerHTML = 'Preencha corretamente o campos marcados com *';
			return false;
			break
		}
	}
}

function numero(campo, tamMaximo) {
	var tam = parseInt(d.getElementById(campo).value.length);
	if (isNaN(d.getElementById(campo).value) || tam > tamMaximo)
		d.getElementById(campo).value = d.getElementById(campo).value.substring((tam-1),0);
}

function bloquear(url, historico){
	descricao = d.getElementById(historico);
	if (descricao.value != '') {
		window.location = url + descricao.value;
	} else {
		alert('Informe o motivo desta operação!');
		descricao.focus();
	}
}

function juntaCheckbox(url, total, msgAviso, campo) {
	
	var ids = '';
	for (var i=0; i <= (total-1); i++) {
		if (d.getElementById(campo+'_'+i).checked == true){
			ids += d.getElementById(campo+'_'+i).value + '|';
		}
	}

	if (ids != '' && d.getElementById('select_'+campo).value != ''){
		var confirma = confirm(msgAviso);
		if (confirma == true) {
			var acao = d.getElementById('select_'+campo).value;
			//alert(url+acao+'&ids='+ids)
			window.location = url+acao+'&ids='+ids;
		} else {
			d.getElementById('select_'+campo).value = '';
		}
	} else {
		alert('Você deve selecionar pelo menos uma opção acima!');
		d.getElementById('select_'+campo).value = '';
	}

}

function remarcar(url, dia, mes, ano, motivo){
	descricao = d.getElementById(motivo);
	dia       = d.getElementById(dia); 
	mes       = d.getElementById(mes); 
	ano       = d.getElementById(ano); 
	if (descricao.value != '' && dia.value != '' && mes.value != '' && ano.value != '') {
		window.location = url + 'data=' + ano.value + '-' + mes.value + '-' + dia.value + '&historico=' + url_encode(descricao.value);
		//alert(url + 'data=' + ano.value + '-' + mes.value + '-' + dia.value + '&historico=' + url_encode(descricao.value));
	} else {
		if (dia.value == '') {
			dia.focus(); alert('Informe o dia para retorno!');
		}
		if (mes.value == '') {
			mes.focus(); alert('Informe o mes para retorno!');
		}
		if (ano.value == '') {
			ano.focus(); alert('Informe o ano para retorno!');
		}		
		if (descricao.value == '') {
			descricao.focus(); alert('Informe o motivo para retorno!');
		}
	}
}

function juntaCheck(nome,id,tipo) {
	for (i=0; i <= id; i++) {
		//alert(nome + i)
		acao = (tipo == 0)?(false):(true);
		document.getElementById(nome + i).checked = acao;
	}	

}

function copy(span){
	cop = document.getElementById(span).createTextRange();
	cop.execCommand("RemoveFormat");
	cop.execCommand("Copy");
}

//inicio_mes, inicio_ano, fim_ano, fim_mes
function comparaAno() {
	
	// Formação
	if (curTab == 2) {
		if (d.getElementById('inicio_ano').value > d.getElementById('fim_ano').value) {
			if (d.getElementById('fim_ano').value != 0) {
				d.getElementById('fim_ano').value = 0;
				alert('Data de término não pode ser menor que a Data de início!')
			}
		}
		if (d.getElementById('inicio_ano').value == d.getElementById('fim_ano').value && d.getElementById('fim_ano').value != 0 && d.getElementById('inicio_ano').value != 0) {
			if (d.getElementById('inicio_mes').value >= d.getElementById('fim_mes').value && d.getElementById('fim_mes').value != 0 && d.getElementById('inicio_mes').value != 0) {
				d.getElementById('fim_mes').value = 0;
				d.getElementById('fim_ano').value = 0;
				alert('Data de término não pode ser menor ou igual que a Data de início!')
			}
		}
	}

	// Experiencia
	if (curTab == 4) {
		if (d.getElementById('exercidainicio_ano').value > d.getElementById('exercidafim_ano').value) {
			if (d.getElementById('exercidafim_ano').value != 0) {
				d.getElementById('exercidafim_ano').value = 0;
				alert('Data de término não pode ser menor que a Data de início!')
			}
		}
		if (d.getElementById('exercidainicio_ano').value == d.getElementById('exercidafim_ano').value && d.getElementById('exercidafim_ano').value != 0 && d.getElementById('exercidainicio_ano').value != 0) {
			if (d.getElementById('exercidainicio_mes').value >= d.getElementById('exercidafim_mes').value && d.getElementById('exercidafim_mes').value != 0 && d.getElementById('exercidainicio_mes').value != 0) {
				d.getElementById('exercidafim_mes').value = 0;
				d.getElementById('exercidafim_ano').value = 0;
				alert('Data de término não pode ser menor ou igual que a Data de início!')
			}
		}
	}
}

// E-mail
function validaEmail(campo){
	var elemento = document.getElementById(campo); 
	var emailad  = elemento.value
    var exclude  = /[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check    = /@[\w\-]+\./;
    var checkend = /\.[a-zA-Z]{2,3}$/;
    if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
		//alert('E-mail inválido!')
        return false;
    } else {
        return true;
    }
}
	
function verificaCentral() {
	nome     = document.getElementById('nome').value;
	email    = document.getElementById('email').value;
	assunto  = document.getElementById('assunto').value;
	mensagem = document.getElementById('mensagem').value;
	if (nome && validaEmail('email') && assunto && mensagem) {
		alert('Mensagem enviada com sucesso. Aguarde nossa resposta em seu e-mail.')
		return true
		//document.getElementById('formulario').submit();
	} else {
		if (! nome) alert('Preencha seu nome!')
		if (validaEmail('email') == false) alert('Preencha corretamente seu email!')
		if (! assunto) alert('Escolha o assunto!')
		if (! mensagem) alert('Escreva sua mensagem!')
		return false
	}
}
function mudaCurso(campo, campo2) {
	if (d.getElementById(campo2).value <= 2) {
		d.getElementById(campo).value = d.getElementById(campo2).options[d.getElementById(campo2).selectedIndex].label;
		d.getElementById(campo).disabled = true;
	} else {
		d.getElementById(campo).value = '';
		d.getElementById(campo).disabled = false;
	}
}

function exibirCamada(idCamada, idCamada2) {
	d.getElementById(idCamada).style.display = "block";
	d.getElementById(idCamada2).style.display = "none";
}

function checaLogin(url, campo) {
	if (d.getElementById(campo).value == '1') {
		d.getElementById('logar_index').action = url+'trabalhador/login.php'
		d.getElementById('label').innerHTML = 'Login&nbsp;&nbsp;'
	} else {
		d.getElementById('logar_index').action = url+'empresa/login.php'
		d.getElementById('label').innerHTML = 'E-mail'
	}
}

function recuperar(url) {
	if (d.getElementById('opcao1').checked == true) {
		window.location = url+'trabalhador/recuperar_senha.php'
	} else {
		window.location = url+'empresa/recuperar_senha.php'
	}
}

function resposta(resposta){
	document.getElementById('form').style.display = 'none'
	if (document.getElementById('table_resposta').style.display == 'none') {
		document.getElementById('table_resposta').style.display = 'block'
	}
	document.getElementById('resposta').innerHTML = resposta
}


/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;