﻿$(document).ready(function () {

    /*** FOOTER ***/
    $("#footerFrame").footer();

    /*** NAV GLOBAL ***/
    $("#navGlobal li").hover(
	  function () {
	      $(".navSub", this).fadeIn(340);
	      $(".navCust", this).fadeIn(340);

	  },
	  function () {
	      $(".navSub", this).fadeOut(150);
	      $(".navCust", this).fadeOut(150);
	  }
	);

    $("#navGlobal .navSub ul li:first-child").not($("#navGlobal .navSub ul li ul li:first-child")).hover(
	  function () {
	      $("#navGlobal .navSub .details").css('background-image', 'url(/images/bgOtrNav.jpg)').fast();
	  },
	  function () {
	  }
	);

    $("#navGlobal .navSub ul li:last-child").not($("#navGlobal .navSub ul li ul li:last-child")).hover(
	  function () {
	      $("#navGlobal .navSub .details").css('background-image', 'url(/images/bgTruckTireNav.jpg)').fast();
	  },
	  function () {
	  }
	);


    $("#navGlobal .navSub ul li ul li").hover(
	  function () {
	      $("#navGlobal .navSub .details").html('');
	      $("#navGlobal .navSub ul li ul li").removeClass('on');

	      $("#navGlobal .navSub .details").html($("div", this).html());
	      $(this).addClass('on');
	  }
	);


    $("#navGlobal .navCust ul li").hover(
	  function () {
	      $("#navGlobal .navCust .details").html('');
	      $("#navGlobal .navCust ul li").removeClass('on');

	      $("#navGlobal .navCust .details").css("background-image", "url(" + $("div", this).attr("name") + ")");
	      $("#navGlobal .navCust .details").html($("div", this).html());
	      $(this).addClass('on');
	  }
	);

    /*** Search Tabs ***/
    $(".searchTabContent").hide();
    $("#searchTabs li:first").addClass("on").show();
    $(".searchTabContent:first").show();

    $("#searchTabs li").click(function () {

        $("#searchTabs li").removeClass("on");
        $(this).addClass("on");
        $(".searchTabContent").hide();

        var activeTab = $(this).find("a").attr("href");
        $(activeTab).fadeIn('slow');
        return false;
    });

    $("#searchTabFrame .key").click(function () {

        $(this).val("");
        $(this).addClass("keyOn");
    });


    $("#mailingList .key").click(function () {

        $(this).val("");
        $(this).addClass("keyOn");
    });



    /*** NAV SITE ***/
    $("#navSite li").hover(
	  function () {
	      $(this).addClass("on");
	      $("ul", this).css("marginLeft", "0");
	      var marginLeft = $(this).outerWidth(true) - $("ul", this).outerWidth(true);
	      marginLeft = Math.round(marginLeft / 2);
	      $("ul", this).css("marginLeft", marginLeft + "px");
	      $("ul", this).slideDown(340);

	  },
	  function () {
	      $(this).removeClass("on");
	      $("ul", this).slideUp(150);
	  }
	);
});

(function ($) { Footer = { style: { absolute: { position: "absolute", bottom: 0 }, relative: { position: "relative", bottom: "auto"} }, configs: { timeOut: 200, zIndex: 200 }, browserAdjust: 0, height: 0, fHeight: 0, fId: 0, monitor: function () { if (Footer.height !== $(document).height()) { Footer.setPosition(); Footer.height = $(document).height(); } if (Footer.fHeight !== $(Footer.fId).height()) { Footer.setFsmHeight(); Footer.footerHeight = $(Footer.fId).height(); } setTimeout(function () { Footer.monitor(); }, Footer.configs.timeOut); }, setPosition: function () { if (($(document).height() - Footer.browserAdjust) > $(window).height()) { $("#footerMargin").remove(); $(Footer.fId).css(Footer.style.relative); } else { if ($("#footerMargin").size() == 0) { $(Footer.fId).parent().append("<div id='footerMargin' style='height: " + $(Footer.fId).height() + "px;'></div>"); } $(Footer.fId).css(Footer.style.absolute); } }, setFsmHeight: function () { if ($("#footerMargin").size() > 0 && $(Footer.fId).height() !== $("#footerMargin").height()) { $("#footerMargin").height($(Footer.fId).height()); } } }; $.fn.footer = function (options) { Footer.configs = $.extend(Footer.configs, options); if (Footer.configs.timeOut < 1) { Footer.configs.timeOut = 1; } if ($(this).attr("id") === "") { $(this).attr("id", "footerAutoGeneratedId"); } $(this).css("z-index", Footer.configs.zIndex); Footer.fId = "#" + $(this).attr("id"); Footer.height = $(document).height(); Footer.fHeight = $(this).height(); if ($.browser.msie) { Footer.browserAdjust = 4; } Footer.setPosition(); Footer.monitor(); }; })(jQuery);

