$(document).ready(function(){

$('#slideshow').cycle({
        fx:     'fade',
        speed:   2000,
        timeout: 6000,
        pause:   1,
        pager:  '#ssnav',
        pagerAnchorBuilder: function(idx, slide) {
        return '#ssnav li:eq(' + (idx) + ') a';
        }
  });

//** TABS and TOGGLE

$(".tab_content").hide();
$("ul.tabs li:first").addClass("active").show();
$(".tab_content:first").show();

$("ul.tabs li").click(function() {
	$("ul.tabs li").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	var activeTab = $(this).find("a").attr("href");
	$(activeTab).fadeIn();
	return false;
 });

$('a#toggle').click(function() {
        $('#togglebox').toggle(400);
        return false;
 });

//** CAROUSEL and TOOLTIP

$('#rackslider').tinycarousel({ display: 9 });

$("#rackslider a").easyTooltip();

//** INJECT TAGS INTO HTML
$('<div class="cart_add_label">Flavors:</div>').insertBefore('select.shoppingFormQuantity');
$('<p>Please complete the information below. Fields marked as <b>BOLD</b> are required fields.</p>').insertAfter('h1.shoppingHeading"');

$('.emailform input[name=formField_First_Name]')
      .val('First name is')
      .click(function() {
        if ($(this).val() == 'First name is')
          $(this).val('')
      }).blur(function() {
        if ($(this).val() == '')
          $(this).val('First name is')
});

$('.emailform input[name=formField_Last_Name]')
      .val('Last name is')
      .click(function() {
        if ($(this).val() == 'Last name is')
          $(this).val('')
      }).blur(function() {
        if ($(this).val() == '')
          $(this).val('Last name is')
});

$('.emailform input[name=formField_Email]')
      .val('My email address is')
      .click(function() {
        if ($(this).val() == 'My email address is')
          $(this).val('')
      }).blur(function() {
        if ($(this).val() == '')
          $(this).val('My email address is')
});


//** MISC

$('.desctext').truncate({max_length: 700});


$("a.switch_thumb").toggle(function(){
	  $(this).addClass("swap"); 
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").addClass("thumb_view"); 
		 });
	  }, function () {
$(this).removeClass("swap");
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").removeClass("thumb_view");
		});
          }); 


});


//** VAR FOR ADDTHIS
var addthis_config = { ui_cobrand: "Dymatize" }