$(function() {
	openVeil = function(href) {
		$('body').addClass('veil');

		window.location.hash = href.replace(/^.+popup\/([^.]+)\.jsp$/, '$1');

		$('#popupframe div').html('<iframe frameborder="0" src="' + href + '"></iframe');

		window.scrollTo(0, 0);
		return false;
	}


	$('ul.links a').click(function() {
		return openVeil(this.href);
	});

	$("#closeVeil").click(function(){
		window.location.hash = '';

		$("body").removeClass("veil");
		return false;
	});

	hash = window.location.hash;

	if(hash.length > 1) {
		openVeil('/popup/' + hash.substr(1) + '.jsp');
	}
});