function deshabilita_tres(campo1, campo2, campo3, seleccionador)
{
	if (seleccionador == 1)
	{
		if (campo1.selectedIndex == 0)
		{
			campo2.disabled = false;
			campo3.disabled = false;
		}
		else
		{
			campo2.disabled = true;
			campo3.disabled = true;
		}
	}
	else if (seleccionador == 2)
        {
                if (campo2.selectedIndex == 0)
                {
                        campo1.disabled = false;
                        campo3.disabled = false;
                }
                else
                {
                        campo1.disabled = true;
                        campo3.disabled = true;
                }
        }
	else if (seleccionador == 3)
        {
                if (campo3.selectedIndex == 0)
                {
                        campo1.disabled = false;
                        campo2.disabled = false;
                }
                else
                {
                        campo1.disabled = true;
                        campo2.disabled = true;
                }
        }
	return(true);
}

function deshabilita_cuatro(campo1, campo2, campo3, campo4, seleccionador)
{
        if (seleccionador == 1)
        {
                if (campo1.selectedIndex == 0)
                {
                        campo2.disabled = false;
                        campo3.disabled = false;
			campo4.disabled = false;
                }
                else
                {
                        campo2.disabled = true;
                        campo3.disabled = true;
                        campo4.disabled = true;
                }
        }
        else if (seleccionador == 2)
        {
                if (campo2.selectedIndex == 0)
                {
                        campo1.disabled = false;
                        campo3.disabled = false;
			campo4.disabled = false;
                }
                else
                {
                        campo1.disabled = true;
                        campo3.disabled = true;
                        campo4.disabled = true;
                }
        }
        else if (seleccionador == 3)
        {
                if (campo3.selectedIndex == 0)
                {
                        campo1.disabled = false;
                        campo2.disabled = false;
			campo4.disabled = false;
                }
                else
                {
                        campo1.disabled = true;
                        campo2.disabled = true;
                        campo4.disabled = true;
                }
        }
        else if (seleccionador == 4)
        {
                if (!campo4.checked)
                {
                        campo1.disabled = false;
                        campo2.disabled = false;
			campo3.disabled = false;
                }
                else
                {
                        campo1.disabled = true;
                        campo2.disabled = true;
                        campo3.disabled = true;
                }
        }
        return(true);
}

function validaProductos(campo1, campo2, campo3)
{
	if ((campo1.selectedIndex == 0) && (campo2.selectedIndex == 0) && (campo3.selectedIndex == 0))
	{
		alert("Debe seleccionar un Producto");
                setTimeout('document.getElementById("' + campo1.id + '").focus();', 1);
		return(false);
	} else {
		return(true);
	}
}

function validaProductosYServicios(campo1, campo2, campo3, campo4)
{
	if ((campo1.selectedIndex == 0) && (campo2.selectedIndex == 0) && (campo3.selectedIndex == 0) && (!campo4.checked))
	{
		alert("Debe seleccionar un Producto");
                setTimeout('document.getElementById("' + campo1.id + '").focus();', 1);
		return(false);
	} else {
		return(true);
	}
}

function validaProducto(campo)
{
	if (campo.selectedIndex == 0)
	{
		alert("Debe seleccionar un Producto");
                setTimeout('document.getElementById("' + campo.id + '").focus();', 1);
                return(false);
	}
	else
	{
		return(true);
	}
}

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);
}
