function validaString(campo, largoMinimo, largoMaximo, nombre)
{
	if (largoMinimo > 0)
        {
                if (campo.value.length < largoMinimo)
                {
                        alert("Escriba por lo menos " + largoMinimo + " caracteres en el campo \"" + nombre  +"\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        return(false);
                }
        }
        if (largoMaximo > 0)
        {
                if (campo.value.length > largoMaximo)
                {
                        alert("El campo \"" + nombre + "\" debe contener " + largoMaximo + " carateres como máximo.");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        return(false);
                }
        }
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ01234567890. \t\r\n\f";
        for (i = 0;  i < campo.value.length;  i++)
        {
                ch = campo.value.charAt(i);
                for (j = 0;  j < checkOK.length;  j++)
                {
                        if (ch == checkOK.charAt(j))
                        {
                                break;
                        }
                }
                if (j == checkOK.length)
                {
			alert("Escriba sólo letras, números, espacios en blanco y \".\" en el campo \"" + nombre + "\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        setTimeout('document.getElementById("' + campo.id + '").select();', 1);
                        return(false);
                }
        }
        return(true);
}

function validaMail(campo, largoMinimo, largoMaximo, nombre)
{
	if (largoMinimo > 0)
        {
                if (campo.value.length < largoMinimo)
                {
                        alert("Escriba por lo menos " + largoMinimo + " caracteres en el campo \"" + nombre  +"\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        return(false);
                }
        }
        if (largoMaximo > 0)
        {
                if (campo.value.length > largoMaximo)
                {
                        alert("El campo \"" + nombre + "\" debe contener " + largoMaximo + " carateres como máximo.");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        return(false);
                }
        }
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@.-_";
        for (i = 0;  i < campo.value.length;  i++)
        {
                ch = campo.value.charAt(i);
                for (j = 0;  j < checkOK.length;  j++)
                {
                        if (ch == checkOK.charAt(j))
                        {
                                break;
                        }
                }
                if (j == checkOK.length)
                {
			alert("Escriba sólo letras, números, \"@\", \"-\", \"_\" y \".\" en el campo \"" + nombre + "\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        setTimeout('document.getElementById("' + campo.id + '").select();', 1);
                        return(false);
                }
        }
        return(true);
}

function validaNumero(campo, largoMinimo, largoMaximo, nombre)
{
	if (largoMinimo > 0)
        {
                if (campo.value.length < largoMinimo)
                {
                        alert("Escriba por lo menos " + largoMinimo + " caracteres en el campo \"" + nombre  +"\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        return(false);
                }
        }
        if (largoMaximo > 0)
        {
                if (campo.value.length > largoMaximo)
                {
                        alert("El campo \"" + nombre + "\" debe contener " + largoMaximo + " carateres como máximo.");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        return(false);
                }
        }
        var checkOK = "0123456789";
        for (i = 0;  i < campo.value.length;  i++)
        {
                ch = campo.value.charAt(i);
                for (j = 0;  j < checkOK.length;  j++)
                {
                        if (ch == checkOK.charAt(j))
                        {
                                break;
                        }
                }
                if (j == checkOK.length)
                {
                        alert("Ingrese solo números en el campo \"" + nombre + "\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        setTimeout('document.getElementById("' + campo.id + '").select();', 1);
                        return(false);
                }
        }
        return(true);
}

function validaFecha(campo, largoMinimo, largoMaximo, nombre)
{
	if (largoMinimo > 0)
	{
		if (campo.value.length < largoMinimo)
		{
			alert("Escriba por lo menos " + largoMinimo + " caracteres en el campo \"" + nombre  +"\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
			return(false);
		}
	}
	if (largoMaximo > 0)
	{
		if (campo.value.length > largoMaximo)
		{
			alert("El campo \"" + nombre + "\" debe contener " + largoMaximo + " carateres como máximo.");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
			return(false);
		}
	}
	var checkOK = "0123456789/-";
	for (i = 0;  i < campo.value.length;  i++)
	{
		ch = campo.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
			if (ch == checkOK.charAt(j))
			{
				break;
			}
		}
		if (j == checkOK.length)
		{
			alert("Ingrese solo números, \"-\" y \"/\" en el campo \"" + nombre + "\".");
                        setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                        setTimeout('document.getElementById("' + campo.id + '").select();', 1);
			return(false);
		}
	}
	return(true);
}

function verificarCursos()
{
	curso1 = document.getElementById('pled_curso_1');
	curso2 = document.getElementById('pled_curso_2');
	curso3 = document.getElementById('pled_curso_3');
	curso4 = document.getElementById('pled_curso_4');
	curso5 = document.getElementById('pled_curso_5');
	curso6 = document.getElementById('pled_curso_6');
	curso7 = document.getElementById('pled_curso_7');
	curso8 = document.getElementById('pled_curso_8');
	curso9 = document.getElementById('pled_curso_9');
	curso10 = document.getElementById('pled_curso_10');

	disabledCurso2 = true;
	disabledCurso3 = true;
	disabledCurso4 = true;
	disabledCurso5 = true;
	disabledCurso6 = true;
	disabledCurso7 = true;
	disabledCurso8 = true;
	disabledCurso9 = true;
	disabledCurso10 = true;

	if ((curso1) && (curso1.selectedIndex > 0) && (curso2))
	{
		disabledCurso2 = false;
		if ((curso2.selectedIndex > 0) && (curso3))
		{
			disabledCurso3 = false;
			if ((curso3.selectedIndex > 0) && (curso4))
			{
				disabledCurso4 = false;
				if ((curso4.selectedIndex > 0) && (curso5))
				{
					disabledCurso5 = false;
					if ((curso5.selectedIndex > 0) && (curso6))
					{
						disabledCurso6 = false;
						if ((curso6.selectedIndex > 0) && (curso7))
						{
							disabledCurso7 = false;
							if ((curso7.selectedIndex > 0) && (curso8))
							{
								disabledCurso8 = false;
								if ((curso8.selectedIndex > 0) && (curso9))
								{
									disabledCurso9 = false;
									if ((curso9.selectedIndex > 0) && (curso10))
									{
										disabledCurso10 = false;
									}
								}
							}
						}
					}
				}
			}
		}
	}

	if (curso2) curso2.disabled = disabledCurso2;
	if (curso3) curso3.disabled = disabledCurso3;
	if (curso4) curso4.disabled = disabledCurso4;
	if (curso5) curso5.disabled = disabledCurso5;
	if (curso6) curso6.disabled = disabledCurso6;
	if (curso7) curso7.disabled = disabledCurso7;
	if (curso8) curso8.disabled = disabledCurso8;
	if (curso9) curso9.disabled = disabledCurso9;
	if (curso10) curso10.disabled = disabledCurso10;
	return(true);
}

function verificarCCC()
{
	radioMiembroCCC = document.form_pled.pled_miembro_ccc;
	radioBecario = document.form_pled.pled_becario;
	selectDepartamento = document.getElementById('pled_beca_departamento');

	disabledRadioBecario = true;
	disabledSelectDepartamento = true;
	
	if ((radioMiembroCCC) && (radioMiembroCCC[0]) && (radioMiembroCCC[0].checked))
	{
		disabledRadioBecario = false;
		if ((radioBecario) && (radioBecario[0]) && (radioBecario[0].checked))
		{
			disabledSelectDepartamento = false;
		}
	}

	if (radioBecario)
	{
		radioBecario[0].disabled = disabledRadioBecario;
		radioBecario[1].disabled = disabledRadioBecario;
	}
	if (selectDepartamento) selectDepartamento.disabled = disabledSelectDepartamento;
	return(true);
}

function verificarBeca()
{
	radioBeca = document.form_pled.pled_beca;
	textareaFundamentos = document.getElementById('pled_beca_fundamentos');
	inputBecaInstitucion = document.getElementById('pled_beca_institucion');

	disabledTextareaFundamentos = true;
	disabledInputBecaInstitucion = true;

	if ((radioBeca) && (radioBeca[0]) && (radioBeca[0].checked))
	{
		disabledTextareaFundamentos = false;
		disabledInputBecaInstitucion = false;
	}

	if (textareaFundamentos) textareaFundamentos.disabled = disabledTextareaFundamentos;
	if (inputBecaInstitucion) inputBecaInstitucion.disabled = disabledInputBecaInstitucion;
	return(true);
}
