﻿/*!
* tg.subscribe.js
* ===========================================
* Copyright (c) 2011 Bauer Consumer Media Ltd
* -------------------------------------------
*/

var subscribe = {
	isDisplayed: false,

	displayBox: function () {
		if (subscribe.isDisplayed === false) {
			var box = $('#subscribeBox');
			if (box.length > 0) {
				var offerSets = box.find('.offerSet').hide();
				var randomIndex = Math.floor(Math.random() * offerSets.length);
				$(offerSets[randomIndex]).show();

				box.fadeIn('slow');
				subscribe.isDisplayed = true;
			}
		}
	},

	hideBox: function () {
		$('#subscribeBox').hide();
		subscribe.isDisplayed = false;
	},

	processHover: function () {
		if (document.cookie.indexOf('subscribeSurfaced') === -1) {
			document.cookie = 'subscribeSurfaced=true; path=/';
			subscribe.displayBox();
		}
	},

	disableSubscriptionBox: function () {
		$('.subscribeLabel').removeAttr('onclick').removeAttr('onmouseover');
		$('.subscribeLink').removeAttr('onclick');
	}
};
