//function populateRoomDropDown(oAdultElement, oChildElement, oInfantElement, availableCount, maxGuestsPerRoom){
//
// 	  var total = availableCount * maxGuestsPerRoom;
//
//	  var adultCount = oAdultElement.selectedIndex;
//	  var childCount = oChildElement.selectedIndex;
//	  var infantCount = oInfantElement.selectedIndex;
//
// 	  for (var i = oAdultElement.options.length - 1; i >= 0; i--){
//	   	oAdultElement.options.remove(i);
// 	   }
//	   for (var i = oChildElement.options.length - 1; i >= 0; i--){
//	   	oChildElement.options.remove(i);
// 	   }
//	   for (var i = oInfantElement.options.length - 1; i >= 0; i--){
//	   	oInfantElement.options.remove(i);
// 	   }
//
	  //total = number of adult + child + infant can add up to
	  //if adult selected to 1, others must show 0..(total-selected) with xCount currently selected
	  //if adultCount > 0, adult must show 0 .. (total - (childCount + infantCount))
      
//	  //populating adult dropdown
//	  for (var i = 0; i <= (total - (childCount + infantCount));i++){
//			oOption = new Option(i, i);
//          oAdultElement.options.add(oOption);
//			if (oOption.index == adultCount) oOption.selected = true;
//	  }

	  //populating child dropdown
//	  for (var i = 0; i <= (total - (adultCount + infantCount));i++){
//			oOption = new Option(i, i);
//            oChildElement.options.add(oOption);
//			if (oOption.index == childCount) oOption.selected = true;
//	  }

	  //populating adult dropdown
//	  for (var i = 0; i <= (total - (adultCount + childCount));i++){
//			oOption = new Option(i, i);
//           oInfantElement.options.add(oOption);
//			if (oOption.index == infantCount) oOption.selected = true;
//	  }
//	  
//	  displayTotalGuests();
//}

function AvailabilityTotalCost(){
	//get all multishare beds, multiply by numbers in multishare dropdowns
	//get all rooms, and their max counts
	var adultArray = window["adultStringArray"];
	var childArray = window["childStringArray"];
	var infantArray = window["infantStringArray"];
	
	var tempNumberNights = window["numberNights"];
	
	var roomTypes = window["roomTypeAndPriceArray"];
	
	var totalCostForSingleNight = 0.00;
	
	//temp placeholder of dropdownlists
	var temp;

	for (var i = 0; i < roomTypes.length; i++)
	{
		var roomTypeEntry = roomTypes[i];
		
		var roomType = roomTypeEntry[0];
		var maxGuests = roomTypeEntry[1];
		var adultPrice = roomTypeEntry[2];
		var childPrice = roomTypeEntry[3];
		
		if (roomType == "Room")
		{
			var totalSelectedGuests = 0;
			
			temp = document.getElementById(adultArray[i]);
			totalSelectedGuests += temp.selectedIndex;

			temp = document.getElementById(childArray[i]);
			totalSelectedGuests += temp.selectedIndex;

			temp = document.getElementById(infantArray[i]);
			totalSelectedGuests += temp.selectedIndex;
			
			totalCostForSingleNight += Math.ceil(totalSelectedGuests/maxGuests) * adultPrice;
		}
		else if (roomType == "Bed")
		{
			var totalSelectedAdults = 0;
			var totalSelectedChildren = 0;
			
			temp = document.getElementById(adultArray[i]);
			totalSelectedAdults += temp.selectedIndex;

			temp = document.getElementById(childArray[i]);
			totalSelectedChildren += temp.selectedIndex;

			totalCostForSingleNight += (totalSelectedAdults * adultPrice) + (totalSelectedChildren * childPrice);
		}
	}
	
	var totalCostForAllNights = totalCostForSingleNight * tempNumberNights;

	document.getElementById("TotalCost").childNodes[0].nodeValue = totalCostForAllNights.toFixed(2);
}
	
function totalAdults(){
	  var adultCounter = 0;
	  var i = 0;
	  
	  var temp = window["adultStringArray"];
	  
	  for (i = 0; i < temp.length; i++){
		var test = document.getElementById(temp[i]);
		adultCounter += test.selectedIndex;
	  }
	  
	  if (adultCounter == 1)
		  document.getElementById("TotalAdults").childNodes[0].nodeValue = adultCounter + " Guest";
	  else if ((adultCounter < 1) || (adultCounter > 1))
		  document.getElementById("TotalAdults").childNodes[0].nodeValue = adultCounter + " Guests";
}

function totalChildren(){
	  var childCounter = 0;
	  var i = 0;
	  
	  var temp = window["childStringArray"];
	  
	  for (i = 0; i < temp.length; i++){
		var test = document.getElementById(temp[i]);
		childCounter += test.selectedIndex;
	  }	  
	  
	  if (childCounter == 1)
		document.getElementById("TotalChildren").childNodes[0].nodeValue = childCounter + " Guest";
	  else if ((childCounter < 1) || (childCounter > 1))	
		document.getElementById("TotalChildren").childNodes[0].nodeValue = childCounter + " Guests";
}

function totalInfants(){
	  var infantCounter = 0;
	  var i = 0;
	  
	  var temp = window["infantStringArray"];
	  
	  for (i = 0; i < temp.length; i++){
		var test = document.getElementById(temp[i]);
		infantCounter += test.selectedIndex;
	  }
	  
	  if (infantCounter == 1)
		document.getElementById("TotalInfants").childNodes[0].nodeValue = infantCounter + " Guest";
	  else if ((infantCounter < 1) || (infantCounter > 1))	
	  	document.getElementById("TotalInfants").childNodes[0].nodeValue = infantCounter + " Guests";
}

//function populateMultishareDropDown(oAdultElement, oChildElement, availableCount, maxGuestsPerRoom){

// 	  var total = availableCount * maxGuestsPerRoom;

//	  var adultCount = oAdultElement.selectedIndex;
//	  var childCount = oChildElement.selectedIndex;

//   	  for (var i = oAdultElement.options.length - 1; i >= 0; i--){
//	   	oAdultElement.options.remove(i);
// 	   }
//	   for (var i = oChildElement.options.length - 1; i >= 0; i--){
//	   	oChildElement.options.remove(i);
// 	   }

	  //total = number of adult + child + infant can add up to
	  //if adult selected to 1, others must show 0..(total-selected) with xCount currently selected
	  //if adultCount > 0, adult must show 0 .. (total - (childCount + infantCount))
      
	  //populating adult dropdown
//	  for (var i = 0; i <= (total - (childCount));i++){
//			oOption = new Option(i, i);
//            oAdultElement.options.add(oOption);
//			if (oOption.index == adultCount) oOption.selected = true;
//	  }

	  //populating child dropdown
//	  for (var i = 0; i <= (total - (adultCount));i++){
//			oOption = new Option(i, i);
//            oChildElement.options.add(oOption);
//			if (oOption.index == childCount) oOption.selected = true;
//	  }

//	  displayTotalGuests();
//}
