/*************** modify seasonal data here ***************/
// 1 = January, 2 = February, ....., 12 = December

var peakStart = 12;
var peakEnd = 1;

var highStart_1 = 8;
var highEnd_1 = 12;
var highStart_2 = 1;
var highEnd_2 = 5;

var lowStart = 4;
var lowEnd = 9;

/*************** do not modify below this point ***************/

function Room(ratePeak, rateHigh, rateLow) {
	this.peak = ratePeak;
	this.high = rateHigh;
	this.low = rateLow;
}

function costOfStay(type) {
	var theForm = document.getElementById('rates_form_' + type);
	var d = parseInt(theForm.arr_day.value);
	var m = parseInt(theForm.arr_month.value);
	var y = parseInt(theForm.arr_year.value);
	
	//var arriving = new Date(y,(m-1),d);
	var season = getSeason(m);
	var nights = eval("parseInt(theForm.nights_" + type + ".value);");
	var room_id = eval("parseInt(theForm.room_type_" + type + "[theForm.room_type_" + type + ".selectedIndex].value);");
	var rate = eval("room_rates_" + type + "[" + room_id + "]." + season);
	
	var total_cost = nights * parseInt(rate);
	
	document.getElementById('total_cost_of_stay_' + type).innerHTML = total_cost;
}

function getSeason(m) {
	
	if ( m == peakStart || m == peakEnd )
		return "peak";
	if ( ( m > highStart_1 && m < highEnd_1 ) || ( m > highStart_2 && m < highEnd_2 ) )
		return "high";
	if ( m > lowStart && m < lowEnd )
		return "low";
}

function doConverter(type) {
	document.getElementById("Amount").value = document.getElementById("total_cost_of_stay_" + type).innerHTML;
	if (document.getElementById("xe_" + type).style.display == 'none')
		document.getElementById("xe_" + type).style.display = 'block';
	else
		document.getElementById("xe_" + type).style.display = 'none';
}
