/**********************************
*     Funciones de Validación     *
*     Desarrolladas por ©Soho     *
**********************************/
function Trim(s) 
{
  while (s.substring(0,1) == ' ') 
  {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') 
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function validoCombo(campo)
{
	if (campo.options[campo.selectedIndex].value == -1)		return false;
	else
		return true;
}

function validoTexto(campo)
{
	if (Trim(campo.value) == "")		return false;
	else
		return true;
}

function validoAno(campo)
{
	if (arguments[1] == null)
		anoinicial = 1900;
	else
		anoinicial = arguments[1];
	if (arguments[2] == null) {
		var fecha_hoy = new Date();
		anofinal = fecha_hoy.getFullYear();
	} else
		anofinal = arguments[2];
	var ano = parseInt(campo.value);
	if (isNaN(ano))
		return false;
	if (ano > anofinal || ano < anoinicial)
		return false;
	return true;
}

function validoEmail(campo)
{
	re = /^[^@\s]+@[^\s\.]+\.[^\s]+$/;
	return re.test(campo.value);

}

function validoRadio(collection)
{
	var i;
	for (i = 0; i < collection.length; i++)
		if (collection[i].checked)
			return true;
	return false;
}

function error(mensaje, objeto)
{
	alert(mensaje);
	objeto.focus();
	return false;
}

function validoPassword(campo1, campo2)
{
	if (validoTexto(campo1) && validoTexto(campo2))
		return (campo1.value == campo2.value);
	else
		return false;
}
