function check_rooms ()			
{
	var i		=	1
	var counter	=	0;
	for (i=1;i<=15;i++)
	{
	if(exist_type[i] == 'Y')
		{
		var room_qty_name = document.getElementById ("room_"+ i);
		var room_qty_value = room_qty_name.value;
		if(room_qty_name.value != 0)
			{
			
			var adult_qty_name 	= 	document.getElementById ("adult_"+ i);
			var child_qty_name 	= 	document.getElementById ("children_"+ i);
			
			adult_qty_value 		= Number(adult_qty_name.value);
			child_qty_value 		= Number(child_qty_name.value);

			var total_occupany_booked = adult_qty_value + child_qty_value;

				if(total_occupany_booked < min_occupants[i])
					{	
					alert("Cannot proceed. \n Room type " + room_name[i] +". min occupancy needs to be at least " + min_occupants[i] +". \n ");
					child_qty_name.value=0; 
					return false;
					}
			
			counter++;		
			}
		}
	}


	if(counter == 0)
		{
		alert('In order to make a booking, you must select at least one room.');
		return false;
		}
	
return true;
}



function HandleChange() 
{

var tPrice			=		0;

	var i	=	1
	for (i=1;i<=15;i++)
	{
		
	var lPrice		=		0;
	if(exist_type[i] == 'Y')
		{
		var room_qty_name = document.getElementById ("room_"+ i);
		var room_qty_value = room_qty_name.value;
		if(room_qty_name.value != 0)
			{
			var adult_qty_name 	= 	document.getElementById ("adult_"+ i);
			var child_qty_name 	= 	document.getElementById ("children_"+ i);
			
			adult_qty_value 		= Number(adult_qty_name.value);
			child_qty_value 		= Number(child_qty_name.value);

			var total_occupany_booked = adult_qty_value + child_qty_value;
			
				if(total_occupany_booked > max_occupants[i])
					{	
					alert("You have exceeded the total occupany for room  " + room_name[i] +".\n Room max occupancy is " + max_occupants[i] +". \n Children quantity has been reset to 0.");
					child_qty_name.value=0; 
					return false;
					}

				var line_label_name	=	"Line_Label_" + i;
				if(default_adults[i] < adult_qty_name.value)
					{
					lPrice		=	(lPrice + (adult_price[i] * (adult_qty_name.value - default_adults[i])));				
					tPrice		=	(tPrice + (adult_price[i] * (adult_qty_name.value - default_adults[i])));
					}
		
			lPrice		=	(lPrice + (roomprice[i] * room_qty_name.value));
			lPrice		=	(lPrice + (child_price[i] * child_qty_name.value));
			
			tPrice		=	(tPrice + (roomprice[i] * room_qty_name.value));
			tPrice		=	(tPrice + (child_price[i] * child_qty_name.value));

			lPrice = lPrice.toFixed(2);
			SetLayerText(line_label_name, lPrice);

			}
		else
			{

			var line_label_name	=	"Line_Label_" + i;
			lPrice = 0;
			lPrice = lPrice.toFixed(2);
			SetLayerText(line_label_name, lPrice);
			}
		}

	}

	tPrice = tPrice.toFixed(2);
	SetLayerText('Total_Label', tPrice);
}




function SetLayerText (sLayerId, sPrice)
{
    var sStatement;
    if (document.all)
	  sStatement = "document.all['" + sLayerId + "'].innerHTML = '" + sPrice + "';";
    else (document.getElementById)
	  sStatement = "document.getElementById('" + sLayerId + "').innerHTML = '" + sPrice + "';";
	    eval (sStatement);
		  sStatement = "document.getElementById('" + sLayerId + "').innerHTML = '" + sPrice + "';";
	    eval (sStatement);
}


