var LightboxHelper = {
	show: function(url) {
		this.__checkInit();
		var link = this.__getLink();
		link.setAttribute('href', url);
		this.__box = new lightbox(link);
		this.__box.activate();
	},

	showCallback: function(callback, style) {
		this.__checkInit();
		this.__box = new lightbox(callback);
		this.__setSize(style);
		this.__box.activate();
	},

	close: function() {
		if (this.__box) {
			this.__box.deactivate();
			this.__box = undefined;
			this.__clearSize();
		}
	},

	__checkInit: function() {
		// If the lightbox script was loaded dynamically then it's onLoad
		// event handlers won't have fired ...
		if (!$('lightbox'))
		{
			// ... so run them now instead
			// NB. In case it wasn't obvious from the context, these two functions
			// are defined in the lightbox.js script - wonderfully unique names aren't they!
			initialize();
			getBrowserInfo();
		}
	},

	__getLink: function() {
		if (!this.__link) {
			var body = document.getElementsByTagName('body').item(0);
			this.__link = document.createElement('a');
			this.__link.setAttribute('style', 'display:none');
			body.appendChild(this.__link);
		}
		return this.__link;
	},

	__setSize: function(style) {
		if (style) {
			var lightbox = $('lightbox');
			$H(style).each(function(pair) {
				lightbox.style[pair[0]] = pair[1];
			});

	/* XXX
		with($('lightbox').style) {
			left = '100px';
			width = '700px';
			top = '75px';
			height = '350px';
			margin = '0';
		}
		*/
			this.sizeOverride = true;
		}
	},

	__clearSize: function() {
		if (this.sizeOverride) {
			with($('lightbox').style) {
				left = '';
				width = '';
				top = '';
				height = '';
				margin = '';
			}
		}
	}
};

