﻿/// <reference path="../../_shared/scripts/jquery-1.3.2-vsdoc.js" />

/*
* Namespace for RF Hotel_2
*/
var RF = window.RF ||
{};

RF.Hotel_2 = {};

RF.Hotel_2 = (function() {

	var fastSpeed = 500;
	var slowSpeed = 1000;
	var defaultSpeed = "fast";
	var loop = 0;
	var slideshowEngine;
	var flashTag = "";

	function init() {
		landingSlideShow();
		groupRates();
		groupRatesSlideShow();
	}

	function introduction() {
		$(".landing_rf_logo_container").show();
		if ($(".landing_logo_container").is(":visible") == true) {
			setTimeout(animateLogo, 4000);
		}
		function animateLogo() {
			var value = $(".landing_text_container").html().trim();
			var width = "";
			var height = "";
			var path = "";
			if (value == "promotion") {
				//Exception for winter promotions
				var currentLanguage = $("#current_language_hiddenfield").val();
				if (currentLanguage == "de") {
					path = "/common/templates/hotel/hotel_2/flash/winter_de.swf";
				}
				else {
					path = "/common/templates/hotel/hotel_2/flash/winter.swf";
				}
				width = "550";
				height = "300";
				$(".landing_text_container").css("margin-left", "75px");
				$(".landing_text_container").css("margin-top", "60px");
			}
			else {
				width = "911";
				height = "150";
				path = "/common/templates/hotel/hotel_2/flash/landing_text.swf";
			}
			flashTag = '<object width="' + width + '" height="' + height + '" id="RoccoForteLandingText" data="' + path + '" type="application/x-shockwave-flash" >' +
					   '<param value="' + path + '" name="movie" />' +
					   '<param value="high" name="quality" />' +
					   '<param value="transparent" name="wmode" />' +
					   '<param value="dynamic_text=__value__" name="FlashVars" />' +
					   '</object>';
			flashTag = flashTag.replace("__value__", value);
			flashTag = flashTag.replace("__value__", value);
			$(".landing_text_container").html("");
			$(".landing_logo_container").fadeOut(slowSpeed, function loadDynamicText() {
				$(".landing_text_container").html(flashTag);
			});
		}
	}

	function landingSlideShow() {
		slideshowEngine = new imageslideshowEngine();
		slideshowEngine.images = $(".landing_image_container a img").get();
		slideshowEngine.init(6000, slowSpeed, imageSwitch);
		loop = 0;

	}
	function imageSwitch(e) {
		if (e.to == 0 && loop != 0) {
			slideshowEngine.pauseEngine();
		}
		loop = e.to;
	}

	function groupRates() {
		$(".group_rates_container .each .content").hide();
		$(".group_rates_container .each .findoutmore").click(function(e) {
			if ($(this).nextAll(".content").is(":visible") == false) {
				$(this).nextAll(".content").slideDown(fastSpeed);
			}
			else {
				$(this).nextAll(".content").slideUp(fastSpeed);
			}
			e.preventDefault();
		});
	}

	//Internal functions
	function groupRatesSlideShow() {
		try {
			$(".group_rates_container .each").each(function() {
				slideshowEngine = new imageslideshowEngine();
				slideshowEngine.images = $(this).children(".group_rates_image_container").children("img").get();
				slideshowEngine.init(6000, slowSpeed);
			});
		} catch (e) { }
	}

	return {
		init: init,
		introduction: introduction
	};
})();

$(RF.Hotel_2.init);