﻿
// Global Variables
var resizeTimer = null;
var quickViewTimer = null;
var quickViewImg = null;
var ProductURL = null;


// Switch between parts and accessories tabs on new category department pages
function PerformanceTabClicked() 
{
    var performanceTab = $("div#performanceTab");
    var partsTab = $("div#partsTab");
    var performanceTabContent = $("div#performanceTabContent");
    var partsTabContent = $("div#partsTabContent");
    var tabBottomImage = $("img#tabBottomImage");

    partsTab.stop(true, true);
    performanceTab.stop(true, true);
    performanceTabContent.stop(true, true);
    partsTabContent.stop(true, true);

    if (performanceTabContent.is(":hidden")) {
        partsTabContent.fadeOut(200, function() {
            performanceTabContent.fadeIn(200);
        });

        // switch tab images
        performanceTab.find("img").attr("src", ImagePath + "/website3/category_navigation/tabs/performance_light.gif");

        partsTab.find("img").attr("src", ImagePath + "/website3/category_navigation/tabs/replacement_dark.gif");

        tabBottomImage.attr("src", ImagePath + "/website3/category_navigation/tabs/performance_tab_bottom.gif");
    }
}

function PartsTabClicked()
{
    var performanceTab = $("div#performanceTab");
    var partsTab = $("div#partsTab");
    var performanceTabContent = $("div#performanceTabContent");
    var partsTabContent = $("div#partsTabContent");
    var tabBottomImage = $("img#tabBottomImage");

    partsTab.stop(true, true);
    performanceTab.stop(true, true);
    performanceTabContent.stop(true, true);
    partsTabContent.stop(true, true);

    if (partsTabContent.is(":hidden")) {
        performanceTabContent.fadeOut(200, function() {
            partsTabContent.fadeIn(200);
        });

        // switch tab images
        performanceTab.find("img").attr("src", ImagePath + "/website3/category_navigation/tabs/performance_dark.gif");

        partsTab.find("img").attr("src", ImagePath + "/website3/category_navigation/tabs/replacement_light.gif");

        tabBottomImage.attr("src", ImagePath + "/website3/category_navigation/tabs/replacement_tab_bottom.gif");
    }
}


// Expand and hide the view all departments menu on the new category page
function ToggleViewAll()
{
	var leftNavPopoutMenu = $("div#leftNavPopoutMenu");

	// set expose size and show (for hide on click away)
	$("div#leftNavPopoutMenuExposeBG").stop(true, true);
	$("div#leftNavPopoutMenuExposeBG").css({ height: $(window).height(), width: $(window).width() });
	$("div#leftNavPopoutMenuExposeBG").toggle();
	
	var offsetLeft = $("div#viewAllDepartments").offset().left + 139;

	leftNavPopoutMenu.css({ left: offsetLeft, top: $("div#viewAllDepartments").offset().top });
	leftNavPopoutMenu.stop(true, true);
	leftNavPopoutMenu.toggle(400);
}


// Check if only one tab should be showing
function ShowTabs(showBothTabs)
{
	if (showBothTabs != undefined && showBothTabs == false)
	{
		// hide tab and remove javascript functionality from remaining tab
		$("div#partsTab").css({ display: "none" });
		$("div#performanceTab").html("<a href=\"#\" onclick=\"javascript:return false;\"><img src=\"" + ImagePath + "/website3/category_navigation/tabs/performance_light_full.gif" + " /></a>");
		
		// if department page the top image needs to be dark (for refinements section)
		if ($("#departmentRefinements").length > 0)
		{
			$("img#tabBottomImage").attr("src", ImagePath + "/website3/category_navigation/tabs/no_tabs_bottom_dark.gif");
		}
		else
		{
			$("img#tabBottomImage").attr("src", ImagePath + "/website3/category_navigation/product_grid/product_grid_top.gif");
		}
	}
	else
	{
		// show both tabs
		$("div#partsTab").css({ display: "block" });
		$("div#performanceTab").css({ display: "block" });
		
		// show performance content
		$("div#performanceTabContent").fadeIn();
		$("div#partsTabContent").fadeOut();
	}
}







