$(function() {
  $("div.productsummarybox ul li p.swatch a").each(function(i, domEl) {
    $(domEl).click(function() {

      var promoprice = $(this).attr("promoprice");
      var price = $(this).attr("price");
      var title = $(this).attr("maintitle");

      //alert('click event fired price=' + price + ' and promoprice=' + promoprice + ' and title = ' + title);

      // if we have a promo price, rewrite the html element to include original price and promo price
//    //unskined control, Maggie had deleted the "$"
//      if (promoprice > 0)
//        $(this).parents("div.productsummarybox").find("li.productPrice").html('<span>$' + price + '</span> <span class="discount">$' + promoprice + "</span>");
//      else
//      	$(this).parents("div.productsummarybox").find("li.productPrice").text('$' + price);
      if (promoprice > 0)
      	$(this).parents("div.productsummarybox").find("li.productPrice").html('<span class="pricebeforediscount">' + price + '</span> <span class="priceafterdiscount">' + promoprice + "</span>");
      else
      	$(this).parents("div.productsummarybox").find("li.productPrice").html('<span class="priceafterdiscount">' + price + '</span>');


      // option specific product page link
      $(this).parents("div.productsummarybox").find("a.productLink").attr("href", $(this).attr("link"));

      // option specific image
      $(this).parents("div.productsummarybox").find("img.largeImg").attr("src", $(this).attr("href"));

      // option specific image title and alt tags
      $(this).parents("div.productsummarybox").find("img.largeImg").attr({ title: title, alt: title });


      // stop page from following url
      return false;
    });
  });
});
