
	var isSpanish = false;
	var isEnglish = false;
	var txtPrice = "";

	function Initialize()
	{
		if(isEnglish)
		{
			txtPriceBed = 'Price per Bed: ';
			txtPriceRoom = 'Price per Room: ';
			txtOn = ' on ';
		}
		else if(isSpanish)
		{
			txtPriceBed = 'Precio por cama: ';
			txtPriceRoom =  'Precio por habitación:	';
			txtOn = ' el ';
		}
	}

	// reset after back button
	try{
		for( i = 0; i < oRoomTypes.Count ;i++ )
			document.getElementById( "d" + oRoomTypes.GetItem(i).DdlId ).selectedIndex = 0;
	}catch(e){}

	var oChoosenRooms = new ChoosenRooms();

	function PreSelect( RoomTypeId, YYYYMMDD, Count )
	{
		DdlId =  "d" + oRoomTypes.GetDdlId_ByRoomTypeId( RoomTypeId, YYYYMMDD );
		Ddl = document.getElementById(DdlId);
		Ddl.selectedIndex = Count;
		AddRType(Ddl);
	}

	function AddRType( Element )
	{
		RoomTypeIndex = GetElementId( Element.id  );
		oChoosenRooms.Add( oRoomTypes.GetItem( RoomTypeIndex ), Element.selectedIndex );

		var discount = GetDiscount(oChoosenRooms);
		var totalPrice = oChoosenRooms.CalculateTotalPrice() - discount;
		DisplayTotalPrice(oChoosenRooms.CalculateTotalPrice());

		/* try catch DIRTY DIRTY HACK,
		for this case that hostel has no discount */
		try{
		if(discount > 0)
			AddDiscountToTotalPrice(discount);
		else
			ResetDiscount();
		}catch(e){}

		window.focus();
	}

							function GetAddFeePerson (rule)
							{
								beds = oChoosenRooms.CalculateMaxBeds();
								ruleArr = new String(rule).split('-');
								var fee = 0;
								for( i = 0; i < ruleArr.length; i++ )
								{
									ruleItem = new String(ruleArr[i]).split('|');
									if (beds >= ruleItem[0]) fee = ruleItem[1] ;
								}
//								alert(beds + ":" + fee);
								return fee + " EUR";
							}

							function GetAddFee (Amount)
							{
								if (Amount == "0.00") return "";
//								ruleTxt = "<% =GetFeeParams()%>";
								if (ruleTxt == "without") return "";
								addTxt = " + ";
								ruleArr = new String(ruleTxt).split(':');
								if (ruleArr[0] == "fix") addTxt += GetAddFeePerson(ruleArr[1]);
								if (ruleArr[0] == "percent") addTxt += ruleArr[1]; //todo calculate the addon
								addTxt += prepaid; //" <% =translator.GetText("prePaid")%>";
								return addTxt;
							}

	function DisplayTotalPrice(Amount)
	{
		totalTxt = totalPrice; // "<% =translator.GetText("totalPrice")%> ";
		totalTxt += Amount + currencyShortName; // + " <%=converter.Currency.ShortName%> ";
		totalTxt += GetAddFee (Amount);
		document.getElementById("spanTotalPrice").firstChild.data = totalTxt;
		document.getElementById("spanTotalPrice2").firstChild.data = totalTxt;
	}
	function AddDiscountToTotalPrice(discountAmount)
	{
		document.getElementById("spanDiscount").innerText = 'Descuento: ' + discountAmount + "";
		document.getElementById("spanDiscount2").innerText = 'Descuento: ' + discountAmount + "";
		document.getElementById("spanDiscoutEuroSign").style.display = "inline";
		document.getElementById("spanDiscoutEuroSign2").style.display = "inline";
	}

	function ResetDiscount()
	{
		document.getElementById("spanDiscount").innerText = '';
		document.getElementById("spanDiscount2").innerText = '';
		document.getElementById("spanDiscoutEuroSign").style.display = "none";
		document.getElementById("spanDiscoutEuroSign2").style.display = "none";
	}

	function ShowDetailDorm( Element )
	{
		RoomTypeIndex = GetElementId( Element.id  );
		RoomType = oRoomTypes.GetItem( RoomTypeIndex );
		// document.getElementById("spanMouseOverDate").innerText = RoomType.Date.getDate() + "." + ( RoomType.Date.getMonth() + 1 ) + "." + RoomType.Date.getFullYear();
		document.getElementById("spanMouseOverDorm").firstChild.data =
				sPricePerBed + ' ' + RoomType.Price + ' ' + sCurrency + ' ' //' EUR '
				+ sOn + ' ' + RoomType.Date.getDate() + "." + ( RoomType.Date.getMonth() + 1 ) + "." + RoomType.Date.getFullYear();
	}

	function ShowDetailPrivate( Element )
	{
		RoomTypeIndex = GetElementId( Element.id  );
		RoomType = oRoomTypes.GetItem( RoomTypeIndex );
		// document.getElementById("spanMouseOverDate").innerText = RoomType.Date.getDate() + "." + ( RoomType.Date.getMonth() + 1 ) + "." + RoomType.Date.getFullYear();
		document.getElementById("spanMouseOverPrivate").innerText =
				sPricePerRoom + ' ' + RoomType.Price + ' ' + sCurrency + ' ' //' EUR '
				+ sOn + ' ' + RoomType.Date.getDate() + "." + ( RoomType.Date.getMonth() + 1 ) + "." + RoomType.Date.getFullYear();
	}

	function GetElementId( Id ){
		return Id.substring(1)
	}

