function setMultipleValuesMS(y,m,d)
{
	y = y+"";
	m = m+"";
	//if (m.length == 1) {m="0"+m;}
	//y = y.charAt(2)+y.charAt(3);
	ym = m+"-"+y;
	d = parseInt(d,10);
	for (var i=0; i < document.forms["searchForm"].frommonthyear.options.length; i++)
	{
		if (document.forms["searchForm"].frommonthyear.options[i].value==ym)
		{
			document.forms["searchForm"].frommonthyear.selectedIndex=i;
		}
	}
	document.forms["searchForm"].fromday.selectedIndex=m;
	for (var i=0; i < document.forms["searchForm"].fromday.options.length; i++)
	{
		if (document.forms["searchForm"].fromday.options[i].value==d)
		{
			document.forms["searchForm"].fromday.selectedIndex=i;
		}
	}
	matchDates();
	//check30();
}
function setMultipleValuesToMS(y,m,d)
{
	y = y+"";
	m = m+"";
	//if (m.length == 1) {m="0"+m;}
	//y = y.charAt(2)+y.charAt(3);
	ym = m+"-"+y;
	d = parseInt(d,10);
	for (var i=0; i < document.forms["searchForm"].tomonthyear.options.length; i++)
	{
		if (document.forms["searchForm"].tomonthyear.options[i].value==ym)
		{
			document.forms["searchForm"].tomonthyear.selectedIndex=i;
		}
	}
	document.forms["searchForm"].today.selectedIndex=m;
	for (var i=0; i < document.forms["searchForm"].today.options.length; i++)
	{
		if (document.forms["searchForm"].today.options[i].value==d)
		{
			document.forms["searchForm"].today.selectedIndex=i;
		}
	}
	//check30();
}
function getDateStringMS(ym_obj,d_obj)
{
	var ym = ym_obj.options[ym_obj.selectedIndex].value;
	var m = ym.split("-")[0];
	var y = ym.split("-")[1];
	var d = d_obj.options[d_obj.selectedIndex].value;
	if (ym=="") { return null; }
	if (d=="") { d=1; }

	var dateString = filterDate(y,m,d);
	return dateString;
}

function getDaysString(ym_obj,d_obj,nights)
{

	var gsDayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');



	var ym = ym_obj.options[ym_obj.selectedIndex].value;
	var d = d_obj.options[d_obj.selectedIndex].value;
	if (ym=="") { return null; }
	if (d=="") { d=1; }
	var m=ym.charAt(0)+ym.charAt(1);
	var y=ym.charAt(3)+ym.charAt(4);

	arr = new Date(y, parseInt(m,10) - 1, parseInt(d,10) - 1);
	dep = new Date(y, parseInt(m,10) - 1, parseInt(d,10) + parseInt(nights,10) - 1);

	var arrDayName = gsDayNames[arr.getDay()];
	var depDayName = gsDayNames[dep.getDay()];

	var dateDisplay = document.getElementById("dayinformation");
}

function filterDy(year, month, day)
{
	var maxDay = 31;
	if (month == 2) { if ((year % 4) == 0) { maxDay = 29; } else { maxDay = 28; } }
	if ((month==4)||(month==6)||(month==9)||(month==11)) {	maxDay = 30; }
	if (day > maxDay) { day = maxDay; }
	return year+'-'+month+'-'+day;
}

function filterDate(year, month, day)
{
	var maxDay = 31;
	if (month == 2) { if ((year % 4) == 0) { maxDay = 29; } else { maxDay = 28; } }
	if ((month==4)||(month==6)||(month==9)||(month==11)) {	maxDay = 30; }
	if (day > maxDay) { day = maxDay; }
	return year+'-'+month+'-'+day;
}

function addMore()
{
	var obj = document.getElementById("numnights");

	if (obj.options[obj.selectedIndex].value == "1")
	{
		obj.remove(obj.selectedIndex);
		for (var i = 2; i < 31; i++)
		{
			addOption(obj,i,i,"");
		}
		obj.selectedIndex = 14;
		obj.focus();
	}
}

function addOption(obj,text,value,selected)
{
	if (obj!=null && obj.options!=null)
	{
		obj.options[obj.options.length] = new Option(text, value, false, selected);
	}
}

function check30()
{
	var obj = document.getElementById("numNights");
	var numNights = obj.options[obj.selectedIndex].value;
	var arrMonth = document.forms['searchForm'].frommonthyear;
	var arrDay = document.forms['searchForm'].fromday;

	getDaysString(arrMonth,arrDay,numNights);

	if (numNights == "30")
	{
		if (!confirm("Please click OK to continue or Cancel to select again."))
		{
			obj.selectedIndex = 0;
			obj.focus();
		}
	}
}

function makeTo1MonthAfterFrom()
{
	var ct = calto;
}