$(function() {
	$(".wrapper-nutrition-facts a").click (function () {
		if ($(".wrapper-nutrition-facts .nutrition-facts").is(":hidden")) {
          $(".wrapper-nutrition-facts .nutrition-facts").show("slow");
        } else {
          $(".wrapper-nutrition-facts .nutrition-facts").slideUp("slow");
        }
	});	
						   
});

$(function() {
$("#flavor").change(function(event) {
            if ($(this).val() == 1) {
              $("#12pack-buy").attr('href', "http://www.amazon.com/Greater-Coconut-Drink-20-Ounce-Bottles/dp/B004NCH6AS/ref=sr_1_1?s=grocery&ie=UTF8&qid=1304024081&sr=1-1");
            } else if ($(this).val() == 2) {
              $("#12pack-buy").attr('href', "http://www.amazon.com/Greater-Coconut-Drink-Orange-Mango-20-Ounce/dp/B004NCJ7C8/ref=sr_1_2?s=grocery&ie=UTF8&qid=1304024081&sr=1-2");
            } else if ($(this).val() == 3) {
              $("#12pack-buy").attr('href', "http://www.amazon.com/Greater-Coconut-Drink-Tropical-20-Ounce/dp/B004NCEFNE/ref=sr_1_1?ie=UTF8&qid=1304023970&sr=8-1-spell");
            } else {
              $("#12pack-buy").attr('href', "http://www.amazon.com/s/ref=bl_sr_grocery?_encoding=UTF8&node=16310101&field-brandtextbin=Drink%20GT");
            }
          });
});

$(function() {
  $(".thumbs li a").each(function() {
    var $thumb = $(this);

    $thumb.click(function(event) {
      event.preventDefault();
      var $path = $(this).prop('href');

      var image_container = $thumb.parent().parent().parent().find('.image');
      var loading = $thumb.parent().parent().parent().find('.loading');

      $.ajax({
      	beforeSend: function() {
          image_container.css('display', 'none');
          loading.css('display', 'inline-block');
        },
        url: 'http://drinkgt.com/fb/store/image.php',
        data: ({src : $(this).attr('href')}),
        dataType: 'html',
        complete: function(data) {
          loading.css('display', 'none');
          image_container.css('display', 'inline-block');
          image_container.html("<img src="+$path+">");
          $thumb.parent().siblings().removeClass('active');
          $thumb.parent().addClass('active');
 		}
      });
    });
  });
});
