//--------------------------------------------
var activeElement;
//NETSCAPE SPECIFIC MOUSE EVENT CAPTURE MECHANISM
if(window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
	window.captureEvents(Event.CLICK);
	window.onmousemove = NS_MouseEventHandler;

	// create window.event object for netscape
	window.event = new Object;
}

//--------------------------------------------
function NS_MouseEventHandler(theMouseEvent) { window.event.clientX = theMouseEvent.pageX; window.event.clientY = theMouseEvent.pageY; routeEvent(theMouseEvent); }

//--------------------------------------------
function setNewDate(theDateStr) { document.getElementById(activeElement).value = theDateStr; document.getElementById("calendar").style.display = "none";
	try { eval(evalOnDateChange); }catch(e){} }

//--------------------------------------------
function showCalendar(theActiveDateBox) {
	activeElement	= theActiveDateBox;
	var my_datebox	= document.getElementById(theActiveDateBox);
	var my_calendar = document.getElementById("calendar");

	if(window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
	
    my_calendar.style.top = window.document.body.scrollTop + window.event.clientY - 50;
	my_calendar.style.position	= "absolute";
}
	else
	my_calendar.style.top = window.document.body.scrollTop + window.event.clientY + 10;
	my_calendar.style.left	= window.event.clientX - 235;
	my_calendar.style.position = "absolute";
	my_calendar.style.display = "block";
}

//--------------------------------------------
function hideCalendar() { document.getElementById("calendar").style.display = "none"; document.getElementById(activeElement).focus(); }

//--------------------------------------------
/*window.onload = function window_loaded() {
	//set default Dates
	var departDate = new Date();
	var returnDate = new Date();
	departDate.setDate(departDate.getDate()+10);
	returnDate.setDate(returnDate.getDate()+11);
	SetDateObj("itineraryStartDate",departDate);
	SetDateObj("itineraryEndDate",returnDate);
}
*/
window.onload = function loadScript() {

		var now = new Date();
		var startDate = new Date();
		newDate = new Date(now.getTime() + (3*24*60*60*1000));
		// ---------------------------------------------
		if ((newDate.getMonth()+1)<10) {
			startMonth = "0" + (newDate.getMonth()+1);
		} else {
			startMonth = (newDate.getMonth()+1);
		}
		// ---------------------------------------------
		startDate = startMonth + "/" +  newDate.getDate() + "/" + newDate.getFullYear();
		document.TravelRequestForm.itineraryStartDate.value = startDate;

		// ---------------------------------------------
		newDate = new Date(now.getTime() + (8*24*60*60*1000));
		// ---------------------------------------------
		if ((newDate.getMonth()+1)<10) {
			startMonth = "0" + (newDate.getMonth()+1);
		} else {
			startMonth = (newDate.getMonth()+1);
		}
		// ---------------------------------------------
		endDate = startMonth + "/" +  newDate.getDate() + "/" + newDate.getFullYear();

		document.TravelRequestForm.itineraryEndDate.value = endDate;

	}

	// -----------------------------------------
	// Start Datefield validation code
	var DepartDate = "";
	var ReturnDate = "";
	// -----------------------------------------
	function InitSaveVariables(fieldDepartDate,fieldReturnDate) {
	DepartDate = fieldDepartDate.value;
	ReturnDate = fieldReturnDate.value;
}






//--------------------------------------------
function SetDateObj(objName,dateObj) { document.getElementById(objName).value = (dateObj.getMonth()+1) + "/" + dateObj.getDate() + "/" + dateObj.getFullYear(); }

//--------------------------------------------
function GetTag(tagId) { return document.getElementById(tagId); }

//--------------------------------------------
// Start Datefield validation code
var DepartDate = "";
var ReturnDate = "";

function InitSaveVariables(fieldDepartDate,fieldReturnDate) { DepartDate = fieldDepartDate.value; ReturnDate = fieldReturnDate.value;}

//--------------------------------------------

	INTERISLAND_STAY_DAYS = 1;
	INBOUND_STAY_DAYS = 7;
	OUTBOUND_STAY_DAYS = 7;


function DepartChecker(fieldDepartDate,fieldReturnDate) {
	var leeDay;

	dtDepart = new Date(fieldDepartDate.value);
	dtReturn = new Date(fieldReturnDate.value);

	day = dtDepart.getDate();
	month = dtDepart.getMonth();
	year = dtDepart.getFullYear();
	leeDay = INTERISLAND_STAY_DAYS;


	for(var i=1; i<=leeDay; i++) { day++; }

	oldDepart = new Date(fieldDepartDate.value);
	oldDepart.setDate(day);
	newDepart = (oldDepart.getMonth() + 1) + "/" + oldDepart.getDate() + "/" + oldDepart.getFullYear();

	if (dtDepart > dtReturn) { fieldReturnDate.value = newDepart; }
}
//--------------------------------------------
/* See the above routine */
function ReturnChecker(fieldDepartDate,fieldReturnDate) {
	dtDepart=new Date(fieldDepartDate.value);
	dtReturn=new Date(fieldReturnDate.value);

	if (dtReturn < dtDepart) { fieldDepartDate.value = fieldReturnDate.value; }
}

//--------------------------------------------
for (var i = 0; i < document.getElementsByTagName('iframe').length; i++)

if (document.getElementsByTagName('iframe')[i].allowTransparency == false)

document.getElementsByTagName('iframe')[i].allowTransparency = true;
