﻿//************************************************************************************* 
// File     :   mcnt_cart_functions.js
// Version  :   1.0.1
// Requires :   jquery.js (1.2.6 or higher)
// Author   :   Kyle Weems (ksw)
// Origin   :   mindfly.com
// Created  :   July 25, 2008
// Modified :   September 9, 2008
// Purpose  :   A library of functions specific to McNett's shopping cart.
//*************************************************************************************


// Called when page loads. If on a product page, it will format the tabs for the page.
function formatProductDescription() {
    // If there is the product tabs list, then proceed.
    if ($("ul#ulProductTabs").length) {
        // Hide all the content in the list (other than the h4s).
        $("ul#ulProductTabs li h4~div").each(function(i) { $(this).addClass("displayNone"); });
        // Add a click event to the h4s that will run the function openProductTab().
        $("ul#ulProductTabs li > h4").click(function() { openProductTab(this); });
        // Move the product's image to inside the first tab (which is the Product Info).
        $("ul#ulProductTabs li h4~div:eq(0)").prepend($("div#showProductImage"));
        // Show the first tab.
        $("ul#ulProductTabs li h4~div:eq(0)").removeClass("displayNone").addClass("productInfoTab");
        $("li#liProductInfo h4").addClass("selected");
    }
} // end of formatProductDescription()


// Called when a user clicks on the tab on the product page.
function openProductTab(elem) {
    // Make sure to hide all the other tabs.
    $("ul#ulProductTabs li h4~div").each(function(i) { $(this).addClass("displayNone"); });
    $("ul#ulProductTabs li h4").removeClass('selected');
    // Show the selected tab.
    $(elem).siblings().removeClass("displayNone");
    $(elem).addClass('selected');
}


// Call the following functions once the DOM is loaded.
$(document).ready(formatProductDescription);