﻿/// <reference path="jquery.intellisense.js"/>

$(document).ready(function() {
	if ($(".ExclusiveOffersTabs li").length > 0) {
		initExclusiveOffers();
	}
});

var initExclusiveOffers = function() {
	$("#ExclusiveOffersLink").click(function() {
		$("#ExclusiveOffers").center();
		$("#ExclusiveOffers").show();
		var maxHeight = 0;
		$(".OfferPanel").each(function() {
			var itemHeight = $(this).height();
			if (itemHeight > maxHeight) maxHeight = itemHeight;
		}).height(maxHeight);
		$("#ExclusiveOffers").expose({
			api: true,
			opacity: 0.85,
			color: "#000",
			onBeforeClose: function() {
				$(".OfferTermsConditions").each(function() {
					$(this).css("left", "510px");
				});
				$(".OfferDetails").each(function() {
					$(this).css("left", "0px");
					$(this).show();
				});
				$("#ExclusiveOffers").hide();
			}
		}).load();
	});

	$(".ExclusiveOffersPanels .OfferTitle").each(function() {
		$(this).css("opacity", "0.7");
		$(this).css("bottom", $(this).height() + "px");
	});

	$(".TermsConditionsLink").each(function() {
		$(this).click(function() {
			var linkPrefix = "OfferTermsLink";
			var offerNumber = $(this).attr('id').substring(linkPrefix.length);
			$("#OfferDetails" + offerNumber).animate({ left: '-510px' }, 500);
			$("#OfferTerms" + offerNumber).animate({ left: '7px' }, 500);

		});
	});

	$(".DetailsLink").each(function() {
		$(this).click(function() {
			var linkPrefix = "DetailsLink";
			var offerNumber = $(this).attr('id').substring(linkPrefix.length);
			$("#OfferDetails" + offerNumber).animate({ left: '0px' }, 500);
			$("#OfferTerms" + offerNumber).animate({ left: '510px' }, 500);
		});
	});

	$(window).resize(function() {
		$("#ExclusiveOffers").center();
	});
}