
jQuery.noConflict();
jQuery(document).ready(function($){

	// Open external links in a new window
	$('a[href^=http]').each(function(){
		if(this.href.indexOf(location.hostname) == -1) {
			$(this)
				.addClass("external")
				.attr({ target:"_blank", rel:"external", title:"External website" })
				.click(function(){
					pageTracker._trackPageview('/outgoing/'+ $(this).attr('href'));
				});
		}
	});

	var strContextMenuSave = ($.browser.msie == 1) ? 'Save Target As...' : 'Save Link As...';

	// Indicate PDF files
	$('a[href$=".pdf"]')
		.addClass("pdf")
		.attr({"target":"_blank", title:"Right-click then '"+strContextMenuSave+"' to download this PDF"})
		.click(function(){
			pageTracker._trackPageview("/download/"+ $(this).attr("href"));
		});

	// Indicate Word files
	$('a[href$=".doc"], a[href$=".docx"]')
		.addClass("doc")
		.attr({"target":"_blank", title:"Right-click then '"+strContextMenuSave+"' to download this Word document"})
		.click(function(){
			pageTracker._trackPageview("/download/"+ $(this).attr("href"));
		});

	// Indicate Powerpoint files
	$('a[href$=".ppt"], a[href$=".pptx"]')
		.addClass("ppt")
		.attr({"target":"_blank", title:"Right-click then '"+strContextMenuSave+"' to download this Powerpoint file"})
		.click(function(){
			pageTracker._trackPageview("/download/"+ $(this).attr("href"));
		});

	// Shh, I hate to do this but...
	if ($.browser.msie == 1){
		$('a[href$=".pdf"]').after('&nbsp; <img src="/assets/templates/harbourssuper/img/icon-pdf.png" alt="" style="vertical-align:middle" />')
	}

});
