
function ltrim (s) // Krish
{
	for (i=0; i<s.length; i++)
		if ( s.charAt(i) != ' '  && s.charAt(i) != '\n'	&&
		     s.charAt(i) != '\t' && s.charAt(i) != '\b' &&
		     s.charAt(i) != '\r' && s.charAt(i) != '\f' )
			break;
	s = s.substring (i);
	return (s);
}

function validateTextField (theField, fieldLabel, shouldTrim, emptyCheck, minLength, maxLength, checkOK, OKString)
{
	fieldNameString = ' "' + fieldLabel + '" ';
	if (shouldTrim)
		theField.value = ltrim (theField.value);

	if (emptyCheck && theField.value == "")
	{
	alert("Please enter a value for the" + fieldNameString + "field.");
	theField.focus();
	return (false);
	}

	if (emptyCheck && minLength > 0 && theField.value.length < minLength)
	{
		alert("Please enter at least " + minLength + " characters in the" + fieldNameString + "field.");
		theField.focus();
		return (false);
	}

	if (maxLength > 0 && theField.value.length > maxLength)
	{
		alert("Please enter at most " + maxLength + " characters in the " + fieldNameString + "field.");
		theField.focus();
		return (false);
	}

	checkOK = ltrim(checkOK);
	if (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)
		{
	alert("Please enter only " + OKString + " in the" + fieldNameString + "field.");
			theField.focus();
			return (false);
		}
	}

	return true;
}

// called onSubmit of form
function validatetax (theForm)
{
  var dateToday = new Date();
  var dateGiven = new Date();
  var str;


 if ( ! validateTextField (theForm.avalue, "ANNUAL VALUE", true, true, 2, 10, "0123456789", "Digits only"))
		return false;

  return (true);
}



function mmcValidation()
{
	var i;

	if ( ! validatemmc(document.forms[0]) )
	  return false ;
	return document.forms[0].action; 
}
