function NewRoom(Container)
{
	this.Type;
	this.NumberOfPersons;
	this.Container = Container;

	this.DisplayHtml = DisplayRoomHtml;
	this.UpdateRoomType = UpdateRoomType;
	this.PeopleSelect;
	this.UpdateNumberOfPeoplePerRoom = UpdateNumberOfPeoplePerRoom;
	this.GenerateXML = GenerateXML;
	
	this.RoomTypeSelect = document.createElement("SELECT");
	
	this.PeopleSelect = document.createElement("SELECT");

}

function GenerateXML()
{
	var xml = "<room>";
		xml += "<type>"+this.Type+"</type>";
		xml += "<guests>"+this.PeopleSelect.options[this.PeopleSelect.selectedIndex].value+"</guests>";
	xml += "</room>"
	return xml;
}

function UpdateRoomType()
{
	this.Type = this.RoomTypeSelect.options[this.RoomTypeSelect.options.selectedIndex].value;
	this.UpdateNumberOfPeoplePerRoom();
}

function UpdateNumberOfPeoplePerRoom()
{
	//Slight duplication of code. Could rework. Will do for now...
	this.PeopleSelect.options.length = 0;
	var objOption = document.createElement("option");
	objOption.appendChild(document.createTextNode("Number of guests?"));
	objOption.value= "Number of guests?";
	this.PeopleSelect.appendChild(objOption);
	switch(this.Type)
	{
		case "Choose":
			break;
		case "Single":
			var objOption = document.createElement("option");
			objOption.appendChild(document.createTextNode("1"));
			objOption.value= "1";
			this.PeopleSelect.appendChild(objOption);
			break;
		case "Twin":
			for(var i=1;i<=2;i++)
			{
				var objOption = document.createElement("option");
				objOption.appendChild(document.createTextNode(i));
				objOption.value= i;
				this.PeopleSelect.appendChild(objOption);	
			}
			break;
		case "Double":
			for(var i=1;i<=2;i++)
			{
				var objOption = document.createElement("option");
				objOption.appendChild(document.createTextNode(i));
				objOption.value= i;
				this.PeopleSelect.appendChild(objOption);	
			}
			break;
		case "Family Suite":
			for(var i=1;i<=4;i++)
			{
				var objOption = document.createElement("option");
				objOption.appendChild(document.createTextNode(i));
				objOption.value= i;
				this.PeopleSelect.appendChild(objOption);	
			}
			break;
	}
}


function DisplayRoomHtml()
{
	var Container = document.getElementById(this.Container);
	
	for(var i=0; i < Types.length;i++)
	{
		var objOption = document.createElement("option");
		objOption.appendChild(document.createTextNode(Types[i]));
		objOption.value= Types[i];
		this.RoomTypeSelect.appendChild(objOption);
	}
	Container.appendChild(this.RoomTypeSelect);
	this.RoomTypeSelect.parentobject = this;
	this.RoomTypeSelect.onchange = function()
									{
										UpdateRooms(this.parentobject);
									}
	this.RoomTypeSelect.style.cssFloat= 'left';
	this.RoomTypeSelect.style.clear="both";
	
	this.PeopleSelect.style.cssFloat= 'left';
	this.PeopleSelect.style.clear="right";
	
	var objOption = document.createElement("option");
	objOption.value= "Number of guests?";
	objOption.appendChild(document.createTextNode("Number of guests?"));
	
	this.PeopleSelect.appendChild(objOption);
	Container.appendChild(this.PeopleSelect);
}

function ValidateRoom()
{
	if(this.RoomTypeSelect.options[this.RoomTypeSelect.options.selectedIndex].value == "Choose")
	{
		alert("Please choose a room type");
	}
	if(this.PeopleSelect.options[this.PeopleSelect.options.selectedIndex].value == "Number Of People")
	{
		alert("Please select the number of people staying");
	}
}
