/*
	JavaScript: tracking
	Author:		elementalblend.com (brandon burkett)
	
	Desc:		functions to call google analytics for document tracking.
				resourceTrack must be the class of the link and resourceTitleTrack has to be inside
				the link (can be hidden).  This is the title that will be tracked (which may not be the link text())
				
	Note:		Can be customized per site.
*/

var blendTracking = 
{
	init: function()
	{
		// link tracking
		$('.gaTrackLink').bind('click', function()
		{
			if(typeof _gaq != "undefined")
			{
				// get title
				var title = ($(this).attr('title') != '') ? $(this).attr('title') : $(this).text();
				title = $.trim(title);
				
				// push event to google
				_gaq.push(['_trackEvent', 'Resource Clicks', title, $(this).attr('href')]);	
				
				// redirect to get track
				setTimeout('document.location = "' + $(this).attr('href') + '"', 100);
			}

			return false;	
		});
		
		// document tracking
		$('.gaTrackDocument').bind('click', function()
		{
			if(typeof _gaq != "undefined")
			{
				// get title
				var title = ($(this).attr('title') != '') ? $(this).attr('title') : $(this).text();
				title = $.trim(title);
				
				// push event to google
				_gaq.push(['_trackEvent', 'Resource Clicks', title, $(this).attr('href')]);	
			}
		})
	}	
}

$(document).ready(function() { blendTracking.init(); });
