// JavaScript Document

function DisplayTicketFeeNum (TicketNumber) {
  var TempTicketFee = document.getElementById('TicketType').value;
  var TicketFee = TempTicketFee.split('|');
  var TicketNum = document.getElementById('TicketNum').value; // (user input pay amount)
  document.getElementById('txtticketfee').value = (TicketFee[1] * TicketNum); //(display room fee when item is selected)
}

function RoomPackageRate () {
  var FromDateField = document.getElementById('FromDate').value;
  var Nights = document.getElementById('Nights').value;
  var FromDateSplit = FromDateField.split('/');
  var FormattedDate = new Date();
  var FormattedDay = FromDateSplit[1];
  var FormattedMonth = FromDateSplit[0];
  FormattedDate.setDate(FormattedDay);
  FormattedDate.setMonth(FormattedMonth-1);
  FormattedDate.setYear(FromDateSplit[2]);

  var Date1From = new Date();
  Date1From.setDate(23);
  Date1From.setMonth(5);
  Date1From.setYear(2010);
  var Date1To = new Date();
  Date1To.setDate(31);
  Date1To.setMonth(11);
  Date1To.setYear(2010);
  
  var RoomType = document.getElementById('RoomType').value;
  var TotalRoomPrice=0;
  var i=0;
  
  if (RoomType == "1 Bedroom")
  {
  for (i=0;i<Nights;i++) {
    if (Date1From<=FormattedDate && FormattedDate<=Date1To) {
	  TotalRoomPrice=TotalRoomPrice+122;
	}
	else {
	  TotalRoomPrice=TotalRoomPrice+78;
	}
	FormattedDate.setDate(FormattedDate.getDate()+1);
  }
  }
  
  if (RoomType == "2 Bedroom")
  {
  for (i=0;i<Nights;i++) {
    if (Date1From<=FormattedDate && FormattedDate<=Date1To) {
	  TotalRoomPrice=TotalRoomPrice+153;
	}
	else {
	  TotalRoomPrice=TotalRoomPrice+98;
	}
	FormattedDate.setDate(FormattedDate.getDate()+1);
  }
  }
  
  return TotalRoomPrice;
}

function ReservationRequestRate (FormRoomType, FormFromDate, FormNights) {
  var FromDateField = FormFromDate;
  var Nights = FormNights;
  var FromDateSplit = FromDateField.split('/');
  var FormattedDate = new Date();
  var FormattedDay = FromDateSplit[1];
  var FormattedMonth = FromDateSplit[0];
  FormattedDate.setDate(FormattedDay);
  FormattedDate.setMonth(FormattedMonth-1);
  FormattedDate.setYear(FromDateSplit[2]);

  var Date1From = new Date();
  Date1From.setDate(23);
  Date1From.setMonth(5);
  Date1From.setYear(2010);
  var Date1To = new Date();
  Date1To.setDate(31);
  Date1To.setMonth(11);
  Date1To.setYear(2010);
  
  var RoomType = FormRoomType;
  var TotalRoomPrice=0;
  var i=0;
  
  if (RoomType == "1 Bedroom")
  {
  for (i=0;i<Nights;i++) {
    if (Date1From<=FormattedDate && FormattedDate<=Date1To) {
	  TotalRoomPrice=TotalRoomPrice+122;
	}
	else {
	  TotalRoomPrice=TotalRoomPrice+78;
	}
	FormattedDate.setDate(FormattedDate.getDate()+1);
  }
  }
  
  if (RoomType == "2 Bedroom")
  {
  for (i=0;i<Nights;i++) {
    if (Date1From<=FormattedDate && FormattedDate<=Date1To) {
	  TotalRoomPrice=TotalRoomPrice+153;
	}
	else {
	  TotalRoomPrice=TotalRoomPrice+98;
	}
	FormattedDate.setDate(FormattedDate.getDate()+1);
  }
  }
  
  return TotalRoomPrice;
}

function RoomRetailRate () {
  var FromDateField = document.getElementById('FromDate').value;
  var Nights = document.getElementById('Nights').value;
  var FromDateSplit = FromDateField.split('/');
  var FormattedDate = new Date();
  var FormattedDay = FromDateSplit[1];
  var FormattedMonth = FromDateSplit[0];
  FormattedDate.setDate(FormattedDay);
  FormattedDate.setMonth(FormattedMonth-1);
  FormattedDate.setYear(FromDateSplit[2]);

  var Date1From = new Date();
  Date1From.setDate(23);
  Date1From.setMonth(5);
  Date1From.setYear(2010);
  var Date1To = new Date();
  Date1To.setDate(31);
  Date1To.setMonth(11);
  Date1To.setYear(2010);
  
  var RoomType = document.getElementById('RoomType').value;
  var TotalRoomPrice=0;
  var i=0;
  
  if (RoomType == "1 Bedroom")
  {
  for (i=0;i<Nights;i++) {
    if (Date1From<=FormattedDate && FormattedDate<=Date1To) {
	  TotalRoomPrice=TotalRoomPrice+172;
	}
	else {
	  TotalRoomPrice=TotalRoomPrice+172;
	}
	FormattedDate.setDate(FormattedDate.getDate()+1);
  }
  }
  
  if (RoomType == "2 Bedroom")
  {
  for (i=0;i<Nights;i++) {
    if (Date1From<=FormattedDate && FormattedDate<=Date1To) {
	  TotalRoomPrice=TotalRoomPrice+232;
	}
	else {
	  TotalRoomPrice=TotalRoomPrice+232;
	}
	FormattedDate.setDate(FormattedDate.getDate()+1);
  }
  }
  
  return TotalRoomPrice;
}