		
var thisForm = document.SearchForm;

// get the dates from the parent page
var DEPm = thisForm.departureDateMonth;
var DEPd = thisForm.departureDateDay;
var DEPy = thisForm.departureDateYear;
var ARRm = thisForm.arrivalDateMonth;
var ARRd = thisForm.arrivalDateDay;
var ARRy = thisForm.arrivalDateYear;

var myFloater = -1;
var thisDate;

var dMax = 550;
var dMin = 0;
var sameDate = false;
var aod = "";
var dateField ="";
var changedDate;

//-----------------------------------------------------------------

function setDate(mn,dy,yr)
{

	var x = 0;

	if (aod=="dep")
	{
		selectInList(DEPm, DEPm, mn);
		selectInList(DEPd, DEPd, dy);
		selectInList(DEPy, DEPy, yr);
	}

	else if (aod=="arr")
	{
		selectInList(ARRm, ARRm, mn);
		selectInList(DEPd, ARRd, dy);
		selectInList(DEPy, ARRy, yr);
	}

	thisDate.value = thisForm.inputDate.value;

}


//-----------------------------------------------------------------
function selectInList(fromList, inList, val)
{
	var x = 0;
	for ( x=0 ; x < fromList.length; x++ )
			if (inList.options[x].value == val)
			{
				inList.options[x].selected = true;
				break;
			}

}

//-----------------------------------------------------------------


function openCal(oInput,oInput2){

	var dt1 = null;
	var dt2 = null;

	if (oInput.name=="dtArr"){
		aod = "arr";
		oInput.value = thisForm.arrivalDateMonth.options[thisForm.arrivalDateMonth.selectedIndex].value + "/" + thisForm.arrivalDateDay.options[thisForm.arrivalDateDay.selectedIndex].value + "/" + thisForm.arrivalDateYear.options[thisForm.arrivalDateYear.selectedIndex].value;
		oInput2.value = thisForm.departureDateMonth.options[thisForm.departureDateMonth.selectedIndex].value + "/" + thisForm.departureDateDay.options[thisForm.departureDateDay.selectedIndex].value + "/" + thisForm.departureDateYear.options[thisForm.departureDateYear.selectedIndex].value;
		thisDate = oInput;

		var thisDate2 = oInput2;

		thisForm.inputDate.value = thisDate.value;

		sameDate = true;
                changedDate = "dtArr";

	}
	else
	{

		aod = "dep";
		oInput2.value = thisForm.arrivalDateMonth.options[thisForm.arrivalDateMonth.selectedIndex].value + "/" + thisForm.arrivalDateDay.options[thisForm.arrivalDateDay.selectedIndex].value + "/" + thisForm.arrivalDateYear.options[thisForm.arrivalDateYear.selectedIndex].value;
		oInput.value = thisForm.departureDateMonth.options[thisForm.departureDateMonth.selectedIndex].value + "/" + thisForm.departureDateDay.options[thisForm.departureDateDay.selectedIndex].value + "/" + thisForm.departureDateYear.options[thisForm.departureDateYear.selectedIndex].value;
		dt1 = new Date(oInput.value);
		dt2 = new Date(oInput2.value);
		thisDate = oInput;

		var thisDate2 = oInput2;

		if (dt1 < dt2)
		{
			thisForm.inputDate.value = thisDate2.value;
			sameDate = false;
		}

		else
		{
			thisForm.inputDate.value = thisDate.value;
			sameDate = true;
		}

                changedDate="dtDep";
	}

	//------


	myFloater = window.open('/scripts/calendar.html','myWindow','scrollbars=no,status=no,width=155,height=200,top=450,left=250,resizable=no');

	if ( myFloater.opener == null ){
	  myFloater.opener = self;
	  myFloater.location.href = "/scripts/calendar.html";
	}
}
//-----------------------------------------------------------------

function openCalFullDate(fieldName){

	dateField=fieldName;

	myFloater = window.open('/scripts/calendar-full-date.html','myWindow','scrollbars=no,status=no,width=155,height=200,top=450,left=250,resizable=no');

	if ( myFloater.opener == null ){
	  myFloater.opener = self;
	  myFloater.location.href = "/scripts/calendar-full-date.html";
	}
}
//-----------------------------------------------------------------
function writeFullDate(myDate){
  
  if (dateField=="arrival_date"){
    document.MainSearchForm.arrival_date.value=myDate;
  }  
  else if (dateField=="departure_date"){
    document.MainSearchForm.departure_date.value=myDate;
  }
}


