// Alex's script to create mini reservation app on pgs.

/**
 * Sets the form dates
 *
 * @param integer month
 * @param integer year
 * @param integer day
 */
function setFormDates(month, year, day)
{
	var select_arrMnthYr_length = document.resLauncher.arrMnthYr.options.length;
	var select_arrMnthYr_index = 0;
	
	var arrMnthYr_date = new Date(year, month, 01);
	
	for (m = 0; m < select_arrMnthYr_length; m++)
	{
		var select_arrMnthYr = document.resLauncher.arrMnthYr.options[m].value;
		
		if (arrMnthYr_date == select_arrMnthYr)
		{
			select_arrMnthYr_index = m;
		}
	}
	
	document.resLauncher.arrMnthYr.selectedIndex = select_arrMnthYr_index;
	
	setDates(true);
	
	// set Day
	
	var select_arrDay_length = document.resLauncher.arrDay.options.length;
	var select_arrDay_index = 0;
	
	var arrDay_date = new Date(year, month, day);
	
	for (d = 0; d < select_arrDay_length; d++)
	{
		var select_arrDay = document.resLauncher.arrDay.options[d].value;
		
		if (arrDay_date == select_arrDay)
		{
			select_arrDay_index = d;
		}
	}
	
	document.resLauncher.arrDay.selectedIndex = select_arrDay_index;
	
	setDates(false);
}

function calePopUp(width, height)
{
	// Get the month/year/dates
	// these must be converted from there full date format to single
	// states such as individual month/year/dates (all numeric values returned)
	
	// month/year here
	
	var selMnthYr_index = document.resLauncher.arrMnthYr.selectedIndex;
	var selMnthYr = new Date(document.resLauncher.arrMnthYr.options[selMnthYr_index].value);
	
	var selMnthYr_mnth = selMnthYr.getMonth();
	var selMnthYr_year = selMnthYr.getFullYear();
	
	// day here
	
	var selDate_index = document.resLauncher.arrDay.selectedIndex;
	var selDate = new Date(document.resLauncher.arrDay.options[selDate_index].value);
	
	var selMnthYr_dayy = selDate.getDate();
	
	// Create url
	
	var winURL = "../calendar.html?var_month=" + selMnthYr_mnth + "&var_year=" + selMnthYr_year + "&var_day=" + selMnthYr_dayy;
	
	// open popup
	
	window.open(winURL,"winCale","toolbar=no,location=no,status=no,directories=no,width=" +width+ ",height=" +height+ ",left=390,top=350,scrollbars=no,resizable=no");
}