jQuery(document).ready(function ($) {

    function mousedownSideNavTracking(e) {

        var $zone = $(this);
        var linkText = $zone.text();
        var $clickedOn = $(e.target);


        // did they click a link? If so, track it.
        if ($clickedOn.is('a')) {

            if (typeof (CreateOnClickEvent) != "undefined")
                CreateOnClickEvent('SideNav', 29, 'SideNav:' + e.data.section + ':' + linkText)   // eVar29

            $zone.unbind('mousedown');

            // only unbind the parent if an image is clicked
            if ($clickedOn.is('img'))
                $zone.parents().unbind('mousedown');
        }
    }

    // Click Events to bind    -----------------------------------------------

    // a with head class
    $('a.head').bind('mousedown', { section: trackingPage }, mousedownSideNavTracking);

    // supergroup links
    $('li.secondary a').bind('mousedown', { section: trackingPage }, mousedownSideNavTracking);

    // group links
    $('ul.jd_menu_vertical ul li a').bind('mousedown', { section: trackingPage }, mousedownSideNavTracking);

    // Category Email Signup
    $('.whyshop a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'email signup'); });

    // Category Lead Imagemap
    //$("div[id*='CategoryLead_CategoryLeadItems'] a").bind('mousedown', { section: trackingPage }, function() { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'lead imagemap'); });
    //$("div[id*='CategoryLead_CategoryLeadItems'] img").bind('mousedown', { section: trackingPage }, function() { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'lead imagemap'); });
    $("div[id*='CategoryLead_CategoryLeadItems']").bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'lead imagemap'); });

    // Category Banners
    $('a .spanSides').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'banner: single span'); });
    $('a .leftSide').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'banner: part a'); });
    $('a .rightSide').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'banner: part b'); });

    // Category Blocks
    $('.spg-block1 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'block: 1'); });
    $('.spg-block2 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'block: 2'); });
    $('.spg-block3 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'block: 3'); });
    $('.spg-block4 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'block: 4'); });
    $('.spg-block5 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'block: 5'); });
    $('.spg-block6 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'block: 6'); });

    // Category lc featured articles
    $('.lc-block1 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'featured article: 1'); });
    $('.lc-block2 a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'featured article: 2'); });

    // Category lc additional articles
    $('.lc-additional a').bind('mousedown', { section: trackingPage }, function () { CreateOnClickEvent('testtitle', 32, CategoryIdTracking + 'additional articles '); });

    $('.coreStoreLink').bind('mousedown', function () { CreateOnClickEvent("BackToCore", 35, "CategoryTop"); $(this).unbind('mousedown'); });
    
    // Category customer care links
    $('a.groupChatTracking').bind('mousedown', function () { CreateOnClickEvent('Business Unit', 15, 'GroupListBox:Chat'); $(this).unbind('mousedown'); });
    $('a.groupEmailTracking').bind('mousedown', function () { CreateOnClickEvent("Business Unit", 15, "GroupListBox:Email"); $(this).unbind('mousedown'); });
    $('a.groupCallTracking').bind('mousedown', function () { CreateOnClickEvent("Business Unit", 15, "GroupListBox:Call"); $(this).unbind('mousedown'); });
    $('a.groupSeeWhyTracking').bind('mousedown', function () { CreateOnClickEvent('Business Unit', 15, 'GroupListBox:SeeWhy'); $(this).unbind('mousedown'); });



});


