/**
 * Site-specific javascript
 *
 * This should be loaded after jQuery and the common javascript index.js
 *
 * @author	Nabha <nabha@ananda.org>
 */

// Do this when the document is (mostly) done loading
jQuery(document).ready(function($){
						   
	// External links: Anything outside of www.ananda.org
	$("a[href^='http://']").not("[href*='anandawordpress-local']").not("[href^='http://anandawordpress-local']").not("a:has(img)").not("a:empty").addClass("external");
	
	// Add tracking code for direct downloads from within ananda.org
	$("a[href^='/mp3/'], a[href^='http://anandawordpress-local/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 = $(this).attr("href");
			// Standardize it
			href = href.replace("http://anandawordpress-local/","/");
			// Add the Google Analytics tracking code, using the actual address
			pageTracker._trackPageview(href);
	});
	
	// Add tracking code for all links to other websites
	$(".external").bind("click", function (arr) {		
			// Get the address
			var href = $(this).attr("href");
			// Standardize it
			href = href.replace("http://","/external/");
			// Add the Google Analytics tracking code, using the actual address
			pageTracker._trackPageview(href);
	});			   
						   
});
