function log(msg) { return window.console ? console.log(msg) : null; }

$.expr[':'].external = function(obj) { return !obj.href.match(/^mailto:/) && (obj.hostname != document.location.hostname); };
$.expr[':'].mailto = function(obj) { return obj.href.match(/^mailto:/); };


$('a:external').filter(function()
{ 
	var me = $(this);
	
		var contents = me.children();
		
		if( ! contents.is('img'))
		{
			me.addClass('external');
		}
		
		me.attr({target: '_blank', title: me.attr('title') + ' (Externe link: opent in nieuw venster)'}).bind('click', function() 
		{
			if(pageTracker && typeof pageTracker != "undefined" && typeof pageTracker._trackEvent == "function") 
			{  
				pageTracker._trackEvent('Link', 'External', me.attr('href')); 
			} 
		});
});

$('a:mailto').filter(function()
{
	var me = $(this);
	me.addClass('mailto').bind('click', function() 
	{
		if(pageTracker && typeof pageTracker != "undefined" && typeof pageTracker._trackEvent == "function") 
		{  
			var email = me.attr('href').replace(/^mailto\:/i, ''); 
			pageTracker._trackEvent('Link', 'Email', email); 
		} 
	});
});

var filetypes = /\.(zip|pdf|doc*|xls*|ppt*|mp3)$/i;

$('a').filter(function()
{ 
	var me = $(this);
	var href = me.attr('href');
	if (href.match(filetypes))
	{  
		me.attr({target: '_blank'}).bind('click', function() 
		{		
			if(typeof pageTracker != "undefined" && typeof pageTracker._trackEvent == "function") 
			{  			
				var extension = ((/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined).toString().toUpperCase();  
				var file_path = href.replace(domain_, '');  
				pageTracker._trackEvent('Download', extension, file_path); 
			}						   
		});
	} 
}); 
