<!--
var Jmonths = new Array( "January","February","March","April","May","June","July","August","September","October","November","December" );

var	date_range_string = "";
var valid_dates = new Array();


var from_dates = new Array();


var thru_dates = new Array();


var limit_to_package_dates = 0;
var min_arrival = "04/06/2007";
var max_arrival = "04/01/2008";
var min_departure = "04/07/2007";
var max_departure = "05/06/2007";

var j_date_functions_js_1 = "The arrival date cannot be before today.\n" +
"The departure date must be after the arrival date.\n" +
"The maximum stay is 30 nights starting on the day of arrival.";
var j_date_functions_js_3 = "The maximum stay is 30 nights starting on the day of arrival.";
var j_date_functions_js_4 = "The departure date can be no further than one year out.\n" +
"The arrival date must be before the departure date.";
var j_date_functions_js_6 = "Dates are limited by the selected package.\n";

//-->


/*
*****************************************************************************************************
Author : Lea Smart
Source : www.totallysmartit.com
Date : 7/3/2001
DHTML Calendar
Version 1.2

You are free to use this code if you retain this header.
You do not need to link to my site (be nice though!)

Amendments
22 Jan 2002; Added ns resize bug code; rewrote date functions into Date 'class';
			 Added support for yyyy-mm-dd date format
			 Added support for calendar beginning on any day
7th Feb 2002 Fixed day highlight when year wasn't current year bug
9th Jun 2002 Fixed bug with weekend colour
			 Amended the code for the date functions extensions.  Shortened addDays code considerably
*****************************************************************************************************
***
	Adapted to RSS Web Booking Engine	- Keith Turner, May 2004
***/

var timeoutDelay = 1000; // milliseconds, change this if you like, set to 0 for the calendar to never auto disappear
var g_startDay = 0// 0=sunday, 1=monday

// preload images
//var imgUp = new Image(16,16);//(8,12);
//imgUp.src = 'images/next.gif';

//var imgDown = new Image(16,16);//(8,12);
//imgDown.src = 'images/prev.gif';

// used by timeout auto hide functions
var timeoutId = false;

var g_Calendar;  // global to hold the calendar reference, set by constructor
//new Calendar(new Date());

// the now standard brwsr sniffer class
function Brwsr()
{
	this.dom = document.getElementById?1:0;
	this.ie4 = (document.all && !this.dom)?1:0;
	this.ns4 = (document.layers && !this.dom)?1:0;
	this.ns6 = (this.dom && !document.all)?1:0;
	this.ie5 = (this.dom && document.all)?1:0;
	this.ok = this.dom || this.ie4 || this.ns4;
	this.platform = navigator.platform;
}

var brwsr = new Brwsr();

// dom brwsrs require this written to the HEAD section

if( brwsr.dom || brwsr.ie4 )
{

	document.writeln('<style>');
	document.writeln('#container {');
	document.writeln('position : absolute;');
	document.writeln('z-index : 99;');
	document.writeln('left : 120px;');
	document.writeln('top : 140px;');
        //document.writeln('left : 0px');
        //document.writeln('top: 0px');
	document.writeln('width : 144px;');;
	brwsr.platform=='Win32'?height=130:height=135;
	document.writeln('height : ' + height +'px;');
	document.writeln('clip:rect(0px 144px ' + height + 'px 0px);');
	//document.writeln('overflow : hidden;');
	document.writeln('visibility : hidden;');
	document.writeln('background-color : #FFFFFF');//#00388D');
	document.writeln('}');
	document.writeln('</style>')
	document.write('<div id="container"');
	if( timeoutDelay )
		document.write(' onmouseout="calendarTimeout();" onmouseover="if( timeoutId) clearTimeout(timeoutId);"');
	document.write('></div>');

}

function calendarTimeout()
{
	if( brwsr.ie4 || brwsr.ie5 )
	{
		if( window.event.srcElement && window.event.srcElement.name!='month')
			timeoutId=setTimeout('g_Calendar.hide();',timeoutDelay);
	}
	if( brwsr.ns6 || brwsr.ns4)
	{
		timeoutId=setTimeout('g_Calendar.hide();',timeoutDelay);
	}
}

// constructor for calendar class
function Calendar()
{
	g_Calendar = this;
	// some constants needed throughout the program
	this.daysOfWeek = new Array("Su","Mo","Tu","We","Th","Fr","Sa");
	this.months = Jmonths;//new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	this.daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if( brwsr.ns4)
	{
		var tmpLayer = new Layer(127);
		if( timeoutDelay)
		{
			tmpLayer.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
			tmpLayer.onmouseover = function(event) { if( timeoutId) clearTimeout(timeoutId); };
			tmpLayer.onmouseout = function(event) { timeoutId=setTimeout('g_Calendar.hide()',timeoutDelay);};
                        alert('mouseover!');
		}
		tmpLayer.x = 100;
		tmpLayer.y = 100;
	    tmpLayer.bgColor = "#ffffff";
	}
	if( brwsr.dom || brwsr.ie4)
	{
		var tmpLayer = brwsr.dom?document.getElementById('container'):document.all.container;
	}
	this.containerLayer = tmpLayer;
	if( brwsr.ns4 && brwsr.platform=='Win32')
	{
		this.containerLayer.clip.height=134;
		this.containerLayer.clip.width=127;
	}

}

Calendar.prototype.getFirstDOM = function()
{
	var thedate = new Date();

	thedate.setDate(1);
	thedate.setMonth(this.month);
	thedate.setFullYear(this.year);
	return thedate.getDay();
}

Calendar.prototype.getDaysInMonth = function ()
{
	if( this.month!=1)
	{
		return this.daysInMonth[this.month]
	}
	else
	{
		// is it a leap year
		if( Date.isLeapYear(this.year))
		{
			return 29;
		}
		else
		{
			return 28;
		}
	}
}

Calendar.prototype.buildString = function()
{
	var tmpStr = '<form onSubmit="this.year.blur();return false;"><table width="100%" border="0" cellspacing="0" cellpadding="2" class="calBorderColor"><tr><td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="1" class="calBgColor">';
	tmpStr += '<tr>';
	tmpStr += '<td width="60%" class="cal" align="left">';
	if( this.hasDropDown )
	{
		tmpStr += '<select class="month" name="month" onchange="g_Calendar.selectChange();">';
		for (var i=0;i<this.months.length;i++)
		{
			tmpStr += '<option value="' + i + '"'
			if( i == this.month) tmpStr += ' selected';
			tmpStr += '>' + this.months[i] + '</option>';
		}
		tmpStr += '</select>';
	}
	else
	{
//		tmpStr += '<table class="calTable" border="0" cellspacing="0" cellpadding="0"><tr><td><a href="javascript: g_Calendar.changeMonth(-1);"><img name="calendar" src="/images/prev.gif" width="8" height="12" border="0" alt=""></a></td><td class="cal" width="100%" align="center">' + this.months[this.month] + '</td><td class="cal"><a href="javascript: g_Calendar.changeMonth(+1);"><img name="calendar" src="images/next.gif" width="8" height="12" border="0" alt=""></a></td></tr></table>';
		tmpStr += '<table class="calTable" border="0" cellspacing="0" cellpadding="0"><tr><td><a href="javascript: g_Calendar.changeMonth(-1);"><img name="calendar" src="/images/prev.gif" width="14" height="12" border="0" alt=""></a></td><td class="cal" width="100%" align="center">' + this.months[this.month] + '</td><td class="cal">&nbsp;</td></tr></table>';
	}
	tmpStr += '</td>';
	/* observation : for some reason if the below event is changed to 'onChange' rather than 'onBlur' it totally crashes IE (4 and 5)!
	 */
	tmpStr += '<td width="40%" align="right" class="cal">';

	if( this.hasDropDown)
	{
		tmpStr += '<input class="year" type="text" size="';
		// get round NS4 win32 length of year input problem
		(brwsr.ns4 && brwsr.platform=='Win32')?tmpStr += 1:tmpStr += 4;
	tmpStr += '" name="year" maxlength="4" onBlur="g_Calendar.inputChange();" value="' + this.year + '">';
	}
	else
	{
//		tmpStr += '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="cal"><a href="javascript: g_Calendar.changeYear(-1);"><img name="calendar" src="images/prev.gif" width="8" height="12" border="0" alt=""></a></td><td class="cal" width="100%" align="center">' + this.year + '</td><td class="cal"><a href="javascript: g_Calendar.changeYear(+1);"><img name="calendar" src="images/next.gif" width="8" height="12" border="0" alt=""></a></td></tr></table>'
		tmpStr += '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="cal">&nbsp;</td><td class="cal" width="100%" align="center">' + this.year + '</td><td class="cal"><a href="javascript: g_Calendar.changeMonth(+1);"><img name="calendar" src="/images/next.gif" width="14" height="12" border="0" alt=""></a></td></tr></table>'
	}
	tmpStr += '</td>';
	tmpStr += '</tr>';
	tmpStr += '</table>';
	var iCount = 1;

	var iFirstDOM = (7+this.getFirstDOM()-g_startDay)%7; // to prevent calling it in a loop

	var iDaysInMonth = this.getDaysInMonth(); // to prevent calling it in a loop

	tmpStr += '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="calBgColor">';
	tmpStr += '<tr>';
	for (var i=0;i<7;i++)
	{
		tmpStr += '<td align="center" class="calDaysColor">' + this.daysOfWeek[(g_startDay+i)%7] + '</td>';
	}
	tmpStr += '</tr>';

	var tmpFrom = parseInt('' + this.dateFromYear + this.dateFromMonth + this.dateFromDay, 10 );
	var tmpTo = parseInt('' + this.dateToYear + this.dateToMonth + this.dateToDay, 10 );	// examples: '20051023', '20060102'
	var tmpCompare;
	var tmpCompare2;

	//alert( 'From: '+tmpFrom+'\nTo: '+tmpTo );

	for( var j=1; j <= 6; j++ )
	{
		tmpStr += '<tr>';
		for( var i=1; i <= 7; i++ )
		{
			tmpStr += '<td width="16" align="center" '
			if(  (7*(j-1) + i) >= iFirstDOM+1  && iCount <= iDaysInMonth )
			{
				if( iCount==this.day && this.year==this.oYear && this.month==this.oMonth )
					tmpStr += 'class="calHighlightColor"';
				else
				{
					if( i==7-g_startDay || i==((7-g_startDay)%7)+1 )
						tmpStr += 'class="calWeekend"';
					else tmpStr += 'class="cal"';
				}
		 		tmpStr += '>';
				/* could create a date object here and compare that but probably more efficient to convert to a number
				and compare number as numbers are primitives */
				tmpCompare = parseInt('' + this.year + padZero(this.month) + padZero(iCount), 10 );
				tmpCompare2 = ( (this.year ) * 100 + this.month ) * 100 + iCount;

				if(		(	( limit_to_package_dates )
						&&	( ! this.DepartureCal )
						&&	( ! isNaN( valid_dates[ tmpCompare2 ] ) ) )
					||
						(	(	( ! limit_to_package_dates )
							||	( this.DepartureCal ) )
						&&
							( tmpCompare >= tmpFrom && tmpCompare <= tmpTo ) ) )
				{
					tmpStr += '<a class="cal" href="javascript: g_Calendar.clickDay(' + iCount + ');">' + iCount + '</a>';
				}
				else
				{
					tmpStr += '<span class="disabled">' + iCount + '</span>';
				}

				iCount++;
			}
			else
			{
				if( i==7-g_startDay || i==((7-g_startDay)%7)+1 )
					tmpStr += 'class="calWeekend"';
				else
					tmpStr +='class="cal"';
				tmpStr += '>&nbsp;';
			}
			tmpStr += '</td>'
		}
		tmpStr += '</tr>'
	}
	tmpStr += '</table></td></tr></table></form>'
	return tmpStr;
}

Calendar.prototype.selectChange = function()
{
	this.month = brwsr.ns6?this.containerLayer.ownerDocument.forms[0].month.selectedIndex:this.containerLayer.document.forms[0].month.selectedIndex;
	this.writeString(this.buildString());
}

Calendar.prototype.inputChange = function()
{
	var tmp = brwsr.ns6?this.containerLayer.ownerDocument.forms[0].year:this.containerLayer.document.forms[0].year;
	if( tmp.value >=1900 || tmp.value <=2100)
	{
		this.year = tmp.value;
		this.writeString(this.buildString());
	}
	else
	{
		tmp.value = this.year;
	}
}

Calendar.prototype.changeYear = function(incr)
{
	(incr==1)?this.year++:this.year--;
	this.writeString(this.buildString());
}

Calendar.prototype.changeMonth = function(incr)
{
	if( this.month==11 && incr==1 )
	{
		this.month = 0;
		this.year++;
	}
	else
	{
		if( this.month==0 && incr==-1 )
		{
			this.month = 11;
			this.year--;
		}
		else
		{
			(incr==1)?this.month++:this.month--;
		}
	}
	this.writeString(this.buildString());
}

Calendar.prototype.clickDay = function(day)
{
	var tmp = eval('document.' + this.target);
	tmp.value = this.formatDateAsString(day,this.month,this.year);
	if( brwsr.ns4) this.containerLayer.hidden=true;
	if( brwsr.dom || brwsr.ie4)
	{
		this.containerLayer.style.visibility='hidden';
	}

	adjust_dates( document.frm );	// kgt
}

Calendar.prototype.formatDateAsString = function(day, month, year)
{
	var delim = eval('/\\' + this.dateDelim + '/g');	//'
	switch( this.dateFormat.replace(delim,"") )
	{
		case 'ddmmmyyyy': return padZero(day) + this.dateDelim + this.months[month].substr(0,3) + this.dateDelim + year;
		case 'ddmmyyyy': return padZero(day) + this.dateDelim + padZero(month+1) + this.dateDelim + year;
		case 'mmddyyyy': return padZero((month+1)) + this.dateDelim + padZero(day) + this.dateDelim + year;
	    case 'yyyymmdd': return year + this.dateDelim + padZero(month+1) + this.dateDelim + padZero(day);
		default: alert('unsupported date format');
	}
}

Calendar.prototype.writeString = function(str)
{
	if( brwsr.ns4)
	{
		this.containerLayer.document.open();
		this.containerLayer.document.write(str);
		this.containerLayer.document.close();
	}
	if( brwsr.dom || brwsr.ie4)
	{
		this.containerLayer.innerHTML = str;
	}
}

Calendar.prototype.show = function( event, target, bHasDropDown, dateFormat, str_dateFrom, str_dateTo, bDepartureCal )
{
	// calendar can restrict choices between 2 dates, if however no restrictions
	// are made, let them choose any date between 1900 and 3000

	dateFrom = new Date( Date.parse( str_dateFrom ) );
	dateTo = new Date( Date.parse( str_dateTo ) );

	this.dateFrom = dateFrom || new Date(1900,0,1);
	this.dateFromDay = padZero(this.dateFrom.getDate());
	this.dateFromMonth = padZero(this.dateFrom.getMonth());
	this.dateFromYear = this.dateFrom.getFullYear();

	this.dateTo = dateTo || new Date(3000,0,1);
	this.dateToDay = padZero(this.dateTo.getDate());
	this.dateToMonth = padZero(this.dateTo.getMonth());
	this.dateToYear = this.dateTo.getFullYear();

	this.hasDropDown = bHasDropDown;
	this.DepartureCal = bDepartureCal;

	this.dateFormat = dateFormat || 'dd-mmm-yyyy';
	switch( this.dateFormat)
	{
		case 'dd-mmm-yyyy':
		case 'dd-mm-yyyy':
		case 'yyyy-mm-dd':
			this.dateDelim = '-';
			break;
		case 'dd/mm/yyyy':
		case 'mm/dd/yyyy':
		case 'dd/mmm/yyyy':
			this.dateDelim = '/';
			break;
	}

	if( brwsr.ns4 )
	{
		if( !this.containerLayer.hidden)
		{
			this.containerLayer.hidden=true;
			return;
		}
	}
	if( brwsr.dom || brwsr.ie4 )
	{
		if( this.containerLayer.style.visibility=='visible' )
		{
			this.containerLayer.style.visibility='hidden';
			return;
		}
	}

	if( brwsr.ie5 || brwsr.ie4)
	{
		var event = window.event;
	}

	if( brwsr.ns4 )
	{
	    this.containerLayer.x = event.x-160;//+10;
	    this.containerLayer.y = event.y-5;
	}
	if( brwsr.ie5 || brwsr.ie4 )
	{
		var obj = event.srcElement;
		x = 0;
		while( obj.offsetParent != null )
		{
			x += obj.offsetLeft;
			obj = obj.offsetParent;
		}
		x += obj.offsetLeft;
		y = 0;
		var obj = event.srcElement;

		while( obj.offsetParent != null )
		{
			y += obj.offsetTop;
			obj = obj.offsetParent;
		}
		y += obj.offsetTop;

        this.containerLayer.style.left = x-120;//+35;	// inline frame positioning
		if( event.y>0 )
			this.containerLayer.style.top = y - 103;
	}
	if( brwsr.ns6 )
	{
	    this.containerLayer.style.left = event.pageX-140;//+10;
		this.containerLayer.style.top = event.pageY-15;
	}

	this.target = target;
	var tmp = eval('document.' + this.target);
	if( tmp && tmp.value && tmp.value.split(this.dateDelim).length==3 && tmp.value.indexOf('d')==-1 )
	{
		var atmp = tmp.value.split(this.dateDelim)
		switch( this.dateFormat)
		{
			case 'dd-mmm-yyyy':
			case 'dd/mmm/yyyy':
				for (var i=0;i<this.months.length;i++)
				{
					if( atmp[1].toLowerCase()==this.months[i].substr(0,3).toLowerCase())
					{
						this.month = this.oMonth = i;
						break;
					}
				}
				this.day = parseInt(atmp[0],10);
				this.year = this.oYear = parseInt(atmp[2],10);
				break;
			case 'dd/mm/yyyy':
			case 'dd-mm-yyyy':
				this.month = this.oMonth = parseInt(atmp[1]-1,10);
				this.day = parseInt(atmp[0],10);
				this.year = this.oYear = parseInt(atmp[2],10);
				break;
			case 'mm/dd/yyyy':
			case 'mm-dd-yyyy':
				this.month = this.oMonth = parseInt(atmp[0]-1,10);
				this.day = parseInt(atmp[1],10);
				this.year = this.oYear = parseInt(atmp[2],10);
				break;
			case 'yyyy-mm-dd':
				this.month = this.oMonth = parseInt(atmp[1]-1,10);
				this.day = parseInt(atmp[2],10);
				this.year = this.oYear = parseInt(atmp[0],10);
				break;
		}
	}
	else
	{ // no date set, default to today
		var theDate = new Date();
		this.year = this.oYear = theDate.getFullYear();
		this.month = this.oMonth = theDate.getMonth();
		this.day = this.oDay = theDate.getDate();
	}
	this.writeString(this.buildString());
        if (!event) {
                event = window.event;
        }

	if (event.pageX || event.pageY) 	{
                //alert(event.pageX + ":" + event.pageY);
		//this.containerLayer.style = 'left: ' + event.pageX + 'px; top:' + event.pageY + 'px;'
                var xPos = (event.pageX) + 'px';
                var yPos = (event.pageY) + 'px';
                this.containerLayer.style.left = xPos; 
                this.containerLayer.style.top = yPos;
                //this.containerLayer.margin-left
	}

	// and then show it!
	if( brwsr.ns4 )
	{
		this.containerLayer.hidden=false;
	}
	if( brwsr.dom || brwsr.ie4 )
	{
		this.containerLayer.style.visibility='visible';
	}
}

Calendar.prototype.hide = function()
{
	if( brwsr.ns4) this.containerLayer.hidden = true;
	if( brwsr.dom || brwsr.ie4)
	{
		this.containerLayer.style.visibility='hidden';
	}
}

function handleDocumentClick(e)
{
	if( brwsr.ie4 || brwsr.ie5) e = window.event;

	if( brwsr.ns6)
	{
		var bTest = (e.pageX > parseInt(g_Calendar.containerLayer.style.left,10) && e.pageX <  (parseInt(g_Calendar.containerLayer.style.left,10)+125) && e.pageY < (parseInt(g_Calendar.containerLayer.style.top,10)+125) && e.pageY > parseInt(g_Calendar.containerLayer.style.top,10));
		if( e.target.name!='imgCalendar' && e.target.name!='month'  && e.target.name!='year' && e.target.name!='calendar' && !bTest)
		{
			g_Calendar.hide();
		}
	}
	if( brwsr.ie4 || brwsr.ie5)
	{
		// extra test to see if user clicked inside the calendar but not on a valid date, we don't want it to disappear in this case
		var bTest = (e.x > parseInt(g_Calendar.containerLayer.style.left,10) && e.x <  (parseInt(g_Calendar.containerLayer.style.left,10)+125) && e.y < (parseInt(g_Calendar.containerLayer.style.top,10)+125) && e.y > parseInt(g_Calendar.containerLayer.style.top,10));
		if( e.srcElement.name!='imgCalendar' && e.srcElement.name!='month' && e.srcElement.name!='year' && !bTest & typeof(e.srcElement)!='object')
		{
			g_Calendar.hide();
		}
	}
	if( brwsr.ns4) g_Calendar.hide();

}

// utility function
function padZero(num)
{
	return ((num <= 9) ? ("0" + num) : num);
}

// Finally licked extending  native date object;
Date.isLeapYear = function(year)
{
	if( year%4==0 && ((year%100!=0) || (year%400==0))) return true; else return false;
}
Date.daysInYear = function(year)
{
	if( Date.isLeapYear(year)) return 366; else return 365;
}

var DAY = 1000*60*60*24;

Date.prototype.addDays = function(num)
{
	return new Date((num*DAY)+this.valueOf());
}

// events capturing, careful you don't override this by setting something in the onload event of
// the body tag
function initCalendar()
{
	new Calendar(new Date());
	if( brwsr.ns4)
	{
		if( typeof document.NSfix == 'undefined')
		{
			document.NSfix = new Object();
	    	document.NSfix.initWidth=window.innerWidth;
			document.NSfix.initHeight=window.innerHeight;
		}
	}
}

if( brwsr.ns4) window.onresize = function()
{
	if( document.NSfix.initWidth!=window.innerWidth || document.NSfix.initHeight!=window.innerHeight )
		window.location.reload(false);
} // ns4 resize bug workaround

window.document.onclick=handleDocumentClick;

/*window.onerror = function(msg,url,line)
{
	alert('JS ERROR' +
		'\nError details \nText:' + msg + '\nurl:' + url + '\nline:' + line);

//	  alert('******* an error has occurred ********' +
//	  '\n\nPlease check that' +
//	  '\n\n1)You have not added any code to the body onload event,'
//	  +  '\nif you want to run something as well as the calendar initialisation'
//	  + '\ncode, add it to the onload event in the calendar library.'
//	  + '\n\n2)You have set the parameters correctly in the g_Calendar.show() method '
//	  + '\n\nSee www.totallysmartit.com\\examples\\calendar\\simple.asp for examples'
//	  + '\n\n------------------------------------------------------'
//	  + '\nError details'
//	  + '\nText:' + msg + '\nurl:' + url + '\nline:' + line);

}
*/

//date_functions.js

var	one_day = 1000 * 60 * 60 * 24;
var	one_month = 30 * one_day;
var	one_year = 364 * one_day;
var	one_year_less_two_days = 362 * one_day;
var	one_year_less_one_day = 363 * one_day;

function fix_year( tm )
{
	at = new Date( tm );
	year = at.getYear();
	if( year < 100 )
	{	year = year + 2000;	}
	else if( year < 1900 )
	{	year = year + 1900;	}
	else if( year < 2000 )
	{	year = year + 2000;	}
	at.setFullYear( year );
	tm = at.getTime();
	return tm;
}

function fix_dates( frm )	// kgt
{
	alrt = 0;

	today = new Date();
	today_str = (today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear();

	todays_time = Date.parse( today_str );

	arrival_time = Date.parse( document.frm.arrival_date.value );
	departure_time = Date.parse( document.frm.departure_date.value );

	min_departure_time = Date.parse( min_departure );
	max_departure_time = Date.parse( max_departure );

	min_arrival_time = Date.parse( min_arrival );
	max_arrival_time = Date.parse( max_arrival );

	if( isNaN(arrival_time) || isNaN(departure_time) )
	{
		arrival_time = todays_time;
		departure_time = todays_time + one_day;
		alrt = 1;
	}

	arrival_time = fix_year( arrival_time );
	departure_time = fix_year( departure_time );

	done = 0;
	limit = 10;
	while( (done == 0) && (limit-- > 0) )
	{
		done = 1;

		at = new Date( arrival_time );
		arrival_month = at.getMonth();
		arrival_day = at.getDate();
		arrival_year = at.getFullYear();

		dt = new Date( arrival_time );
		departure_month = dt.getMonth();
		departure_day = dt.getDate();
		departure_year = dt.getFullYear();

		if( limit_to_package_dates )
		{
			i = 0;
			while( !isNaN( Date.parse( from_dates[i] ) ) )
			{
				fd_time = Date.parse( from_dates[i] );
				td_time = Date.parse( thru_dates[i] );
				if(		( arrival_time >= fd_time )
					&&	( arrival_time <= td_time ) )
				{
					min_arrival_time = fd_time;
					min_departure_time = fd_time + one_day;
					max_departure_time = td_time + one_day;
					max_arrival_time = max_departure_time - one_day;
					done = 0;
					break;
				}
				i++;
			}
		}
		else
		{
			max_departure_time = arrival_time + one_month;
		}


		if(    (arrival_time   < todays_time)
			|| (departure_time < todays_time) )
		{
			arrival_time = todays_time;
			departure_time = todays_time + one_day;
			done = 0;
			alrt = 1;
		}
		/*else */if( departure_time > max_departure_time )
		{
			departure_time = max_departure_time;
			done = 0;
			alrt = 6;
		}
		/*else */if( arrival_time >= departure_time )
		{
			departure_time = arrival_time  + one_day;
			done = 0;
			alrt = 2;
		}
		/*else */if( departure_time > (arrival_time + one_month) )
		{
			departure_time = arrival_time  + one_month;
			done = 0;
			alrt = 3;
		}
		/*else */if(   (departure_time > (todays_time + one_year))
				|| (arrival_time   > (todays_time + one_year_less_one_day)) )
		{
			departure_time = todays_time + one_year;
			arrival_time = todays_time + one_year_less_one_day;
			done = 0;
			alrt = 4;
		}
		/*else */if(	( limit_to_package_dates )
				&&	(	(min_arrival_time > arrival_time)
					||	(max_departure_time < departure_time) ) )
		{
			departure_time = max_departure_time;
			arrival_time = min_arrival_time;
			done = 0;
			alrt = 5;
		}
		/*else */if(	( limit_to_package_dates )
				&&	( isNaN( valid_dates[ ( ( arrival_year ) * 100 + arrival_month ) * 100 + arrival_day ] ) ) )
		{
			departure_time = max_departure_time;
			arrival_time = min_arrival_time;
			done = 0;
			alrt = 6;
		}

		if( max_departure_time > arrival_time + one_month )
		{
			max_departure_time = arrival_time + one_month;
			done = 0;
		}

		if( max_departure_time > todays_time + one_year )
		{
			max_departure_time = todays_time + one_year;
			done = 0;
		}

	}

	nights = Math.ceil( ( departure_time - arrival_time ) / one_day );

	at = new Date( arrival_time );
	dt = new Date( departure_time );

	mt = new Date( max_departure_time );
	mit = new Date( arrival_time + one_day );

	arrival_month = at.getMonth();
	arrival_day = at.getDate();
	arrival_year = at.getFullYear();

	departure_month = dt.getMonth();
	departure_day = dt.getDate();
	departure_year = dt.getFullYear();

	max_month = mt.getMonth();
	max_day = mt.getDate();
	max_year = mt.getFullYear();

	min_month = mit.getMonth();
	min_day = mit.getDate();
	min_year = mit.getFullYear();

	document.frm.arrival_date.value = (arrival_month + 1) + "/" + arrival_day + "/" + arrival_year;
	document.frm.departure_date.value = (departure_month + 1) + "/" + departure_day + "/" + departure_year;

	max_departure = (max_month + 1) + "/" + max_day + "/" + max_year;
	min_departure = (min_month + 1) + "/" + min_day + "/" + min_year;

	//alert( 'XX From: '+min_departure+'\nTo: '+max_departure );

	document.frm.nights.value = nights;

	return alrt;
}

function arrival_plus_nights( frm )
{
	nights = document.frm.nights.value;

	if( nights > 30 ){	nights = 30;	}

	arrival_time = Date.parse( document.frm.arrival_date.value );
	departure_time = arrival_time + Math.ceil( nights * one_day );

	dt = new Date( departure_time );

	departure_month = dt.getMonth();
	departure_day = dt.getDate();
	departure_year = dt.getFullYear();

	document.frm.departure_date.value = (departure_month + 1) + "/" + departure_day + "/" + departure_year;

	fix_dates( frm, true );
}

function adjust_dates( frm )
{
	res = fix_dates( frm );

	if( ! res )	return;

	switch( res )
	{
		case 1:
			//msg = "The arrival date cannot be before today.\n" +
			//	"The departure date must be after the arrival date.\n" +
			//	"The maximum stay is 30 nights starting on the day of arrival.";
			alert( j_date_functions_js_1 );
			document.frm.arrival_date.focus();
			break;
		case 2:
			//msg = "The departure date must be after the arrival date.\n" +
			//	"The maximum stay is 30 nights starting on the day of arrival.";
			//alert( j_date_functions_js_2 );
			break;
		case 3:
			//msg = "The maximum stay is 30 nights starting on the day of arrival.";
			alert( j_date_functions_js_3 );
			document.frm.arrival_date.focus();
			break;
		case 4:
			//msg = "The departure date can be no further than one year out.\n" +
			//	"The arrival date must be before the departure date.";
			alert( j_date_functions_js_4 );
			document.frm.arrival_date.focus();
			break;
		case 5:
		case 6:
			//msg = "Dates are limited by the selected package.\n"
			alert( j_date_functions_js_6 + date_range_string );
			document.frm.arrival_date.focus();
			break;
		default:
			msg = "Error: " + res;
			alert( msg );
			document.frm.arrival_date.focus();
			break;
	}
}

//-->
<!--
	function confirm_quit_if_folio_exists()
	{
		if( 0 )
		{
			//return confirm('If you quit, the package you are building will be lost.\nAre you sure that you want to quit?');
			return confirm('If you quit, the package you are building will be lost.\nAre you sure that you want to quit?');
		}
		return true;
	}

	function confirm_folio_save( loc )
	{
		if( 0 )
		{
			//return confirm('By clicking this link, you will be saving your current Package and quiting.\nAn agent will review your Package and contact you. \nAre you ready to proceed?');
			res = confirm('By clicking this link, you will be saving your current package and quiting.\nAn agent will review your package and contact you. \nAre you ready to proceed?');
			if( res )
			{
				this.location = loc;
			}
		}
	}

	function popup( url, size )
	{
		if( url.indexOf( '?' ) < 0 )
		{
			url += '?calledfrom=/search.php';
		}
		else
		{
			url += '&calledfrom=/search.php';
		}
		if( size == 'xsmall' )
		{
			wo = window.open( url, 'WBPOP1', 'toolbar=no,location=no,scrollbars=yes,statusbar=no,menubar=no,resizable=yes,width=450,height=240');
		}
		if( size == 'small' )
		{
			wo = window.open( url, 'WBPOP2', 'toolbar=no,location=no,scrollbars=yes,statusbar=no,menubar=no,resizable=yes,width=500,height=300');
		}
		if( size == 'medium' )
		{
			wo = window.open( url, 'WBPOP3', 'toolbar=no,location=no,scrollbars=yes,statusbar=no,menubar=no,resizable=yes,width=750,height=400');
		}
		if( size =='large' )
		{
			wo = window.open( url, 'WBPOP4', 'toolbar=no,location=no,scrollbars=yes,statusbar=no,menubar=no,resizable=yes,width=800,height=600');
		}
		if( size == 'medium_tall' )
		{
			wo = window.open( url, 'WBPOP4', 'toolbar=no,location=no,scrollbars=yes,statusbar=no,menubar=no,resizable=yes,width=750,height=570');
		}
		wo.focus();
	}
//-->
<!--
function bmouseover(obj)
{
	obj.className = "mouseoverformbutton";
}
function bmouseout(obj)
{
	obj.className = "formbutton";
}
function nabmouseover(obj)
{
	obj.className = "namouseoverformbutton";
}
function nabmouseout(obj)
{
	obj.className = "naformbutton";
}
//-->
<!--

function findObj(n, d)
{ //v4.01
	var p,i,x;
	if( !d )	d=document;
	if( ( p = n.indexOf("?") ) > 0 && parent.frames.length )
	{
		d = parent.frames[ n.substring(p+1) ].document;
		n = n.substring(0,p);
	}
	if( !(x=d[n])&&d.all) x=d.all[n];
	for( i=0; !x && i<d.forms.length; i++ )	x=d.forms[i][n];
	for( i=0; !x && d.layers && i > d.layers.length; i++ )	x=findObj( n, d.layers[i].document );
	if( !x && d.getElementById )	x=d.getElementById(n);
	return x;
}

function showHideLayers()
{
	var i, p, v, b, obj, args = showHideLayers.arguments;

	for( i = 0; i < (args.length - 2); i += 3 )
	{
		if( ( obj = findObj( args[i] ) ) != null )
		{
			v=args[i+2];
			b=args[i+1];
			if( obj.style )
			{
				obj=obj.style;
				b=(v=='show')?((b=='')?'block':b):'none';
				v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			}
    		obj.visibility=v;
    		obj.display=b;
		}
	}
}
//-->
<!--

function bdf()
{
	//msg = "Any products you have added to your folio will be removed. Are you sure you want to start over?";

	if( confirm( "Any products you have added to your folio will be removed. Are you sure you want to start over?" ) )
	{
		loc = "search.php?delete_all_items=yes";
		this.location = loc;
	}
}

function hide_ages()
{
showHideLayers(
 'ages','','hide',
  'age1','','hide',
   'age2','','hide',
    'age3','','hide',
     'age4','','hide',
      'age5','','hide',
       'age6','','hide',
        'age7','','hide',
         'age8','','hide' );
}

function show_ages()
{
	hide_ages();

	switch( document.frm.number_of_children.selectedIndex )
	{
		case 8:
			showHideLayers( 'age8','inline','show' );
		case 7:
			showHideLayers( 'age7','inline','show' );
		case 6:
			showHideLayers( 'age6','inline','show' );
		case 5:
			showHideLayers( 'age5','inline','show' );
		case 4:
			showHideLayers( 'age4','inline','show' );
		case 3:
			showHideLayers( 'age3','inline','show' );
		case 2:
			showHideLayers( 'age2','inline','show' );
		case 1:
			showHideLayers(
			 'age1','inline','show',
			  'ages','','show' );
			break;
	}
}

function frm_Validator(theForm)
{

	if (theForm.arrival_date.value == "")
	{
		//alert("Please enter a value for the \"Arrival Date\" field.");
		alert( "Please enter a value for the \"Arrival Date\" field." );
		theForm.arrival_date.focus();
		return (false);
	}

	if (theForm.arrival_date.value.length < 8)
	{
		//alert("Please enter at least 8 characters in the \"Arrival Date\" field.");
		alert( "Please enter at least 8 characters in the \"Arrival Date\" field." );
		theForm.arrival_date.focus();
		return (false);
	}

	if (theForm.arrival_date.value.length > 10)
	{
		//alert("Please enter at most 10 characters in the \"Arrival Date\" field.");
		alert( "Please enter at most 10 characters in the \"Arrival Date\" field." );
		theForm.arrival_date.focus();
		return (false);
	}

	var checkOK = "0123456789-/";
	var checkStr = theForm.arrival_date.value;
	var allValid = true;
	var validGroups = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		//alert("Please enter only digit and \"/\" characters in the \"Arrival Date\" field.");
		alert( "Please enter only digit and \"/\" characters in the \"Arrival Date\" field." );
		theForm.arrival_date.focus();
		return (false);
	}

	if (theForm.departure_date.value == "")
	{
		//alert("Please enter a value for the \"Arrival Date\" field.");
		alert( "Please enter a value for the \"Arrival Date\" field." );
		theForm.departure_date.focus();
		return (false);
	}

	if (theForm.departure_date.value.length < 8)
	{
		//alert("Please enter at least 8 characters in the \"Departure Date\" field.");
		alert( "Please enter at least 8 characters in the \"Departure Date\" field." );
		theForm.departure_date.focus();
		return (false);
	}

	if (theForm.departure_date.value.length > 10)
	{
		//alert("Please enter at most 10 characters in the \"Departure Date\" field.");
		alert( "Please enter at most 10 characters in the \"Departure Date\" field." );
		theForm.departure_date.focus();
		return (false);
	}

	var checkOK = "0123456789-/";
	var checkStr = theForm.departure_date.value;
	var allValid = true;
	var validGroups = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		//alert("Please enter only digit and \"/\" characters in the \"Departure Date\" field.");
		alert( "Please enter only digit and \"/\" characters in the \"Departure Date\" field." );
		theForm.departure_date.focus();
		return (false);
	}


	if( theForm.number_of_children.selectedIndex > 0 )
	{
		if( ( theForm.number_of_children.selectedIndex > 0 ) && ( document.getElementById( 'a1' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 1st child.");
			alert( "Please select an age for the 1st child." );
			document.getElementById( 'a1' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 1 ) && ( document.getElementById( 'a2' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 2nd child.");
			alert( "Please select an age for the 2nd child." );
			document.getElementById( 'a2' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 2 ) && ( document.getElementById( 'a3' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 3rd child.");
			alert( "Please select an age for the 3rd child." );
			document.getElementById( 'a3' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 3 ) && ( document.getElementById( 'a4' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 4th child.");
			alert( "Please select an age for the 4th child." );
			document.getElementById( 'a4' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 4 ) && ( document.getElementById( 'a5' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 5th child.");
			alert( "Please select an age for the 5th child." );
			document.getElementById( 'a5' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 5 ) && ( document.getElementById( 'a6' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 6th child.");
			alert( "Please select an age for the 6th child." );
			document.getElementById( 'a6' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 6 ) && ( document.getElementById( 'a7' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 7th child.");
			alert( "Please select an age for the 7th child." );
			document.getElementById( 'a7' ).focus();
			return (false);
		}
		if( ( theForm.number_of_children.selectedIndex > 7 ) && ( document.getElementById( 'a8' ).selectedIndex == 0 ) )
		{
			//alert("Please select an age for the 8th child.");
			alert( "Please select an age for the 8th child." );
			document.getElementById( 'a8' ).focus();
			return (false);
		}
	}


	return (true);
}



function do_reset( frm )
{
	document.frm.number_of_children.selectedIndex = 0;
	show_ages();
}

//-->