<!-- PUBLICIDADE BANNERS -->

//configuration
OAS_url ='http://banner.catho.com.br/RealMedia/ads/';
OAS_listpos = 'Top,TopLeft';
OAS_query = '';
OAS_sitepage = 'www3.catho.com.br/testesonline/';
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);

}

//POPUP GERAL
var win = null;
function NewWindow(mypage,myname,w,h,scroll,toolbar,statubar){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	
	settings = 'height='+h+',width='+w+',scrollbars='+scroll+',resizable,toolbar,status'
	win = window.open(mypage,myname,settings)
}


// HINT BOX NO MOUSE OVER

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox


// FORMULARIO
var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}

// DIVS DOS HELPS 

function ajuda(div_name) {
		var new_display = (document.getElementById(div_name).style.display == "block") ? "none" : "block";
		document.getElementById(div_name).style.display = new_display;
}

function vLogin() {

	if (document.getElementById('login').value == '') {
		document.getElementById('login').focus();
		document.getElementById('login').style.backgroundColor = '#DBE7DB';
		document.getElementById('senha').style.backgroundColor = '#FFFFFF';
				
		alert('Por favor especifique um login para entrar na área de assinante');
		
		return false;
	}

	if (document.getElementById('senha').value == '') {
		document.getElementById('senha').focus();
		document.getElementById('senha').style.backgroundColor = '#DBE7DB';
		document.getElementById('login').style.backgroundColor = '#FFFFFF';
				
		alert('Por favor especifique um login para entrar na área de assinante');
		
		return false;
	}
	
	return true;
}

function checkUncheckAll(currentform, element) 
{
    theform = currentform;
	
    for(i=0;i < theform.length;i++) 
    {
        if (theform[i].type == 'checkbox' && theform[i].name != 'checkall') 
        {
        	if (theform.checkall.checked == true)  
        	{
	        	theform[i].checked             = true;
	        	theform.checkallBottom.checked = true;
	        } else {
	        	theform[i].checked             = false;
	        	theform.checkallBottom.checked = false;	        
	        }
        }
    }    
}

function checkUncheckAllBottom(currentform, element) 
{
    theform = currentform;
	
    for(i=0;i < theform.length;i++) 
    {
        if (theform[i].type == 'checkbox' && theform[i].name != 'checkallBottom') 
        {
        	if (theform.checkallBottom.checked == true)  
        	{
	        	theform[i].checked             = true;
	        	theform.checkall.checked = true;
	        } else {
	        	theform[i].checked             = false;
	        	theform.checkall.checked = false;	        
	        }
        }
    }    
}

function foo(currentform) {
    theform = currentform;

    for(i=0;i < theform.length;i++) 
    {
        if (theform[i].type == 'text' && theform[i].name == 'email[]' && theform[i].value != '')
        {
       		theform[i+3].checked = true;
		}
	}
}

function checkSendEmail(currentform) {
    theform = currentform;
    for(i=0;i < theform.length;i++){
        if (theform[i].id == 'email' && theform[i].value != '') {
        	theform[i+2].checked  = true;
	       	theform[i+2].disabled = false;
	       	theform[i+1].disabled = true
        }
        
        if (theform[i].id == 'email' && theform[i].value == '') {
           	theform[i+2].checked  = false;
           	theform[i+2].disabled = true;
           	theform[i+1].disabled = false;
        }
        
        if (theform[i].id =='cpf' && theform[i].value != '') {
           	theform[i-1].disabled = true;
        }
        
        if (theform[i].id =='cpf' && theform[i].value == '') {
           	theform[i-1].disabled = false;
        }

	}
}

function validacpfobj (obj) {
 str_aux = "";
strcpf =  obj.value ;

 for (i = 0; i <= strcpf.length - 1; i++)

   if ((strcpf.charAt(i)).match(/\d/))

     str_aux += strcpf.charAt(i);

   else if (!(strcpf.charAt(i)).match(/[\.\-]/)) {

     return false;

   }

 

 if (str_aux.length != 11) {

   return false;

 }

 

 soma1 = soma2 = 0;

 for (i = 0; i <= 8; i++) {

   soma1 += str_aux.charAt(i) * (10-i);

   soma2 += str_aux.charAt(i) * (11-i);

 }

 d1 = ((soma1 * 10) % 11) % 10;

 d2 = (((soma2 + (d1 * 2)) * 10) % 11) % 10;

 if ((d1 != str_aux.charAt(9)) || (d2 != str_aux.charAt(10))) {

   return false;

 }



 return true;

}

function validacpf (strcpf) {
 str_aux = "";

 

 for (i = 0; i <= strcpf.length - 1; i++)

   if ((strcpf.charAt(i)).match(/\d/))

     str_aux += strcpf.charAt(i);

   else if (!(strcpf.charAt(i)).match(/[\.\-]/)) {

     return false;

   }

 

 if (str_aux.length != 11) {

   return false;

 }

 

 soma1 = soma2 = 0;

 for (i = 0; i <= 8; i++) {

   soma1 += str_aux.charAt(i) * (10-i);

   soma2 += str_aux.charAt(i) * (11-i);

 }

 d1 = ((soma1 * 10) % 11) % 10;

 d2 = (((soma2 + (d1 * 2)) * 10) % 11) % 10;

 if ((d1 != str_aux.charAt(9)) || (d2 != str_aux.charAt(10))) {

   return false;

 }



 return true;

}

function fnTickaEmail(obj){
	obj2 = obj.parentNode.childNodes;
	for(x=0;x<obj2.length;x++){
		if(obj2[x].id == "enviar_email"){					
			if(obj.value != ""){
				obj2[x].checked  = true;
				obj2[x].disabled = false;
			}else{	
				obj2[x].checked  = false;					
				obj2[x].disabled = true;
			}
		}
	}
}
		
function validacpf2(cpf){
   var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;
   if(!filtro.test(cpf)){
	 return false;
   }
   
   cpf = remove(cpf, ".");
   cpf = remove(cpf, "-");
    
   if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
	  cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
	  cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
	  cpf == "88888888888" || cpf == "99999999999"){
	  return false;
   }

   soma = 0;
   for(i = 0; i < 9; i++)
   	 soma += parseInt(cpf.charAt(i)) * (10 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(9))){
	 return false;
   }
   soma = 0;
   for(i = 0; i < 10; i ++)
	 soma += parseInt(cpf.charAt(i)) * (11 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(10))){
	 return false;
   }
   return true;
 }
 
 function remove(str, sub) {
   i = str.indexOf(sub);
   r = "";
   if (i == -1) return str;
   r += str.substring(0,i) + remove(str.substring(i + sub.length), sub);
   return r;
 } 
function deleteParentRow(r){
  var i=r.parentNode.parentNode.rowIndex
		r.parentNode.parentNode.parentNode.deleteRow(i);
}
function addCandidato() {
	var newArea = document.getElementById('tblInclusaoCandidatos');
	//trNum = newArea.getElementsByTagName('tr');
	//trNum.length
	if(document.getElementById('g')){
		g = document.getElementById('g').value;	
		document.getElementById('g').value = parseInt(document.getElementById('g').value) + 1;
	}else{
		g=0;
	}

	elm = document.createElement('input');	
	elm.setAttribute('type', 'text');
	elm.setAttribute('size', '20');
	elm.setAttribute('name', '');
	elm.setAttribute('id', 'nome');

	
	elmB = document.createElement('input');	
	elmB.setAttribute('type', 'text');
	elmB.setAttribute('size', '20');
	elmB.setAttribute('name', '');
	elmB.setAttribute('id', 'email');
	
	
	elmB.setAttribute('onblur', 'checkSendEmail(this.form)');
	elmB.setAttribute('onkeyup', 'checkSendEmail(this.form)');
	
	elmD = document.createElement('input');	
	elmD.setAttribute('type', 'text');
	elmD.setAttribute('size', '15');
	elmD.setAttribute('maxlength', '11');
	elmD.setAttribute('name', '');
	elmD.setAttribute('id', 'cpf');
	elmD.setAttribute('onblur',  'checkSendEmail(this.form)');
	elmD.setAttribute('onkeyup', "checkSendEmail(this.form)");
		
	elmC = document.createElement('input');	
	elmC.setAttribute('type', 'checkbox');
	elmC.setAttribute('name', '');
	elmC.setAttribute('id', 'enviar_email');

	elmC.setAttribute('id',    'send_email');

	elmC.setAttribute('disabled', 'true');
	elmC.setAttribute('value', '1');	
	
	elmE = document.createElement('a');	
	elmE.setAttribute('href', 'javascript:;');
	elmE.setAttribute('onclick', 'deleteParentRow(this)');	
	
	table  = document.createElement("TABLE");
	tbody  = document.createElement("TBODY");
	newbr  = document.createElement("BR");
	tr     = document.createElement("TR");
	td     = document.createElement("TD");	
	
	nome  = document.createTextNode(' Nome:');
	email = document.createTextNode(' Email:');
	cpf   = document.createTextNode(' ou CPF:');
	send  = document.createTextNode('  Enviar por e-mail');
	textDelete  = document.createTextNode('Delete');

	linha = newArea.appendChild(tr);	
	novaColuna1 = linha.appendChild(td);
	novaColuna1.appendChild(nome);
	novaColuna1.appendChild(elm);
	
	novaColuna2 = linha.appendChild(td);
	novaColuna2.appendChild(email);
	novaColuna2.appendChild(elmB);
	
	novaColuna3 = linha.appendChild(td);
	novaColuna3.appendChild(cpf);
	novaColuna3.appendChild(elmD);
		
	novaColuna3 = linha.appendChild(td);
	novaColuna3.appendChild(elmC);
	novaColuna3.appendChild(send);
	
	novaColuna3 = linha.appendChild(td);

	aux = novaColuna3.innerHTML
	novaColuna3.innerHTML = aux+"&nbsp;&nbsp;&nbsp;&nbsp;";
	
	elmE.appendChild(textDelete);
	novaColuna3.appendChild(elmE);
	
	inputs = document.getElementsByTagName('input');	
	aux = false;
	for(x=0;x<inputs.length;x++){				
		if(inputs[x].id.search('cpf') >= 0 && inputs[x].name==''){
			inputs[x].name = 'cpf['+ g +']';
		}else if(inputs[x].id.search('nome') >= 0  && inputs[x].name==''){
			inputs[x].name = 'nome['+ g +']';
		}else if((inputs[x].id.search('enviar_email') >= 0 || inputs[x].id.search('send_email') >= 0) && inputs[x].name==''){
			inputs[x].name = 'enviar_email['+ g +']';
		}else if(inputs[x].id.search('email')  >= 0 && inputs[x].name==''){
			inputs[x].name = 'email['+ g +']';
		}
	}		
}
//esta função foi substituída pela função acima. Mas mantenho para evitar que ela esteja sendo usada em outro lugar que não é do meu conhecimento.
function addArea() {
	var newArea = document.getElementById('area');
		
	elm = document.createElement('input');	
	elm.setAttribute('type', 'text');
	elm.setAttribute('size', '20');
	elm.setAttribute('name', '');
	
	elmB = document.createElement('input');	
	elmB.setAttribute('type', 'text');
	elmB.setAttribute('size', '20');
	elmB.setAttribute('name', '');

	elmB.setAttribute('onblur', 'checkSendEmail(this.form)');
	
	elmD = document.createElement('input');	
	elmD.setAttribute('type', 'text');
	elmD.setAttribute('size', '15');
	elmD.setAttribute('maxlength', '11');
	elmD.setAttribute('name', '');
	
	elmD.setAttribute('onblur', 'checkSendEmail(this.form)');
		
	elmC = document.createElement('input');	
	elmC.setAttribute('type', 'checkbox');
	elmC.setAttribute('name', '');
//	elmC.setAttribute("checked", "checked");
	elmC.setAttribute('id',    'send_email');
	elmC.setAttribute('value', '1');

	table  = document.createElement("TABLE");
	tbody  = document.createElement("TBODY");
	newbr  = document.createElement("BR");
	tr     = document.createElement("TR");
	td     = document.createElement("TD");	
	
	nome  = document.createTextNode(' Nome:');
	email = document.createTextNode(' Email:');
	cpf   = document.createTextNode(' CPF:');
	send  = document.createTextNode('  Enviar por e-mail');

	newArea.appendChild(newbr);	
	
	newArea.appendChild( nome  );
	newArea.appendChild( newbr );
	newArea.appendChild( elm   );

	newArea.appendChild( email );
	newArea.appendChild( newbr );
	newArea.appendChild( elmB  );

	newArea.appendChild( cpf );
	newArea.appendChild( newbr );
	newArea.appendChild( elmD );

	newArea.appendChild( newbr );
	newArea.appendChild( elmC  );
	newArea.appendChild( send  );
	
	elmC.checked = "checked";
	
	newArea.appendChild(newbr);
}
function previewConvite(form) {
	var str_query = "";

	for (i=0;i<document.forms[1].elements.length;i++) {
		if (document.forms[1].elements[i].name != "undefined" && document.forms[1].elements[i].value != "undefined") {
			if (document.forms[1].elements[i].type != 'radio' || (document.forms[1].elements[i].type == 'radio' && document.forms[1].elements[i].checked)) {
				str_query += '&' + document.forms[1].elements[i].name + '=' + document.forms[1].elements[i].value;
			}
		}
	}

	newWindow = window.open('?popup/previewconvite/' + str_query, '_New', 'width=600,height=500,scrollbars=1');
		
	return false;
}

function setConvite(form) {

	if (!confirm('Você realmente deseja gravar este modelo de carta convite ?')) {
		return false;
	}
	
	var str_query = "";

	for (i=0;i<document.forms[1].elements.length;i++) {
		if (document.forms[1].elements[i].name != "undefined" && document.forms[1].elements[i].value != "undefined") {
			str_query += '&' + document.forms[1].elements[i].name + '=' + document.forms[1].elements[i].value;
		}
	}

	newWindow = window.open('?popup/addconvite/' + str_query, '_New', 'width=600,height=500,scrollbars=1');
	
	return false;	
}


function verificaEmail(mail){
	str = new String(mail);

    if (str.charAt(str.length-1) == ".") {// Ultimo caracter é ponto
    	return false;
    }

 	var arroba = str.indexOf("@",0);

    if (arroba > 0){ // Tem arroba

    	var ponto = str.indexOf(".",arroba);

    	if (ponto > 0){ // Tem ponto

    		if (str.length-1 > ponto){ // Tem algo depois do ponto
    			if ((arroba + 1) != ponto){ // Tem algo entre a arroba e o ponto
    					// É um E-mail !!!
    					return true;
   				}

   				return false;
   			}

   			return false;
    	}
    	return false;
    }

    return false;
}
    
function validaCancelamento()
{

	if (document.getElementById('nome').value == "")
	{
		alert("Por favor, digite seu nome");

		document.getElementById('nome').focus();

		return false;
	}

    if (document.getElementById('empresa').value == "")
	{
		alert("Por favor, digite o nome de sua empresa");

		document.getElementById('empresa').focus();

		return false;
	}

    if (document.getElementById('email').value == ""){

        alert("Por favor, digite seu e-mail");
		document.getElementById('email').focus();

		return false;
    }
    
	if (document.getElementById('telefone').value == "")
	{
		alert("Por favor, digite seu telefone");
		document.getElementById('telefone').focus();

		return false;
	}

    if (document.getElementById('login').value == "")
	{
		alert("Por favor, digite seu login");
		document.getElementById('login').focus();

		return false;
	}

    if (document.getElementById('senha').value == "")
	{
		alert("Por favor, digite sua senha");

		document.getElementById('senha').focus();

		return false;
	}
	
	if  (document.getElementById('grau_satisfacao').value == '') 
	{
		alert("Por favor, selecione o grau de satisfação");

		document.getElementById('grau_satisfacao').focus();

		return false;
	}

	var motivo = false;
	
	for (var i=0;i<document.forms[0].elements.length;i++) {
     	var x = document.forms[0].elements[i];
     	
     	if (x.name == 'motivo_cancelamento[]' && x.checked) {
     		motivo = true;
     	}
    }

	if (motivo == false && document.getElementById('motivo_outros').value == '') 
	{
		alert("Por favor, escolha um motivo do cancelamento");

		return false;
	}
	
	var	recomendado = false;	
	for (i=0;i<document.forms[0].recomendaria.length;i++) 
	{
		if (document.forms[0].recomendaria[i].checked) {
			recomendado = true;
		}
	}
	
	if (recomendado == false) {
		alert("Por favor, a pergunta se você recomendaria este serviço não foi respondida");

		return false;
	}

	var	autorizado = false;	
	for (i=0;i<document.forms[0].autoriza.length;i++) 
	{
		if (document.forms[0].autoriza[i].checked) {
			autorizado = true;
		}
	}
	
	if (autorizado == false) {	
		alert("Por favor,  a pergunta se você autoriza a divulgação dos dados não foi respondida");

		return false;
	}
	
	return true;
}


function aceitaNumeros(e){

    if (event.keyCode == 13) {

        return;

    }

    

    if (event.keyCode < 48 || event.keyCode > 57) {

        event.returnValue = false;

    }

}



function f_verifica(xobj)

{

	if (xobj.nome.value == "")

	{

		alert("Por favor, digite seu NOME");

		xobj.nome.focus();

		return false;

	}



	function verificaEmail(mail){

    	str = new String(mail);

        

        if (str.charAt(str.length-1) == '.') {// Ultimo caracter é ponto

            return false;

        }

        

    	var arroba = str.indexOf('@',0);

    	if (arroba > 0){ // Tem arroba

    		var ponto = str.indexOf('.',arroba);

    		if (ponto > 0){ // Tem ponto

    			if (str.length-1 > ponto){ // Tem algo depois do ponto

    				if ((arroba + 1) != ponto){ // Tem algo entre a arroba e o ponto

    					// É um E-mail !!!

    					return true;

    				}

    				return false;

    			}

    			return false;

    		}

    		return false;

    	}

    	return false;

    }

    if (xobj.email.value == "") {
        alert("Por favor, digite seu E-MAIL");
		xobj.email.focus();
		
		return false;

    } else {
        if (!verificaEmail(xobj.email.value)) {
            alert("Por favor, digite seu E-MAIL corretamente");

    		xobj.email.focus();

    		return false;
        }
    }

	

    if (xobj.ddd.value == "")
	{
		alert("Por favor, digite o DDD do seu Telefone");

		xobj.ddd.focus();

		return false;
	}

	if (xobj.telefone.value == "")
	{
		alert("Por favor, digite seu TELEFONE");

		xobj.telefone.focus();

		return false;
	}

		

	if (xobj.empresa.value == "")

	{

		alert("Por favor, digite o nome da EMPRESA");

		xobj.empresa.focus();

		return false;

	}

	

	if (xobj.cargo.value == "")
	{
		alert("Por favor, selecione o CARGO");

		xobj.cargo.focus();

		return false;
	}		



	if (xobj.assunto.value == "")
	{
		alert("Por favor, selecione o ASSUNTO de sua mensagem");

		xobj.assunto.focus();

		return false;
	}		

	if (xobj.mensagem.value == "")
	{
		alert("Por favor, escreva sua MENSAGEM");

		xobj.mensagem.focus();

		return false;
	}	
}

function check_submit(field, msg) {
	if (document.getElementById(field).value == "") {
		alert(msg);
		document.getElementById(field).focus();
		
		return false;
	} 
	else 
	{
		document.forms[0].submit();
	}
}

function check_extrato_form(activate)
{
	if (activate == 'periodo') {
		document.forms[0].busca_mes.disabled     = true;
		document.forms[0].busca_periodo.disabled = false;
	} else {
		document.forms[0].busca_mes.disabled     = false;
		document.forms[0].busca_periodo.disabled = true;
	}
}

function criarGrupo(frm, location)
{
	var x = 0;
	
	for(i=0;i<frm.length;i++) {
		if (frm[i].type == 'checkbox' && frm[i].checked == true) {
			x++;
		}
	}
	
	if (x == 0) {
		alert('É necessário selecionar ao menos um usuário para criar um novo processo');
		return false;
	}
	
	frm.action = location;	
	return true;
}

function enviaComunicado(frm, location)
{
	var x = 0;
	
	for(i=0;i<frm.length;i++) {
		if (frm[i].type == 'checkbox' && frm[i].checked == true) {
			x++;
		}
	}
	
	if (x == 0) {
		alert('É necessário selecionar ao menos um usuário para enviar comunicado');
		return false;
	}

	frm.action = location;

	newWindow = window.open(location, '_Comunicado', 'width=600,height=350,scrollbars=1');
	frm.target = '_Comunicado';
	frm.submit();

	return false;
}

function gravarComunicado(frm, job_id) 
{
	frm.action = '?popup/gravarcomunicado/&job_id=' + job_id;

	frm.submit();
}

function validateTest(frm)
{
	var x = 0;
	
	for(i=0;i<frm.length;i++)
	{
		if (frm.elements[i].type == 'checkbox' && frm.elements[i].checked == true) {
			x++;
		}
	}
	
	if(document.getElementById("atv").checked && frm.salario.value == 0){
		alert('Selecione a faixa salarial');
		return false;
	}
	
	if (x == 0) {
		alert('Selecione pelo menos um teste para continuar');
		return false;
	} else {
		frm.submit();
	}
}

function validateImport()
{
	if (document.getElementById('arquivo').value == '') {
		alert('Você deve especificar um arquivo para ser importado');
		return false;
	}
	
	var strFile = document.getElementById('arquivo').value ;
			
	if(strFile){
		var numPositionDot = strFile.lastIndexOf('.');
		var strExtension = strFile.substr(numPositionDot);

		if (strExtension != '.csv' && strExtension != '.CSV'){
			alert('Somente é permitido fazer upload de arquivo com extensão csv\nPor favor tente novamente.');
			return false;
		}
	}
	
	return true;
}
function verificaEmail(mail){
	str = new String(mail);
	
	if (str.charAt(str.length-1) == '.') {// Ultimo caracter é ponto
		return false;
	}
	
	var arroba = str.indexOf('@',0);
	if (arroba > 0){ // Tem arroba
		var ponto = str.indexOf('.',arroba);
		if (ponto > 0){ // Tem ponto
			if (str.length-1 > ponto){ // Tem algo depois do ponto
				if ((arroba + 1) != ponto){ // Tem algo entre a arroba e o ponto
					// É um E-mail !!!
					return true;
				}
				return false;
			}
			return false;
		}
		return false;
	}
	return false;
}
function verificaEmailObj(mail){
	if(mail.value == ""){return true;}	
	
	str = new String(mail);	
	if (str.charAt(str.length-1) == '.') {// Ultimo caracter é ponto
		return false;
	}
	
	var arroba = str.indexOf('@',0);
	if (arroba > 0){ // Tem arroba
		var ponto = str.indexOf('.',arroba);
		if (ponto > 0){ // Tem ponto
			if (str.length-1 > ponto){ // Tem algo depois do ponto
				if ((arroba + 1) != ponto){ // Tem algo entre a arroba e o ponto
					// É um E-mail !!!
					return true;
				}
				alert('Por favor digite um email valido.');
				return false;
			}
			alert('Por favor digite um email valido.');
			return false;
		}
		alert('Por favor digite um email valido.');
		return false;
	}
	alert('Por favor digite um email valido.');
	return false;
}

function validateAddUserForm(form_index)
{
	if (form_index != 0) {
		form_index = 2;
	}


	var current_cpf;
	var frm = document.forms[form_index];	
	var strNome = "";
	for(i=0;i<frm.length;i++){
		if (frm.elements[i].name.search("nome\\[([0-9]{0,100})\\]") >= 0) {
			strNome = frm.elements[i].value;
			while(strNome.search(" ") >= 0)
				strNome = strNome.replace(" ", "");
		}

		if (frm.elements[i].name.search("nome\\[([0-9]{0,100})\\]") >= 0 && strNome.length < 2) {			
			alert('É necessário preencher o nome de todos os candidatos');			
			return false;
		}else{ 

			if (frm.elements[i].name.search("^email\\[([0-9]{0,100})\\]") >= 0 && frm.elements[i].value == '' &&
				frm.elements[i+1] && frm.elements[i+1].name.search("cpf\\[([0-9]{0,100})\\]") >= 0 && frm.elements[i+1].value == '') {
					alert('É necessário especificar email ou CPF para todos os candidatos.');				
					return false;
			}else{
				if (frm.elements[i+1] && frm.elements[i+1].name.search("^email\\[([0-9]{0,100})\\]") >= 0 && frm.elements[i+1].value != '') {
					current_email = frm.elements[i+1].value;

					if (verificaEmail(current_email)) {
						
					} else {
						alert('O Email especificado não é válido.');
						frm.elements[i+1].focus();
						return false;					
					}
				}
				
				/*if (frm.elements[i+2].name == 'cpf[]' && frm.elements[i+2].value != '') {
					current_cpf = frm.elements[i+2].value;
		
					if (validacpf(current_cpf)) {
					} else {
						alert('O CPF especificado não é válido\nDigite somente números');
						return false;
							
					}
				}*/
			}
		}
	}

	return true;	
}

function validaBusca()
{
	if (document.getElementById('job_id').value == '') {
		alert('Selecione o processo que deseja visualizar.');
		
		return false;
	}
	
	return true;
}

function validateStepOne()
{
	if (document.getElementById('processo').checked == false && document.getElementById('processo_avaliacao').checked == false)
	{
		alert('Você deve especificar qual o tipo de processo.');
		return false;
	}

	if (document.getElementById('nome_processo').value == '') 
	{
		alert('Você deve especificar o nome do processo seletivo.');
		document.getElementById('nome_processo').focus();

		return false;
	}
	
	return validateAddUserForm(0);
}

function mudarPagina(pagina, valor, tipo , order_field , order_direction , viewall){
	if(viewall != undefined)
		viewall = "&viewall="+viewall;
	else
		viewall="";
		
	if(order_field !=   undefined && order_direction !=   undefined){
		strOrder ="&order_field="+order_field+"&order_direction="+order_direction; 	
	}else{
		strOrder="";
	}
	window.location = '?assinante/findcandidate/&page=' + pagina + '&' + tipo + '=' + valor + '&tipo_busca=' + tipo +strOrder+viewall;
}

function showBenchmark(link)
{
	newWindow = window.open(link, '_TableBench', 'width=800,height=600,scrollbars=1,resizable');
	
	return false;
}

function finalizaProcesso(job_id)
{
	if (confirm('Deseja realmente finalizar o processo ?')) {
		window.location.href = '?assinante/finalizarprocesso/&job_id=' + job_id;
		
		return true;
	}
	
	return false;
}

function openATV(link)
{
	newWindow = window.open(link, '_ATV', 'width=400,height=480,scrollbars=1');

	return false;
}

function validaNome(tipo_processo) 
{
	// se a radio mostrar nome da empresa for definida como aberto
	if (document.getElementsByName("confidencial")[0].value == "0" && document.getElementById('empresa').value == '') {
		alert('Você deve preencher o nome da empresa para continuar.');

		document.getElementById('empresa').style.backgroundColor = "#E5EEE5";
		document.getElementById('empresa').focus();
		
    	return false;
	}

	if (tipo_processo == 'seletivo') {
	    if (document.getElementById('nome_vaga').value == '') {
	    	alert('Você deve preencher o nome da vaga para continuar.');

	    	return false;
	    }
	}
	
	if (tipo_processo == '') {
	    alert('Verifique as etapas anteriores antes de continuar');

	    return false;
	}
	
	if (document.getElementById('assunto').value == '') {
		alert('Você deve preencher o assunto para continuar.');
		
		return false;
	}
	
	if (document.getElementById('nome').value == '') {
		alert('Você deve preencher o campo seu nome para continuar.');
		
		return false;		
	}
	
	if(document.getElementById("convite").value.length < 2){
		alert("Você deve preencher o campo Texto personalizando com as informações que achar necessárias.");
		return(false);
	}
	
	return true;
}

function setLetter(letter_selected)
{
	var msg = '';

	switch(letter_selected) {
		case '0':
			//msg += 'Prezado(a) senhor(a),\n\n';
			msg += 'Gostaríamos de convidá-lo(a) para responder  o(s) questionário(s) a seguir como parte de processo seletivo para uma posição que acreditamos se enquadrar ao seu perfil profissional.\n\n';
			msg += 'O preenchimento desse(s) questionário(s) o(a) incluirá automaticamente no processo seletivo, e fazemos votos de que você seja o(a) escolhido(a).\n\n';
			//msg += 'Atenciosamente,\n';

			break;
		case '1':
			//msg += 'Prezado(a) senhor(a),\n\n';
			msg += 'Gostaríamos de convidá-lo(a) para responder  o(s) questionário(s) a seguir como parte do processo de avaliação interna.\n\n';
			msg += 'O preenchimento desse(s) questionário(s) são parte integrante desse, sendo assim, gostaria de incentivá-lo(a) a responder para podermos dar continuidade ao processo.\n\n';
			//msg += 'Atenciosamente,\n';

			break;		
		case '2':
			//msg += 'Prezado(a) senhor(a),\n\n';
			msg += 'Gostaríamos de convidá-lo(a) para responder  o(s) questionário(s) a seguir como parte do processo de avaliação que está participando.\n\n';
			msg += 'O preenchimento desse(s) questionário(s) são parte integrante desse, por isso é necessário que você separe um tempo para respondê-lo.\n\n';
			//msg += 'Atenciosamente,\n';

			break;		
		case '3':

			//msg += 'Prezado(a) Sr.(a),\n\n';
			msg += 'Você está recebendo novamente o convite para realização do(s) questionário(s) abaixo, que são parte do processo seletivo.\nSendo assim, gostaria de incentivá-lo(a) a responder, para darmos continuidade ao processo.\n\n';
			//msg += 'Atenciosamente,\n';

			break;		
		case '4':
			msg = '';
			
			break;
	}
	
	document.getElementById('convite').innerHTML = msg;
}

function validaComunicado(form)
{
	if (document.getElementById('assunto').value == '') {
		alert('Preencha o campo assunto para continuar');
		document.getElementById('assunto').style.backgroundColor = "#E5EEE5";
		document.getElementById('assunto').focus();

		return false;
	}
	
	if (document.getElementById('gravar_comunicado').checked && document.getElementById('nome_processo').value == '') {
		alert('Preencha o campo título ou desmarque a opção: Desejo gravar o comunicado acima');
		document.getElementById('nome_processo').style.backgroundColor = "#E5EEE5";
		document.getElementById('nome_processo').focus();

		return false;
	}
	
	if(document.getElementById("convite").value.length < 2){
		alert("Você deve preencher o campo Texto personalizando com as informações que achar necessárias.");
		return(false);
	}
	
	
	return true;
}

var atv_values = false;

function unsetATV()
{
	var selected_values = 0;
	
	for(i=0;i<document.forms[0].elements.length;i++) {
		if (document.forms[0].elements[i].type == 'radio' && document.forms[0].elements[i].value == '') {
			selected_values += 1;
		}
	}

	if (selected_values == 0 && atv_values == false) {
		for (x=0;x<window.opener.document.forms[0].elements.length;x++) {
			if (window.opener.document.forms[0].elements[x].name == "teste[]" && window.opener.document.forms[0].elements[x].value == '63' && window.opener.document.forms[0].elements[x].checked == true) {
				window.opener.document.forms[0].elements[x].checked = false;
			}
		}
	}
}

function mostra_salario(){

	if(document.getElementById("atv").checked){
		document.getElementById("salario").style.display = 'block';
	}else{
		document.getElementById("salario").style.display = 'none';
	}
}

function verifica(objthis){
	objTeste = document.getElementsByName('testes[]');
	objapice = document.getElementsByName('apice');
	objapice = objapice[0];
	
	var testechecked = false;
	for(x=0; x<objTeste.length;x++){
		if(objTeste[x].checked == true){
			testechecked = true;
		}
	}
	
	objapice.disabled = testechecked;
	
	if(objthis.value == '75'){
		for(x=0;x<objTeste.length;x++){
			objTeste[x].disabled = objthis.checked;
		}
	}
	
	somaTestes();
}

function somaTestes(){
	objTeste = document.getElementsByName('testes[]');
	objapice = document.getElementsByName('apice');
	objapice = objapice[0];
	var valor_teste = 0;
	
	for(x=0; x<objTeste.length;x++){
		if(objTeste[x].checked == true){
			preco = document.getElementById('teste_preco_' + objTeste[x].value);
			eval('valor_teste = '+preco.innerHTML + " + "  + valor_teste);
		}
	}
	
	/*if(objapice.checked == true){
		preco = document.getElementById('teste_preco_75');
		eval('valor_teste = '+preco.innerHTML + " + "  + valor_teste);
	}*/
	
		preco_total = document.getElementById("pricetotal");
		box_preco_total = document.getElementById("txt_preco_total");

		if(valor_teste > 0){
			preco_total.innerHTML = valor_teste + ",00";
			box_preco_total.style.display = 'block';
		}else{
			preco_total.innerHTML = "0,00";
			box_preco_total.style.display = 'none';
		}

}

function verifica_contratar_tol(){
	objTeste = document.getElementsByName('testes[]');
	//objapice = document.getElementsByName('apice');
	//objapice = objapice[0];
	var testechecked = false;
	
	for(x=0;x<objTeste.length;x++){
		if(objTeste[x].checked == true){
			testechecked = true;
		}
		

		if(objTeste[x].value == '63' && objTeste[x].checked == true){
			if(document.getElementsByName('salario')[0].value == 0){
				alert("Por favor, selecione Faixa Salarial Anual para o \nteste Avaliador de Talentos para Vendas");
				return(false);
			}
		}
	}
	
	if(testechecked == false){
		alert("Por favor, selecione um teste para prosseguir.");
		return(false);
	}
	
	/*if(testechecked == false && objapice.checked == false){
		alert("Por favor, selecione um teste para prosseguir.");
		return(false);
	}else if(testechecked == true && objapice.checked == true){
		alert("Por favor, caso o teste APICE esteja selecionado não selecione nenhum \noutro teste, desmarque os outros teste para prosseguir.");
		return(false);
	}else if(testechecked == false && objapice.checked == true){
		return(confirm("Você selecionou um teste APICE, este teste será realizado isoladamente."));
	}*/
}

