var dep;

function showBanner(idAtivador, idBanner){
	$(idAtivador).mouseover(function(){
		$(this).nextAll(idBanner).show();
	}).mouseleave(function(){
		$(this).nextAll(idBanner).hide();
	})
}

function loadAutoCompletes(){
	
	    $("#textSearchJobs, #cargo, #objetivo").autocomplete("/home2009/funcoesLocais.php", {
	    	width: 'auto',
	        minChars: 1,		
	        matchSubset: 0,  
	        autoFill:true,
	        extraParams:{
	    		action:'suggestHome',
	    		type:'vag'    	
	    	} 
	    });
	    
	    $("#textSearchResumes").autocomplete("/home2009/funcoesLocais.php", {
	    	width: 'auto',
	        minChars: 1,		
	        matchSubset: 0,   
	        autoFill:true,
	        extraParams:{
	    		action:'suggestHome',
	    		type:'cur'    	
	    	}
		});
	    
}

$(document).ready(function()
{    	
	
	$("#telefone, #telefoneCv").mask('99-9999-9999', {placeholder:"_"});
    
    $(".ac_results").css({display:"block",zIndex:5});
    
    $("#planoProm").bind("change", function(){
      listaAreap($(this).val());
      listaNivelh($(this).val());
    });
    
    $(".Localidade select").val("");
    
	$('.lasttimevacancies').css('display', 'block');

	$('#link_vag_ult_hora').click(function(){
		 $('.lasttimevacancies').css('display', 'block');   	
		 $('.vacanciesfeatured').css('display', 'none');  
		 
		}
    );
	$('#link_vag_destaque').click(function(){
		 $('.lasttimevacancies').css('display', 'none');   	
		 $('.vacanciesfeatured').css('display', 'block');   	
	    }
    );

	$(".maisCidades").click(function(){
		$(this).next("ul").show()
		return false;
	})
	
	
	
	showBanner(".seloDestaque", ".dicaVagaDestaque")
	
	showBanner(".btndicasAzul", ".dica")
	
	showBanner(".btndicasVerde", ".dica")
	
	
	var mouseTgt;
	var prevMouseTgt;
	$(document).ready(function(){
		$("body").mousemove(function(e){
	        e=e||window.event;
	        prevMouseTgt = mouseTgt;
	        mouseTgt = e.scrElement||e.target;
		});
	});
		
	$(".BoxImg1000 img").hover(function() {
		$(".dica1000maiores").css({"display": "none"});
		$(this).parent().next(".dica1000maiores").css({"display": "block"});
	}, function() {
		var obj = $(this);
		setTimeout(function(){
			if($(prevMouseTgt)) {
				if($(prevMouseTgt).parents('.dica1000maiores').length == 0 && !$(prevMouseTgt).hasClass('dica1000maiores')){
					$(obj).parent().next(".dica1000maiores").css({"display": "none"});
				}
			}
		}, 100);

	});		
	
	$(".dica1000maiores").bind('mouseleave', function(){ $(this).hide(); });

	
	
	
	
	$('#jobSearchTitleOn, #jobSearchTitleOff').click(function(){
		$("#search_resumes").hide();
		$("#search_jobs").show();
		$(".aba-01off").removeClass("aba-01off").addClass("aba-01on");
		$(".aba-02on").removeClass("aba-02on").addClass("aba-02off");
		$('#textSearchJobs').val($('#textSearchResumes').val());
	});
	
	$('#resumeSearchTitleOn, #resumeSearchTitleOff').click(function(){
		$("#search_resumes").show();
		$("#search_jobs").hide();
		$(".aba-01on").removeClass("aba-01on").addClass("aba-01off");
		$(".aba-02off").removeClass("aba-02off").addClass("aba-02on");
		$('#textSearchResumes').val($('#textSearchJobs').val());
	});

    elementosServico = '.free-services > ul li,.subscribers-services > ul li,.single-services > ul li,.subscribers-services > ul li,.companies-leftcolumn > ul li,.companies-rightcolumn > ul li';
    $(elementosServico).children('a').css({'cursor':'pointer'});
    $(elementosServico).children('a').click(function(){
	    $(this).parent().parent().find('li').attr('class', 'title-services');
	    $(this).parent().parent().find('li > div').css('display', 'none');
	    $(this).parent().toggleClass('title-serv-checked');
	    $(this).next().toggle();
	}
    )


    var elementosSessoes = '#catho_noticias,#estilo_gestao,#carreira_sucesso,#catho_blog';
    $(elementosSessoes).css({'cursor':'pointer'}).click(
	function()
	{
	    $(elementosSessoes).attr('class', 'title');
		$(this).css({'cursor':'default'});
	    $(elementosSessoes).next().attr('class', 'contentnew')
	    $(this).attr('class', 'title-checked');
	    $(this).next().attr('class', 'contentnew-open');
	}
    );

    //profissional
    dep = $('#dep_0');
    dep.fadeIn('slow');
    $('#next_dep').click(function(){
		$(dep).hide();
		dep = $(dep).next("span[id^='dep_']");
		if(typeof $(dep).attr('id') == 'undefined' || $(dep).attr('id').substring(0, 4) != 'dep_')
		    dep = $('#dep_0');
		$(dep).show();
    });

    $('#prev_dep').click(function(){
		$(dep).hide();
		dep = $(dep).prev("span[id^='dep_']");
		if(typeof $(dep).attr('id') == 'undefined' || $(dep).attr('id').substring(0, 4) != 'dep_')
		    dep = $('#dep_0').nextAll(':last');
		$(dep).show();
    });
    
    //empresas
   
    depEmp = $('#depEmp_0');
    depEmp.fadeIn('slow');
    
    $('#next_depEmp').click(function(){
		$(depEmp).hide();
		depEmp = $(depEmp).next("span[id^='depEmp_']");
		if(typeof $(depEmp).attr('id') == 'undefined' || $(depEmp).attr('id').substring(0, 7) != 'depEmp_')
		    depEmp = $('#depEmp_0');
		$(depEmp).show();
    });

    $('#prev_depEmp').click(function(){
		$(depEmp).hide();
		depEmp = $(depEmp).prev("span[id^='depEmp_']");
		if(typeof $(depEmp).attr('id') == 'undefined' || $(depEmp).attr('id').substring(0, 7) != 'depEmp_')
		    depEmp = $('#depEmp_0').nextAll(':last');
		$(depEmp).show();
    });

    loadAutoCompletes();

});

function removerBuscaSalva(id, element)
{
	
	if (confirm('Deseja excluir esta busca?')) {
		if ($('#ul_buscasSalvas_CB li').length <= 1) {
			$('#buscasSalvas_CB, .contentBuscaSalva').remove()
		} else {
			$(element).parent('li').remove()
		}
		
		$.ajax({
			url: "",
	        type: "POST",
	        data: {
	        	"states": "removerBuscaSalva",
	    		"search_id": id
	        },
	        success: function(q){
	        	console.log(q)
	        }
		})
	}
	
}

function abre2()
{
    var origem = document.formii.origem.value;
    var nome = document.formii.nome.value;
    var email = document.formii.email.value;
    window.open("http://www.catho.com.br/parceiros/ReceberMail.php?email="+ email+"&origem="+ origem +"&nome="+ nome +"","Obrigado","'toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=200,height=200'");
    return false;
}

function clearOptions(element)
{
	elemento = document.getElementById(element);
	elemento.length = 0;
	elemento.options[0] = new Option("Carregando...", 0, false, false);
}

function appendCidades(element, estadoId)
{
    clearOptions(element);
	document.getElementById(element).disabled=false;
	$.ajax({
		url: "funcoesLocais.php",
		type: "POST",
		data: "action=cidade&id="+estadoId,
		dataType: "text",
		success: function(retorno) {
			retorno = url_decode(retorno);
			elemento = document.getElementById(element);
			elemento.length = 0;
			elemento.options[0] = new Option("Carregando...", 0, false, false);
			var v = retorno.split(';');
			for(i=0; i < v.length; i++){
				aux = v[i].split('|');
				elemento[i] = new Option(aux[1], aux[0], false, false);
			}
		}
	});
}


function addOptions(element, values)
{
	elemento = document.getElementById(element);
	elemento.length = 0;
	elemento.options[0] = new Option("Carregando...", 0, false, false);
	v = values.split('|');
	for(i=0; i < v.length; i++)
	{
	    aux = v[i].split(':');
	    elemento[i] = new Option(aux[1], aux[0], false, false);

	}
}

function listaNivelh(plano)
{
    var plano_id;
    var ajaxhttp          = ajax();
    var selectNivelh      = document.getElementById("nivelh");
    
    switch(plano)
	{            
	    case "Pro":
	    case "Ppd":
             plano_id = 1;
             break;

	    case "Est":
             plano_id = 3;
             break;

	    case "Ope":
             plano_id = 9;
             break;
	}

    cleanList(selectNivelh);
    selectNivelh.disabled = true;

    if(ajaxhttp)
    {
        ajaxhttp.open("POST","home2009/ajax.php",true);
        ajaxhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajaxhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        ajaxhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        ajaxhttp.setRequestHeader("Pragma", "no-cache");
        ajaxhttp.send("acao=miniform_nivelh&plano_id="+plano_id);
       
        ajaxhttp.onreadystatechange = function()
        {
            if(ajaxhttp.readyState == 4)
            {
                if(ajaxhttp.status == 200)
                {
                    var resp            = ajaxhttp.responseText;
                    var conteudoNivelh  = url_decode(resp);
                    var arrayNivelh     = conteudoNivelh.split(";");

                    selectNivelh.disabled = false;
                    
                    selectNivelh.options[0] = new Option("Escolha uma opção","",false,false );
                    for(count=1;count<arrayNivelh.length;count++)
                    {
            	       var array_nivelh_campos = arrayNivelh[count].split("::");
                       selectNivelh.options[count] = new Option(array_nivelh_campos[1], array_nivelh_campos[0], false, false);
                    }
                }
            }
           
            if(ajaxhttp.readyState == 1)
            {
                selectNivelh.options[0] = new Option("Carregando...","",false,false );
            }
        }
    }
}

function listaAreap(plano)
{	
    var plano_id;
    var ajaxhttp          = ajax();
    var selectAreap       = document.getElementById("areap");
    
    switch(plano)
	{            
	    case "Pro":
	    case "Ppd":
             plano_id = 1;
             break;

	    case "Est":
             plano_id = 3;
             break;

	    case "Ope":
             plano_id = 9;
             break;
	}

    cleanList(selectAreap);
    selectAreap.disabled = true;

    if(ajaxhttp)
    {
        ajaxhttp.open("POST","home2009/ajax.php",true);
        ajaxhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajaxhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        ajaxhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        ajaxhttp.setRequestHeader("Pragma", "no-cache");
        ajaxhttp.send("acao=miniform_areap&plano_id="+plano_id);
       
        ajaxhttp.onreadystatechange = function()
        {
            if(ajaxhttp.readyState == 4)
            {
                if(ajaxhttp.status == 200)
                {
                    var resp          = ajaxhttp.responseText;
                    var conteudoAreap = url_decode(resp);
                    var arrayAreap    = conteudoAreap.split(";");

                    selectAreap.disabled = false;
                    
                    selectAreap.options[0] = new Option("Escolha uma opção","",false,false );
                    for(count=1;count<arrayAreap.length;count++)
                    {
            	       var array_areap_campos = arrayAreap[count].split("::");
                       selectAreap.options[count] = new Option(array_areap_campos[1], array_areap_campos[0], false, false);
                    }
                }
            }
           
            if(ajaxhttp.readyState == 1)
            {
                selectAreap.options[0] = new Option("Carregando...","",false,false );
            }
        }
    }
}

function cleanList(selectForm)
{
    var qtdeformList = selectForm.length;
  
    if( qtdeformList > 0 )
    {
	    //exclui elementos antigos
        while(qtdeformList != 0)
        {
         selectForm.options[0] = null;
         qtdeformList = selectForm.length;
        }
    }
}

function formInclusao(plano){
	if( plano == 'Ope' ){
		document.getElementById('plano_id_inc').value='7';
		document.getElementById('perfil_id_inc').value='9';
		document.getElementById('ppd_id_inc').value='0';
	}
	else if( plano == 'Ppd' ){
		document.getElementById('plano_id_inc').value='1';
		document.getElementById('perfil_id_inc').value='1';
		document.getElementById('ppd_id_inc').value='1';
	}
	else if( plano == 'Est' ){
		document.getElementById('plano_id_inc').value='2';
		document.getElementById('perfil_id_inc').value='3';
		document.getElementById('ppd_id_inc').value='0';
	}
	else{
		document.getElementById('plano_id_inc').value='1';
		document.getElementById('perfil_id_inc').value='1';
		document.getElementById('ppd_id_inc').value='0';
	}
}
var xajax = new Object(); 
function showLayerReativa(){
	if( navigator.userAgent.indexOf("MSIE") > 0 ){
		showModal('/home2009/lib/templates/layer-reative.php', 628, 243, 'Reative sua assinatura', false, false);
	}
	else{
		showModal('/home2009/lib/templates/layer-reative.php', 628, 240, 'Reative sua assinatura', false, false);
	}
}

function showLayerOpine(){
        if( navigator.userAgent.indexOf("MSIE") > 0 ){
                showModal('http://www.catho.com.br/home2009/layer-opine.php', 731, 288, 'Opine sobre esta página', false, false);
        }
        else{
                showModal('http://www.catho.com.br/home2009/layer-opine.php', 731, 285, 'Opine sobre esta página', false, false);
        }
}

function showModal(urlArg, widthArg, heightArg, titleArg, scrollBarArg, showCloseArg) {
//        this.scroll(1,-1000);
        var dmp = document.getElementById('divModalPanel');
        var divModalBorder = document.getElementById('divModalBorder');

        var dm = document.getElementById('divBackground');

	if( navigator.userAgent.indexOf("MSIE") > 0 ){
	}
	else{
	        // default is true
	        if (scrollBarArg == null || scrollBarArg == undefined) {
	                scrollBarArg = true;
	        }
	        if (scrollBarArg) {
	                document.getElementById('divModalPanelFrame').setAttribute('scrolling','auto');
	                document.getElementById('divModalPanelFrame').scrolling='auto';
	        } else {
	                document.getElementById('divModalPanelFrame').setAttribute('scrolling','no');
	                document.getElementById('divModalPanelFrame').scrolling='no';
	        }
	}

        document.getElementById('divModalTitle').innerHTML = titleArg;

        document.getElementById('divModalPanelFrame').src = urlArg;
        document.getElementById('divModalPanelFrame').width = widthArg;
        document.getElementById('divModalPanelFrame').height = heightArg;
        divModalBorder.width = widthArg;
        divModalBorder.height = heightArg;

        if (showCloseArg == null && showCloseArg == undefined) {
                showCloseArg = true;
        }

        if (showCloseArg) {
                document.getElementById('closeModalEvent').style.display = '';
        } else {
                document.getElementById('closeModalEvent').style.display = 'none';
        }

        dm.style.display='';
        dmp.style.display='';

        var altTela = Math.floor(document.body.offsetHeight);
        var largTela =  Math.floor(document.body.offsetWidth);
        var largDiv = Math.floor(divModalBorder.offsetWidth);
        var altDiv = Math.floor(divModalBorder.offsetHeight);


        dm.style.width=largTela+'px';
        if( document.all ){
                dm.style.height=alturaContent+'px';
        }
        else{
                dm.style.height=altTela+'px';
        }

        dmp.style.left=((largTela/2)-(largDiv/2))+'px';
        var posY = 90;
        if( document.all ){
		if (!document.documentElement.scrollTop)
			posY = document.body.scrollTop;
		else
			posY = document.documentElement.scrollTop;
        }
        else{
                posY = window.pageYOffset;
        }
        dmp.style.top= (Number(posY)+50)+'px';

        var t = 0;
        var h = $(document).height();

        var cssArg = {'top':t+'px','height':h+'px', 'visibility':'visible'}

        $('#divBackground').css(cssArg).show();
}

function closeModal(timeArg) {
        if (timeArg != undefined && timeArg != null && timeArg > 0) {
                window.setTimeout(function() {
                        closeModal();
                }, timeArg*1000);
        } else {
                document.getElementById('divModalPanel').style.display='none';
                document.getElementById('divBackground').style.display='none';
                document.getElementById('divModalTitle').innerHTML = '';
                document.getElementById('divModalPanelFrame').src = '';
        }
}

function ajax(){
        try{
                xmlhttp = new XMLHttpRequest();
        }
        catch(ee){
                try{
                        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e){
                        try{
                                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch(E){
                                xmlhttp = false;
                        }
                }
        }
        return xmlhttp;
}


function url_encode(str) {
        var hex_chars = "0123456789ABCDEF";
        var noEncode = /^([a-zA-Z0-9\_\-\.])$/;
        var n, strCode, hex1, hex2, strEncode = "";

        for(n = 0; n < str.length; n++){
                if (noEncode.test(str.charAt(n))){
                        strEncode += str.charAt(n);
                }
                else{
                        strCode = str.charCodeAt(n);
                        hex1 = hex_chars.charAt(Math.floor(strCode / 16));
                        hex2 = hex_chars.charAt(strCode % 16);
                        strEncode += "%" + (hex1 + hex2);
                }
        }
        return strEncode;
}


function mudaEx(tipo){
        document.getElementById('exEmailConf').style.display = 'none';
        switch(tipo){
                case "email":
                        document.getElementById("exEmail").style.display = 'block';
                        document.getElementById("exLogin").style.display = 'none';
                break;
                case "login":
                        document.getElementById("exEmail").style.display = 'none';
                        document.getElementById("exLogin").style.display = 'block';
                break;
        }
}

function validaBusca(tipo)
{
    var textEl = (tipo == 'jobs')?'#textSearchJobs':'#textSearchResumes';
    
    if($.trim($(textEl).val()) == "" || $(textEl).val() == 'Digite aqui o cargo desejado'){
    	if($('#search_jobs:visible').length){
    		alert("Para buscar vagas de emprego, digite um cargo, ou o nome da empresa, ou uma especialidade ou um termo qualquer que deseja encontrar no resultado.");
		}else{
			alert("Para buscar currículos, digite um cargo, ou experiência profissional, ou uma especialidade ou um termo qualquer que deseja encontrar no resultado.")
		}
		return false;
    }
    
    return !$(".ac_over:visible").length;
    
}

function validaFormLogin(){
        if( document.getElementById('loginEx').value == '' ){
                alert("Preencha o campo de login.");
                return false;
        }
        if( document.getElementById('senhaEx').value == '' ){
                alert("Preencha o campo de senha.");
                return false;
        }

        window.parent.location="http://www3.catho.com.br/usr/login.php?login="+document.getElementById('loginEx').value+"&senha="+document.getElementById('senhaEx').value;
}

function KeyPressAscCode(objEvent,param) {
        var Code;

        if (navigator.appName == 'Microsoft Internet Explorer') {
                Code = event.keyCode;
                var shift = false;
                if( Code == 16 ){
                        shift = true;
                }
        }
        else if(navigator.appName == 'Netscape'){
                Code = objEvent.keyCode;
                shift = objEvent.shiftKey;
        }

        if( Code == 13 ){
                sendMail(param);
                return false;
        }
}

function sendMail(field){
	if( field == 2 ){
		var email = document.getElementById('email_exass2').value;
	}
	else if( field == 3 ){
		var cpf = document.getElementById('cpf_exass').value + "" + document.getElementById('cpf_exass1').value + "" + document.getElementById('cpf_exass2').value + "" + document.getElementById('cpf_exass3').value;
	}
	else{
		var email = document.getElementById('email_exass').value;
	}
	if( email == "" && field != 3 ){
		alert("Por favor, digite o seu e-mail.");
	}
	else if( field == 3 && cpf == "" ){
		alert("Por favor, digite o seu cpf.");
	}
	else{
		document.getElementById('exassStep2').style.display='none';
		document.getElementById('reative').style.display='';
		var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		if ( email && !email.match(re) && field != 3 ) {
			alert("E-mail inválido.");
			email.focus();
		}
		else{
			var ajaxhttp = ajax();
			if( field == 3 ){
				ajaxhttp.open("GET","/home2009/procura_cliente_ajax.php?cpf_exass="+url_encode(cpf)+"&origem_email=pop_home",false);
			}
			else{
				ajaxhttp.open("GET","/home2009/procura_cliente_ajax.php?email_exass="+url_encode(email)+"&origem_email=pop_home",false);
			}
			ajaxhttp.send(null);
			var retorno = "   " + ajaxhttp.responseText;
			if( field == 3 && retorno.indexOf("||") > 0 ){
				var retornoTemp = retorno.split("||");
				retorno = retornoTemp[0];
				email = retornoTemp[1];
			}
			if( retorno.indexOf('1') > 0 ){
				document.getElementById("exEmailConfText").innerHTML = "<br><br><center><span class='exasspad' style='font-size:14px'>Seus dados de acesso foram enviados para <br><b>"+email+"</b>, por favor, verifique seu e-mail.<br><br><br>Caso não tenha recebido o e-mail com seus dados de acesso, <a href='http://www3.catho.com.br/help/geral/duvidaSAC.php' onClick='parent.closeModal(0);' target='_blank'>clique aqui</a>.</span>";
			}
			else if( retorno.indexOf('2') > 0 ){
				document.getElementById("exEmailConfText").innerHTML = "<br><br><center><span class='exasspad' style='align:center;valign:middle;font-size:14px;'>Seus dados de reativação foram enviados para <br><b>"+email+"</b>, por favor, verifique seu e-mail.<br><br><br>Caso não tenha recebido o e-mail com seus dados de reativação, <a href='http://www3.catho.com.br/help/geral/duvidaSAC.php' onClick='parent.closeModal(0);' target='_blank'>clique aqui</a>.</span></center>";
			}
			else if( retorno.indexOf('3') > 0 && ( field == 2 || field == 3 ) ){
				document.getElementById("exEmailConfText").innerHTML = "<br><br><center><span class='exasspad' style='font-size:14px'><font color='red'>Seus dados <b>não constam</b> em nosso site.</font><br><br>Por favor, entre em contato com o <a href='http://www3.catho.com.br/help/geral/duvidaSAC.php' onClick='parent.closeModal(0);' target='_blank'>Serviço de Atendimento Catho Online</a>.<br>Ou, se preferir, faça um novo <a href='http://inclusao.catho.com.br/inclusao/formulario_v15.php?nova_inclusao=1&tipoinclusao=93&usr[plano_id]=1&cur[perfil_id]=1&cur[use_personalizado]=0&a=0&ppd=0' target='_parent'>anúncio de currículo</a> agora mesmo.</span></center>";
			}
			else if( retorno.indexOf('3') > 0 ){
				document.getElementById('exassStep2').style.display='';
				document.getElementById('reative').style.display='none';
				document.getElementById('emailEx2').innerHTML = "<b>"+email+"</b>";
				document.getElementById("email_exass2").value = email;
			}
			else if( retorno.indexOf('4') > 0 ){
				document.getElementById('exEmailConf').style.display = 'block';
				document.getElementById('exLogin').style.display = 'none';
				document.getElementById('exEmail').style.display = 'none';
				document.getElementById("exEmailConfText").innerHTML = "<br><br><center><span class='exasspad' style='font-size:14px'><b class='exasspad'>Você possui uma assinatura incompleta.<br> Seus dados foram enviados para seu e-mail.</b></span></center>";
			}
			else if( retorno.indexOf('5') > 0 ){
				document.getElementById("exEmailConfText").innerHTML = "<br><br><center><span class='exasspad' style='font-size:14px'>Seus dados de acesso foram enviados para <br><b>"+email+"</b>, por favor, verifique seu e-mail.<br><br><br>Caso não tenha recebido o e-mail com seus dados de acesso, <a href='http://www3.catho.com.br/help/geral/duvidaSAC.php' onClick='parent.closeModal(0);' target='_blank'>clique aqui</a>.</span>";
			}

			if( field == 2 || field == 3 ||  retorno.indexOf('1') > 0 || retorno.indexOf('2') > 0 || retorno.indexOf('4') > 0 ||  retorno.indexOf('5') > 0 ){
				document.getElementById('exEmailConf').style.display = 'block';
				document.getElementById('exLogin').style.display = 'none';
				document.getElementById('exEmail').style.display = 'none';
			}
			else{
				document.getElementById('exEmailConf').style.display = 'none';
				document.getElementById('exLogin').style.display = 'none';
				document.getElementById('exEmail').style.display = '';
			}
		}
	}
}

function nextField( field, totalMax, nextField ){
        if( field.value.length >= totalMax ){
                document.getElementById(nextField).focus();
        }
}

function flagStatusFields( area ){
        if( area == "login" ){
                document.getElementById('loginEx').disabled = false;
                document.getElementById('senhaEx').disabled = false;
                document.getElementById('email_exass').disabled = true;
        }
        else if( area == "email" ){
                document.getElementById('loginEx').disabled = true;
                document.getElementById('senhaEx').disabled = true;
                document.getElementById('email_exass').disabled = false;
        }
}

function goToFranquia(urlFranquia){
	if( urlFranquia.value.length > 1 ){
//		urchinTracker('/track/home/Escritórios franqueados');
		var indice = urlFranquia.selectedIndex;
		var url = urlFranquia.options[indice].value;
		window.open(url,"popupfranquias","");
}}	

function popup(url,name,features){
	window.open(url,name,features);
}

function saveData(){
                var nome    = document.getElementById('nomeSugest').value;
                var email   = document.getElementById('usremail').value;
                var tel     = document.getElementById('telSugest').value;
                var id      = document.getElementById('idSugest').value;
                var message = document.getElementById('messageSugest').value;
                var url     = '';


                var xmlhttp = ajax();

                if( nome.length < 2 ){
                        alert("Preencha corretamente o nome.");
                        return false;
                }

                var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
                if (!email.match(re)) {
                        alert("O campo de email não foi preenchido corretamente.");
                        return false;
                }


                if( message.length < 10 ){
                        alert("Preencha corretamente a mensagem");
                        return false;
                }

                xmlhttp.open("POST", "funcoesLocais.php",true);
                xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1");
                xmlhttp.onreadystatechange=function(){
                        if (xmlhttp.readyState==4){
                                retorno = url_decode(xmlhttp.responseText);
                                document.getElementById('sugestform').style.display='none';
                                document.getElementById('sugestconfirm').style.display='';
                                setTimeout(function(){document.getElementById('sugest').style.display='none';},5000);
                        }
                }
                xmlhttp.send('nome='+url_encode(nome)+'&email='+url_encode(email)+'&tel='+url_encode(tel)+'&id='+url_encode(id)+'&message='+url_encode(message)+'&action=sugest&url='+url_encode(url));
        }

        function mailVerify(email){
        if( document.getElementById('divemail') && document.getElementById('emails') ){
                var divDead = document.getElementById('emails');
                var divSuggestDead = document.getElementById('divemail');
                divDead.removeChild(divSuggestDead);
        }
        var xmlhttp = ajax();
        if( email.indexOf('@') > 0 && email.length > 4 ){
                var emailParts = email.split("@");
                var domain = url_encode(emailParts[1]);
                xmlhttp.open("POST", "../../funcoesLocais.php");
                xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1");
                xmlhttp.onreadystatechange=function(){
                        if (xmlhttp.readyState==4){
                                var rightDomain = url_decode(xmlhttp.responseText);
                                if( rightDomain.length > 1 ){
                                        var div = document.getElementById('emails');
                                        var divNew = document.createElement('div');
                                        divNew.setAttribute('id','divemail');
                                        div.appendChild(divNew);
                                        var content = "<b><a href='javascript:;' class='araz' onClick=\"addMailSugestion('"+emailParts[0]+"@"+rightDomain+"');\">"+emailParts[0]+"@"+rightDomain+"</b></a>";
                                        var finalContent = "<span class=araz>E-mail inválido</span><br><span class=araz>Clique na sugestão a seguir para alterá-lo:</span><br>"+content;
                                        document.getElementById('divemail').innerHTML=finalContent;
                                }
                        }
                }
                xmlhttp.send("action=email&domain="+domain);
        }
}

function logLastSearch(canal,usr_id,url){
	$.ajax({
		url: "/home2009/funcoesLocais.php",
		type: "POST",
		async: false,
		data: "action=logLastSearch&usr_id="+usr_id+"&canal="+canal,
		dataType: "txt",
		success: function(){
			location.href=url;
		}
	});
}


function cleanLastSearch(){
	var retorno;

	$.ajax({
		url: "/home2009/funcoesLocais.php",
		type: "POST",
		async: false,
		data: "action=lastSearch",
		dataType: "txt",
		success: function(){
			$("#spanLastSearch").hide();
		}
	});

}

// url_decode version 1.0
function url_decode(str) {
        var n, strCode, strDecode = "";

        for (n = 0; n < str.length; n++) {
                if (str.charAt(n) == "%") {
                        strCode = str.charAt(n + 1) + str.charAt(n + 2);
                        strDecode += String.fromCharCode(parseInt(strCode, 16));
                        n += 2;
                } else if (str.charAt(n) == "+") {
                        strCode = str.charAt(n);
                        strDecode += " ";
                } else {
                        strDecode += str.charAt(n);
                }
        }
        return strDecode;
}
$(function() {
	$('#vagasDestaque').show();
});

function setLog(URL){
	$.get(URL);
}

// RealMedia

<!--
//configuration
OAS_url ='http://banner.catho.com.br/RealMedia/ads/';
OAS_listpos = 'Position1,Top3';
OAS_query = '';
OAS_sitepage = 'www.catho.com.br/home2009/';
//end of configuration
OAS_version = 10;
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String (Math.random()); OAS_rns = OAS_rn.substring (2, 11);
function OAS_NORMAL(pos) {
document.write('<A HREF=' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + OAS_query + ' TARGET=_top>');
document.write('<IMG SRC=' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + OAS_query + ' BORDER=0></A>');
}
//-->
<!--
OAS_version = 11;
if (navigator.userAgent.indexOf('Mozilla/3') != -1)
OAS_version = 10;
if (OAS_version >= 11)
document.write('<SCRIPT LANGUAGE=JavaScript1.1 SRC=' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + OAS_query + '><\/SCRIPT>');
//-->
<!--
document.write('');
function OAS_AD(pos)
{
if (OAS_version >= 11)
 OAS_RICH(pos);
else
 OAS_NORMAL(pos);
}

//ABAS CANDIDADOS CONTRATADOS

	$(document).ready(function(){
							   
		/*$( "#header h1" ).css( "top", $( "div.numbers" )[0].offsetTop + 240 + "px" ); */
		$(".abas a").hover(function() {
			$(this).nextAll("em").css({"display": "block"});
		}, function() {
			$(this).nextAll("em").css({"display": "none"});
		});	
		
		$(".vaga-info a").hover(function() {
			$(this).nextAll("em").css({"display": "block"});
			
			if ($.browser.msie) {
				if($.browser.version<7) {
					$("select").css({"visibility": "hidden"});
				}
			}
			
		}, function() {
			$(this).nextAll("em").css({"display": "none"});
			
			if ($.browser.msie) {
				if($.browser.version<7) {
					$("select").css({"visibility": "visible"});
				}
			}
		});	
		
	});


