function stripWhiteSpace(s)
{
   s = s.replace(/\ /g,"");
   return s;
}

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 isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function checkIfLeapYear(datea)
{
	datea = parseInt(datea);

	if(datea%4 == 0)
	{
		if(datea%10 != 0)
		{
			return true;
		}
		else
		{
			if(datea%400 == 0)
				return true;
			else
				return false;
		}
	}
	return false;
}

function checkValidDay(form)
{
   if(form.month.value==4 || form.month.value==6 || form.month.value==9 || form.month.value==11)
   {
      if(form.day.value < 1 || form.day.value > 30)
	  {
	     alert("Please enter a Date of Birth day value in the range [1 - 30] or select a different month");
	     form.day.select();
		 return false;
	  }
   }
   else if(form.month.value==2)
   {
      if(checkIfLeapYear(form.year.value))
      {
         if(form.day.value < 1 || form.day.value > 29)
	     {
	        alert("Please enter a Date of Birth day value in the range [1 - 29]");
	        form.day.select();
		    return false;
	     }
      }
      else
      {
         if(form.day.value < 1 || form.day.value > 28)
	     {
	        alert("Please enter a Date of Birth day value in the range [1 - 28]");
	        form.day.select();
		    return false;
	     }
      }
   }
   else // months with 31 days
   {
      if(form.day.value < 1 || form.day.value > 31)
	  {
	     alert("Please enter a Date of Birth day value in the range [1 - 31]");
	     form.day.select();
		 return false;
	  }
   }
   return true;
}

function containsIllegalChars(strString) //  check for valid numeric strings	
{
   var strInvalidChars = "\"\'\\/";
   var strChar;
   var blnResult = false;

   for (i = 0; i < strString.length && blnResult == false; i++)
   {
      strChar = strString.charAt(i);
      if (strInvalidChars.indexOf(strChar) != -1)
      {
         blnResult = true;
      }
   }
   return blnResult;
}
