$(function() {

	// outbound link tracking
	$('a:external').filter(function()
	{
		$(this).addClass('external').attr({target: '_blank', title: $(this).attr('title') + ' (Externe link: opent in nieuw venster)'}).bind('click', function()
		{
			if(typeof pageTracker != "undefined" && typeof pageTracker._trackEvent == "function")
			{
				pageTracker._trackEvent('Link', 'External', $(this).attr('href'));
			}
		});
	});
	$('a:external').live('click', function()
	{
		$(this).addClass('external').attr({target: '_blank', title: $(this).attr('title') + ' (Externe link: opent in nieuw venster)'}).bind('click', function()
		{
			if(typeof pageTracker != "undefined" && typeof pageTracker._trackEvent == "function")
			{
				pageTracker._trackEvent('Link', 'External', $(this).attr('href'));
			}
		});
	});

	// mailto click tracking
	$('a:mailto').filter(function ()
	{
		$(this).addClass('mailto').bind('click', function()
		{
			if(typeof pageTracker != "undefined" && typeof pageTracker._trackEvent == "function")
			{
				var email = $(this).attr('href').replace(/^mailto\:/i, '');
				pageTracker._trackEvent('Link', 'Email', email);
			}
		});
	});

/*
	var filetypes = /\.(zip|pdf|doc*|xls*|ppt*|mp3)$/i;

	// file download tracking
	$('a').filter(function()
	{
		var href = $(this).attr('href');
		if(href.match(filetypes))
		{
			$(this).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);
				}
			});
		}
	});*/

	var tweet_types = ['search','profile'];

	// get twitter feed asynchronous
	$('.tweets').each(function() {

		var me 		= $(this),
			space 	= /\s/,
			rel 	= $(this).attr('rel').split(space);

		var type 	= rel[0] || 'search',
			q 		= rel[1] || null;

		for (key in tweet_types) {  if (tweet_types[key] == type) { $.get(domain_+'tweets/'+type+'/'+q, function(data) { me.html(data); }, "html"); return; } }

	});



});
