$(document).ready(function() {
  // Add 'external' CSS class to all external links
	$("a").filter(function() {
    return (this.hostname && location.hostname !== this.hostname);
	}).addClass('external').attr('target', '_blank');
	
	$('.partnerlink').each(function() {
		var $dialog = $('<div id="partnerdialog"></div>');
		var $link   = $(this).attr('href');
		var $title  = $(this).attr('title');
		
		$(this).click(function() {
			$dialog
				.load($link)
				.dialog({
					title: $title,
					autoOpen: true,
					bgiframe: true,
					width: 700,
					height: 420,
					close: function(event, ui) {
						$(this).remove();
					}
				});
			return false;
		});
	});

});
