
jQuery.noConflict();

function exitscript() {
	jQuery('a[href^="http://"]').bind('click', function(e) {
		var referense = jQuery(this).attr('href');
		var ref = referense.match(/(algeta|kundeweb|hugin)/)
		if(!ref) {
			e.preventDefault();
			redirect_url = jQuery(this).attr('href');
			popup(redirect_url);
		}
	});
}




function popupwindow(arg) {
	var arg = arg;
	var popup = '<div id="popup"></div>';
	jQuery('html').prepend(popup);
	jQuery('#popup').fadeTo('fast', 1, function() {
		jQuery('#popup').append('<p>You are now leaving ' + document.domain + '. Links to sites outside of Algeta are provided as a resource to the viewer. Algeta accepts no responsibility for the content of linked sites.</p>');
		setTimeout(function() {
			jQuery('#fadelayer').remove();
			jQuery('#popup').remove();
			jQuery(location).attr('href',arg);
		},5000);
	});
}

function popup(redirect_url) {
		var arg = redirect_url;
		var fadelayer = '<div id="fadelayer"></div>';
		jQuery('html').prepend(fadelayer);
		jQuery('#fadelayer').css({
			'position':'fixed',
			'width':'100%',
			'height':'100%',
			'background':'#000',
			'z-index':'10000',
			'opacity': '0.0'
		});
		
		jQuery('#fadelayer').fadeTo('fast', 0.8, function() {
			popupwindow(arg);
		});
		
}


jQuery(document).ready(function() {
    exitscript();
});
