﻿TM.Campaign = {
ShowVideoIntro: function(bloggerKey) {
		TM.GoogleAnalytics.customLink('youtube', 'youtube:'+bloggerKey, '');
		TM.GreyBox.Show();
		var div = $('video-intro' + bloggerKey);
		var width = 680;
		if (null == div) {
			div = document.createElement('div');
			div.id = 'video-intro' + bloggerKey;
			div.className = 'overview-popup';
			div.style.width = width + 'px';
			div.style.left = ((screen.width) ? (screen.width - width) / 2 : 100) + 'px';
			div.innerHTML = JsLib.Ajax.LoadTEXT('/Silos/Traveller/Campaign/Tools/VideoIntro.aspx?bloggerkey=' + bloggerKey);
			document.body.appendChild(div);
		}
		div.style.display = 'block';
	},
	CloseVideoIntro: function(bloggerKey) {
		document.body.removeChild($('video-intro' + bloggerKey));
		TM.GreyBox.Hide();
	},
	timerId: new Array(),
	ShowComments: function(objid) {
		if (this.timerId[objid] != null) {
			window.clearTimeout(this.timerId[objid]);
			this.timerId[objid] = null;
		}
		if ($(objid).style.display == 'none') {
			JsLib.Utilities.Show(objid);
			this.PositionComments(objid);
		}
	},
	PositionComments: function(objid) {
		var obj = $(objid);
		var size = obj.getDimensions();

		if (obj.cumulativeOffset().top + size.height > document.body.clientHeight || obj.style.marginTop) {
			obj.style.marginTop = (-40 - size.height) + 'px';
		}
	},
	SetHideCommentsTimeout: function(objid) {
		this.timerId[objid] = window.setTimeout("TM.Campaign.HideComments('" + objid + "')", 1000);
	},
	HideComments: function(objid) {
		var obj = $(objid);
		var size = obj.getDimensions();

		if (obj.style.display == 'block') {
			JsLib.Utilities.Hide(objid);
		}
	}
}