function measure()
{
	$('a').each(
		function (index) 
		{
			$(this).bind('click',
				function ()
				{
					var text = $(this).text();
					var goto = $(this).attr('href');
					var gotolocation = goto;
					var target = $(this).attr('target');
					var location = window.location.href;
					var referrer = document.referrer;
					var url = 'http://www.tuxx.nl/ajax/measure/' + Math.floor(Math.random()*999999) + '/';
					var parentid = $(this).closest("div").attr("id");
					var parentclass = $(this).closest("div").attr("class");
					if (parentclass!='anchor')
					{
						$.post(url, 
							{
								v_id: index,
								v_text: text,
								v_goto: gotolocation,
								v_target: target,
								v_location: location,
								v_referrer: referrer,
								v_class: parentclass,
								v_parentid: parentid
							},
							function(data) 
							{
								document.title = data;
								if (target == '_blank')
								{
									window.open(gotolocation);
								} else {
									window.location = gotolocation;
								}
							}
						);
					}
					return false;
				}
			);
		}
	);
}
measure();
$(document).ready(function(){measure();});
$(window).load(function() {measure();});
