	// Version 1.01 Current as of 09/15/00
	
	// Only says that this is in a valid date format ie[xx/xx/xxxx or any numeric combo with slash
	// delimiters (you still have to check if month day combo is legal)
	function isDateFormat(str)
	{
		// Get into string object
		var sTemp = new String(str);
		x = sTemp.search(/([0][1-9]|[1][012]|[1-9])[\/]([0][1-9]|[12]\d?|[3][01]|[1-9])[\/](\d{2}|\d{4})$/);	// all combos still have to chek month day combo validation
		return TrueorFalse(x);
	}
	
	function isDate(str)
	{
		var day;
		var pos1;
		var pos2;
		var month;
		var year;
		
		
		
		var sTemp = new String(str);
		if(!isDateFormat(sTemp))
			return false;
		
		// Now we know it is in a good format
		sTemp = trim(sTemp);
		
		// Get the month(position of first "/")
		pos1 = instr(1,sTemp,"/");
		month = left(sTemp,pos1-1);
		
				
		// Get day (position of second "/")
		sTemp = mid((pos1+1),sTemp,len(sTemp));
		pos2 = instr(1,sTemp,"/");
	
		day = left(sTemp,pos2-1);
		
		// Validate day month combo, need year to get leapyear possibility
		year = right(sTemp,len(sTemp)-pos2);
		
		
		if (isValidMonthDay(month,day,year))
		{
			// Now Check Safe SQL Year
						
			if (instr(1,right(sTemp,4),"/") == 0)
			{
				// This is a four digit year, check that it is greater than 1752
				if(	right(sTemp,4) > "1752")
				{
					
					return true; // OK SQL Date
				}
				else
				{
					return false; // Bad SQL Date
				}
			}
			else
				return true; // Good two digit year
		}
		else // Not a valid date
		{
			return false;
		}
		
		
		
			
		
		
	}	
	
	// Returns true if leapyear
function isLeapYear(year)
{
	return (year % 4 == 0 && (year % 100 !=0 || year % 400 ==0));
}

// Returns true if Day Month Combo is Legal
function isValidMonthDay(month,day,year)
{
		
	// Return Value to be assigned
	var  gooddate = true;
	
	
	// Months with thrity days
	var sThirty = " 09 9 04 4 06 6 11 "
		
	// Check for Feb First
	if ( month == "02" || month == "2" )
	{
		
		if(isLeapYear(year))
		{
			if(day <= 29) // If leap year and 29 or less date is good
				gooddate = true;
			else 
				gooddate = false;
			
		}
		else // Not a leap year check day less than equal to 28
		{
			if(day >= 29)
			 gooddate = false;
			
			
		}
				
	} // Not feb
	else
	{
		// If not Feb check if should have thirty days
		// Returns 0 if not found
		var index = instr(1,sThirty,month)
	
		if (index > 0) // This month must have thiry days 
		{
			if(day > 30)
				gooddate = false;
					
		}
		else
		{
			 if(day > 31)
				goodate = false;
		}
	}
		
	
	return gooddate;
}
	
	function isZipcode(str)
	{
		var sTemp = new String(str);
		x = sTemp.search(/(\d{5}$)|\d{5}-?\d{4}/); // Matches xxxxx or xxxxx-xxxx
		return TrueorFalse(x);
	}
	
	function reformat (s)

	{   var arg;
	    var sPos = 0;
	    var resultString = "";

	    for (var i = 1; i < reformat.arguments.length; i++) {
	       arg = reformat.arguments[i];
	       if (i % 2 == 1) resultString += arg;
	       else {
	           resultString += s.substring(sPos, sPos + arg);
	           sPos += arg;
	       }
	    }
	    return resultString;
	}

	function reformatSSN(str)
	{   
		newssn=(reformat(str, "", 3, "-", 2, "-", 4));
	}

	
	function isSocialSecurity(str)
	{
		var sTemp = new String(str);
		x = sTemp.search(/\d{3}-?\d{2}-?\d{4}$/); // Matches xxx-xx-xxxx or xxxxxxxx
		return TrueorFalse(x);
	}
	
	function isPhoneNumber(str)
	{
		
		var sTemp = new String(str);
		x = sTemp.search(/\d{3}-?\d{3}-?\d{4}$/); // Matches xxx-xxx-xxxx or xxxxxxxx 
		return TrueorFalse(x);
	}
	 
	
	
	
	// Returns a string as with vb
	function mid(start,str,length)
	{
		start = (start == 1) ? 0 : (start - 1);
		length = start + length;
		
		var sTemp = new String(str);
		
		// Get substring
		return sTemp.substring(eval(start),eval(length));
	}
	
	
	// Returns trimmed version of string
	function trim(str)
	{
		var sTemp = new String(str);
		var sReturn = new String();
		for(var i = 0;i<=sTemp.length;i++)
		{
			if(sTemp.charAt(i) != " ")
				sReturn = sReturn + sTemp.charAt(i);
		}
		return sReturn;
				
		
	}
	
	// Returns left part of string as with vb
	function left(str,length)
	{
		var sTemp = new String(str);
		
		// Get substring
		return sTemp.substring(0,eval(length));
	}
	
	// Returns left part of string as with vb
	function right(str,length)
	{
		var sTemp = new String(str);
		var endofstr = sTemp.length;
		var start = endofstr - length;
		
		// Get substring
		return sTemp.substring(start,endofstr);
	}
	
	
	// Returns index of a string or character within a string as with vb
	// Returns 0 if not found
	function instr(start,strToSearch,strToFind)
	{
		
		var sTemp = new String(strToSearch);
		
		start = (start == 1) ? 0 : (start - 1);
				
		// Get substring
		return (sTemp.indexOf(strToFind,start) + 1);
	}
	
	// Returns length of string
	function len(str)
	{
		sTemp = new String(str);
		return sTemp.length; 
		
	}
	
	// Returns upper case version of string
	function ucase(str)
	{
		sTemp = new String(str);
		sTemp = sTemp.toUpperCase();
		return sTemp; 
		
	}
	
	
	// Returns lower case version of string
	function lcase(str)
	{
		sTemp = new String(str);
		sTemp = sTemp.toLowerCase();
		return sTemp; 
		
	}
	
	
	// Validates numbers
	function isNumeric(val)
	{
		sTemp = new String(val);
		//Use reg expr digits only
		return(TrueorFalse(sTemp.search(/\d+$/)));
	}
	
	function valnumbers (entry)
	{
		retval=true
		if (entry == " ")
			{
			retval=false;
			return retval;
			}
				for (var i=0; i<entry.length; i++)
				{
				if (entry.charAt(i) != " ")	
					{
					if ( !parseFloat(entry.charAt(i)) && entry.charAt(i)!="0"  && entry.charAt(i)!="." )
						{
						retval=false;
						break;
						}
					}
				}
		return retval;
	}



	// Validates Currency
	function isCurrency(str)
	{
		
		var sTemp = new String(str);
		//x = sTemp.search( /(\d|\$)\d*\.?\d\d$/);  
		x = sTemp.search(/(\$)?(\d{1,3}((\,\d{3})*)|(\d+))?(\.\d\d)?$/) // Allows commas
		
		return TrueorFalse(x);
	}

	 function isTime(str)
	{
		// Get into string object
		var sTemp = new String(str);
		x = sTemp.search(/([0][1-9]|[1][012]|\d)[:][0-5]\d([:][0-5]\d)?\s?(AM|am|PM|pm)$/);  // also accept optional space before AM/PM
		return TrueorFalse(x);
	}

	
	// This function is a utility to use inside of other functions
	// False values are any non-zero values
	function TrueorFalse(val)
	{
		return (val == 0) ? true : false; 
	}
	
	
	function echeck(str) 
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}
	
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}
	
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
			return false
		}
	
		 if (str.indexOf(at,(lat+1))!=-1){
			//alert("Invalid E-mail ID")
			return false
		 }
	
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			//alert("Invalid E-mail ID")
			return false
		 }
	
		 if (str.indexOf(dot,(lat+2))==-1){
			//alert("Invalid E-mail ID")
			return false
		 }
			
		 if (str.indexOf(" ")!=-1){
			//alert("Invalid E-mail ID")
			return false
		 }
	
		 return true					
	}
	
	var bag = "0123456789";
	function stripCharsNotInBag (s, bag)
	
	{   var i;
		var returnString = "";
	
		// Search through string's characters one by one.
		// If character is in bag, append to returnString.
	
		for (i = 0; i < s.length; i++)
		{
			// Check that current character isn't whitespace.
			var c = s.charAt(i);
			if (bag.indexOf(c) != -1) returnString += c;
		}
	
		return returnString;
	}
	
	var goodbag = "`~!@#$%^&*()-+=[{]}\|';<>,?/";
	function stripCharsNotInMyBag (s, goodbag)
	
	{   var i;
		var returnString = "";
	
		// Search through string's characters one by one.
		// If character is in bag, append to returnString.
	
		for (i = 0; i < s.length; i++)
		{
			// Check that current character isn't whitespace.
			var c = s.charAt(i);
			if (goodbag.indexOf(c) != -1) returnString += c;
		}
	
		return returnString;
	}
	
	function valnumbers (entry)
	{
		retval=true
		if (entry == " ")
			{
			retval=false;
			return retval;
			}
				for (var i=0; i<entry.length; i++)
				{
				if (entry.charAt(i) != " ")	
					{
					if ( !parseFloat(entry.charAt(i)) && entry.charAt(i)!="." && entry.charAt(i)!="0" )
						{
						retval=false;
						break;
						}
					}
				}
		return retval;
	}
	
	function calculateage() {
	var ap;
	dd = document.frmSEIBERT.Birthday.value;
	mm = document.frmSEIBERT.BirthMonth.value;
	yy = document.frmSEIBERT.BirthYear.value;
	//if (yy < 1900)
	//yy =+ 1900;
	with(document.frmSEIBERT) {
	}
	main="valid";
	if ((mm < 1) || (mm > 12) || (dd < 1) || (dd > 31) || (yy < 1) ||(mm == "") || (dd == "") || (yy == ""))
	main = "Invalid";
	else 
	if (((mm == 4) || (mm == 6) || (mm == 9) || (mm == 11)) && (dd > 30))
	main = "Invalid";
	else 
	if (mm == 2) 
	{
		if (dd > 29)
		main = "Invalid";
		else if((dd > 28) && (!lyear(yy)))
		main="Invalid";
	}
	else
		if((yy > 9999)||(yy < 0))
		main = "Invalid";
	else
		main = main;
		if(main == "valid") 
		{
			function leapyear(a) 
			{
				if(((a % 4 == 0) && (a % 100 != 0)) || (a % 400 == 0))
				return true;
				else 
				return false;
			}
			days = new Date();
			gdate = days.getDate();
			gmonth = days.getMonth();
			gyear = days.getYear();
			if (gyear < 2000) gyear += 1900;
			age = gyear - yy;
			if((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) 
			{
			age = age;
			}
			else {
				if(mm <= (gmonth)) {
				age = age;
				}
					else {
					age = age - 1; 
					}
		}
	if(age == 0)
	age = age;
	document.frmSEIBERT.age.value=age;
	if(mm <= (gmonth + 1))
	age = age - 1;
	if((mm == (gmonth + 1)) && (dd > parseInt(gdate))) 
	age = age + 1;
	var m;
	var n;
	if (mm == 12) { n = 31 - dd; }
	if (mm == 11) { n = 61 - dd; }   
	if (mm == 10) { n = 92 - dd; }  
	if (mm == 9) { n = 122 - dd; } 
	if (mm == 8) { n = 153 - dd; }   
	if (mm == 7) { n = 184 - dd; }   
	if (mm == 6) { n = 214 - dd; }  
	if (mm == 5) { n = 245 - dd; } 
	if (mm == 4) { n = 275 - dd; } 
	if (mm == 3) { n = 306 - dd; }
	if (mm == 2) { n = 334 - dd; if(leapyear(yy)) n = n + 1; }
	if (mm == 1) { n = 365 - dd; if (leapyear(yy)) n = n + 1; }
	if (gmonth == 1) m = 31;
	if (gmonth == 2) { m = 59;   if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 3) { m = 90;   if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 4) { m = 120;  if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 5) { m = 151;  if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 6) { m = 181;  if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 7) { m = 212;  if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 8) { m = 243;  if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 9) { m = 273;  if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 10) { m = 304; if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 11) { m = 334; if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 12) { m = 365; if (leapyear(gyear)) m = m + 1; }
	totdays = (parseInt(age) * 365);
	totdays += age / 4;
	totdays = parseInt(totdays) + gdate + m + n;
	months = age * 12;
	months += 12 - parseInt(mm);
	months += gmonth;
	if (gmonth == 1) p = 31 + gdate;
	if (gmonth == 2) { p = 59 + gdate;   if (leapyear(gyear)) m = m + 1; }
	if (gmonth == 3) { p = 90 + gdate;   if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 4) { p = 120 + gdate;  if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 5) { p = 151 + gdate;  if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 6) { p = 181 + gdate;  if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 7) { p = 212 + gdate;  if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 8) { p = 243 + gdate;  if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 9) { p = 273 + gdate;  if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 10) { p = 304 + gdate; if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 11) { p = 334 + gdate; if (leapyear(gyear)) p = p + 1; }
	if (gmonth == 12) { p = 365 + gdate; if (leapyear(gyear)) p = p + 1; }
	weeks = totdays / 7;
	weeks += " weeks";
	weeks = parseInt(weeks);

	var time = new Date();
	ghour = time.getHours();
	gmin = time.getMinutes();
	gsec = time.getSeconds();
	hour = ((age * 365) + n + p) * 24;
	hour += (parseInt(age / 4) * 24);
	if(ap == 0)
	hour = hour - hr;
	else {
	if(ap == 1) {
	hour = hour - (11 + hr)
	   }
	}

	var min;
	min = (hour * 60) + gmin;

	sec = (min * 60) + gsec;

	var millisec;
	var gmil;
	gmil = days.getMilliseconds();
	millisec = (sec * 1000) + gmil;
	mm = mm - 1;
	var r;
	if(mm == 0) r = 1;
	if(mm == 1) r = 31;
	if(mm == 2) { r = 59;    if (leapyear(gyear)) m = m + 1; }
	if(mm == 3) { r = 90;    if (leapyear(gyear)) r = r + 1; }
	if(mm == 4) { r = 120;   if (leapyear(gyear)) r = r + 1; }
	if(mm == 5) { r = 151;   if (leapyear(gyear)) r = r + 1; }
	if(mm == 6) { r = 181;   if (leapyear(gyear)) r = r + 1; }
	if(mm == 7) { r = 212;   if (leapyear(gyear)) r = r + 1; }
	if(mm == 8) { r = 243;   if (leapyear(gyear)) r = r + 1; }
	if(mm == 9) { r = 273;   if (leapyear(gyear)) r = r + 1; }
	if(mm == 10) { r = 304;  if (leapyear(gyear)) r = r + 1; }
	if(mm == 11) { r = 334;  if (leapyear(gyear)) r = r + 1; }
	if(mm == 12) { r = 365;  if (leapyear(gyear)) r = r + 1; }
	mm = mm + 1;
	r = parseInt(r) + parseInt(dd);
	if( mm > (gmonth + 1)) 
	{
	bday = r - m - gdate;
	}
	else {
		if(mm == (gmonth + 1) && (gdate < dd)) 
		{
		bday = (r - m - gdate);
		}
		else {
		if((leapyear(gyear)) && ((mm > 2) && (dd < 29))) {
		a = 366;
	}
	else {
	a = 365; 
	}
	bday = a + (r - m - gdate);
	   }
	}
	nhour = 24-parseInt(ghour);
	nmin = 60 - parseInt(gmin);
	nsec = 60 - parseInt(gsec);
	
		function lyear(a) 
		{
		if(((a % 4 == 0) && (a % 100 != 0)) || (a % 400 == 0)) return true;
		else return false;
		}
	mm = parseInt(mm);
	dd = parseInt(dd);
	yy = parseInt(yy);
	if ((mm < 1) || (mm > 12) || (dd < 1) || (dd > 31) || (yy < 1) ||(mm == " ") || (dd == " ") || (yy == " "))  main="Invalid";
	else 
	if (((mm == 4) || (mm == 6) || (mm == 9) || (mm == 11)) && (dd > 30)) main = "Invalid";
	else
	if (mm == 2) 
	{
		if (dd > 29)
		main = "Invalid";
		else
		if(( dd > 28) && (!lyear(yy)))
		main = "Invalid";
	}
	else main = main;
	if(main == "valid") 
	{
		var m;
		if (mm == 1) n = 31;
		if (mm == 2) n = 59 + 1;
		if (mm == 3) n = 90 + 1;
		if (mm == 4) n = 120 + 1;
		if (mm == 5) n = 151 + 1;
		if (mm == 6) n = 181 + 1;
		if (mm == 7) n = 212 + 1;
		if (mm == 8) n = 243 + 1;
		if (mm == 9) n = 273 + 1;
		if (mm == 10) n = 304 + 1;
		if (mm == 11) n = 334 + 1;
		if (mm == 12) n = 365 + 1;
		if((mm == 1)||(mm == 3)||(mm == 5)||(mm == 7)||(mm == 8)||(mm == 10)||(mm == 12))
		n += 31 + dd;
		else if((mm == 4)||(mm == 6)||(mm == 9)||(mm == 11))
		n += 31 + dd + 1;
		else if(mm == 2) {
		if(lyear(yy)) n += 29 + dd - 3;
		else if(!lyear(yy)) n += 28 + dd - 1;
	}
	fours = yy / 4;
	hunds = yy / 100;
	fhunds = yy / 400;
	var day;
	day = (yy + n + fours - hunds + fhunds) % 7;
	day = parseInt(day)

	}
	else {
	document.frmSEIBERT.age.value += main + " Date";
	      }
	   }
	
	else {
	document.frmSEIBERT.age.value = main + " Date";

	   }
	}
	
	
	
	




