var header = "Click here to see more!";
var footer = "Click here to see even more!";
//var pathToFetcher = 'http://www.rompmedia.net/tools/bp/fetcher.php';
function nicePopup(elem, url) {
	var a = $(elem);
	//$.get(pathToFetcher+"?fetch", function(data) {
		var data = header+"-@-@-"+footer;
		var headfoot=data.split('-@-@-');
		$('body').append("<div id='niceoverlay' style='filter: alpha(opacity=30);'></div><div id='centeredtext'>Image is loading</div><div id='nicepopup'></div>");
		var overlay = $('#niceoverlay');
		var popup = $('#nicepopup');
		var txt = $("#centeredtext");
		popup.css({
			'text-align' : 'center',
			'padding' : '10px',
			'z-index' : '30000', 
			'display' : 'none',
			'position' : 'fixed', 
			'background' : '#FFFFFF',
			'border' : '1px solid #DEDEDE'
		});
		overlay.css({
			'display' : 'none', 
			'z-index' : '29999', 
			'position' : 'fixed', 
			'top' : '0',
			'left' : '0', 
			'background' : '#121212',
			'opacity' : '0.3',
			'width' : '100%',
			'height' : $(document).height()
		});
		overlay.css();
		txt.css('width', 100);
		txt.css({ 
			'color' : 'white',
			'display' : 'none',
			'top' : $(window).height()/2-txt.height()/2, 
			'left' : $(window).width()/2-txt.width()/2,
			'position' : 'fixed'
		});
		overlay.show('normal', function() {
			var img = new Image();
			txt.show('fast');
			$(img).load(function () {
				txt.remove();
				popup.append("<a href='#' onclick='return false;' id='niceclose'>CLOSE</a><div id='niceheader'><a href='"+url+"' target='_blank'>"+headfoot[0]+"</a></div><div id='niceimg'></div><div id='nicefooter'><a href='"+url+"' target='_blank'>"+headfoot[1]+"</a></div>");
				$('#niceclose').css({ 'font-size' : '.8em', 'float' : 'right' }).click(function() {
					popup.hide('blind',{},500,function() { overlay.hide('normal', function() { overlay.remove(); popup.remove(); }); });
				});
				$("#nicepopup a").css({ 'color' : 'black' });;
				$("#niceheader").css({'margin-bottom':'5px'});
				$("#nicefooter").css({'margin':'5px 0'});				
				$('#niceimg').append(this);
				if(popup.height() > $(window).height()-5) {
					$(img).css('height', $(window).height()-91-15);
				}
				popup.css({ 
					'top' : $(window).height()/2-popup.height()/2, 
					'left' : ($(window).width()-popup.width())/2
				});				
				popup.show('blind',{},500);
			}).attr('src', a.attr('href'));
		});
	//});	
}
