
var sMsg       = ""
var sAlpha     = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- ";
var sAlphaExt  = "ÁÉÍÓÚÑÄËÏÖÜÂÊÎÔÛ áéíóúñäëïöüâêîôû";
var sAlphaMail = "@.-_";
var sNumeric   = "1234567890";
var sDot       = ".";
var sHyphen	   = "-";
var sAlphaOk = "@.-_,:;$!()|?¿<";

function ValidateString(theField, checkOK)
{
  var checkStr = theField.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
	sMsg = "debe poseer caracteres válidos";
    return (false);
  }
  else
  {
    return (true);
  }
}

function validaEditor(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

    if (ValidateString(datos.telefono, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.telefono.focus();
           alert("El telefono ingresado contiene caracteres no válidos.");
           return false;
      } 

if(datos.comentario.value=="")
		{
		alert("Ingrese su comentario");
		datos.comentario.focus();
		return false;
		}
    if (ValidateString(datos.comentario, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.comentario.focus();
           alert("El comentario ingresado contiene caracteres no válidos.");
           return false;
      } 

	return true;

}



function validaSecciones(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

    

if(datos.comentario.value=="")
		{
		alert("Ingrese su comentario");
		datos.comentario.focus();
		return false;
		}
    if (ValidateString(datos.comentario, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.comentario.focus();
           alert("El comentario ingresado contiene caracteres no válidos.");
           return false;
      } 

	return true;

}



function validaMensaje(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

    if (ValidateString(datos.edad, sNumeric)== false) {
           datos.edad.focus();
           alert("La edad ingresada contiene caracteres no válidos, solo números.");
           return false;
      } 

if (ValidateString(datos.lugar, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.lugar.focus();
           alert("El lugar de origen ingresado contiene caracteres no válidos.");
           return false;
      } 

if(datos.comentario.value=="")
		{
		alert("Ingrese su comentario");
		datos.comentario.focus();
		return false;
		}
    if (ValidateString(datos.comentario, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.comentario.focus();
           alert("El comentario ingresado contiene caracteres no válidos.");
           return false;
      } 

	return true;

}


function validaTitulares(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

    	return true;

}

function validaRecomendar(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

	if(datos.nombredest.value=="")
		{
		alert("Ingrese el nombre del destinatario");
		datos.nombredest.focus();
		return false;
		}
    if (ValidateString(datos.nombredest, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombredest.focus();
           alert("El Nombre  del destinatario ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellidodest.value=="")
		{
		alert("Ingrese el apellido del destinatario")
		datos.apellidodest.focus();
		return false;
		}
    if (ValidateString(datos.apellidodest, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido del destinatario ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.emaildest.value != "")
	{
		if (ValidateString(datos.emaildest, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.emaildest.focus();
			alert("El email del destinatario ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.emaildest.value.indexOf(".") == -1) || (datos.emaildest.value.indexOf("@") == -1) )
		{
		alert ("La dirección de correo del destinatario es incorrecta");
		datos.emaildest.focus();
		return false
		}
	} else {
		alert ("La dirección de correo del destinatario es incorrecta");
		datos.emaildest.focus();
		return false
	}


if(datos.comentarios.value=="")
		{
		alert("Ingrese su comentario");
		datos.comentarios.focus();
		return false;
		}
    if (ValidateString(datos.comentarios, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.comentarios.focus();
           alert("El comentario ingresado contiene caracteres no válidos.");
           return false;
      } 

	return true;

}

function validaTiempoLoco(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

    if (ValidateString(datos.telefono, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
           datos.telefono.focus();
           alert("El telefono ingresado contiene caracteres no válidos.");
           return false;
      } 
	if (datos.video.value=="" && datos.foto.value=="")
		{
		alert("Ingrese un Video o una Foto.")
		datos.video.focus();
		return false;
		}


	return true;

}

function validaComentarios(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

	if(datos.comentario.value=="")
		{
		alert("Ingrese el comentario");
		datos.comentario.focus();
		return false;
		}
}

function validaComentariosAbuso(datos)
    {
	if(datos.nombre.value=="")
		{
		alert("Ingrese su nombre");
		datos.nombre.focus();
		return false;
		}
    if (ValidateString(datos.nombre, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.nombre.focus();
           alert("El Nombre ingresado contiene caracteres no válidos.");
           return false;
      } 

	if (datos.apellido.value=="")
		{
		alert("Ingrese su apellido")
		datos.apellido.focus();
		return false;
		}
    if (ValidateString(datos.apellido, sAlphaExt+sAlpha+sAlphaOk)== false) {
           datos.apellido.focus();
           alert("El apellido ingresado contiene caracteres no válidos.");
           return false;
      } 


	if (datos.email.value != "")
	{
		if (ValidateString(datos.email, sAlphaExt+sAlpha+sAlphaOk+sNumeric)== false) {
			datos.email.focus();
			alert("El email ingresado contiene caracteres no válidos.");
			return false;
		} 

		if ((datos.email.value.indexOf(".") == -1) || (datos.email.value.indexOf("@") == -1) )
		{
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
		}
	} else {
		alert ("Su dirección de correo es incorrecta");
		datos.email.focus();
		return false
	}

}
// Textarea
keytotal2 = 600;
function changed1 (form, mytext2) {
	var s = mytext2.name;
	var index;
	if (s.indexOf('[') == -1) {
	index = 0;
	} else {
	index = s.substring( s.indexOf('[')+1,s.indexOf(']') );
	}
	checkit2(mytext2,index);
}

function checkit2(mytext2,zindex) {
	if (!(zindex >= 0)) {
	zindex = '';
	}
	var s = mytext2.name;
	var zindex;
	if (s.indexOf('[') == -1) {
	zindex = 0;
	}
	else
	{
	zindex = s.substring( s.indexOf('[')+1,s.indexOf(']') );
	}
	if (mytext2.value.length > keytotal2) {
	mytext2.value = mytext2.value.substring(0,keytotal2);
	}
	if (document.getElementById('charCountA'+zindex)) {
	document.getElementById('charCountA'+zindex).innerHTML = mytext2.value.length
	}
}

