/*

 * jQuery code that adds Google Analytics tracking code for links to files and external pages

 *

 * Author: Nick Schoonens <nick@marketing-results.com.au>

 * Date: 26/06/2008

 * Version: 1.1

 */





var fileTypes = ['doc','docx','xls','xlsx','ppt','pdf','mov','wav','mp3','jpg','gif','png','mp3'];

$(document).ready(function() {

	$('a').each(function() {

		var $a = $(this);

		var href = $a.attr('href');

		if (href != undefined) {

			var hrefArray = href.split('.');

			var extension = hrefArray[hrefArray.length - 1];

			if ( (href.match(/^http/)) && (! href.match(document.domain)) ) {

				// if so, add the GA tracking code

				$a.click(function() {

					pageTracker._trackPageview('/outgoing/' + href);

				});

			} 

			else if ($.inArray(extension,fileTypes) != -1) {

				$a.click(function() {

					// get the post title if there is one

					// and add it to the string for tracking

					pageTracker._trackPageview('/documents/' + href);

				});

			}

		}

	});

});