		
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 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(ARRd, ARRd, dy);
		selectInList(ARRy, 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){

  if(oInput2==null)
	{
   	 openCal_OneParam(oInput)
        }
	else
	{
	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('/includes/javascript/calendar.html','myWindow','scrollbars=no,status=no,width=155,height=202,top=450,left=250,resizable=no');

	if ( myFloater.opener == null ){
	  myFloater.opener = self;
	  myFloater.location.href = "/includes/javascript/calendar.html";
	}
    }
}
//-----------------------------------------------------------------

function openCal_OneParam(oInput){

		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;
		thisDate = oInput;


		thisForm.inputDate.value = thisDate.value;

		sameDate = true;


	myFloater = window.open('/includes/javascript/calendar.html','myWindow','scrollbars=no,status=no,width=155,height=202,top=450,left=250,resizable=no');

	if ( myFloater.opener == null ){
	  myFloater.opener = self;
	  myFloater.location.href = "/includes/javascript/calendar.html";
	}

}
//-----------------------------------------------------------------

