<!-- //incluir en la etiqueta de form: onSubmit="return validar(this)"


function validarTextFields(arraynombres){//(nombre, mensaje, nombre, mensaje, etc)

validarTextFields(arraynombres, "")
	
}//fin de funcion js

function validarTextFields(arraynombres, iniciomensaje){//(nombre, mensaje, nombre, mensaje, etc)

  
	for (i=0;i<arraynombres.length;i+=2){ 
	
		var t=document.getElementById(arraynombres[i]);
		
		if (t.value == ""){
			var m=arraynombres[i+1];
			if (iniciomensaje) m=iniciomensaje+m;
			alert(m);
			t.focus();
			return (false);
		}
  
	}

	//nombre,direccion,horario	
	
}//fin de funcion js

function RemoveInvalidChars(theinput, pattern) {
	reg = new RegExp(pattern, 'g');
	newstring = theinput.value.replace(reg, '');
	// only update the input if invalid chars have been replaced
	// to avoid annoying behavior (e.g. moving cursor to end of text)
	if (newstring != theinput.value) {
		theinput.value = newstring;
	}
	return true;
}

function ForceUppercase(theinput) {
	// ex: <input type="text" onKeyUp="RemoveInvalidChars(this, '[^A-Za-z0-9 \-]');">
	newstring = theinput.value.toUpperCase();
	// only update the input if invalid chars have been replaced
	// to avoid annoying behavior (e.g. moving cursor to end of text)
	if (newstring != theinput.value) {
		theinput.value = newstring;
	}
	return true;
}

function ForceLowercase(theinput) {
	newstring = theinput.value.toLowerCase();
	// only update the input if invalid chars have been replaced
	// to avoid annoying behavior (e.g. moving cursor to end of text)
	if (newstring != theinput.value) {
		theinput.value = newstring;
	}
	return true;
}

function CharacterReplace(theinput, from, to) {
	newstring = theinput.value.replace(from, to);
	if (newstring != theinput.value) {
		theinput.value = newstring;
	}
	return true;
}

function FormatPhoneNumber(theinput) {
	reg = new RegExp('[^0-9]', 'g');
	numbersonly = theinput.value.replace(reg, '');

	if (numbersonly.length > 7) {
		newstring = '(' + numbersonly.substr(0, 3) + ')' + numbersonly.substr(3, 3) + '-' + numbersonly.substr(6, 4);
	} else if (numbersonly.length > 3) {
		newstring = numbersonly.substr(0, 3) + '-' + numbersonly.substr(3, 4);
	} else {
		newstring = numbersonly;
	}
	// only update the input if the text has changed
	// to avoid annoying behavior (e.g. moving cursor to end of text)
	if (newstring != theinput.value) {
		theinput.value = newstring;
	}
	return true;
}

function MatchesPattern(theString, pattern) {
	// Note: regular expressions passed to this function that have escaped
	// characters also need the escape character escaped, otherwise JavaScript
	// will make it disappear, for example:
	// MatchesPattern(mystring, '\w\.\w');    // won't work
	// MatchesPattern(mystring, '\\w\\.\\w'); // will work
	reg = new RegExp(pattern, 'g');
	return Boolean(reg.exec(theString));
}

function IsValidEmail(emailstring) {
	// regex adapted from http://www.yxscripts.com/fg/form.html
	return MatchesPattern(emailstring, '\\w[\\w\\-\\.]*\\@\\w[\\w\\-]+(\\.[\\w\\-]{2,})+');
}

function IsValidURL(urlstring) {
	return MatchesPattern(urlstring, 'http:\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+');
}

function IsValidHexColor(urlstring) {
	return MatchesPattern(urlstring, '^#[0-9a-zA-Z]{6}$');
}

function SetElementTextColor(theelement, thecolor) {
	if (theelement.style) {
		theelement.style.color = thecolor;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////
/*function HighlightThis(theelement) {
	theelement.className = 'hitelite';	
	return true;
}*/

function Highlight(theelement,clase) {
	theelement.className = clase;	
	return true;
}

//-->