// ezzato Javascript funcions
// version: 1.0
// feb 2007

t_nxt=0;
st_nxt=0;
sp_nxt=0;
b_nxt=0;
pc_nxt = 0;

// ---------------------------------------------------------------------------------------
// validation funcions
// ---------------------------------------------------------------------------------------
function verificaLogin()
{   
    if (document.form.id_perfil.value=='')
  	{
		window.alert("Selecione o seu perfil.");
		document.form.id_perfil.focus();
		return false;
  	}
  		
	if (document.form.login.value=='')
  	{
		window.alert("Digite o login.");
		document.form.login.focus();
		return false;
  	}

	if (document.form.senha.value=='')
  	{
		window.alert("Digite a senha.");
		document.form.senha.focus();
		return false;
  	}	
}

function addCurso()
{
    erro = 0;
    if (document.cursos.n_cursoextra.value == '')
    {
        erro = 1;
        window.alert("Selecione o tipo de curso.");
		document.cursos.n_cursoextra.focus();
    }
    else
    {
        if (document.cursos.n_curso.value == '')
        {
            erro = 1;
            window.alert("Digite o nome do curso.");
		    document.cursos.n_curso.focus();
        }
        else
        {
             if (document.cursos.n_data.value == '')
            {
                erro = 1;
                window.alert("Digite a data de conclusão do curso.");
	            document.cursos.n_data.focus();
            }
            else
            {
                if (document.cursos.n_instituicao.value == '')
                {
                    erro = 1;
                    window.alert("Digite o nome da instituição.");
	                document.cursos.n_instituicao.focus();
                }
            }
        }
    }
    if (erro == 0)
    {
        document.cursos.submit();
    }
}


function removeCurso(id)
{
  parent.document.ajuda.location.href='ajuda.asp?act=R&opt=C&id_curso='+id;
}

function addProfissao()
{
    erro = 0;
    if (document.profissao.empresa.value == '')
    {
        erro = 1;
        window.alert("Digite o nome da empresa.");
		document.profissao.empresa.focus();
    }
    else
    {
        if (document.profissao.data_adm.value == '')
        {
            erro = 1;
            window.alert("Digite a data de admissão.");
		    document.profissao.data_adm.focus();
        }
        else
        {
            if (document.profissao.data_dem.value == '')
            {
                erro = 1;
                window.alert("Digite a data de demissão.");
	            document.profissao.data_dem.focus();
            }
            else
            {
                if (document.profissao.funcao.value == '')
                {
                    erro = 1;
                    window.alert("Digite a sua função.");
	                document.profissao.funcao.focus();
                }
                else
                {
                    if (document.profissao.tipoemprego.value == '')
                    {
                        erro = 1;
                        window.alert("Selecione o tipo de emprego.");
	                    document.profissao.tipoemprego.focus();
                    }
                    else
                    {
                         if (document.profissao.atividade.value == '')
                        {
                            erro = 1;
                            window.alert("Digite suas principais atividades.");
	                        document.profissao.atividade.focus();
                        }
                    }
                }
            }
        }
    }
    if (erro == 0)
    {
        document.profissao.submit();
    }
}


function removeProfissao(id)
{
  parent.document.ajuda.location.href='ajuda.asp?act=R&opt=P&id_profissao='+id;
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}

function validaCPF()
{
    len = 11;
    cpf = document.form.cpf.value;
    cpf = cpf.replace(".","");
    cpf = cpf.replace(".","");
    cpf = cpf.replace("-","");
    
    if(cpf.length >= len)
    {  
         if ((cpf == '11111111111') || (cpf == '22222222222') || (cpf == '33333333333') || (cpf == '44444444444') || (cpf == '55555555555') || (cpf == '66666666666') || (cpf == '77777777777') || (cpf == '88888888888') || (cpf == '99999999999') || (cpf == '00000000000'))
         {
            alert("CPF Invalido.") 
            document.form.cpf.value = '';
            return false;
         }
       else
       {  
            var i;       
            s = cpf;       
            var c = s.substr(0,9);       
            var dv = s.substr(9,2);       
            var d1 = 0;       
            for (i = 0; i < 9; i++)       
            {       
                d1 += c.charAt(i)*(10-i); 
            } 
              
            if (d1 == 0)
            { 
                alert("CPF Invalido.") 
                document.form.cpf.value = '';
                return false; 
            } 
              
            d1 = 11 - (d1 % 11); 
            if (d1 > 9) d1 = 0; 
            if (dv.charAt(0) != d1) 
            { 
                alert("CPF Invalido.") 
                document.form.cpf.value = '';
                return false; 
            } 
                  
            d1 *= 2; 
            for (i = 0; i < 9; i++) 
            { 
                d1 += c.charAt(i)*(11-i); 
            } 
              
            d1 = 11 - (d1 % 11); 
            if (d1 > 9) d1 = 0; 
            if (dv.charAt(1) != d1) 
            { 
                alert("CPF Invalido.") 
                document.form.cpf.value = '';
                return false; 
            } 
           
            return true; 
          }
        }  
}

function hasAselection(groupName) 
{ 
    var elms = document.getElementsByName(groupName); 
    for(var k=0, elm;elm=elms[k];k++) 
    if(elm.checked) return true; 
    return false; 
} 



function verificaCurriculo()
{
    if (document.form.nome.value == '')
    {
        window.alert("Digite o seu nome completo.");
		document.form.nome.focus();
		return false;
    }
    
    if (document.form.datanascimento.value == '')
    {
        window.alert("Digite a sua data de nascimento.");
		document.form.datanascimento.focus();
		return false;
    }
    
    //if (document.form.rg.value == '')
    //{
       // window.alert("Digite o seu RG.");
		//document.form.rg.focus();
		//return false;
    ///}
    
    //if (document.form.cpf.value == '')
   // {
       // window.alert("Digite o seu CPF.");
		//document.form.cpf.focus();
		//return false;
    //}
    
    if (document.form.sexo.value == '')
    {
        window.alert("Selecione o seu sexo.");
		document.form.sexo.focus();
		return false;
    }
    
    //if (document.form.estadocivil.value == '')
   // {
       // window.alert("Selecione o seu estado civil.");
		//document.form.estadocivil.focus();
		//return false;
   // }
    
   //if (document.form.naturalidade.value == '')
    //{
       // window.alert("Selecione a sua naturalidade.");
	//	document.form.naturalidade.focus();
	  //  return false;
   // }
    
    //if (document.form.nacionalidade.value == '')
    //{
       // window.alert("Selecione a sua nacionalidade.");
		//document.form.nacionalidade.focus();
		//return false;
   // }
    
    if(! hasAselection('habilitacao') ) 
    { 
        window.alert("Informe se você possui carteira de habilitação.");
   		return false;  
    } 
    
    //if(! hasAselection('reservista') ) 
   // { 
       // window.alert("Informe se você possui certificado de reservista.");
   		//return false;  
   // } 
    
   // if (document.form.pai.value == '')
   // {
       // window.alert("Digite o nome do seu pai.");
		//document.form.pai.focus();
		//return false;
    //}
    
   // if (document.form.mae.value == '')
   // {
       // window.alert("Digite o nome da sua mãe.");
		//document.form.mae.focus();
		//return false;
  //  }
    
   // if (document.form.endereco.value == '')
   // {
       // window.alert("Digite o seu endereço.");
		//document.form.endereco.focus();
		//return false;
   // }
    
    //if (document.form.bairro.value == '')
   // {
      //  window.alert("Digite o bairro do seu endereço.");
		//document.form.bairro.focus();
		//return false;
    //}
    
    if (document.form.zona.value == '')
    {
        window.alert("Selecione a zona do seu endereço.");
		document.form.zona.focus();
		return false;
    }
    
  // if (document.form.municipio.value == '')
   // {
      //  window.alert("Digite o município do seu endereço.");
	//	document.form.municipio.focus();
	//	return false;
   // }
    
   if (document.form.estado.value == '')
    {
        window.alert("Selecione o estado do seu endereço.");
		document.form.estado.focus();
		return false;
    }  
    
  // if (document.form.cep.value == '')
   // {
       //window.alert("Digite o CEP do seu endereço.");
		//document.form.cep.focus();
		//return false;
   // }  
    
     //if (document.form.telefone.value == '')
    //{
       // window.alert("Digite um telefone de contato.");
		//document.form.telefone.focus();
		//return false;
    //}  
    
    if (document.form.areainteresse.value == '')
    {
        window.alert("Selecione a área de interesse.");
		document.form.areainteresse.focus();
		return false;
    } 
    
   // if (document.form.funcao.value == '')
   // {
        //window.alert("Digite a função pretendida.");
		//document.form.funcao.focus();
		//return false;
  //  }  
    
   // if (document.form.ultsalario.value == '')
   // {
     //   window.alert("Digite o valor do seu último salário.");
		//document.form.ultsalario.focus();
		//return false;
   // } 
    
    if (document.form.pretsalario.value == '')
    {
        window.alert("Digite a sua pretensão salarial.");
		document.form.pretsalario.focus();
		return false;
    }
    
   // if (document.form.experiencia.value == '')
    //{
        //window.alert("Digite a sua experiência profissional.");
		//document.form.experiencia.focus();
		//return false;
    //}
    
    if (document.form.s_escolaridade.value == '')    
     {
        window.alert("Selecione a sua escolaridade.");
		document.form.s_escolaridade.focus();
		return false;
    }
    
    if ((document.form.s_escolaridade.value == '4')||(document.form.s_escolaridade.value == '5'))
    {
        if (document.form.s_curso.value == '')
        {
            window.alert("Digite o nome do curso.");
		    document.form.s_curso.focus();
		    return false;
        }
    } 
      
     //if (document.form.s_data.value == '')
   // {
       // window.alert("Digite a data de conclusão do curso.");
		//document.form.s_data.focus();
		//return false;
    //}
    
    // if (document.form.s_instituicao.value == '')
   // {
     //   window.alert("Digite o nome da instituição de ensino.");
	//	document.form.s_instituicao.focus();
	//	return false;
   // }
    
      
   
}


function verificaNomeCurso(escolaridade)
{
     if ((escolaridade == '4')||(escolaridade == '5'))
    {
       document.form.s_curso.disabled = false;
       document.form.s_curso.readOnly = false;
       document.form.s_curso.value = "";
       document.form.s_curso.focus();
		
    }
    else
    {
       document.form.s_curso.disabled = true;
       document.form.s_curso.readOnly = true;  
       document.form.s_curso.value = document.form.s_escolaridade.options[document.form.s_escolaridade.selectedIndex].text ;
    }
}


// ---------------------------------------------------------------------------------------
//  default funcions
// ---------------------------------------------------------------------------------------

function popup(fileName,windowName,windowScrolling,windowWidth,windowHeight) {
	//
	window.open (fileName,windowName,"toolbar=no,left=50,location=no,directories=no,status=no,menubar=no,scrollbars="+windowScrolling+",resizable=no,copyhistory=no,width="+windowWidth+",height="+windowHeight+"");
	//
}

function trace(param) {
	
	alert(param);
	
}

// ---------------------------------------------------------------------------------------
//  specific functions
// ---------------------------------------------------------------------------------------

function showTopMenu(fv_current) {
	
	
	detectFlash( '../flash/topmenu.swf' , '100%' , '168' , '#ffffff' , 'high' , 'opaque' , 'flash_topmenu','fv_current='+fv_current);
	
}

function showSideMenu(fv_current,fv_areas) {
	
	//fv_current = 0;
	//fv_areas = "Hstória;company.htm|Visão;company2.htm|Missão;company3.htm|Nossos Clientes;company_4.htm";
	detectFlash( '../flash/sidemenu.swf' , '100%' , '190' , '#ffffff' , 'high' , 'transparent' , 'flash_side','fv_current='+fv_current+'&fv_areas='+fv_areas);
	
}

function showClients(fv_logos) {
	
	//fv_current = 0;
	//fv_areas = "Hstória;company.htm|Visão;company2.htm|Missão;company3.htm|Nossos Clientes;company_4.htm";
	var fv_logos = "../images/clients/logo1.jpg|../images/clients/logo8.jpg|../images/clients/logo4.jpg|../images/clients/logo5.jpg|../images/clients/logo2.jpg|../images/clients/logo6.jpg|../images/clients/logo7.jpg";
	detectFlash( '../flash/clients.swf' , '500' , '270' , '#ffffff' , 'high' , 'transparent' , 'flash_clients','fv_logos='+fv_logos);
	
}

function splasher(myWidth , myHeight , banners , speed) {

	
	//var banners = "../images/ads/splash01.jpg;page_1_3.asp;Transparência, Qualidade<br>e Agilidade Sempre;r|../images/ads/splash02.jpg;page_1_3.asp;Foco Total no<br>Ponto de Venda;r|../images/ads/splash03.jpg;page_1_3.asp;Excelência em<br>Merchandising;r|../images/ads/splash04.jpg;page_1_3.asp;Equipe Treinada<br>Significa Bons Resultados;r|../images/ads/splash05.jpg;page_1_3.asp;Comprometimento<br>com os Objetivos;c|../images/ads/splash06.jpg;page_1_3.asp;Soluções<br>Personalizadas em RH;l|../images/ads/splash07.jpg;page_1_3.asp;Terceirização Sob Medida<br>Para Cada Cliente;l"
	//var speed = 6 ;// seconds
	//var myWidth = '100%';
	//var myHeight = '170';
	
	detectFlash( '../flash/splasher.swf' , myWidth , myHeight , '#000000' , 'high' , 'opaque' , 'flash_splash'+sp_nxt,'fv_banners='+banners+'&fv_speed='+speed);
	sp_nxt++;
}


function createTittle(tittle_text,tittle_color) {

	var givenName = "flashTit"+t_nxt;
	var myStartWidth = 100;
	var myStartHeight = 42;
	
 	document.writeln('<table width="'+myStartWidth+'" height="'+myStartHeight+'" name="td_'+givenName+'" id="td_'+givenName+'" border="0" cellspacing="0" cellpadding="0"><tr><td>');
	document.writeln('<script>detectFlash( "../flash/title.swf",  width="100%", height="42", "ffffff", "high", "transparent", "'+givenName+'", "objectName='+givenName+'&myTittle='+tittle_text+'&myColor='+tittle_color+'");</script>');
	document.writeln('</td></tr></table>');
	t_nxt++;
	
	
}

function changeObjectSize(object,given_width,given_height) {
	
	if(given_width != undefined) {
		
		//document.getElementById(object).style.width=given_width;
		document.getElementById(object).setAttribute("width", given_width);

	}

	if(given_height != undefined) {
		
		//document.getElementById(object).style.height=given_height;
		document.getElementById(object).setAttribute("height", given_height);
		
	}	
	
}

// ---------------------------------------------------------------------------------------
//  fireworks over behaviors
// ---------------------------------------------------------------------------------------


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



// ---------------------------------------------------------------------------------------
// flash detect
// ---------------------------------------------------------------------------------------


// initialize global variables

var detectableWithVB = false;
var pluginFound = false;
var MinimalVersion= 8;

// functions

function redirectCheck(pluginVersion, pluginFound, SWF_NAME, SWF_WIDTH, SWF_HEIGHT, SWF_BGCOLOR, SWF_QUALITY, SWF_WMODE, SWF_ID, SWF_VARS) {
	
	if( pluginFound ) {
		// Verify version
		if(pluginVersion >= MinimalVersion) {

			var myVars = SWF_VARS+"&object_id="+SWF_ID;

			document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" VIEWASTEXT id='+SWF_ID+' name='+SWF_ID+' width="'+ SWF_WIDTH +'" height="'+ SWF_HEIGHT +'" wmode="'+SWF_WMODE+' swLiveConnect="TRUE" showMenu="false">');
			document.writeln('<PARAM NAME=movie VALUE="'+SWF_NAME+'" >');
			document.writeln('<PARAM NAME=FlashVars VALUE="'+myVars+'">');
			document.writeln('<PARAM NAME=quality VALUE="'+SWF_QUALITY+'">');
			document.writeln('<PARAM NAME="wmode" VALUE="'+SWF_WMODE+'" >');
			document.writeln('<PARAM NAME="showMenu" VALUE="false">');
			document.writeln('<PARAM NAME="bgcolor" value="'+SWF_BGCOLOR+'">'); 
			document.writeln('<EMBED src="' + SWF_NAME + '" showMenu="false" name="'+SWF_ID+'" FlashVars="'+myVars+'" swLiveConnect="TRUE" width="'+ SWF_WIDTH +'" height="'+ SWF_HEIGHT +'" type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" bgcolor="' + SWF_BGCOLOR + '" quality="' + SWF_QUALITY + '" wmode="'+SWF_WMODE+'"></EMBED>');
			document.writeln('</OBJECT>');
			
		} else {

			noFlashFound();
		}
		
    } else {

		noFlashFound();
    }	
}

function detectFlash( SWF_NAME, SWF_WIDTH, SWF_HEIGHT, SWF_BGCOLOR, SWF_QUALITY, SWF_WMODE, SWF_ID, SWF_VARS) {
    pluginFound = detectPlugin('Shockwave','Flash'); 

    // if not found, try to detect with VisualBasic
    if( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.' + versionFlash() );
    }
	pluginVersion = versionFlash();
    // check for redirection
    return redirectCheck(pluginVersion, pluginFound, SWF_NAME, SWF_WIDTH, SWF_HEIGHT, SWF_BGCOLOR, SWF_QUALITY, SWF_WMODE, SWF_ID, SWF_VARS);
}

function versionFlash() {
	var sAux = 8;
	
	for( i = 10; i > 2; i-- ) {
		
		pluginFound = detectPlugin('Shockwave Flash ' + i); 		
		// if not found, try to detect with VisualBasic
		if(!pluginFound && detectableWithVB) {
			pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.' + i);
		}
		if ( pluginFound ) {
			sAux = i;
			break;
		}
	}
	
	return sAux;
}

function detectPlugin() {

    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;

    // consider pluginFound to be false until proven true
    var pluginFound = false;

    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
	
		// for each plugin...
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	
			// loop through all desired names and check each against the current plugin name
			var numFound = 0;
			for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
			
				// if desired plugin name is found in either plugin name or description
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
					(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					// this name was found
					numFound++;
				}   
			}
	
			// now that we have checked all the required names against this one plugin,
			// if the number we found matches the total number provided then we were successful
			if(numFound == daPlugins.length) {
				pluginFound = true;
				// if we've found the plugin, we can stop looking through at the rest of the plugins
				break;
			}
		}
    }
    
    return pluginFound;
    
} // detectPlugin

// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}

function noFlashFound() {
	
		document.write('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" >'
  + '  <tr>'
  + '    <td align="center" valign="middle"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="../images/noflash.jpg"  border="0"></a></td>'
  + '  </tr>'
  + '</table>');
}



