// JavaScript Document
<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter2(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter3(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter4(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter5(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter6(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter7(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter8(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter9(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
function textCounter10(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

function valida_ref(valor)
{
	var tem = valor;
    var i = tem.length;
	var j = 0;
	var x = 0;
	var z = 0;
	for (k = 0; k<=i; k++)
	{
		j = tem.indexOf(" ",0);
		tem = tem.substring(0,j) + tem.substring(j+1,tem.length);
	}
	x = tem.indexOf("<a href=",0);
	z = tem.indexOf("</a>",0);	
	if ((x >= 0) || (z >= 0))
		return true;
	return false;
}

<!--  Verifamos que los datos no sean un vacio-->
function ValidaDatos(form, idioma)
{
	form.txt_name.style.background="#FFFFFF";
  	form.txt_lastname.style.background="#FFFFFF";
  	form.txt_email.style.background="#FFFFFF";
  	form.txt_phone.style.background="#FFFFFF";
	form.txt_comment.style.background="#FFFFFF";
	//var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
  	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;  
	if (idioma == 1)
	{
		if (trim(form.txt_name.value) == "")
		{
			alert ("There is an error. Please fill the field: NAME from the form");    
			form.txt_name.focus(); 
			form.txt_name.style.background="#E9EDF0";
			return false;				 
		}
		else
		if (valida_ref(form.txt_name.value))
		{
			alert ("There is an error. Links are not permitted.");
			form.txt_name.focus(); 
			form.txt_name.style.background="#E9EDF0";
			return false;	
		}
		else
		if (trim(form.txt_lastname.value) == "")
		{
			alert ("There is an error. Please fill the field: LASTNAME from the form");    
			form.txt_lastname.focus(); 
			form.txt_lastname.style.background="#E9EDF0";
			return false;			 
		}
		else
		if (valida_ref(form.txt_lastname.value))
		{
			alert ("There is an error. Links are not permitted.");
			form.txt_lastname.focus(); 
			form.txt_lastname.style.background="#E9EDF0";
			return false;	
		}
		else
		if (trim(form.txt_email.value) == "")
		{
			alert ("There is an error. Please fill the field: EMAIL from the form");    
			form.txt_email.focus(); 
			form.txt_email.style.background="#E9EDF0";
			return false;		 
		}
		else
		if (!filter.test(form.txt_email.value)){
			alert("There is an error. The EMAIL is wrong");
			form.txt_email.focus(); 
			form.txt_email.style.background="#E9EDF0";
			return false;
		}
		else 
		if (trim(form.txt_phone.value) == "")
		{
			alert ("There is an error. Please fill the field: PHONE from the form");    
			form.txt_phone.focus(); 
			form.txt_phone.style.background="#E9EDF0";
			return false;	 	 
		}
		else 
		if (valida_ref(form.txt_phone.value))
		{
			alert ("There is an error. Links are not permitted.");   
			form.txt_phone.focus(); 
			form.txt_phone.style.background="#E9EDF0";
			return false;	 	 
		}
		//adicionales
		else
		if (trim(form.txt_country.value)==0)
		{
			alert ("There is an error. Please fill the field: COUNTRY from the form");    
			form.txt_country.focus(); 
			form.txt_country.style.background="#E9EDF0";
			return false;
		} 
		else
		if (valida_ref(form.txt_country.value))
		{
			alert ("There is an error. Links are not permitted.");
			form.txt_country.focus(); 
			form.txt_country.style.background="#E9EDF0";
			return false;
		} 
		else
		if (valida_ref(form.txt_comment.value))
		{
			alert ("There is an error. Links are not permitted.");
			form.txt_comment.focus(); 
			form.txt_comment.style.background="#E9EDF0";
			return false;
		}  
		else
		{
			return true;
		}
	}
	else
	{
		if (trim(form.txt_name.value) == "")
		{
			alert ("Error. Por favor complete el campo: NOMBRE del formulario");    
			form.txt_name.focus(); 
			form.txt_name.style.background="#E9EDF0";
			return false;				 
		}
		else
		if (valida_ref(form.txt_name.value))
		{
			alert ("Error. Los links no son permitidos.");
			form.txt_name.focus(); 
			form.txt_name.style.background="#E9EDF0";
			return false;	
		}
		else
		if (trim(form.txt_lastname.value) == "")
		{
			alert ("Error. Por favor complete el campo: APELLIDO del formulario");    
			form.txt_lastname.focus(); 
			form.txt_lastname.style.background="#E9EDF0";
			return false;			 
		}
		else
		if (valida_ref(form.txt_lastname.value))
		{
			alert ("Error. Los links no son permitidos.");
			form.txt_lastname.focus(); 
			form.txt_lastname.style.background="#E9EDF0";
			return false;	
		}
		else
		if (trim(form.txt_email.value) == "")
		{
			alert ("Error. Por favor complete el campo: EMAIL del formulario");    
			form.txt_email.focus(); 
			form.txt_email.style.background="#E9EDF0";
			return false;		 
		}
		else
		if (!filter.test(form.txt_email.value)){
			alert("Error. EL EMAIL es incorrecto");
			form.txt_email.focus(); 
			form.txt_email.style.background="#E9EDF0";
			return false;
		}
		else 
		if (trim(form.txt_phone.value) == "")
		{
			alert ("Error. Por favor complete el campo: TELEFONO del formulario");    
			form.txt_phone.focus(); 
			form.txt_phone.style.background="#E9EDF0";
			return false;	 	 
		}
		else 
		if (valida_ref(form.txt_phone.value))
		{
			alert ("Error. Los links no son permitidos.");
			form.txt_phone.focus(); 
			form.txt_phone.style.background="#E9EDF0";
			return false;	 	 
		}
		//adicionales
		else
		if (trim(form.txt_country.value)==0   )
		{
			alert ("Error. Por favor complete el campo: PAIS del formulario");    
			form.txt_country.focus(); 
			form.txt_country.style.background="#E9EDF0";
			return false;
		} 
		else
		if (valida_ref(form.txt_country.value))
		{
			alert ("Error. Los links no son permitidos.");
			form.txt_country.focus(); 
			form.txt_country.style.background="#E9EDF0";
			return false;
		} 
		else
		if (valida_ref(form.txt_comment.value))
		{
			alert ("Error. Los links no son permitidos.");
			form.txt_comment.focus(); 
			form.txt_comment.style.background="#E9EDF0";
			return false;
		}  
		else
		{
			return true;
		}
	}
}



function acceptNum(evt){
var nav4 = window.Event ? true : false;
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57

var key = nav4 ? evt.which : evt.keyCode;

return (key <= 13 || (key >= 40 && key <= 41) || (key >= 45 && key <= 45)|| (key >= 48 && key <= 57));

}

function ver_otros()
{
valor=document.customize_form.txt_find.value;
if (valor=="Otro Medio")
{
ver.style.visibility="visible";
}
else
{
ver.style.visibility="hidden";
	
	}
}
