﻿/// <reference path="jquery-1.3.2-vsdoc.js" />

/*
* Namespace for RF Hotels that contains functionalities that share acroos the rocco sites
* such as top menu bar, slideshow, and panel toggle (Choo 20/07/2009)
*/
var RF = window.RF ||
{};

RF.Hotels = {};

RF.Hotels = (function() {
	var fastSpeed = 500;
	var slowSpeed = 1000;
	var panelSpeed = "slow";

	function init() {
		topMenu();
		slideShow();
		panels();
		expandDefaultPanelItem();
		slidingBodyContent();
	}

	function topMenu() {
		//Show popup
		$("#header #top_menu li a").click(function(e) {
			if ($(this).hasClass("logo") == false) {
				//Css class of the click element must match the popup id
				var currentLanguage = $("#current_language_hiddenfield").val();
				var imageFilename = $(this).attr("name").split('_')[1] + "_images.htm";
				topMenuPopupHandler($("#" + $(this).attr("name")), imageFilename, currentLanguage);
				e.preventDefault();
			}
		});
		function topMenuPopupHandler(element, imageFilename, language) {
			if ($(element).is(":visible") == false) {
				$(".popup_content").hide();
				$(element).slideDown(fastSpeed, function getImages() {
					//Ajax calls to load images
					$(element).find(".include_image_container").load("/assets/group/" + language + "/html/include/" + imageFilename);
				});
				$("#header #top_menu li a").removeClass("active");
				$("#header #top_menu li ." + $(element).attr("id")).addClass("active");
				$("#overlay").css("height", $("#maincontent").css("height"));
				jQuery.each(jQuery.browser, function(i, val) {
					if (val == true) {
						if (i == "msie" && jQuery.browser.version.substr(0, 3) == "6.0") {
							var height = 0;
							if ($(".landing_image_container").length > 0) {
								height = $(".landing_image_container").css("height");
								height = height.substring(0, height.length - 2);
								height = parseInt(height, 10);
							}
							else {
								var el = document.getElementById("content_container");
								height = el.offsetHeight;
								height = parseInt(height, 10);
							}
							$("select").hide();
							$("#overlay").css("height", height);
						}
					}
				});
				$("#overlay").show();
			} else {
				$(element).slideUp(fastSpeed);
				$(this).parents("ul").children("li").children("a").css("color", "#666666");
				$("#overlay").hide();
				$("select").show();
				$("#top_menu li a").removeClass("active");
			}
		};
		//Hover
		$("#popup_hotels .right_panel a, #popup_resorts .left_panel a, #popup_packages .right_panel a, #popup_meetings .left_panel a, #popup_kids .right_panel a, #popup_weddings .left_panel a, #popup_restaurants .right_panel a, #popup_spas .left_panel a, #popup_gifts .right_panel a").hover(
		function() {
			try {
				var elementClass = $(this).attr('class');
				if (elementClass != "" || elementClass != null) {
					$("img." + elementClass).fadeIn("slow");
				}
			} catch (e) { }
		}, function() {
			try {
				var elementClass = $(this).attr('class');
				if (elementClass != "" || elementClass != null) {
					$("img." + elementClass).fadeOut("slow");
				}
			} catch (e) { }
		});
		//Map
		$("#popup_hotels .left_panel li a").hover(function(e) {
			var selectedItem = $(this).parent().attr("class");
			var parent = $("#popup_hotels .right_panel li ." + selectedItem).parent().parent().parent();
			var parentName = $(parent).attr("class");
			if (parent.is(":visible") == false) {
				if (parentName == "opened_hotels_container") {
					switchToOpenedHotels();
				}
				else {
					switchToOpeningHotels();
				}
			}
			$("#popup_hotels .right_panel li ." + selectedItem).addClass("active");
		});
		$("#popup_hotels .left_panel li a").mouseout(function(e) {
			var selectedItem = $(this).parent().attr("class");
			$("#popup_hotels .right_panel li ." + selectedItem).removeClass("active");
		});
		//Close button
		$(".popup_content .close").click(function(e) {
			$("#overlay").hide();
			$(".popup_content").slideUp();
			$("#top_menu li a").removeClass("active");
		});
		//Hotel paging
		var openedHotelsContainer = $(".opened_hotels_container");
		var openingHotelsContainer = $(".opening_hotels_container");
		var openedHotelTrigger = $(".opened_hotels_trigger");
		var openingHotelTrigger = $(".opening_hotels_trigger");
		$(openingHotelsContainer).hide();
		$(openedHotelTrigger).hide();
		$(".hotel_paging_container a").click(function(e) {
			if ($(openedHotelsContainer).is(":visible") == true) {
				switchToOpeningHotels();
			}
			else {
				switchToOpenedHotels();
			}
			e.preventDefault();
		});

		function switchToOpeningHotels() {
			$(openedHotelsContainer).hide();
			$(openingHotelsContainer).fadeIn("slow");
			$(openedHotelTrigger).show();
			$(openingHotelTrigger).hide();
		}

		function switchToOpenedHotels() {
			$(openedHotelsContainer).show("slow");
			$(openingHotelsContainer).hide();
			$(openedHotelTrigger).hide();
			$(openingHotelTrigger).show();
		}
	}


	function slideShow() {
		slideshowEngine = new imageslideshowEngine();
		slideshowEngine.images = $("#image_container .images img").get();
		slideshowEngine.init(6000, slowSpeed, imageSwitched);
		$("#thumbs img").each(function(i) {
			$(this).click(function(e) {
				slideshowEngine.jumpToPair(i, true);
				var altText = $(this).attr("alt");
				$("#image_caption").slideUp(fastSpeed, function() {
					$("#image_caption").html(altText).slideDown(slowSpeed);
				});
				e.preventDefault();
			});
		});
	}
	function imageSwitched(i) {
		try {
			if ($("#image_container .images img").size() > 0) {
				var altText = $("#image_container .images img").eq(i.to).attr("alt");
				$("#image_caption").slideUp(fastSpeed, function() {
					$("#image_caption").html(altText).slideDown(slowSpeed);
				});
			}
		} catch (e) { }
	}

	function panels() {
		$("#right_panel #panel li").each(function() {
			$(this).children(".panel_content").hide();
		});
		$("#right_panel #panel li .panel_header").click(function(e) {
			if ($(this).hasClass("default_link") == true) {
				return;
			}
			if ($(this).nextAll(".panel_content").is(":visible") == false) {
				$("#right_panel #panel li").children(".panel_content").slideUp(panelSpeed);
				$("#right_panel #panel li a").removeClass("active");
				$(this).addClass("active");
				$(this).nextAll(".panel_content").slideDown(panelSpeed);
			}
			else {
				$(this).removeClass("active");
				$(this).nextAll(".panel_content").slideUp(panelSpeed);
			}
			e.preventDefault();
		});
	}

	function expandDefaultPanelItem() {
		$("#panel #check_availability a").addClass("active");
		$("#panel #check_availability .panel_content").show();
	}

	function propertyChanged(sender, e) {
		//This function needs to be amended once all the site have converted into .net
		try {
			var selectedValue = $(sender).val();
			if (selectedValue != "-1") {
				//Pickup current local from masterpage
				var currentLocale = $(".current_locale_hiddenfield").val().split('-')[0];
				switch (e) {
					case "check_availability":
					case "factsheets":
						window.location = "http://" + selectedValue;
						break;
					case "brochures":
						switch (selectedValue) {
							case "www.verduraresort.com":
							case "www.thebalmoralhotel.com":
								window.location = "http://" + selectedValue + "/special/brochure";
								break;
							case "www.theaugustinehotel.de":
								window.location = "http://" + selectedValue + "/special/broschÃ¼ren";
								break;
							case "www.assoufid.com":
								window.location = "http://www.assoufid.com/about/";
								break;
							default:
								window.location = "http://" + selectedValue + "/special/brochures";
								break;
						}
					case "photographs":
						var categories = "";
						var categoryList = [];
						switch (selectedValue) {
							case "all":
								categoryList.push(4, 12, 6, 13, 8, 14, 7, 2, 3, 1, 9, 16, 15, 5, 10, 17, 0);
								break;
							case "abudhabi":
								categoryList.push(4, 6, 7, 2, 3, 5, 0);
								break;
							case "angleterre":
								categoryList.push(4, 12, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "amigo":
								categoryList.push(4, 6, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "assoufid":
								categoryList.push(13, 14, 1, 9, 10, 17, 0);
								break;
							case "astoria":
								categoryList.push(4, 12, 6, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "augustine":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "balmoral":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "browns":
								categoryList.push(4, 12, 13, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "charles":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 9, 5, 0);
								break;
							case "de_rome":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 9, 5, 0);
								break;
							case "de_russie":
								categoryList.push(4, 6, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "jeddah":
								categoryList.push(2, 0);
								break;
							case "le_richemond":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "lowry":
								categoryList.push(4, 6, 13, 8, 7, 2, 3, 9, 5, 0);
								break;
							case "roccoforte_team":
								categoryList.push(8, 10, 0);
								break;
							case "savoy":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 1, 9, 5, 0);
								break;
							case "verdura":
								categoryList.push(4, 12, 13, 8, 14, 7, 2, 3, 1, 9, 16, 15, 5, 10, 0);
								break;
							case "villa_kenedy":
								categoryList.push(4, 12, 13, 8, 7, 2, 3, 9, 5, 0);
								break;
							default:
								break;
						}
						categories = generateCategories(categoryList, currentLocale);
						$(".photographs_category_container").html(categories);
						break;
				}
			}
		} catch (e) { }
	}

	function generateCategories(categoryList, currentLocale) {
		var result = "";
		var title = "";
		for (var i = 0; i < categoryList.length; i++) {
			switch (currentLocale) {
				case "en":
					title = categoryList[i] == 0 ? "Show All Images" : title;
					title = categoryList[i] == 1 ? "Local Images" : title;
					title = categoryList[i] == 2 ? "Hotel External Images" : title;
					title = categoryList[i] == 3 ? "Hotel Internal Reception & Lobby Images" : title;
					title = categoryList[i] == 4 ? "Bedroom & Bathroom Images" : title;
					title = categoryList[i] == 5 ? "Restaurant and Bar Images" : title;
					title = categoryList[i] == 6 ? "Conference & Meeting Room Images" : title;
					title = categoryList[i] == 7 ? "Health Club & Spa Images" : title;
					title = categoryList[i] == 8 ? "Generic Images" : title;
					title = categoryList[i] == 9 ? "Logos" : title;
					title = categoryList[i] == 10 ? "Team Images" : title;
					title = categoryList[i] == 12 ? "Conference & Banqueting" : title;
					title = categoryList[i] == 13 ? "Detail Images" : title;
					title = categoryList[i] == 15 ? "Resort Images" : title;
					title = categoryList[i] == 16 ? "Pool" : title;
					title = categoryList[i] == 17 ? "Villas" : title;
					break;
				case "de":
					title = categoryList[i] == 0 ? "Alle Bilder zeigen" : title;
					title = categoryList[i] == 1 ? "Umgebung" : title;
					title = categoryList[i] == 2 ? "Hotelansicht" : title;
					title = categoryList[i] == 3 ? "Rezeption & Lobby" : title;
					title = categoryList[i] == 5 ? "Restaurant and Bar" : title;
					title = categoryList[i] == 4 ? "Zimmer & Suiten" : title;
					title = categoryList[i] == 6 ? "Konferenz & Bankett" : title;
					title = categoryList[i] == 7 ? "Fitness & Spa" : title;
					title = categoryList[i] == 8 ? "Generische" : title;
					title = categoryList[i] == 9 ? "Logos" : title;
					title = categoryList[i] == 10 ? "Team" : title;
					title = categoryList[i] == 12 ? "Konferenz & Bankett" : title;
					title = categoryList[i] == 13 ? "Detailansichten" : title;
					title = categoryList[i] == 15 ? "Resort Images" : title;
					title = categoryList[i] == 16 ? "Pool" : title;
					title = categoryList[i] == 17 ? "Villas" : title;
					break;
			}
			result += "<option value=\"" + categoryList[i] + "\">" + title + "</option>";
		}
		result = result != "" ? "<select class=\"photographs_category_dropdownlist\">" + result + "</select>" : "";
		return result;
	}

	function photographs() {
		var url = "http://imagelibrary.quadrant.uk.com/(S(fpug5uabzqe0q1450aovaq55))/rf/";
		var selectedProperty = $(".phogographs_dropdownlist").val();
		var selectedCategory = $(".photographs_category_dropdownlist").val();
		var parameters = "";
		var clientId = 0;
		clientId = selectedProperty == "hotels" ? 0 : clientId;
		clientId = selectedProperty == "abudhabi" ? 68 : clientId;
		clientId = selectedProperty == "angleterre" ? 35 : clientId;
		clientId = selectedProperty == "browns" ? 33 : clientId;
		clientId = selectedProperty == "amigo" ? 2 : clientId;
		clientId = selectedProperty == "assoufid" ? 69 : clientId;
		clientId = selectedProperty == "astoria" ? 3 : clientId;
		clientId = selectedProperty == "de_rome" ? 46 : clientId;
		clientId = selectedProperty == "de_russie" ? 5 : clientId;
		clientId = selectedProperty == "jeddah" ? 67 : clientId;
		clientId = selectedProperty == "savoy" ? 9 : clientId;
		clientId = selectedProperty == "le_richemond" ? 41 : clientId;
		clientId = selectedProperty == "roccoforte_team" ? 32 : clientId;
		clientId = selectedProperty == "verdura" ? 49 : clientId;
		clientId = selectedProperty == "augustine" ? 64 : clientId;
		clientId = selectedProperty == "balmoral" ? 4 : clientId;
		clientId = selectedProperty == "charles" ? 42 : clientId;
		clientId = selectedProperty == "lowry" ? 6 : clientId;
		clientId = selectedProperty == "villa_kenedy" ? 44 : clientId;
		clientId = selectedProperty == "all" ? 0 : clientId;

		//If category is selected
		if (selectedCategory != null && selectedCategory != "" && selectedCategory != undefined) {
			parameters = "category.aspx?client=" + clientId + "&category=" + selectedCategory;
		} else {
			selectedProperty = "0";
			parameters = "hotel.aspx?client=" + selectedProperty;
		}
		url = "<iframe id=\"photographs_iframe\" frameborder=\"0\" src=\"" + encodeURI(url) + parameters + "\"></iframe>";
		if ($("content_container").size() > 0) {
			$("#content_container").html(url);
		}
		else {
			$("#content").html(url);
		}
		return false;
	}

	function ajaxCalendarArrivalDate(sender, e) {
		var arrivalDateElement;
		var departureDateElement;
		var arrivalDateDropDownList;
		var arrivalMonthYearDropDownList;
		var departureDateDropDownList;
		var departureMonthYearDropDownList;
		var delimiter;
		if (sender._id.match("DLink") != null) {
			arrivalDateElement = ".dlink_arrival_date";
			departureDateElement = ".dlink_departure_date";
			arrivalDateDropDownList = ".dlink_arrival_date_dropdownlist";
			arrivalMonthYearDropDownList = ".dlink_arrival_monthyear_dropdownlist";
			departureDateDropDownList = ".dlink_departure_date_dropdownlist";
			departureMonthYearDropDownList = ".dlink_departure_monthyear_dropdownlist";
		}
		else if (sender._id.match("Panel") != null) {
			arrivalDateElement = ".panel_arrival_date";
			departureDateElement = ".panel_departure_date";
			arrivalDateDropDownList = ".panel_arrival_date_dropdownlist";
			arrivalMonthYearDropDownList = ".panel_arrival_monthyear_dropdownlist";
			departureDateDropDownList = ".panel_departure_date_dropdownlist";
			departureMonthYearDropDownList = ".panel_departure_monthyear_dropdownlist";
		}

		var arrivalDate = $(arrivalDateElement).val();
		var temp = [];
		var temp2 = [];
		var departureDate = new Date();
		var arrivalDateJoined;
		var departureDateJoined
		if (arrivalDate.indexOf("/") > -1) {
			delimiter = "/";
		}
		else if (arrivalDate.indexOf(".") > -1) {
			delimiter = ".";
		}
		temp = arrivalDate.split(delimiter);

		//temp[0] = date
		//temp[1] = month
		//temp[2] = year		
		if (temp[0].charAt(0) == "0") {
			temp[0] = temp[0].substring(1, 2);
		}
		$(arrivalDateDropDownList).val(temp[0]);
		if ($(arrivalMonthYearDropDownList).val().indexOf("/") > -1) {
			delimiter = "/";
		}
		else if ($(arrivalMonthYearDropDownList).val().indexOf(".") > -1) {
			delimiter = ".";
		}
		arrivalDateJoined = temp[1] + delimiter + temp[2];
		$(arrivalMonthYearDropDownList).val(arrivalDateJoined);

		departureDate.setFullYear(temp[2], temp[1] - 1, temp[0]);
		departureDate.setFullYear(departureDate.getFullYear(), departureDate.getMonth(), departureDate.getDate() + 1);
		departureDate = departureDate.format('dd/MM/yyyy');
		if (departureDate.indexOf("/") > -1) {
			delimiter = "/";
		}
		else if (departureDate.indexOf(".") > -1) {
			delimiter = ".";
		}
		temp2 = departureDate.split(delimiter);
		if (temp2[0].charAt(0) == "0") {
			temp2[0] = temp2[0].substring(1, 2);
		}
		$(departureDateDropDownList).val(parseInt(temp2[0], 10));
		if ($(departureMonthYearDropDownList).val().indexOf("/") > -1) {
			delimiter = "/";
		}
		else if ($(departureMonthYearDropDownList).val().indexOf(".") > -1) {
			delimiter = ".";
		}
		departureDateJoined = temp2[1] + delimiter + temp2[2];
		$(departureMonthYearDropDownList).val(departureDateJoined);
	}

	function ajaxCalendarDepartureDate(sender, e) {
		var arrivalDateElement;
		var departureDateElement;
		var arrivalDateDropDownList;
		var arrivalMonthYearDropDownList;
		var departureDateDropDownList;
		var departureMonthYearDropDownList;
		var delimiter;
		if (sender._id.match("DLink") != null) {
			arrivalDateElement = ".dlink_arrival_date";
			departureDateElement = ".dlink_departure_date";
			arrivalDateDropDownList = ".dlink_arrival_date_dropdownlist";
			arrivalMonthYearDropDownList = ".dlink_arrival_monthyear_dropdownlist";
			departureDateDropDownList = ".dlink_departure_date_dropdownlist";
			departureMonthYearDropDownList = ".dlink_departure_monthyear_dropdownlist";
		}
		else if (sender._id.match("Panel") != null) {
			arrivalDateElement = ".panel_arrival_date";
			departureDateElement = ".panel_departure_date";
			arrivalDateDropDownList = ".panel_arrival_date_dropdownlist";
			arrivalMonthYearDropDownList = ".panel_arrival_monthyear_dropdownlist";
			departureDateDropDownList = ".panel_departure_date_dropdownlist";
			departureMonthYearDropDownList = ".panel_departure_monthyear_dropdownlist";
		}

		var temp = [];
		var temp2 = [];
		var arrivalDate = new Date();
		var departureDate = new Date();
		var departureDateJoined;
		if ($(arrivalDateElement).val().indexOf("/") > -1) {
			delimiter = "/";
		}
		else if ($(arrivalDateElement).val().indexOf(".") > -1) {
			delimiter = ".";
		}
		temp = $(arrivalDateElement).val().split(delimiter);
		arrivalDate.setFullYear(temp[2], temp[1] - 1, temp[0]);
		temp2 = $(departureDateElement).val().split(delimiter);
		departureDate.setFullYear(temp2[2], temp2[1] - 1, temp2[0]);
		if (departureDate < arrivalDate) {
			$(departureDateDropDownList).val(arrivalDate.getDate() + 1);
			departureDateJoined = arrivalDate.getMonth() + 1;
			if (departureDateJoined <= 10) {
				departureDateJoined = "0" + departureDateJoined;
			}
			if ($(departureMonthYearDropDownList).val().indexOf("/") > -1) {
				delimiter = "/";
			}
			else if ($(departureMonthYearDropDownList).val().indexOf(".") > -1) {
				delimiter = ".";
			}
			departureDateJoined = departureDateJoined + delimiter + departureDate.getFullYear();
			$(departureMonthYearDropDownList).val(departureDateJoined);
			$(departureDateElement).val(arrivalDate.getDate() + 1 + delimiter + departureDateJoined);
		}
		else {
			$(departureDateDropDownList).val(departureDate.getDate());
			departureDateJoined = departureDate.getMonth() + 1;
			if (departureDateJoined <= 10) {
				departureDateJoined = "0" + departureDateJoined;
			}
			if ($(departureMonthYearDropDownList).val().indexOf("/") > -1) {
				delimiter = "/";
			}
			else if ($(departureMonthYearDropDownList).val().indexOf(".") > -1) {
				delimiter = ".";
			}
			departureDateJoined = departureDateJoined + delimiter + departureDate.getFullYear();
			$(departureMonthYearDropDownList).val(departureDateJoined);
			$(departureDateElement).val(departureDate.getDate() + delimiter + departureDateJoined);
		}
	}

	function arrivalDropDownList(type) {
		var arrivalDateDropDownList;
		var arrivalMonthYearDropDownList;
		var departureDateDropDownList;
		var departureMonthYearDropDownList;
		var delimiter;
		switch (type) {
			case "panel":
				arrivalDateDropDownList = ".panel_arrival_date_dropdownlist";
				arrivalMonthYearDropDownList = ".panel_arrival_monthyear_dropdownlist";
				departureDateDropDownList = ".panel_departure_date_dropdownlist";
				departureMonthYearDropDownList = ".panel_departure_monthyear_dropdownlist";
				break;
			case "dlink":
				arrivalDateDropDownList = ".dlink_arrival_date_dropdownlist";
				arrivalMonthYearDropDownList = ".dlink_arrival_monthyear_dropdownlist";
				departureDateDropDownList = ".dlink_departure_date_dropdownlist";
				departureMonthYearDropDownList = ".dlink_departure_monthyear_dropdownlist";
				break;
		}

		var selectedArrivalDate = $(arrivalDateDropDownList).val();
		var selectedArrivalMonthYear = $(arrivalMonthYearDropDownList).val();
		var temp = [];
		var arrivalDate = new Date();
		var departureDate = new Date();
		var departureDateJoined;
		if (selectedArrivalMonthYear.indexOf("/") > -1) {
			delimiter = "/";
		}
		else if (selectedArrivalMonthYear.indexOf(".") > -1) {
			delimiter = ".";
		}
		temp = selectedArrivalMonthYear.split(delimiter);
		//temp[0] = month
		//temp[1] = year
		arrivalDate.setFullYear(temp[1], temp[0] - 1, selectedArrivalDate);
		departureDate.setFullYear(arrivalDate.getFullYear(), arrivalDate.getMonth(), arrivalDate.getDate() + 1);
		$(departureDateDropDownList).val(departureDate.getDate());
		departureDateJoined = departureDate.getMonth() + 1;
		if (departureDateJoined < 10) {
			departureDateJoined = "0" + departureDateJoined;
		}
		departureDateJoined = departureDateJoined + delimiter + departureDate.getFullYear();
		$(departureMonthYearDropDownList).val(departureDateJoined);
		temp = selectedArrivalMonthYear.split(delimiter);

		if (temp[0].substring(0, 1) == 0) {
			temp[0] = temp[0].substring(1, temp[0].length);
		}
		switch (temp[0]) {
			//february                                                              
			case '2':
				if (selectedArrivalDate > 28) {
					$(arrivalDateDropDownList).val(28);
					$(departureDateDropDownList).val(departureDate.getDate() - 1);
				}
				break;
			//april, june, september or november                                                                                                                                
			case '4':
			case '6':
			case '9':
			case '11':
				if (selectedArrivalDate > 30) {
					$(arrivalDateDropDownList).val(30);
					$(departureDateDropDownList).val(departureDate.getDate() - 1);
				}
				break;
		}
	}

	function departureDropDownList(type) {
		var arrivalDateDropDownList;
		var arrivalMonthYearDropDownList;
		var departureDateDropDownList;
		var departureMonthYearDropDownList;
		var delimiter;
		switch (type) {
			case "panel":
				arrivalDateDropDownList = ".panel_arrival_date_dropdownlist";
				arrivalMonthYearDropDownList = ".panel_arrival_monthyear_dropdownlist";
				departureDateDropDownList = ".panel_departure_date_dropdownlist";
				departureMonthYearDropDownList = ".panel_departure_monthyear_dropdownlist";
				break;
			case "dlink":
				arrivalDateDropDownList = ".dlink_arrival_date_dropdownlist";
				arrivalMonthYearDropDownList = ".dlink_arrival_monthyear_dropdownlist";
				departureDateDropDownList = ".dlink_departure_date_dropdownlist";
				departureMonthYearDropDownList = ".dlink_departure_monthyear_dropdownlist";
				break;
		}
		var selectedArrivalDate = $(arrivalDateDropDownList).val();
		var selectedArrivalMonthYear = $(arrivalMonthYearDropDownList).val();
		var selectedDepartureDate = $(departureDateDropDownList).val();
		var selectedDepartureMonthYear = $(departureMonthYearDropDownList).val();
		var temp = [];
		var temp2 = [];
		var arrivalDate = new Date();
		var departureDate = new Date();
		var departureDateJoined;
		if (selectedArrivalMonthYear.indexOf("/") > -1) {
			delimiter = "/";
		}
		else if (selectedArrivalMonthYear.indexOf(".") > -1) {
			delimiter = ".";
		}
		temp = selectedArrivalMonthYear.split(delimiter);
		arrivalDate.setFullYear(temp[1], temp[0] - 1, selectedArrivalDate);
		temp2 = selectedDepartureMonthYear.split(delimiter);
		departureDate.setFullYear(temp2[1], temp2[0] - 1, selectedDepartureDate);
		departureDateJoined = arrivalDate.getMonth() + 1;
		if (departureDateJoined < 10) {
			departureDateJoined = "0" + departureDateJoined;
		}
		departureDateJoined = departureDateJoined + delimiter + arrivalDate.getFullYear();
		if (departureDate < arrivalDate) {
			$(departureDateDropDownList).val((arrivalDate.getDate() + 1));
			$(departureMonthYearDropDownList).val(departureDateJoined);
		}

		temp = [];
		temp = selectedDepartureMonthYear.split(delimiter);
		//temp[0] = month
		//temp[1] = year
		switch (temp[0]) {
			//february              
			case '2':
				if (selectedDepartureDate > 28) {
					$(departureDateDropDownList).val(28);
				}
				break;
			//april, june, september or november              
			case '4':
			case '6':
			case '9':
			case '11':
				if (selectedDepartureDate > 30) {
					$(departureDateDropDownList).val(30);
				}
				break;
		}
	}

	function setPPCTracking(sender) {
		try {
			//For google analytics PPC cross-site tracking
			if ($(sender).is("a") == true) {
				_gaq.push(['_link'], sender.href);
			}
			else {
				var currentForm = document.getElementById("aspnetForm");
				_gaq.push(['_linkByPost'], currentForm);
			}
		} catch (e) { }
	}

	function slidingBodyContent() {
		$("#canvas #content .curtain").hide();
		$("#canvas #content .trigger a").click(function(e) {
			if ($(this).parent().nextAll(".curtain").is(":visible") == false) {
				$(this).parent().nextAll(".curtain").slideDown("fast");
			}
			else {
				$(this).parent().nextAll(".curtain").slideUp("fast");
			}
			e.preventDefault();
		});
	}

	return {
		init: init,
		expandDefaultPanelItem: expandDefaultPanelItem,
		propertyChanged: propertyChanged,
		photographs: photographs,
		ajaxCalendarArrivalDate: ajaxCalendarArrivalDate,
		ajaxCalendarDepartureDate: ajaxCalendarDepartureDate,
		arrivalDropDownList: arrivalDropDownList,
		departureDropDownList: departureDropDownList,
		setPPCTracking: setPPCTracking
	};
})();


$(document).ready(RF.Hotels.init);
