function nullcheck()
{

/*
		if ( turkey.dec29.value=='True')
		{
			alert("Sold out until January 6")
			return false;	
		}
*/

	var first_name=document.turkey.first_name.value;
	var last_name=document.turkey.last_name.value;
	var email=document.turkey.email.value;
	var phone_home=document.turkey.phone_home.value;
	var phone_work=document.turkey.phone_work.value;
	//var address=document.turkey.address.value;
	//var city=document.turkey.city.value;
	//var province=document.turkey.province.value;
	//var postal_code=document.turkey.postal_code.value;
	var pickup_date=document.turkey.pickup_date.value;
//	var meal=document.turkey.meal.value;

	if(first_name==""){ alert('please enter first name'); document.turkey.first_name.focus(); return false; }
	if(last_name==""){ alert('please enter last name'); document.turkey.last_name.focus(); return false; }
	if(email==""){ alert('please enter email'); document.turkey.email.focus(); return false; }
//	if(!(email.indexOf(".")>2) || !(email.indexOf("@")>0))
	if(!(email.indexOf(".")>0) || !(email.indexOf("@")>0))
	{ alert('email address is not valid'); document.turkey.email.focus(); return false; }
	
	if(phone_home==""){ alert('please enter phone(Primary)'); document.turkey.phone_home.focus(); return false; }
			invalidChars1 = " ?/:,;=+'\"<>.|\\`~{}#$%@!^&*()_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	if(document.turkey.phone_home.value.length<12){ alert('please enter valid phone(Primary)'); document.turkey.phone_home.focus(); return false; }
			for (i=0; i<invalidChars1.length; i++) // does it contain any invalid characters?
				{
					badChar1 = invalidChars1.charAt(i)
					if (phone_home.indexOf(badChar1,0) > -1) 
						{
							alert("Invalid Phone #")
							phone_home.focus();
							return false
						}
				}

			invalidChars1 = " ?/:,;=+'\"<>.|\\`~{}#$%@!^&*()_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	if(phone_work=="");
	else if(document.turkey.phone_work.value.length<12){ alert('please enter valid phone(Alternate)'); document.turkey.phone_work.focus(); return false; }
			for (i=0; i<invalidChars1.length; i++) // does it contain any invalid characters?
				{
					badChar1 = invalidChars1.charAt(i)
					if (phone_work.indexOf(badChar1,0) > -1) 
						{
							alert("Invalid Phone #")
							phone_work.focus();
							return false
						}
				}



//	if(phone_work==""){ alert('please enter phone(work)'); document.turkey.phone_work.focus(); return false; }

	//if(address==""){ alert('please enter address'); document.turkey.address.focus(); return false; }
	//if(city==""){ alert('please enter city'); document.turkey.city.focus(); return false; }
	//if(province==""){ alert('please enter province'); document.turkey.province.focus(); return false; }
	//if(postal_code==""){ alert('please enter postal code'); document.turkey.postal_code.focus(); return false; }

// Declaring valid date character, minimum year and maximum year
//////////// pick up date function
	if(pickup_date==""){ alert('please enter pickup date'); return false; }


var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
//		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		alert("Please enter a valid 4 digit year")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

//////////////////////function ValidateForm(){ validate for a valid date 
	var dt=document.turkey.pickup_date
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}





//// current date
	var myDate = new Date();
	myDate.setDate(myDate.getDate());
	myDate = (myDate.getMonth()+1)+'/'+myDate.getDate()+'/'+myDate.getYear()
//	alert(myDate);
////// current time
  var currentTime = new Date()
  var hours = currentTime.getHours()
  var minutes = currentTime.getMinutes()

  var suffix = "AM";
  if (hours >= 12) {
  suffix = "PM";
  hours = hours - 12;
  }
  if (hours == 0) {
  hours = 12;
  }
  if (minutes < 10)
  minutes = "0" + minutes

  var myTime = hours + ":" + minutes +suffix;
//  alert(myTime);
	
	var pt = document.turkey.pickup_time.value;
	if (pt == '')
	{
		pt = "12:00PM"
	}
//	alert(pt);
	var pd = document.turkey.pickup_date.value;
//	alert(pd);
	
	
////////////////////// date difference 


function isValidDate(dateStr) {
// Date validation function courtesty of 
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
// Checks for the following valid date formats:
// MM/DD/YY MM/DD/YYYY MM-DD-YY MM-DD-YYYY
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert(dateStr + " Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false;
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
return false;
}
}
return true;
}
function isValidTime(timeStr) {
// Time validation function courtesty of 
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.
var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];
if (second=="") { second = null; }
if (ampm=="") { ampm = null }
if (hour < 0 || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using. OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
}
}
if (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute < 0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return true;
}

//function dateDiff() {
date1 = new Date();
date2 = new Date();
diff = new Date();
if (isValidDate(pd) && isValidTime(pt)) { // Validates first date 
date1temp = new Date(pd + " " + pt);
date1.setTime(date1temp.getTime());
}
else return false; // otherwise exits
if (isValidDate(myDate) && isValidTime(myTime)) { // Validates second date 
date2temp = new Date(myDate + " " + myTime);
date2.setTime(date2temp.getTime());
}
else return false; // otherwise exits
// sets difference date to difference of first date and second date
if (date1.getTime() < date2.getTime())
{
	alert("Pick Up Date/Time Not Valid");   //////////////////// date 1 is less then date 2 check
	return false;
}
diff.setTime(Math.abs(date1.getTime() - date2.getTime()));
timediff = diff.getTime();

weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
timediff -= weeks * (1000 * 60 * 60 * 24 * 7);
days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
timediff -= days * (1000 * 60 * 60 * 24);
hours = Math.floor(timediff / (1000 * 60 * 60)); 
timediff -= hours * (1000 * 60 * 60);
mins = Math.floor(timediff / (1000 * 60)); 
timediff -= mins * (1000 * 60);
secs = Math.floor(timediff / 1000); 
timediff -= secs * 1000;
difference = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds";
if (weeks > 0 )
{
	hours = hours + (weeks * 168)
}
if (days > 0)
{
	hours = hours + (days * 24)
}
//alert(hours);         time difference in hours
if(hours<72)
{
	alert("Minimum 72 Hours Lead Time Required");
	return false;
}

//return false; // form should never submit, returns false
//}

/*
if(dateDiff()<72)
{
	alert("Minimum 72 Hours Lead Time Required");
	return false;
}
*/

/////////////////////// 25 dec 2008 check 


if ( turkey.demo1.value=='12/25/2008')
{
	alert("Sold Out, Please Pick Some Other Date")
	turkey.demo1.focus()
	return false;	
}


//<input type=text name=firstdate value="" size=10 maxlength=10>
//<input type=text name=firsttime value="" size=10 maxlength=10> (HH:MM:SS format)
//<input type=text name=seconddate value="" size=10 maxlength=10> (MM/DD/YYYY format)
//<input type=text name=secondtime value="" size=10 maxlength=10> (HH:MM:SS format)
//<input type=text name=difference value="" size=60>

////////////////////
//	if(meal==0){ alert('please select turkey meal(how many)'); return false; }


//////////// check for turkey meal


		Option_meal = -1;
		for (i=turkey.meal.length-1; i > -1; i--)
		{
			if (turkey.meal[i].checked)
			{
				Option_meal = i;
			}
		}

//////////// check for only turkey or hem

		Option_only = -1;
		for (j=turkey.only.length-1; j > -1; j--)
		{
			if (turkey.only[j].checked)
			{
				Option_only = j;
			}
		}


		if (Option_meal == -1 && Option_only == -1)
		{
			alert("please select turkey meal(how many)");
			return false;
		}

		if (Option_meal == -1 && Option_only == 2)
		{
			alert("please select turkey meal(how many)");
			return false;
		}

		if (Option_meal == 4 && Option_only == -1)
		{
			alert("please select turkey meal(how many)");
			return false;
		}

		if (Option_meal == 4 && Option_only == 2)
		{
			alert("please select turkey meal(how many)");
			return false;
		}






// check for free meal
/*
		myOption_free = -1;
		for (i=turkey.free_meal.length-1; i > -1; i--) {
		if (turkey.free_meal[i].checked) {
		myOption_free = i;
		}
		}
		if (myOption_free == -1) {
		alert("Select Free Apple or Pumpkin Pie with Turkey Meal");
		return false;
		}

*/


	document.turkey.submit();
}