// JavaScript Document

function validateEMail(eMailString) {
	if (!validateASCIIData(eMailString)) {
		/*alert("El email tiene caracteres invalidos.");*/
		return false;
	}

	var invalidCharsString = "\"|&;<>!*\'\\";

	for (var iIndex = 0; iIndex < invalidCharsString.length; iIndex++) {
		if (eMailString.indexOf(invalidCharsString.charAt(iIndex)) != -1) {
			/*alert("Caracteres invalidos en el email.\nLos siguientes caracteres no estan permitidos:\n" + invalidCharsString);*/
			return false;
		}
	}

	if (eMailString.indexOf("@")==-1) {
		/*alert("El email debe contener el simbolo @.");*/
		return false;
	}

	if (eMailString.indexOf(" ") != -1) {
		/*alert("No puede poner espacios en el email.");*/
		return false;
	}
		if (window.RegExp) {
		var reg1String = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var reg2String = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";

		var reg1RegExp = new RegExp (reg1String);
		var reg2RegExp = new RegExp (reg2String);
		if (reg1RegExp.test(eMailString) || !reg2RegExp.test(eMailString)) {
			/*alert("El email contiene caracteres invalidos.");*/
			return false;
		}
	}
	return true;
}

function validateASCIIData(targetString) {
	var iIndex;

	for (iIndex = 0; iIndex < targetString.length; iIndex++) {
		if ((targetString.charAt(iIndex) < " ") || (targetString.charAt(iIndex) > "~"))
		{
			return false;
	}
	}
	return true;
}

function Checkear(){
	if (!(document.fcontact.Nombre.value !='')){
		alert('El campo nombre es obligatorio');
		document.fcontact.Nombre.focus();
		return false;
	}
	
	if (!(document.fcontact.Apellido.value !='')){
		alert('El campo apellido es obligatorio');
		document.fcontact.Apellido.focus();
		return false;
	}
	
	if (!(document.fcontact.Email.value !='') || !validateEMail(document.fcontact.Email.value)){
		alert('El campo email es obligatorio');
		document.fcontact.Email.focus();
		return false;
	}
	
	if (!(document.fcontact.Comentarios.value !='')){
		alert('El campo comentarios es obligatorio');
		document.fcontact.Comentarios.focus();
		return false;
	}
	
	return true;
}

<!--
function checkEmail(mail)
{
  var result = false;
  var theStr = new String(mail);
  var index = theStr.indexOf("@");
  
  if (theStr.indexOf(" ") != -1) return false;
  
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
  }
  return result;
}

function validarCampos() {
	if (document.fcontact.Nombre.value ==''){
		alert('El campo NOMBRE es obligatorio');
		document.fcontact.Nombre.focus();
		return false;
	}
	if (document.fcontact.Apellido.value ==''){
		alert('El campo APELLIDO es obligatorio');
		document.fcontact.Apellido.focus();
		return false;
	}	
	if (document.fcontact.Email.value =='' || !checkEmail(document.fcontact.email.value)){
		alert('Debes ingresar un E-MAIL correcto');
		document.fcontact.Email.focus();
		return false;
	}
	if (document.fcontact.Telefono.value ==''{
		alert('Debes ingresar un TELEFONO correcto');
		document.fcontact.Telefono.focus();
		return false;
	}
	if (document.fcontact.Comentarios.value ==''){
		alert('El campo COMENTARIOS es obligatorio');
		document.fcontact.Comentarios.focus();
		return false;
	}
	return true;
}

-->
