/**
 * 
 */
Function.prototype.hitch = function(context)
{
	var fn = this;
	return function ()
	{
		return fn.apply(context, arguments);
	};
};

var Lightboxer = {
	
	$popShown: $("_nothing_"),
	
	closeme: function(e)
	{
		var el= e.target;
		var ps = $(el).parents('.pop').hide();
	},
	
	init: function()
	{
		$(".lightboxLink a.name, a.lightboxLink.name").bind("click", this.openBox.hitch(this));
		$(".closeme").bind("click", this.closeme);
		// TODO: attach a handler on "close" links
	},

	openBox: function(e)
	{
		this.$popShown.hide();
		var el = e.currentTarget;
		var id = $(el).attr("data-id");
		this.$popShown = $("." + id).show();
	}
};


$(document).ready(
	function()
	{
		Lightboxer.init();
	}
);
