//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
$(document).ready(function(){	

//-------------------------------------------------------------------------------------------------------
//	External Links
//-------------------------------------------------------------------------------------------------------
	$('a[href^="http://"]').attr("target", "_blank");

//-------------------------------------------------------------------------------------------------------
//	Track Downloads
//-------------------------------------------------------------------------------------------------------
	$("a.download,a[href$='pdf'],a[href$='doc'],a[href$='mp3']").click(function(){

		//	Master category for all downloads
		var	category	= 'Downloads';

		//	Path of file being downloaded
		var	filepath	= $(this).attr("href");

		//	Use the file extention as the "action" parameter for the event
		filepath		= filepath.split(".");
		var	filetype	= filepath[ ( filepath.length - 1 ) ].toUpperCase();

		//	Label based on title or href
		var	label		= $(this).attr("title");

		if( !label )
		{
			label		= $(this).attr("href");
		}

		//	Send the event to Analytics
		_gaq.push(['_trackEvent', category, filetype, label ]);

		//	Open in new tab	
		$(this).attr("target","_blank");
	});

//---------------------------------------------------------------------------------------------------------
//	Expandible widgets
//---------------------------------------------------------------------------------------------------------
    $(".expand").click(function (event) {
		event.preventDefault();
		$(this).toggleClass("expanded");
		$(this).next(".expandable").slideToggle(75);
    });    

});


