function isNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function isAlphanumeric(strString)
   //  check for valid alphanumeric strings	
   {
   var strValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function isAlphanumericOrSpace(strString)
   //  check for valid alphanumeric strings	
   {
   var strValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function containsAmpersand(strString)
   //  check for string containing ampersand	
   {
   var strValidChars = "@";
   var strChar;
   var blnResult = false;

   if (strString.length == 0) return false;

   //  test strString contains ampersand
   for (i = 0; i < strString.length && blnResult == false; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == 0)
         {
         blnResult = true;
         }
      }
   return blnResult;
   }
   
function _checkblank(object_value)
	{
		if	(object_value.length == 0)
			return false;
		else
			return true;
	}

function _passwordmatch(new_password, repeat_password)
	{
		if (new_password == repeat_password)
			return true;
		else
			return false;
	}
	
function _newpasswordmatch(new_password, repeat_password)
{
	if (new_password == repeat_password)
		return true;
	else
		return false;
}

function _checkjpg(object_value)
{
//Returns true for jpg files otherwise returns false

var file_length = object_value.length;
var file_type = object_value.substring(object_value.length - 4);

if (file_type == ".jpg" || file_type == ".JPG" || file_type == "jpeg" || file_type == "JPEG" || object_value.length == 0)
	return true;
else
	return false;
}


function _checkeurodate(object_value)
    {
    //Returns true if value is a eurodate format or is NULL
    //otherwise returns false

    if (object_value.length == 0)
	return true;

    //Returns true if value is a date in the dd/mm/yyyy format
	isplit = object_value.indexOf('/');

	if (isplit == -1)
	{
		isplit = object_value.indexOf('.');
	}

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sDay = object_value.substring(0, isplit);

	monthSplit = isplit + 1;

	isplit = object_value.indexOf('/', monthSplit);

	if (isplit == -1)
	{
		isplit = object_value.indexOf('.', monthSplit);
	}

	if (isplit == -1 ||  (isplit + 1 )  == object_value.length)
		return false;

    sMonth = object_value.substring((sDay.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_checkinteger(sMonth)) //check month
		return false;
	else
	if (!_checkrange(sMonth, 1, 12)) // check month
		return false;
	else
	if (!_checkinteger(sYear)) //check year
		return false;
	else
	if (!_checkrange(sYear, 0, null)) //check year
		return false;
	else
	if (!_checkinteger(sDay)) //check day
		return false;
	else
	if (!_checkday(sYear, sMonth, sDay)) //check day
		return false;
	else
		return true;
    }

function _checkday(checkYear, checkMonth, checkDay)
    {

	maxDay = 31;

	if (checkMonth == 4 || checkMonth == 6 ||
			checkMonth == 9 || checkMonth == 11)
		maxDay = 30;
	else
	if (checkMonth == 2)
	{
		if (checkYear % 4 > 0)
			maxDay =28;
		else
		if (checkYear % 100 == 0 && checkYear % 400 > 0)
			maxDay = 28;
		else
			maxDay = 29;
	}

	return _checkrange(checkDay, 1, maxDay); //check day
    }

function _checkinteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false

    if (object_value.length == 0)
	return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return _checknumber(object_value);
    else
	return false;
    }

function _numberrange(object_value, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
	{
	if (object_value < min_value)
		return false;
	}

    // check maximum
    if (max_value != null)
	{
	if (object_value > max_value)
		return false;
	}

    //All tests passed, so...
    return true;
    }

function _checknumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false

    if (object_value.length == 0)
	return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;

	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)
				trailing_blank = true;
	// ignore leading blanks

		}
		else if (trailing_blank)
			return false;
		else
			digits = true;
	}
    //All tests passed, so...
    return true
    }

function _checkrange(object_value, min_value, max_value)
    {
    //if value is in range then return true else return false

    if (object_value.length == 0)
	return true;


    if (!_checknumber(object_value))
	{
	return false;
	}
    else
	{
	return (_numberrange((eval(object_value)), min_value, max_value));
	}

    //All tests passed, so...
    return true;
    }
    
// checks that a radio button is selected
function _isChecked(obj)
{
	for (i=0; i < obj.length; i++)
	{
		if (obj[i].checked)
		return true;
	}
	return false;	
}
