// -----------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------
/*
	Ejemplo de uso

	// -------------------------------------------
	// Definicion de campos a validar.

	fv_arrFields = [
		{ name: "txtname",			msg: "Debe completar su nombre",		testFunc: fv_valid_string },
		{ name: "txtlastname",		msg: "Debe completar su apellido",		testFunc: fv_valid_string },
		{ name: "txtcompany",		msg: "Debe completar su compañía",		testFunc: fv_valid_string },
		{ name: "txtemail",			msg: "Su email es inválido",			testFunc: fv_valid_email },
		{ name: "txtcomments",		msg: "Debe completar su comentario",	testFunc: fv_valid_comments }
	];



*/

// -------------------------------------------
// Definicion de campos a validar.
// ---------------------------------------------
fv_arrFields = [];

// ---------------------------------------------
// Funciones Predefinidas de comparacion
// ---------------------------------------------
function fv_valid_string( value )
{
	if( value == "" )
		return false;
	return true;
}

function fv_valid_email( value )
{
	emailRegExp = /^\w+([\.-]?\w+)*@([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	if( !emailRegExp.test( value ) )
		return false;
	return true;
}
function fv_valid_comments( value )
{
	if( (value.length < 6) || (value.indexOf( ' ' ) == -1) )
		return false;
	return true;
}

// ---------------------------------------------
// ---------------------------------------------
function fv_valid_form( formId )
{
	pForm = document.getElementById( formId );
	for( n = 0; n < fv_arrFields.length; n++ )
	{
		pField		= fv_arrFields[ n ];

		pFieldObj	= pForm[ pField.name ];
		if( !pField.testFunc( pFieldObj.value ) )
		{
			alert( pField.msg );
			pFieldObj.focus();
			return;
		}
	}

	pForm.submit();
}



