function checkDate() {
  var myDayStr = document.builds.formDate.value;
var myMonthStr = document.builds.formMonth.value;
var myYearStr = document.builds.formYear.value;
var myDateStr = myDayStr + ' ' + myMonthStr + ' ' + myYearStr;

/* Using form values, create a new date object
which looks like "Wed Jan 1 00:00:00 EST 1975". */
var myDate = new Date( myDateStr );

// Convert the date to a string so we can parse it.
var myDate_string = myDate.toGMTString();

/* Split the string at every space and put the values into an array so,
using the previous example, the first element in the array is "Wed", the
second element is "Jan", the third element is "1", etc. */
var myDate_array = myDate_string.split( ' ' );

/* If we entered "Feb 31, 1975" in the form, the "new Date()" function
converts the value to "Mar 3, 1975". Therefore, we compare the month
in the array with the month we entered into the form. If they match,
then the date is valid, otherwise, the date is NOT valid. */
if ( myDate_array[2] != myMonthStr ) {
  alert( myDateStr + '" is NOT a valid date.' );
  return false;
} else { 
	cmpDate=compareDate(myDate);
	retr=true;
	if ((cmpDate>=7) & (cmpDate<=14)) {
	  alert( 'The due date requested: "' + myDateStr + '" is less than 2 weeks away and may NOT be able to be fulfilled. Call for more info.');
	} else { 
		if ((cmpDate>=0) & (cmpDate<7)) {
		  alert( 'The due date requested: "' + myDateStr + '" is less than 1 week away and may NOT be able to be fulfilled. Call for more info.');
		} else { 
			if (cmpDate<0) {
			  alert( 'The due date requested: "' + myDateStr + '" is before todays date. Pick a different date.');
			  retr=false;
			}
		}	
	}
	return retr;
}
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function compareDate(date1) {
    var now = new Date();

    var difference =
        Date.UTC(y2k(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0)
      - Date.UTC(y2k(now.getYear()),now.getMonth(),now.getDate(),0,0,0);
    return difference/1000/60/60/24;
}
function setSelected(list, value) {
for (i=0;i<list.options.length;i++)
  if (list.options[i].text==value) {
    list.options[i].selected=true;
  } else list.options[i].selected=false;
}
function writeOptions(startNumber, endNumber)
{
  var optionCounter;
  for (optionCounter = startNumber; optionCounter <= endNumber; optionCounter++)
  {
      document.write('<OPTION value=' + optionCounter + '>' + optionCounter);
  }
}
function writeMonthOptions()
{
   var theMonth;
   var monthCounter;
   var theDate = new Date();

   for (monthCounter = 0; monthCounter < 12; monthCounter++)
   {
      theDate.setMonth(monthCounter);
      theMonth = theDate.toString();
      theMonth = theMonth.substr(4,3);
      document.write('<OPTION value=' + theMonth + '>' + theMonth);
   }
}
function setDateValues(inDate) {
	var nowDate = new Date();
	var days=15;
	if (inDate=="") {
		var newDate = new Date(nowDate.getTime() + days*24*60*60*1000);
	} else {
		var newDate = new Date(inDate);
	}
	setSelected(document.builds.formMonth,newDate.toString().substr(4,3));
	setSelected(document.builds.formDate,newDate.getDate().toString());
	setSelected(document.builds.formYear,newDate.getYear().toString());
}
function setComments(value) {
	document.builds.Comment.value=value;
}
