
var jqtubekey = 'AI39si5bS36Qdsm7kdd_xaOpvaSQy_N91n-liXfyvUcxe8KlG7deXFYG9gz9a652gdhih840ZpFKA_aMTGF9mLEb6eS4JS5C7A'; 

function showmodal(target)
{
	$('<div id="modalbackground"></div>')
		.prependTo($('body'));
	
	var closer = $('<a href="#" class="modalcloser">close</a>').click(function(evt){evt.preventDefault(); hidemodal(); }); 	 
	target.prependTo($('body')).addClass('modal')
								.children('a.modalcloser')
								.remove()
								.end()
								.append(closer)
								.show(); 
}
function hidemodal()
{
	$('.modal').fadeOut(200, function()
		{
			$('#modalbackground').fadeOut(200, function()
				{
					$(this).remove(); 
				}); 
		}); 
	
}	




//modalise links
(function( $ ){

  $.fn.modaliseLinks = function(callback) 
  	{
		return this.each(function() 
    		{
     			//check that this isn't already modalised. 
     			if(!$(this).is('.modalised'))
     			{
     				$(this).addClass('modalised')
	     				.bind('click', function(evt)
		     			{
		     				evt.preventDefault(); 
		     				$('<div class="modal"></div>').load($(this).attr('href'), {}, function()
		     					{
		     						showmodal($(this));
		     						if(callback) callback();  
		     					}); 
		     			});
		     	}	
    		});
  };
})( jQuery );
