function is_statezip(city,state, zip, zip4)
{
	if (state.value.length < 2)
	{
		alert("Please enter at least 2 characters in the \"State\" field.");
		state.focus();
		return (false);
	}
	  
	if (zip.value.length < 5)
	{
		alert("Please enter at least 5 digits in the \"Zip\" field.");
		zip.focus();
		return (false);
	}
	
	////////////////////////////////////////////////////////////
	//makes sure input to state and zip fields were in proper format 
	////////////////////////////////////////////////////////////
	var allValid = true;
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 
	var chkOK = "1234567890";
	var checkStr = state.value;
	var chkStr = zip.value;

	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 letters in the \"State\" field.");
		state.focus();
		return (false);
	}

	for (i = 0;  i < chkStr.length;  i++)
	{
		ch = chkStr.charAt(i);
		for (j = 0;  j < chkOK.length;  j++)
			if (ch == chkOK.charAt(j))
				break;
		if (j == chkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Please enter only digits in the \"Zip\" field.");
		zip.focus();
		return (false);
	}
	
	return true;
}

function is_full_address(addr, city, state, zip)
{
  if (addr.value == "")
  {
    alert("Please enter the address.");
	addr.focus();
    return (false);
  }
  
  if (city.value == "")
  {
    alert("Please enter the address including city.");
	city.focus();
    return (false);
  }

  if (state.value.length < 2)
	  {
	  	alert("Please enter at least 2 characters in the \"State\" field.");
		state.focus();
    	return (false);
	  }
  
  if (zip.value.length < 5)
  {
    alert("Please enter at least 5 digits in the \"Zip\" field.");
	zip.focus();
    return (false);
  }
////////////////////////////////////////////////////////////
//makes sure input to state and zip fields were in proper format 
////////////////////////////////////////////////////////////
  var allValid = true;
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 
  var chkOK = "1234567890";
  var checkStr = state.value;
    
  var chkStr = zip.value;

  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 letters in the \"State\" field.");
	  state.focus();
	  return (false);
  }

for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digits in the \"Zip\" field.");
    zip.focus();
    return (false);
  }
}

function is_phone(phone_code, phone)
{
////////////////////////////////////////////////////////////
//checks on the phone number
////////////////////////////////////////////////////////////
  var chkOK = "1234567890";
  var allValid = true;
  var chkStr = phone_code.value;
  for (i = 0;  i < chkStr.length;  i++)  
  {    
	ch = chkStr.charAt(i);
	for (j = 0;  j < chkOK.length;  j++)  
	if (ch == chkOK.charAt(j)) break; 
	if (j == chkOK.length)    
	{     
		allValid = false;      
		break;    
	} 
  }

  var chkStr = phone.value;

  if (8 == chkStr.length && '-' != chkStr.charAt(3))
  allValid = false;

  for (i = 0;  i < chkStr.length;  i++)  
  {    
  if (i == 3 && '-' == chkStr.charAt(3))
  ;
  else
  {
  ch = chkStr.charAt(i);
	for (j = 0;  j < chkOK.length;  j++)  
	if (ch == chkOK.charAt(j)) break; 
	
	if (j == chkOK.length)    
	{     
		allValid = false;      
		break;    
	} 
  }
  }

  if (phone_code.value.length < 3 || phone.value.length < 8 || !allValid) 
  {
    alert("Please enter the number in the form ### ###-####.");
    phone_code.focus();
    return (false);
  }

  return true;
}

function is_1_phone(phone){
	var bad="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ,.<>/?'[{]}\|+=_-)(*&^%$#@!`~" + '"';
	strip(phone, bad);
	//alert(phone.value.length);
	if(phone.value.length != 10){
		alert("Too few characters\n\nPlease enter the area code");
		return false
	}
	
	//force in the dashes
	var area,phone3, phone4;
	area = phone.value.substring(0,3) + '-';
	phone3 = phone.value.substring(3,6) + '-';
	phone4 = phone.value.substring(6, phone.value.length);
	phone.value = area+phone3+phone4;
	
	
}

function is_money(amount)
{
////////////////////////////////////////////////////////
//check amount characters
///////////////////////////////////////////////////  
  if (amount.value == "")
  {
    alert("Please enter a payment amount.");
    amount.focus();
    return (false);
  }
  
  
	var chkOK = "1234567890.$,";
	var chkStr = amount.value;
	var allValid = true; 
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
	if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
    alert("Illegal character in \"Amount\" field.");
    amount.focus();
    return (false);
  }
  
  //check for proper syntax of "$"
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
	if ( ch =='$' && i != 0) 
	{
		allValid = false;
		break;
	}
	
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
  	alert("Invalid format\n\n \"$\" must be first character only");
    amount.focus();
	allValid = false;
    return (allValid);
  }
  
  //check for proper sytnax of "."
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
	if ( ch =='.' && i != chkStr.length-3) 
	{
		allValid = false;
		break;
	}
	
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
  	alert("Invalid format of \".\"");
    amount.focus();
	allValid = false;
    return (allValid);
  }
  
  
  //make sure amount is greater than 0
   
  for (i = 0;  i < chkStr.length;  i++)
  {
    
	if (chkStr.charAt(i) != NaN)
		ch = chkStr.charAt(i);
	else
		continue;
		
	if(ch > 0)
	{	allValid = true;
		break;
	}
	
	else allValid = false;
  }
  
  if (!allValid)
  {
  	alert("Please enter an amount greater than 0");
    amount.focus();
	allValid = false;
    return (allValid);
  }
  
  //end of amount check

}

function is_date(dateField) 
{
	//function was added 3/12/2004 from http://www.breakingpar.com/bkp/home.nsf/Doc?OpenNavigator&U=75A5C758B9DF576087256AFB00140789
	//replaced old is_date function because it was much more robust
    // dateStr must be of format month day year with either slashes
    // or dashes separating the parts. Some minor changes would have
    // to be made to use day month year or another format.
    // This function returns True if the date is valid.
	
	var dateStr = dateField.value
	
//SLASH 1************************************************************************************
    var slash1 = dateStr.indexOf("/");
    if (slash1 == -1) { slash1 = dateStr.indexOf("-"); }
	
    // if no slashes or dashes, invalid date
    if (slash1 == -1) 
	{ 
		alert("Improper format please enter date in 'mm/dd/yyyy format");
		return false; 
	}
//*******************************************************************************************
	
    var dateMonth = dateStr.substring(0, slash1)
    var dateMonthAndYear = dateStr.substring(slash1+1, dateStr.length);

//SLASH 2************************************************************************************	
    var slash2 = dateMonthAndYear.indexOf("/");
    if (slash2 == -1) { slash2 = dateMonthAndYear.indexOf("-"); }
	
    // if not a second slash or dash, invalid date
    if (slash2 == -1) 
	{
		alert("Improper format please enter date in 'mm/dd/yyyy format");
		return false; 
	}
//*******************************************************************************************
	
    var dateDay = dateMonthAndYear.substring(0, slash2);
    var dateYear = dateMonthAndYear.substring(slash2+1, dateMonthAndYear.length);
    if ( (dateMonth == "") || (dateDay == "") || (dateYear == "") )  
	{
		alert("Improper format please enter date in 'mm/dd/yyyy format");
		return false; 
	}
	
//CHECK MONTH FOR DIGITS THEN CONVERT TO INT*************************************************
    for (var x=0; x < dateMonth.length; x++) 
	{
		var digit = dateMonth.substring(x, x+1);
		if ((digit < "0") || (digit > "9"))  
		{
			alert("Improper format please enter only numbers seperated by slashes");
			return false; 
		}
    }
    var numMonth = 0;
    for (var x=0; x < dateMonth.length; x++) 
	{
        digit = dateMonth.substring(x, x+1);
        numMonth *= 10;
        numMonth += parseInt(digit);
    }
    if ((numMonth <= 0) || (numMonth > 12))  
	{
		alert("Invalid month. Please enter a number from 1 to 12 for the month");
		return false; 
	}
//*******************************************************************************************
	
//CHECK DAY FOR DIGITS THEN CONVERT TO INT***************************************************
    for (var x=0; x < dateDay.length; x++) 
	{
        digit = dateDay.substring(x, x+1);
        if ((digit < "0") || (digit > "9"))  
        {
			alert("Improper format please enter only numbers seperated by slashes");
            return false; 
        }
    }
    var numDay = 0;
    for (var x=0; x < dateDay.length; x++) 
	{
        digit = dateDay.substring(x, x+1);
        numDay *= 10;
        numDay += parseInt(digit);
    }
    if ((numDay <= 0) || (numDay > 31)) 
	{
         alert("Invalid day. Please enter a number from 1 to 31 for the day");
         return false; 
	}
	
	// February can't be greater than 29 (leap year calculation comes later)
    if ((numMonth == 2) && (numDay > 29)) 
	{
		alert("Invalid day. Please enter a number from 1 to 29 for the day");
        return false; 
    }
    // check for months with only 30 days
    if ((numMonth == 4) || (numMonth == 6) || (numMonth == 9) || (numMonth == 11)) 
	{ 
        if (numDay > 30) 
		{
			alert("Invalid day. Please enter a number from 1 to 30 for the month");
			return false; 
        }
    }
//*******************************************************************************************
	
//CHECK YEAR FOR DIGITS THEN CONVERT TO INT**************************************************
    for (var x=0; x < dateYear.length; x++) 
	{
        digit = dateYear.substring(x, x+1);
        if ((digit < "0") || (digit > "9")) 
		{
			alert("Improper format please enter only numbers seperated by slashes");
			return false; 
		}
    }
    // convert the text year to a number
    var numYear = 0;
    for (var x=0; x < dateYear.length; x++) 
	{
        digit = dateYear.substring(x, x+1);
        numYear *= 10;
        numYear += parseInt(digit);
    }
//*******************************************************************************************

    // Year must be a 2-digit year or a 4-digit year
    if ( (dateYear.length != 2) && (dateYear.length != 4) ) 
	{ 
		alert("Improper format please enter date with a 2 or 4 digit year");
		return false; 
	}
	
    // if 2-digit year, use 50 as a pivot date
    if ( (numYear < 50) && (dateYear.length == 2) ) { numYear += 2000; }
    if ( (numYear >= 50) && (dateYear.length == 2) ) { numYear += 1900; }
    if ((numYear <= 0) || (numYear > 9999)) { return false; }
	
    // check for leap year if the month and day is Feb 29
    if ((numMonth == 2) && (numDay == 29)) 
	{
        var div4 = numYear % 4;
        var div100 = numYear % 100;
        var div400 = numYear % 400;
        // if not divisible by 4, then not a leap year so Feb 29 is invalid
        if (div4 != 0) 
		{ 
			alert("Invalid date. The given year is not a leap year");
			return false; 
		}
        // at this point, year is divisible by 4. So if year is divisible by
        // 100 and not 400, then it's not a leap year so Feb 29 is invalid
        if ((div100 == 0) && (div400 != 0)) 
		{ 
			alert("Invalid date. The given year is not a leap year");
			return false; 
		}
    }
	
    // date is valid
    return true;
}

function is_date_old(expdate)
{
////////////////////////////////////////////////////////
//check for date
///////////////////////////////////////////////////
  if (expdate.value == "")
  {
    alert("Please enter the date.");
    expdate.focus();
    return (false);
  }
  
  if (expdate.value.length < 10)
  {
    alert("Improper format in \"Date\" field.\n\n Please use the format \n\n mm/dd/yyyy ");
    expdate.focus();
    return (false);
  }
  
	var chkOK = "1234567890/";
	var chkStr = expdate.value;
	var allValid = true; 
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
    alert("Illegal character in \"Date\" field.\n\n Please use the format \n\n mm/dd/yyyy ");
    expdate.focus();
    return (false);
  }
  
  
  for (x=0; x < chkStr.length; x++)
  {
  	ch = chkStr.charAt(x);
  	if ( (ch =="/") && ((x!=2) && (x!=5)) )
		{
		allValid = false;		
		break;	
		}
  }
  
  if (chkStr.charAt(2)!= "/" && chkStr.charAt(5)!= "/")
  	allValid = false;
	
	
  if (!allValid)
  {
    alert("Improper format in \"Date\" field.\n\n Please use the format \n\n mm/dd/yyyy ");
    expdate.focus();
    return (allValid);
  }
  
  try {
    alert(CDate(expdate.value));
  }
  catch (exception) {
    alert("Please enter a valid date");
    return false;
  }
  
  return true
// end of date check

}

function is_number(num)
{
	var chkOK = "1234567890-";
	var chkStr = num.value;
	var allValid = true; 
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
	
  }
  
  if (!allValid)
  {
    alert("Improper format in please use only numbers");
    num.focus();
  }
  return (allValid);
}

function is_float(num)
{
	var chkOK = "1234567890.-";
	var chkStr = num.value;
	var allValid = true;
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
	
  }
  
  
  if (!allValid)
  {
    alert("Improper format in please use only numbers");
    num.focus();
    return (allValid);
  }
  
}


function is_letter(alpha)
{
	var chkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	var chkStr = alpha.value;
	var allValid = true; 
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
	
  }
  
  if (!allValid)
  {
    alert("Improper format in please use only letters");
    alpha.focus();
    return (allValid);
  }
  
}

function is_email(email)
{
	email.value = strip(email, " ")
	
  if (email.value == "")
  {
    alert("Please enter the email address.");
    email.focus();
    return (false);
  }
  
  var amp=false;
  for (j = 1;  j < email.value.length-1;  j++)  
  {
  	if (email.value.charAt(j) == "@")
  	amp=true;
  }

  if (email.value.length == 0)
  	amp=true;

  if (email.value.charAt(0) == "@" || email.value.charAt(email.value.length-1) == "@")
  {
    alert("Your e-mail address can't start or end with an @.");
    email.focus();
    return (false);
  }


  if (!amp)
  {
    alert("Your e-mail address has to have an @.");
    email.focus();
    return (false);
  }
  
  return (true);
}

function is_there(it)
{	/* there is no alert box so you can customize 
	your alert box message in the Validation function*/
  if (it.value == "")
  	return (false);
  else 
  	return (true);
}

function is_checked(it)
{	/* there is no alert box so you can customize 
	your alert box message in the Validation function*/
  if (it.checked)
  	return (true);
  else 
  	return (false);
}

function is_time(time)
{
	var chkOK = "1234567890:";
	var chkStr = time.value;
	var allValid = true; 
	var ch;
	var size = time.value.length, colon=size-3;
	
  if(time.value == "")
	{
		alert("Please enter the time\n\nPlease use the format ##:##");
	    time.focus();
	    return (false);
	}
	
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
    for (j = 0;  j < chkOK.length;  j++)
      if (ch == chkOK.charAt(j))
        break;
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
	
  }
  
  if (!allValid)
  {
    alert("Illegal character	'"+ ch +"'\n\nplease re-enter information");
    time.focus();
    return (allValid);
  }
  
  for (i = 0;  i < chkStr.length;  i++)
  {
    ch = chkStr.charAt(i);
	if ( ch ==':' && i != chkStr.length-3) 
	{
		allValid = false;
		break;
	}
	
    if (j == chkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
  	alert("Improper format of time\n\nPlease use the format ##:##");
    time.focus();
	allValid = false;
    return (allValid);
  }
	
	if(chkStr.charAt(size-3) != ':')
	{
		alert("Improper format of time\n\nPlease use the format ##:##");
	    time.focus();
	    return (false);
	}
	
	if(time.value.length<4)
	{
		alert("Please enter at least 4 characters for the time\n\n example:	#:##	or	##:##");
	    time.focus();
	    return (false);
	}
  
	
}

function strip(naked, illegal){
	//naked is the form element to be stripped of characters specified in the string "illegal"
	//var naked_str = naked.value;
	var naked_str = ""
	for(x=0; x<= naked.value.length; x++)
	{	
		var bad = false;
		chr = naked.value.charAt(x);
		for(i=0; i <= illegal.length; i++)
		{
			if(chr == illegal.charAt(i) )
			{	bad = true;
				break;}
				
		}
		
		if(!bad)
			naked_str += chr;
	}
	
	naked.value = naked_str;
  
  return naked.value

}

function keep(naked, legal){
	//strip the form element of everything but the characters passed to it
	
	var naked_str = ""
	for(x=0; x<= naked.value.length; x++)
	{	
		var good = false;
		chr = naked.value.charAt(x);
		for(i=0; i <= legal.length; i++)
		{
			if(chr == legal.charAt(i) )
			{	good = true;
				break;}
		}
		
		if(good)
			naked_str += chr;
	}
	
	naked.value = naked_str;

  return naked.value

}
function is_Radio(radio){
	var i;
	for (i=0; i<radio.length; i++)  {
		if (radio[i].checked==true)  {
			return true;
		}
	}
	alert("Please select a button")
//	for (i=0; i<radio.length; i++)  {
//		radio[i].focus()
//	}
	return false;
}