﻿var pageTracker = _gat._getTracker("UA-5870493-8");
pageTracker._trackPageview();

function TrackSiteEvent(eventId) {
    var SiteEventTracker = _gat._getTracker("UA-5870493-8");
    SiteEventTracker._trackPageview(eventId);
    //eConduit.trackEvent(eventId);
}

//function pageTracker(){
//   this._trackPageview = function (universal_tag){
//               eConduit.trackEvent(universal_tag);
//       }
//    return this;
//};
//var pageTracker = pageTracker();

function enableTracking()
{
    $('.google-track-product').each(function(i){
        if($(this).parents('#product-navigation') != '')
        {
            var trackCode = $(this).attr('rev');
            trackCode += '-' + $('input#product-id').val();
            $(this).attr('rev', trackCode);
        }
    });
    
    $('.google-track-recipe').each(function(i){
		var trackCode = $(this).attr('rev');
		trackCode += '-' + $('input#recipe-id').val();
		$(this).attr('rev', trackCode);
    });

    $('.google-track').each(function(i) {
        var trackCode = $(this).attr('rev');
        $(this).attr('rev', trackCode);
    });

    $('.google-track-dyp-calendar').each(function(i) {
        var trackCode = $(this).attr('rev');
        $(this).attr('rev', trackCode);
    });

    $('.google-track, .google-track-product, .google-track-recipe').live('click', function(e) {
        var trackCode = $(this).attr('rev');

        //console.info(trackCode);
        TrackSiteEvent(trackCode);
    });

    $('.google-track-dyp-calendar').live('mouseenter', function(e) {
        var trackCode = $(this).attr('rev');

        //console.info(trackCode);
        TrackSiteEvent(trackCode);
    });


    $('.google-track-mouse-over').live('mouseenter', function(e) {
        var trackCode = $(this).attr('rev');

        //console.info(trackCode);
        TrackSiteEvent(trackCode);
    });
    $('.google-track-focus-search').live('focus', function(e) {
        var trackCode = "site.search.clicked";
        TrackSiteEvent(trackCode);
    });
}

$(document).ready(function()
{
    enableTracking();
});
