<!--  to hide script contents from old browsers
var startDate;
var endDate;
var callbacks = 0;

function resetDates() 
{
	startDate = endDate = null;
}


// Given two dates (in seconds) find out if date1 is bigger, date2 is bigger or
// they're the same, taking only the dates, not the time into account.
// In other words, different times on the same date returns equal.
// returns -1 for date1 bigger, 1 for date2 is bigger 0 for equal
function compareDatesOnly(date1, date2) 
{
	var year1 = date1.getYear();
	var year2 = date2.getYear();
	var month1 = date1.getMonth();
	var month2 = date2.getMonth();
	var day1 = date1.getDate();
	var day2 = date2.getDate();

	if (year1 > year2)
		return -1;
	else if (year2 > year1)
		return 1;

	//years are equal
	if (month1 > month2) 
		return -1;
	else if (month2 > month1) 
		return 1;

	//years and months are equal
	if (day1 > day2) 
		return -1;
	else if (day2 > day1) 
		return 1;

	return 0;	//days are equal
}

function filterDates1(cal) 
{
	startDate = cal.date;
	/* If they haven't chosen an 
	end date before we'll set it to the same date as the start date This
	way if the user scrolls in the start date 5 months forward, they don't
	need to do it again for the end date.
	*/

	if (endDate == null) 
	{ 
		Zapatec.Calendar.setup({
			inputField 		: "txtchkout",
			weekNumbers 	: false,
			button 			: "btnchkout",	// What will trigger the popup of the calendar
			ifFormat 		: "%d-%m-%Y",	// format of the input field: Mar 18, 2005
			timeFormat		: "24",
			date 			: startDate,
			electric 		: false,
			showsTime 		: false,		//no time
			disableFunc 	: dateInRange2,	//the function to call
			onUpdate 		: filterDates2,
			controlMonth 	: ControlMonth(document.frm_search.txtchkin.value, document.frm_search.txtchkout.value),
			numberMonths 	: 2,
			monthsInRow 	: 2
		});
	}
}

function filterDates2(cal)
{
	endDate = cal.date;
	cal.controlMonth = ControlMonth(document.frm_search.txtchkin.value, document.frm_search.txtchkout.value);
}

// Both functions disable and hilight dates.
			
// Can't choose days after the
// end date if it is choosen, hilights start and end dates with one style and dates between them with another
function dateInRange1(date)
{
	if (endDate != null) 
	{
		// Disable dates after end date
		var compareEnd = compareDatesOnly(date, endDate);

		if  (compareEnd < 0) 
			return (true);

		// Hilight end date with "edges" style
		if  (compareEnd == 0) {
		{return "edges";}
		}


		// Hilight inner dates with "between" style
		if (startDate != null)
		{
			var compareStart = compareDatesOnly(date, startDate);
			if  (compareStart < 0) 
			{
				return "between";
			} 
		} 
	}

	//disable days prior to today
	var today = new Date();
	var compareToday = compareDatesOnly(date, today);

	if (compareToday > 0) 
		return(true);

	//all other days are enabled
	return false;
//	return(ret);
}

// Can't choose days before the
// start date if it is choosen, hilights start and end dates with one style and dates between them with another
function dateInRange2(date) 
{
	if (startDate != null) 
	{
		// Disable dates before start date
		var compareDays = compareDatesOnly(startDate, date);
		if  (compareDays < 0)
			return (true);

		// Hilight end date with "edges" style
		if  (compareDays == 0) {
			{return "edges";}
		}

		// Hilight inner dates with "between" style
		if ((endDate != null) && (date > startDate) && (date < endDate))
			return "between";
	} 

	var now = new Date();
	if (compareDatesOnly(now, date) < 0)
		return (true);

	//all other days are enabled
	return false;
}
// end hiding contents from old browsers  -->

///////// FINALLY
var cal = new Zapatec.Calendar.setup({
	inputField		: "txtchkin",   // id of the input field
	weekNumbers		: false,
	button			: "btnchkin",	// What will trigger the popup of the calendar
	ifFormat		: "%d-%m-%Y",	// format of the input field: Mar 18, 2005
	showsTime		: false,		//no time
	dateStatusFunc	: dateInRange1,	//the function to call
	onUpdate		: filterDates1,
	numberMonths	: 2,
	monthsInRow		: 2
});

Zapatec.Calendar.setup({
	inputField		: "txtchkout",
	weekNumbers		: false,
	button			: "btnchkout",  // What will trigger the popup of the calendar
	ifFormat		: "%d-%m-%Y",       // format of the input field: Mar 18, 2005
	showsTime		: false,          //no time
	dateStatusFunc	: dateInRange2, //the function to call
	onUpdate		: filterDates2,
	numberMonths	: 2,
	controlMonth	: ControlMonth(document.frm_search.txtchkin.value, document.frm_search.txtchkout.value),
	monthsInRow		: 2
});

function ControlMonth(start_dt, end_dt)
{
	var r=0;
	
	if((start_dt != "") && (end_dt != ""))
	{
		var start_arr = start_dt.split('-');
		var start_mm = parseInt(start_arr[1]);
		
		var end_arr = end_dt.split('-');
		var end_mm = parseInt(end_arr[1]);

		r = (end_mm > start_mm)? 2: 1;
	}
	else
		r = 1;
}