jQuery(document).ready(function(){
	
	/**
	 * @todo Document
	 */
	
	// Add classes to special links

	// Files
	jQuery("a[href$='.pdf']").not("a:has(img)").not("a:empty").addClass("pdf");
	jQuery("a[href$='.doc']").not("a:has(img)").not("a:empty").addClass("document");
	jQuery("a[href$='.mp3'], a[href$='.ram'], a[href$='.m3u']").not("a:has(img)").not("a:empty").addClass("audio");

	// Videos
	jQuery("a[href^='javascript:videoWindow'], a[href^='http://blip.tv/file'], a[href^='http://www.youtube.com/watch'], a[href^='http://www.vimeo.com']").not("a:has(img)").not("a:empty").addClass("video");
	
	// External links: Anything outside of www.anandaonlineclasses.org
	jQuery("a[href^='http://']").not("[href*='www.anandaonlineclasses.org']").not("[href^='http://anandaonlineclasses.org']").not("a:has(img)").not("a:empty").addClass("external");
	
	// Add tracking code for direct downloads from within anandaonlineclasses.org
	jQuery("a[href^='/mp3/'], a[href^='http://www.anandaonlineclasses.org/mp3/'], a[href$='.pdf'], a[href$='.doc'], a[href$='.ram'], a[href$='.mp3'],   a[href$='.swf']").not(".external").bind("click", function (arr) {																																												
			// Get the address
			var href = jQuery(this).attr("href");
			// Standardize it
			href = href.replace("http://www.anandaonlineclasses.org/","/");
			// Add the Google Analytics tracking code, using the actual address
			pageTracker._trackPageview(href);
			//_gaq.push(['_trackPageview', href]);
	});
	
	// Add tracking code for direct downloads from within anandaonlineclasses.org
	jQuery("a[href^='mailto:']").addClass("email").bind("click", function (arr) {																																												
			// Get the address
			var href = jQuery(this).attr("href");
			// Standardize it
			// href = href.replace("http://www.anandaonlineclasses.org/","/");
			// Add the Google Analytics tracking code, using the actual address
			//_gaq.push(['_trackPageview', href]);
			pageTracker._trackPageview(href);
	});
	
	// Add tracking code for all links to other websites
	jQuery(".external").bind("click", function (arr) {				
			// Get the address
			var href = jQuery(this).attr("href");
			// Standardize it
			href = href.replace("http://","/external/");
			// Add the Google Analytics tracking code, using the actual address
			//_gaq.push(['_trackPageview', href]);
			pageTracker._trackPageview(href);
	});
	
});
