﻿function MibJumpMenu(targ,selObj,restore){
  // Somente muda de página se o atributo value estiver preenchido
  if(selObj.options[selObj.selectedIndex].value!='')
  {
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
  }
}
//******************************************************************************

//******************************************************************************
function new_window(w, h, url)
{
    window.open(url,'_blank','width='+w+',height='+h+',top=30,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,toolbar=no');
}
//******************************************************************************


//******************************************************************************
function new_popup(w, h, url)
{
    window.open(url,'_blank','width='+w+',height='+h+',top=250,left=350,location=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,toolbar=no');
}
//******************************************************************************

//******************************************************************************
function tick() {
  var hours, minutes, seconds, ap;
  var intHours, intMinutes, intSeconds;
  var today;

  today = new Date();

  intHours = today.getHours();
  intMinutes = today.getMinutes();
  intSeconds = today.getSeconds();

  if (intHours == 0) {
     hours = "12:";
     ap = "PM";
  } else if (intHours < 12) {
     hours = intHours+":";
     ap = "AM";
  } else if (intHours == 12) {
     hours = "12:";
     ap = "PM";
  } else {
     intHours = intHours - 12
     hours = intHours + ":";
     ap = "PM";
  }

  if (intMinutes < 10) {
     minutes = "0"+intMinutes+":";
  } else {
     minutes = intMinutes+":";
  }

  if (intSeconds < 10) {
     seconds = "0"+intSeconds+" ";
  } else {
     seconds = intSeconds+" ";
  }

  timeString = hours +  minutes+ seconds + ap;
  Clock.innerHTML = timeString;
  window.setTimeout("tick();", 100);
}
//******************************************************************************
function high(which2){
    theobject=which2
    highlighting=setInterval("highlightit(theobject)",50)
}

function low(which2)
{
    clearInterval(highlighting)

    if (which2.style.MozOpacity)
        which2.style.MozOpacity=10.3
    else if (which2.filters)
        which2.filters.alpha.opacity=50

}

function highlightit(cur2)
{
    if (cur2.style.MozOpacity<1)
        cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
    else if (cur2.filters&&cur2.filters.alpha.opacity<100)
        cur2.filters.alpha.opacity+=10
    else if (window.highlighting)
        clearInterval(highlighting)
}


//*****************************************************************************
// Submit combos
function carrega_combos(object)
{
    frm.submit();
}

function Check_Fields(idioma)
{

    /*
    if (document.frm.email.value == '')
	{
		alert('Campo email é obrigatório!');
        document.frm.email.focus();
		return false;
	}
	else
	{
		if (VerificaEmail(document.frm.email.value) == false)
		{
			alert("O e-mail informado inválido!");
			document.frm.email.focus();
			return false;
		}
	}
    */

    if (document.frm.id_contact.value == '')
    {
		if(idioma==1) {
			alert('El campo Enviar Para es obligatorio!');
		}else if(idioma==2){
			alert('Campo Enviar Para é obrigatório!');
		}else if(idioma==3){
			alert('Field required.');
		}
        document.frm.id_contact.focus();
        return false;
    }

    if (document.frm.message.value == '')
    {
		if(idioma==1) {
			alert('El campo Mensaje es obligatorio!');
		}else if(idioma==2) {
			alert('Campo mensagem é obrigatório!');
		}else if(idioma==3) {
			alert('Field required.');
		}
        document.frm.message.focus();
        return false;
    }
    document.frm.Post.value = 'true';
    document.frm.submit();
}

//-- Valida e-mail
function VerificaEmail(email) {
	if (!email) return false;
	var  BadChars = "*|,\":<>[]{}`\';()&$#% ";
	var  GoodChars = "@.";
	for (var i = 0; i < email.length; i++) {
		if (BadChars.indexOf(email.charAt(i)) != -1) {
			return false;
		}
	}
	for (var i = 0; i < GoodChars.length; i++) {
		if (email.indexOf(GoodChars.charAt(i)) == -1) {
			return false;
		}
	}
 	if (email.indexOf ('@.',0) != -1 || email.indexOf ('.@',0) != -1) {
		return false;
	}
   return true;
}
//--Fim da validao de email

//--valida forum
function ValidaForum()
{
    if (document.frm.nome.value == '')
    {
        alert('Campo nome é obrigatório!');
        document.frm.nome.focus();
        return false;
    }
    if (document.frm.email.value == '')
    {
        alert('Campo e-mail é obrigatório!');
        document.frm.email.focus();
        return false;
    }
    else
    {
        if (VerificaEmail(document.frm.email.value) == false)
        {
            alert("O e-mail informado é inválido!");
            document.frm.email.focus();
            return false;
        }
    }
    if (document.frm.setor.value == '')
    {
        alert("Campo setor é obrigatório!");
        document.frm.setor.focus();
        return false;
    }
    if (document.frm.mensagem.value == '')
    {
        alert('Campo mensagem é obrigatório!');
        document.frm.mensagem.focus();
        return false;
    }

    document.frm.Post.value = 'true';

    document.frm.submit();
}

//--valida formulario da CC de interesse no Media Training (em PortalCCForm.aspx)
function ValidaAndinaForm()
{
if (document.frm.nombre.value == '')
    {
        alert("El campo nombre es obligatorio.");
        document.frm.nombre.focus();
        return false;
    }
    if (document.frm.apellido.value == '')
    {
        alert("El campo apellido es obligatorio.");
        document.frm.apellido.focus();
        return false;
    }
    if (document.frm.empresa.value == '')
    {
        alert("El campo empresa es obligatorio.");
        document.frm.empresa.focus();
        return false;
    }
    if (document.frm.telefono.value == '')
    {
        alert("El campo teléfono es obligatorio.");
        document.frm.telefono.focus();
        return false;
    }
    if (document.frm.email.value == '')
    {
        alert("El campo e-mail es obligatorio.");
        document.frm.email.focus();
        return false;
    }
    if (document.frm.mensaje.value == '')
    {
        alert("El campo mensage es obligatorio.");
        document.frm.mensaje.focus();
        return false;
    }

    document.frm.Post.value = 'true';
    document.frm.submit();
}

function ValidaAndinaFormRegister()
{
if (document.frm.nombre.value == '')
    {
        alert("El campo nombre es obligatorio.");
        document.frm.nombre.focus();
        return false;
    }
    if (document.frm.apellido.value == '')
    {
        alert("El campo apellido es obligatorio.");
        document.frm.apellido.focus();
        return false;
    }
    if (document.frm.empresa.value == '')
    {
        alert("El campo empresa es obligatorio.");
        document.frm.empresa.focus();
        return false;
    }
    if (document.frm.telefono.value == '')
    {
        alert("El campo teléfono es obligatorio.");
        document.frm.telefono.focus();
        return false;
    }
    if (document.frm.email.value == '')
    {
        alert("El campo e-mail es obligatorio.");
        document.frm.email.focus();
        return false;
    }

    document.frm.Post.value = 'true';
    document.frm.submit();

}

//--valida formulario de RH em Andina (em AN_RH_Form.aspx)
function RH_Valid()
{
    if (document.frm.name.value == '')
    {
        alert("El campo nombre es obligatorio.");
        document.frm.name.focus();
        return false;
    }
    if (document.frm.middle_name.value == '' && document.frm.last_name.value == '')
    {
        alert("El campo apellido es obligatorio.");
        document.frm.middle_name.focus();
        return false;
    }
    if (document.frm.rg.value == '')
    {
        alert("El campo documento de identificación es obligatorio.");
        document.frm.rg.focus();
        return false;
    }
    if (document.frm.country.value == '')
    {
        alert("El campo país es obligatorio.");
        document.frm.country.focus();
        return false;
    }
    if (document.frm.city.value == '')
    {
        alert("El campo ciudad de residencia es obligatorio.");
        document.frm.city.focus();
        return false;
    }
    if (document.frm.phone.value == '')
    {
        alert("El campo teléfono es obligatorio.");
        document.frm.phone.focus();
        return false;
    }
    if (document.frm.email.value == '')
    {
        alert("El campo e-mail es obligatorio.");
        document.frm.email.focus();
        return false;
    }
    else
    {
        if (VerificaEmail(document.frm.email.value) == false)
        {
            alert("El campo e-mail es invalido!");
            document.frm.email.focus();
            return false;
        }
    }
    if (document.frm.password.value == '')
    {
        alert("El campo clave es obligatorio.");
        document.frm.password.focus();
        return false;
    }
    if (!document.frm.gender[0].checked && !document.frm.gender[1].checked)
    {
        alert("El campo sexo es obligatorio.");
        return false;
    }
    if (document.frm.place_birth.value == '')
    {
        alert("El campo lugar de nacimiento es obligatorio.");
        document.frm.place_birth.focus();
        return false;
    }
    if (document.frm.day_birth.value == 0)
    {
        alert("El campo fecha de nacimiento es obligatorio.");
        document.frm.day_birth.focus();
        return false;
    }
    if (document.frm.month_birth.value == 0)
    {
        alert("El campo fecha de nacimiento es obligatorio.");
        document.frm.month_birth.focus();
        return false;
    }
    if (document.frm.year_birth.value == 0)
    {
        alert("El campo fecha de nacimiento es obligatorio.");
        document.frm.year_birth.focus();
        return false;
    }
    if (document.frm.nationality.value == '')
    {
        alert("El campo nacionalidad es obligatorio.");
        document.frm.nationality.focus();
        return false;
    }
		document.frm.frmpost.value = 'true';
    document.frm.submit();
}
function carrega_cidades() {
    document.frm.frmpost.value = "country";
    document.frm.submit();
}
function RH_Valid_21()
{
	if(document.form1.school_level.value==0)
	{
		alert("El campo nivel educacional es obligatorio.");
		document.form1.school_level.focus();
		return;
	}

	if(document.form1.month_finished_date.value==0)
	{
		alert("El campo fecha de grado es obligatorio.");
		document.form1.month_finished_date.focus();
		return;
	}

	if(document.form1.year_finished_date.value==0)
	{
		alert("El campo fecha de grado es obligatorio.");
		document.form1.year_finished_date.focus();
		return;
	}
	document.form1.form1_hidden.value = "true";
	document.form1.submit();
}
function RH_Valid_22()
{
	document.form2.submit();
}
function RH_Valid_23()
{
	if(document.frm.profession.value==0)
	{
		alert("El campo profesión es obligatorio.");
		document.frm.profession.focus();
		return;
	}
	document.frm.submit();
}
function RH_Valid_31()
{
	if(document.form1.sector.value==0)
	{
		alert("El campo sector es obligatorio.");
		document.form1.sector.focus();
		return;
	}
	if(document.form1.cargo.value==0)
	{
		alert("El campo cargo es obligatorio.");
		document.form1.cargo.focus();
		return;
	}
	if(document.form1.area.value==0)
	{
		alert("El campo área de trabajo es obligatorio.");
		document.form1.area.focus();
		return;
	}
	if(document.form1.month_begin_date.value==0)
	{
		alert("El campo fecha de ingreso es obligatorio.");
		document.form1.month_begin_date.focus();
		return;
	}
	if(document.form1.year_begin_date.value==0)
	{
		alert("El campo fecha de ingreso es obligatorio.");
		document.form1.year_begin_date.focus();
		return;
	}
	if(document.form1.atual.value=="No") {
		if(document.form1.month_end_date.value==0)
		{
			alert("El campo fecha de retiro es obligatorio.");
			document.form1.month_end_date.focus();
			return;
		}
		if(document.form1.year_end_date.value==0)
		{
			alert("El campo fecha de retiro es obligatorio.");
			document.form1.year_end_date.focus();
			return;
		}
	}
	document.form1.submit();
}
function email_rh()
{
	if(document.email.name_from.value=='')
	{
		alert("El campo nombre es obligatorio.");
		document.email.name_from.focus();
		return;
	}
	if (document.email.mail_from.value == '')
	{
	        alert("El campo e-mail es obligatorio.");
        	document.email.mail_from.focus();
	        return;
	}
	else
	{
        	if (VerificaEmail(document.email.mail_from.value) == false)
	        {
        	    alert("El campo e-mail es invalido!");
	            document.email.mail_from.focus();
        	    return;
	        
		}
	}
	
	if(document.email.name_to.value=='')
	{
		alert("El campo nombre es obligatorio.");
		document.email.name_to.focus();
		return;
	}
	if (document.email.mail_to.value == '')
	{
	        alert("El campo e-mail es obligatorio.");
        	document.email.mail_to.focus();
	        return;
	}
	else
	{
        	if (VerificaEmail(document.email.mail_to.value) == false)
	        {
        	    alert("El campo e-mail es invalido!");
	            document.email.mail_to.focus();
        	    return;
	        
		}
	}
	document.email.submit();
}
function perfil_rh()
{
	if(document.perfil.name.value=='')
	{
		alert("El campo nombre es obligatorio.");
		document.perfil.name.focus();
		return;
	}
	document.perfil.submit();
}
function troca_pais()
{
	document.form_country.submit();
}
function submit_trainee()
{
	document.form2.submit();
}
function adform()
{
	document.form3.submit();
}
function adForm2()
{
	document.frm_trip.submit();
}
function seleciona_faculdade() {
    document.form1.form1_hidden.value = "escola";
		document.form1.submit();
}