$(function() {
  $('#gt_facebook').click(function() {
    _gaq.push(['_trackPageview', '/social/facebook/']);
  });
  $('#gt_flickr').click(function() {
    _gaq.push(['_trackPageview', '/social/flickr/']);
  });
  $('#gt_twitter').click(function() {
    _gaq.push(['_trackPageview', '/social/twitter/']);
  });
  $('#gt_youtube').click(function() {
    _gaq.push(['_trackPageview', '/social/youtube/']);
  });
  $('#gt_tn_where_to_buy').click(function() {
    _gaq.push(['_trackPageview', '/topnav/where-to-buy/']);
  });
  $('#gt_tn_register_your_barbecue').click(function() {
    _gaq.push(['_trackPageview', '/topnav/register-your-barbecue/']);
  });
  $('#gt_tn_contact').click(function() {
    _gaq.push(['_trackPageview', '/topnav/contact/']);
  });
  $('#top-slider-main a').click(function() {
    _gaq.push(['_trackPageview', '/homepage-banner/' + $(this).attr('href') + '/']);
  });
  $('#featured a').click(function() {
    _gaq.push(['_trackPageview', '/homepage-pod/' + $(this).attr('href') + '/']);
  });
  $('#homepage-products .section a').click(function() {
    _gaq.push(['_trackPageview', '/homepage-product-pod/' + $(this).attr('href') + '/']);
  });
  $('#barbecue-listing div.arrows a').click(function() {
    var direction = $(this).hasClass('prev') ? 'Previous' : 'Next';
    _gaq.push(['_trackEvent', 'Product Carousel - ' + $(this).data('list-type'), $(this).data('category'), direction]);
  });
  $('#print_specifications').click(function() {
    _gaq.push(['_trackPageview', location.pathname + 'print-specifications/']);
  });
  $('#print_my_comparisons').click(function() {
    _gaq.push(['_trackPageview', location.pathname + 'print-comparisons/']);
  });
  $('#product_tabs a').click(function() {
    _gaq.push(['_trackPageview', location.pathname + $(this).attr('href')]);
  });
  $('#product-thumbnails img').click(function() {
    _gaq.push(['_trackEvent', 'Product Thumbnails', $(this).attr('alt'), $(this).data('source')]);
  });
  $('#history-carousel div.arrow-left a, #history-carousel div.arrow-right a').click(function() {
    var direction = $(this).hasClass('prev') ? 'Previous' : 'Next';
    _gaq.push(['_trackEvent', 'History', 'Carousel', direction]);
  });
  $('#gt_warranty, #gt_warranty_form').click(function() {
    _gaq.push(['_trackPageview', location.pathname + '/warranty-pdf/']);
  });
  $('#page-anchors a').click(function() {
    _gaq.push(['_trackPageview', '/support/faqs/'+$.trim($(this).text())+'/']);
  });
  $('#where-to-buy-submit').click(function() {
    var formArray = $(this).closest('form').serializeArray();
    var formValues = '';
    $.each(formArray, function(key, value) {
      if (value.value) {
        var item = value.name.replace('where_to_buy[', '').replace(']', '');
        if (formValues.length) {
          formValues += '&';
        }
        formValues += item + '=' + value.value;
      }
    });
    if (formValues.length) {
      _gaq.push(['_trackPageview', '/support/where-to-buy/search/?' + formValues]);
    }
  });
  $('#store-list div.store-url a').click(function() {
    _gaq.push(['_trackPageview', '/support/where-to-buy/outbound/' + $(this).attr('href')]);
  });
});
