﻿
jQuery_1_3_2(document).ready(function(){ 
  var processed = 0;
      var totalItemCountForHeight = 1;

    jQuery_1_3_2(".categoriesTD").children("a").children(".categoryWrap").click(function() {
          jQuery_1_3_2("#sideMenuContent").css({'width':'170px'});
    if (processed == 0) {
      processed = 1;
      var sideMenuX = jQuery_1_3_2("#sideMenuContent").offset().left;
      var sideMenuY = jQuery_1_3_2("#sideMenuContent").offset().top;
      var newImageHeight = 43;
      var colCount = 1;
      var rowCount = 1;
      var totalItemCount = 0;
      jQuery_1_3_2(this)
      .animate({opacity: 0.6}, 125)
      .animate({opacity: 1.0}, 275);

      jQuery_1_3_2(".categoryWrap").each(
        function(intIndex){
          totalItemCount++;
        }
      );
        
      jQuery_1_3_2("#sideMenuContent").animate({height: totalItemCount * newImageHeight}, 500);
      
      jQuery_1_3_2(".categoryWrap").each(
        function(intIndex){
        
          var increment = newImageHeight * intIndex;
          var categoryX 	= jQuery_1_3_2(this).offset().left;
          var categoryY 	= jQuery_1_3_2(this).offset().top;
          if(intIndex == 0) {
            var vPaddingTotal = 0;
          } else {
            var vPaddingTotal = 00 * intIndex;
          };
          var gotoX = sideMenuX - categoryX;
          var gotoY = sideMenuY - categoryY + increment + vPaddingTotal;
          var moveSpeed = (totalItemCount * 125) - (rowCount * 75) + 300;

          jQuery_1_3_2(this).css({'position' : 'absolute'})
          .animate({height: newImageHeight}, 350)
          .animate({marginLeft: gotoX, marginTop: gotoY}, moveSpeed);
          
          colCount++;
          
          if (colCount == 4){
            colCount=1;
            rowCount++;
          };
        }
      );
      
      jQuery_1_3_2(this)
      .animate({opacity: 0.5}, 125)
      .animate({opacity: 1.0}, 275)
      .animate({opacity: 0.5}, 125)
      .animate({opacity: 1.0}, 275)
      .animate({opacity:0.99}, 1000,
      function() {
        window.location.href = jQuery_1_3_2(this).parent().attr("href");
      });
      
    };
  });
});