(function($) {
  var cache2 = [];
  // Arguments are image paths relative to the current page.
  $.preloadImages2 = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) 
    {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache2.push(cacheImage);
    }
  }
})(jQuery)

$(document).ready(function() {
 
    // Preload images
    jQuery.preloadImages2('skin1/images/tabs/tab_sizing_sel.jpg', 'skin1/images/tabs/tab_description.jpg', 'skin1/images/tabs/tab_description_sel.jpg', 'skin1/images/tabs/tab_sizing.jpg'); 
    // Containers
    var tabContainers = $('div.product_tab_container'); // Get the array of containers
    tabContainers.hide().filter(':first').show(); // hide all except first
    // a tab is clicked
    $('div.product_tabs .tab_navigation .tab_image').click(function () {
        tabContainers.hide(); // hide all tabs
        // change the images
        if('img_description'==$(this).attr('id')) // first tab is selected
        {
         tabContainers.filter('#first').show(); // show the current container content
         $('#img_description').attr("src",'skin1/images/tabs/tab_description_sel.jpg'); 
         $('#img_sizing').attr("src",'skin1/images/tabs/tab_sizing.jpg'); 
        } else { // second tab is selected
         tabContainers.filter('#second').show(); // show the current container content
         $('#img_description').attr("src",'skin1/images/tabs/tab_description.jpg'); 
         $('#img_sizing').attr("src",'skin1/images/tabs/tab_sizing_sel.jpg'); 
        }
        return false;
    }).filter(':first').click();
    
});
