$j = jQuery;

$j(function() {
  // homepage promos
  $j(".homepage-promos ul li a").click(function() {
    _gaq.push(['_trackPageview', '/homepage-pod/'+ $j(this).children(":first").attr("alt") +'/']);
  });

  // sidebar brand links
  $j("ul.popular-products li .brand-title a").click(function() {
    _gaq.push(['_trackPageview', '/side-pod/'+$j(this).html()+'/']);
  });

  // most popular product links
  $j("ul.most-viewed li a").click(function() {
    _gaq.push(['_trackPageview', '/most-popular/'+$j(this).find("span.inner:first").html()+'/']);
  });

  // product page review form submit
  $j("form#review-form").submit(function() {
    //_gaq.push(['_trackPageview', RELATIVE_URL+'review-submit/']);

    // track rating values, only ones that have been checked mind!
    var radios = $j(this).find("input[type='radio']:checked");
    if (radios.length > 0) {
      // we have some checked, we need to track this
      var radio_tracking_str = "";
      radios.each(function() {
        var field_title = $j(this).parent().siblings("th:first").html();
        var field_value = $j(this).attr("id").replace(field_title + "_", "");

        radio_tracking_str += field_title + ": " + field_value + ", ";
      });

     radio_tracking_str = radio_tracking_str.substring(0, radio_tracking_str.length-2); // removes last ', ' from tracking string
     _gaq.push(['_trackEvent', 'Product Review', productTitle, radio_tracking_str]);
    }
  });
});
