<!--
// Valid dates (v1.0) - T. Nelson '06

window.dbIE  = document.all ? true : false; // IE 4+
window.dbDOM = (document.getElementById && ! document.all) ? true : false; // All other browsers

function limitList(listObj,length) { // Limit drop menu
   var list = listObj
   if (length<(list.selectedIndex+1)) { // Reduce current selected index to new length
      list.selectedIndex=length-1; 
   }
   if (window.dbIE || window.dbDOM) { // All browsers
      if (list.options.length<length) {
         for (var i=list.options.length+1; i<=length; i++) { 
             var oOption = document.createElement('OPTION');
             if (window.dbIE) { // IE
                list.options.add(oOption);
                oOption.innerText = i;
                oOption.Value = i;
             } else if (window.dbDOM) { // Mozilla      
                oOption.text = ' '+i;
                oOption.Value = i;
                list.add(oOption,null);
             }
          }
      } 
	  else if (list.options.length>length) {
         for (var i=list.options.length; i>=length; i--) { 
             list.remove(i);
         }               
      }
  }
}

function validDate() { // Set 'Day' drop menu based on month and year selected

var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31); // Days in the month

var day  = parseInt(document.Search.Day.value);
var month = parseInt(document.Search.Month.value);
var year = parseInt(document.Search.Year.value);

if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { // Leap year so adjust Feb days to 29
	monthLength[1] = 29;
}

var objDay = document.getElementById('Day') // Set 'Day' menu object

var listLength = monthLength[month-1] // Adjust 'Day' menu
limitList(objDay,listLength);
}

// Future dates (v1.0) - T. Nelson '06
function futureDate() {
// Find out values in drop menu
var day  = parseInt(document.Search.Day.value);
var month = parseInt(document.Search.Month.value);
var year = parseInt(document.Search.Year.value);

var now = new Date(); // Date now
now = now.getTime()

var dateToCheck = new Date(); // Date to check
dateToCheck.setYear(year);
dateToCheck.setMonth(month-1);
dateToCheck.setDate(day);

var checkDate = dateToCheck.getTime();

if (now > checkDate) { // Check date
	alert('Your departure date cannot be in the past!');
	return false;
}

return true;
}

function searchValidate() {
// Get menu positions
var selectedAirport = (parseInt(document.Search.Airport.options.selectedIndex));
var selectedResort = (parseInt(document.Search.Turkey.options.selectedIndex));
// Set menu positions in hidden field
var selectedStr = (selectedAirport + ',' + selectedResort);
document.Search.Menu.value = selectedStr;
//if (document.Search.Type[2].checked != true) {
	if (document.Search.Airport.options.selectedIndex == 0) {
		alert('Please select a departure airport.');
		return false;
	} else if (document.Search.Turkey.options.selectedIndex == 0) {
		alert('Please select a resort.');
		return false;
	}
//} else {
//	if (document.Search.Turkey.options.selectedIndex == 0) {
//		alert('Please select a resort.');
//		return false;
//	}
// }
return futureDate();
return true;
}
// -->