﻿/*****************

Description:
            A generic wrapper for Google Analytics.
******************/

function GATrackEventInternal(Category, Action, Label) {
    if (typeof pageTracker != 'undefined') {
        pageTracker._trackEvent(Category, Action, Label);
    }
    else if (typeof _gaq != 'undefined') {
        _gaq.push(['_trackEvent', Category, Action, Label]);
    }
    
}

function GATrackEvent(Category, Action, Label, usePath) {
   
    if (usePath == true && Label == '') {
        GATrackEventInternal(Category, Action, window.location.pathname)
    }
    else {
        var escapedLabel = Label.replace(/\+/g, ' ').replace(/&lt;br.\/&gt;/g,' ');

        GATrackEventInternal(Category, Action, escapedLabel)
    }
}

/*
Tracks whena  'feature' is displayed on the page, looping through each displayed item and launching a tracking event.
*/
function TrackDisplayedFeatures() {
    jQuery('#ButtonPanel a').each(function (key, value) {
        if (jQuery(this).hasAttr('rel')) {
            GATrackEvent('ET_Features', 'Displayed', jQuery(this).attr('rel'), false)
        }
    });
}

jQuery(document).ready(function () { TrackDisplayedFeatures() });

