function CheckDate(obj)
{
    
    //strip the spaces
	obj.value = obj.value.replace(/(^ +)|( +$)/g, "");
	
  //Make sure there is a value to check
  if (obj.value!="")
    {	
	if ((obj.value.lastIndexOf("/") < 6) && (obj.value.lastIndexOf("/") > -1))
  	  {
		//values for comparison
		var mToday = new Date();
		var mYear = mToday.getYear();	
		var mMonth = mToday.getMonth();
		var mDay = mToday.getDate();
							
		if (obj.value.lastIndexOf("/") == 1 || obj.value.length < 6) {  //dateformat is 10/17
			obj.value = obj.value + "/" + mYear;
		}
							
		var lenYear = obj.value.substring(obj.value.lastIndexOf("/") + 1, obj.value.length);
		if (lenYear.length > 4) 
		{
  			var yyyy  = obj.value.substring(obj.value.lastIndexOf("/") + 1, obj.value.lastIndexOf("/") + 5);
		}
		else
		{
  			var yyyy  = obj.value.substring(obj.value.lastIndexOf("/") + 1, obj.value.length);
		}

  		var inMonth = obj.value.substring(0,obj.value.indexOf("/"));
  
  		if (inMonth.substring(0,1) == "0" && inMonth.length > 1)
  			inMonth = inMonth.substring(1,inMonth.length);
  		inMonth = parseInt(inMonth);
  				
  		if (isNaN(inMonth)) { inMonth = ""}

  		var inDay   = obj.value.substring(obj.value.indexOf("/") + 1, obj.value.lastIndexOf("/"));

  		if (inDay.substring(0,1) == "0" && inDay.length > 1)
  			inDay = inDay.substring(1,inDay.length);
  		inDay = parseInt(inDay);
  				
  		if (isNaN(inDay)) { inDay = ""}
		if (yyyy.length ==0) {yyyy = mYear}  //looks like 10/12/  		
		if (yyyy.length ==1) {yyyy = "0" + yyyy}  //looks like 10/12/2  		
		if (yyyy.length == 2) {
			
			var intYYYY = parseFloat(yyyy); //actual 2-digit input year	
			if (isNaN(intYYYY)) {intYYYY = mYear}  //dateformat is 10/17/		
					
			var intYear = parseInt(mYear);  //current 4 digit year					
			var tenYYYY = intYear + 10 - 2000;  //currentYear + 10 - 2000 to give us a 2-digit year comparison
			
			if (intYYYY > tenYYYY) { //dateformat is 10/17/99
				var newYear = 1900 + intYYYY;
				obj.value = inMonth + "/" + inDay + "/" + newYear;
				yyyy = newYear;
			} 
			else {	//dateformat is 10/17/02
				var newYear = 2000 + intYYYY;
				obj.value = inMonth + "/" + inDay + "/" + newYear;	
				yyyy = newYear;
			}			
		}						
		else {
			obj.value = inMonth + "/" + inDay + "/" + yyyy;	
		}
  		var inYear  = yyyy //parseInt(obj.value.substring(obj.value.lastIndexOf("/") + 1, obj.value.length));
  		var numDays = 0;

  	   // Test that the months have the right number of days
  		if (inMonth == 1 || inMonth == 3 || inMonth == 5 || inMonth == 7 || inMonth == 8 || inMonth == 10 || inMonth == 12) {
  			numDays = 31;
  		}
  		else if (inMonth == 4 || inMonth == 6 || inMonth == 9 || inMonth == 11) {
  				numDays = 30;
  		}
  		else if (inMonth == 2) {
  			// February is special ....
  			if (((inYear % 4)==0) && ((inYear % 100)!=0) || ((inYear % 400)==0)) {
  				numDays = 29;
  			}
  			else {
  				numDays = 28;
  			}
  		}
		
  	   // Test that all are integers
  		if (!(inDay) || !(inMonth) || !(inYear))
  		  {
  			alert("The date specified is not in the mm/dd/yyyy format.");
  			obj.focus();
  			obj.select();
  			return false;
  		  }

  	   // Test that the month is within a valid range
  		if (inMonth < 0 || inMonth > 12)
  		  {
  			alert("The Month specified is invalid.");
  			obj.focus();
  			obj.select();
  			return false;
  		  }

  	   // Test that the day is within a valid range
  		if (inDay < 0 || inDay > numDays)
  		  {
  			alert("The Day specified is invalid.");
  			obj.focus();
  			obj.select();
  			return false;
  		  }

  		var YearLength = "" + inYear;
		
  	   // Test that the year is 4 digits
  		if (YearLength.length != 4)
  		  {
  			alert("Please enter a 2 or 4-digit Year.");
  			obj.focus();
  			obj.select();
  			return false;
  		  }
  		 // test that year is 1900 or later
  		  if (inYear < 1900)
  		  {
  			alert("The year you entered is before 1900, please re-enter a valid year.");
  			obj.focus();
  			obj.select();
  			return false;
  		  }  		  
  		  else if (yyyy > mYear + 10) {
  			alert("The year you entered is greater than ten years from today, please re-enter a valid year.");
  			obj.focus();
  			obj.select();
  			return false;
  		  
  		  }
  		  
  	  }
  	  else
  	  {
  		alert("The date specified is not in the mm/dd/yyyy format.");
  		obj.focus();
  		obj.select();
  		return false;
  	  }
  	  
  }
  return true;
}
/*******************************************************************************/


 function validate(object,field_type,min_length,show_extra)
  {
	//*** Define Local Variables ***
	var object_value=object.value;
	   var flgReturns = 0;
	   var illegal_count = 0;
	   var acceptable_string = "";
	   var msg_string = "";
	   var tmp_string = "";
	   var sub_string = "";
	   var trace_string = "";

		// This will determine if we need to show the long or
		// short version of the error message if the field is
		// not valid.
		if (validate.arguments.length == 3 ) show_extra = false;

	    //**** Define acceptable values based on field_type
		if (field_type == "Quantity"){
		  field_desc = 'Quantity'
	   	  acceptable_string = "0123456789";
		}
		else if (field_type == "Name"){
			field_desc = "Last Name"
			acceptable_string = "0123456789";
	   		acceptable_string += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	   		acceptable_string += " -abcdefghijklmnopqrstuvwxyz'";
		}
		else if (field_type == "Date"){
			field_desc = "Date"
			acceptable_string = "0123456789";
	   		acceptable_string += "/";
		}
    	else if (field_type == "Address"){
			field_desc = "Address"
			acceptable_string = "0123456789";
			acceptable_string += " #ABCDEFGHIJKLMNOPQRSTUVWXYZ";
			acceptable_string += "-.abcdefghijklmnopqrstuvwxyz";
		}
		else if (field_type == "City"){
			field_desc = "City"
			acceptable_string = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
			acceptable_string += "-abcdefghijklmnopqrstuvwxyz";
		}
		else if (field_type == "Zip_Code"){
			field_desc = "Postal Code"
			acceptable_string = "0123456789-";
		}
		else if (field_type == "Contact_Data"){
			field_desc = "Contact Information"
			acceptable_string = "0123456789";
			acceptable_string += "(ABCDEFGHIJKLMNOPQRSTUVWXYZ)";
			acceptable_string += "abcdefghijklmnopqrstuvwxyz-@_. ";
		}
		else if (field_type == "Email"){
			field_desc = "e-mail"
			acceptable_string = "0123456789";
			acceptable_string += "ABCDEFGHIJKLMNOPQRSTUVWXYZ@.-_";
			acceptable_string += "abcdefghijklmnopqrstuvwxyz";
		}
		else if (field_type == "Comments"){
			field_desc = "Comments"
			acceptable_string = "0123456789:";
			acceptable_string += " ABCDEFGHIJKLMNOPQRSTUVWXYZ.-";
			acceptable_string += "@!#$%^&*()}{[]'?></;:\|,+=_";
			acceptable_string += "abcdefghijklmnopqrstuvwxyz";
		}

	   //**** Loop through each character in oject_value ****
	   for (var i = 0; i < object_value.length; i++)
	     {
	   		//get the next character in the object_value
	   		sub_string = object_value.substring(i,i+1)

	   		//*** Test if the sub_string character is contained ***
	   		//*** in the acceptable_string                      ***
	   		if (acceptable_string.indexOf(sub_string) < 0)
	   		  {
	   			//*** Trap all carrage returns ***
	   			if (field_type != "Text_Notes") {
	   			if (sub_string == "\r" || sub_string == "\n" || sub_string == "\r\n")
	   			  {
	   				flgReturns++;
	   			  }
	   			else //*** if sub_string is not a carriage return ***
	   			  {
	   				illegal_count++; //keep track of # illegal characters
	   				msg_string += " " + sub_string; //add illegal character to the msg_string
	   				tmp_string += sub_string; //add illegal character to the tmp_string
	   			  }
	   			 }
//				if (navigator.appName == "Netscape")
//				  {
//					// could use this approach if alert boxes used a monospaced font (they don't)
//					trace_string += "^";
//				  }
			  }
			else
			  {
//			    if (navigator.appName == "Netscape")
//			      {
//					// could use this approach if alert boxes used a monospaced font  (they don't)
//					trace_string += "_";
//				  }
			  }
	     }

	   //if we found a bad character in object_value then we'll add
	   //some helpful info to the error message
 	   if (illegal_count != 0 || flgReturns > 0)
	     {
	   	if (tmp_string.indexOf(" ") > -1 || flgReturns > 0)
	   	  {
	   		msg_string += "\r\r     Please Note:\r        1)"

			//if illegal characters include spaces
 	   		if (tmp_string.indexOf(" ") > -1)
	   		  {
	   			msg_string += " Spaces are not allowed\r";
	   			if (flgReturns > 0 )
	   			  {
	   				msg_string += "        2)"; //add this to msg_string
				  }
	   		  }

			//if illegal characters include spaces
	   		if (flgReturns > 0)
	   		  {
	   			msg_string += " Carriage Returns are not allowed"; //add this to msg_string
	   			illegal_count += (flgReturns/2)
	   		  }
	   	  }
	   	object.focus(); //put focus on this object

	   	//send a message box informing the user of the illegal input
	   	alert(object_value + "\r" + trace_string + "\rThis entry should be a "
	   	+ field_desc + " value. There are " + illegal_count + " unacceptable values: " + msg_string + ".");
	   	object.value = object.value.substring(0,object.value.length-1);
	   	object.focus();

	   	return false; //object_value has invalid characters
	     }

	   return true; //object is valid
	}
