$(document).ready(function () {
    var browser = navigator.userAgent;
    /************************************************************************************************************************************ 
    #Header | Global / Mini Cart Toggle / Drop Down / Carousel
    ************************************************************************************************************************************/
    /******************************************** 
    #Main Homepage Banner Rotator
    ********************************************/
    $('.bannernav li:first-child').addClass('active');

    rotate = function () {
        var slideHeight = $('.rotatebanner img').height();
        var slideID = active.find('a').attr("rel");
        var slide = slideID * slideHeight;
        $('.bannerwrap').stop(true, true).animate({ marginTop: -slide }, { duration: 500, easing: 'jswing' });
        $('.bannernav li').removeClass('active'); //Remove all active class
        active.addClass('active');
    };
    rotateSwitch = function () {
        play = setInterval(function () {
            active = $('.bannernav li.active').next();
            if (active.length === 0) {
                active = $('.bannernav li:first');
            }
            rotate();
        }, 5000);
    };
    $('.bannernav li').click(function () {
        active = $(this);
        clearInterval(play);
        rotate();
        rotateSwitch();
        return false;
    });
    $(window).blur(function () {
        clearInterval(play);
    })
    $(window).focus(function () {
        clearInterval(play);
        rotateSwitch();
    })
    rotateSwitch(); //Run function on launch
    /******************************************** 
    #Main Homepage Banner Rotator
    ********************************************/
    /*$('li.ymm span').click(function(){
    $(this).next().slideToggle();							
    });
    if($('li.ymm span').html().replace(' <a href="#">(edit)</a>','').length >= 25){
    var vehicleInfo = $('li.ymm span').html().replace(' <a href="#">(edit)</a>','').slice(0,25);//This reduces the amount of characters for the vehicle information.
    $('li.ymm span').html(vehicleInfo+'&hellip; <a href="#">(edit)</a>');
    }*/
    /******************************************** 
    #Store Banner - Global
    ********************************************/
    var storeView = $('.storequickview').height();
    var storeViewHeight = storeView + 70;

    $(".storequickview").animate({ top: -storeViewHeight, pacity: 0 }, 1);

    $(".storebanner a.trigger").toggle(function () {
        $(this).parent().stop().animate({ height: storeViewHeight }, 300);
        $(this).parent().find(".storequickview").stop().animate({
            top: '-5px',
            opacity: 1
        }, function () { $(this).css("z-index", "9999") });
    }, function () {
        $(this).parent().stop().animate({ height: '50px' });
        $(this).parent().find(".storequickview").stop().animate({
            top: -storeViewHeight,
            opacity: 1
        }).css("z-index", "0");
        return false;
    });
    /******************************************** 
    #ToolTip Tour
    ********************************************/
	/*function closeToolTip(){
		$('.tooltTipContainer').hide();
		saveCookie('4wdtour', '1', '48000'); //add cookie
	}
	function toolTipTour(){
		function slideInToolTip (toolTipContainer, slidingTime){
			toolTipContainer.css({'opacity':'0','display':'block'});
			var toolTipContainerTopPos = toolTipContainer.position();
			toolTipContainer.css({'top':'500px'});
			toolTipContainer.animate({
									 top:toolTipContainerTopPos.top,
									 opacity:100
									 },slidingTime);
		}
		var toolTipContainer = $('#step1');
		
		$('.closeToolTip').live('click',function(){
			closeToolTip();
		});
		
		$('.nextToolTip').live('click',function(){
			var currentStep = parseInt($(this).parents('.tooltTipContainer').attr('id').replace('step',''),10)+1;
			var nextStep = $('#step'+currentStep+'.tooltTipContainer');
			$(this).parents('.tooltTipContainer').hide();
			slideInToolTip(nextStep,800);
		});
		slideInToolTip(toolTipContainer,2000);
	}
	$(':not(.tooltTipContainer)').live('click', function(){//Closes the tooltip if user clicks anywhere but the tooltip itself
		var tooltTipContainer = $('.tooltTipContainer');
		if(tooltTipContainer.is(':visible')){
			closeToolTip();
			return false;
		}
	});
	
	if (document.cookie.indexOf('4wdtour') == -1) {
		toolTipTour();
	}*/
    /******************************************** 
    #Meta Nav Drop Down Menu
    ********************************************/
	//Set custom hover configurations
	function metaNavDropDown(){
		var metaNavDropDownTrigger = $('.metanav_dropdown');
		var metaNavDropDownContent = $('ul');
		
		function metaNavMouseIn(){
			metaNavDropDownTrigger.stop().removeClass('active').find(metaNavDropDownContent).hide();
			$(this).addClass('active').find(metaNavDropDownContent).stop().slideDown();
		}
		
		function metaNavMouseOut(){
			$(this).find(metaNavDropDownContent).stop().slideUp();
			$(this).delay(5000).removeClass('active');
		}
			
		var metaNavDropDownConfig = {
			sensitivity:2,
			over: metaNavMouseIn, // function = onMouseOver callback (REQUIRED)
			timeout: 800, // number = milliseconds delay before onMouseOut
			out: metaNavMouseOut // function = onMouseOut callback (REQUIRED)
		};
		metaNavDropDownTrigger.hoverIntent(metaNavDropDownConfig);//This is the hover over the mega dropdown
	}
	metaNavDropDown();
    /************************************************************************************************************************************ 
    #Content | Tabs / Misc
    ************************************************************************************************************************************/
    /******************************************** 
    #Equal Height
    ********************************************/
    $.fn.equalHeight = function () {
        var tonneauCat = location.search;
        //This is only for IE7 and below because they have a bug with display:clear
        if ($.browser.msie) {
            $('ul.col3.gridview li:nth-child(3n+1)').addClass("clear");
            $('ul.col4.gridview li:nth-child(4n+1)').addClass("clear");
            if (jQuery.browser.version == 7.0 || jQuery.browser.version == 6) {
                $("ul.gridview li .thumb a img").each(function () {
                    var Himg = parseInt($(this).height(), 10);
                    if (Himg == 0) {
                        Himg = 195; //This catches a bug were the images haven't load yet. We assume the image height is 145px. This is our usual size.
                    }
                    if (Himg < 180) {
                        var Hctn = parseInt($(this).parent().height(), 10);
                        var paddingTop = (Hctn / 2) - (Himg / 2);
                        $(this).css("padding-top", paddingTop);
                    }
                });
                if (tonneauCat == "?catid=3&subcat=141&ptid=3135" || tonneauCat == "?t_c=3&t_s=141&t_pt=3135") {
                    $("ul.gridview li").css("height", "380px");
                }
                else {
                    $("ul.gridview li:not(ul.gridview li ul li).clear").each(function () {
                        var liIndex = $("ul.gridview li:not(ul.gridview li ul li)").index(this);
                        var liHeight = 0;
                        //col3
                        $("ul.gridview.col3 li:not(ul.gridview.col3 li ul li)").slice(liIndex, liIndex + 3).each(function () {
                            var thisLiHeight = $(this).height();
                            if (thisLiHeight > liHeight) {
                                liHeight = thisLiHeight;
                            }
                        });
                        $("ul.gridview.col3 li:not(ul.gridview.col3 li ul li)").slice(liIndex, liIndex + 3).css("height", liHeight);
                        //col4
                        $("ul.gridview.col4 li:not(ul.gridview.col4 li ul li)").slice(liIndex, liIndex + 4).each(function () {
                            var thisLiHeight = $(this).height();
                            if (thisLiHeight > liHeight) {
                                liHeight = thisLiHeight;
                            }
                        });
                        $("ul.gridview.col4 li:not(ul.gridview.col4 li ul li)").slice(liIndex, liIndex + 4).css("height", liHeight);
                    });
                }
            }
        }
        /*function equalHeightAdjust(group) {
        tallest = 0;
        group.each(function() {
        var thisHeight = $(this).height();
        if(thisHeight > tallest) {
        tallest = thisHeight;
        }
        });
        group.height(tallest);
        if ($('.testimonials').is(':visible')) {
        var tallest = tallest + 20;
        $('.testimonials').css({'height' : tallest});
        }
        }
        if( $(this).hasClass('gridview')) { //When running the equal height on a col4
        $(this).each(function() {
        equalHeightAdjust($(this).find('li')); //Run it on each listitem
        });
        } else {
        equalHeightAdjust($(this)); //Run default equal height function
        }*/
    }
    //Load if list has only a col4 thumb view
    $(window).load(function () {
        if ($('.products ul.gridview:first').hasClass("listview")) {
        } else if ($('ul.gridview').is(':visible')) {
            $('.products ul.gridview:first').equalHeight();
        } else if ($('.testimonials').is(':visible')) {
            $('.testimonials blockquote').equalHeight();
        }
    });

    $('.equalHeight, .gridview').equalHeight();
    /******************************************** 
    #Teaser truncate '...'
    ********************************************/
    $.fn.showhide = function () {
        fullText = $(this).html(); //Get full HTML of 
        teasText = fullText.substring(0, 40) + "..."; //Cut down html  to xxx characters (teaser version)
        $(this).html(teasText); //Replace with new teaser version
    }; //end function

    $('#videos h3 a').each(function () { //On each of the #videos headings...
        $(this).showhide(); //Run showhide function
    });
    /******************************************** 
    #Select Option Jump
    ********************************************/
    $('select.jump').change(function () {
        window.location = $(this).attr('value');
    });
    /******************************************** 
    #Testimonials Rotator
    ********************************************/
    $('.testimonials blockquote:first-child').show();
    $(function () {
        $('.testimonials blockquote:gt(0)').hide();
        setInterval(function () {
            $('.testimonials blockquote:first-child').fadeOut()
			 .next().fadeIn()
			 .end().appendTo('.testimonials');
        },
		  15000);
    });
    /******************************************** 
    #Mega Drop Down Menu
    ********************************************/
	var screen_width = parseInt(screen.width,10);
	var screen_width_is_1024 = false;
	if(screen_width <= 1024){//Screen resolution is 1024
		screen_width_is_1024 = true;
		$('.navContainer').remove();
		$('div#megaDropDown').addClass('width1024');
		var firstItem = $('div#megaDropDown.width1024 .megaDropDownColumn .navRow:first a').text();
		if(firstItem == "Best Sellers"){
			$('div#megaDropDown.width1024 .megaDropDownColumn .navRow:first').parent().remove();
		}
	}
	else{
		$('.navRow').each(function(){
			var NavRowText = $(this).text();
			$(this).find('a').remove();
			$(this).append('<em>'+NavRowText+'</em>');
		});
	}
	//Set custom hover configurations
	function megaDropDown(){
		if ($.browser.msie) {//IE Style Fixes
            if (jQuery.browser.version == 7.0 || jQuery.browser.version == 6 || jQuery.browser.version == 8) {
				$('ul#topnav li').first().css('padding','0');
				$('ul#topnav li').last().css('padding','20px 0 20px 10px');
				$('.navContainer .row').each(function(){
					$(this).find('ul').first().css('margin','0');
					$(this).find('ul.colBanner li').first().css('margin','0');
				});
			}
		}
		var dropDownTrigger = $('.megaDDTrigger');
		var subNavTrigger = $('div#megaDropDown ul.megaDropDownColumn li span.navRow');
		var subNavNextTrigger;
		var subNav = $('#megaDropDown');
		var autoComplete = $('#divSuggestions .yui-ac-content');
		var tooltTipContainer = $('.tooltTipContainer');
		var megaDropDownContainer = $('#megaDropDownContainer');
		
		function subNavMouseIn(){
			$('.navContainer').hide();
			if(dropDownTrigger.is('.active')){
				//Do Nothing
			}
			else{//Show the Mega Drop Down
				if(screen_width_is_1024 == false){//Screen resolution is more than 1024
					$('.navContainer:first').show();
					$('.navRow:first').addClass('active');
				}
				subNav.slideDown();
				dropDownTrigger.addClass('active');
				if(autoComplete.is(':visible')){//If the autocomplete search is visible we hide it
					autoComplete.hide();
				}
				if(tooltTipContainer.is(':visible')){
					closeToolTip();
				}
			}
		}
		
		function subNavMouseOut(){
			subNav.removeClass('active').hide();
			dropDownTrigger.removeClass('active');
			$('.navContainer').hide();
			subNavTrigger.removeClass('active');
		}
			
		var config = {
			sensitivity:2,
			over: subNavMouseIn, // function = onMouseOver callback (REQUIRED)
			timeout: 800, // number = milliseconds delay before onMouseOut
			out: subNavMouseOut // function = onMouseOut callback (REQUIRED)
		};
		megaDropDownContainer.hoverIntent(config);//This is the hover over the mega dropdown
		
		subNavTrigger.hoverIntent(function(){//This is the hover over the menu category links
			var navTrigger = $(this);
			$('.navContainer').hide();
			subNavTrigger.removeClass('active');
			if(subNav.is('.active')){
				subNavTrigger.removeClass('active');
				$('.navContainer').hide();
				navTrigger.stop(true,true).next('.navContainer').show();
				navTrigger.addClass('active');
			}
			else{//First Run
				$('.navContainer').hide();
				subNavTrigger.removeClass('active');
				navTrigger.addClass('active');
				subNav.addClass('active');
				navTrigger.next('.navContainer').show();
			}
		},function(){
			//nothing
		});
	}
	megaDropDown();
    /************************************************************************************************************************************ 
    #Content | Tabs / Misc
    ************************************************************************************************************************************/
    /******************************************** 
    #Equal Height
    ********************************************/
    $.fn.equalHeight = function () {
        var tonneauCat = location.search;
        //This is only for IE7 and below because they have a bug with display:clear
        if ($.browser.msie) {
            $('ul.col3.gridview li:nth-child(3n+1)').addClass("clear");
            $('ul.col4.gridview li:nth-child(4n+1)').addClass("clear");
            if (jQuery.browser.version == 7.0 || jQuery.browser.version == 6) {
                $("ul.gridview li .thumb a img").each(function () {
                    var Himg = parseInt($(this).height(), 10);
                    if (Himg == 0) {
                        Himg = 195; //This catches a bug were the images haven't load yet. We assume the image height is 145px. This is our usual size.
                    }
                    if (Himg < 180) {
                        var Hctn = parseInt($(this).parent().height(), 10);
                        var paddingTop = (Hctn / 2) - (Himg / 2);
                        $(this).css("padding-top", paddingTop);
                    }
                });
                if (tonneauCat == "?catid=3&subcat=141&ptid=3135" || tonneauCat == "?t_c=3&t_s=141&t_pt=3135") {
                    $("ul.gridview li").css("height", "380px");
                }
                else {
                    $("ul.gridview li:not(ul.gridview li ul li).clear").each(function () {
                        var liIndex = $("ul.gridview li:not(ul.gridview li ul li)").index(this);
                        var liHeight = 0;
                        //col3
                        $("ul.gridview.col3 li:not(ul.gridview.col3 li ul li)").slice(liIndex, liIndex + 3).each(function () {
                            var thisLiHeight = $(this).height();
                            if (thisLiHeight > liHeight) {
                                liHeight = thisLiHeight;
                            }
                        });
                        $("ul.gridview.col3 li:not(ul.gridview.col3 li ul li)").slice(liIndex, liIndex + 3).css("height", liHeight);
                        //col4
                        $("ul.gridview.col4 li:not(ul.gridview.col4 li ul li)").slice(liIndex, liIndex + 4).each(function () {
                            var thisLiHeight = $(this).height();
                            if (thisLiHeight > liHeight) {
                                liHeight = thisLiHeight;
                            }
                        });
                        $("ul.gridview.col4 li:not(ul.gridview.col4 li ul li)").slice(liIndex, liIndex + 4).css("height", liHeight);
                    });
                }
            }
        }
        /*function equalHeightAdjust(group) {
        tallest = 0;
        group.each(function() {
        var thisHeight = $(this).height();
        if(thisHeight > tallest) {
        tallest = thisHeight;
        }
        });
        group.height(tallest);
        if ($('.testimonials').is(':visible')) {
        var tallest = tallest + 20;
        $('.testimonials').css({'height' : tallest});
        }
        }
        if( $(this).hasClass('gridview')) { //When running the equal height on a col4
        $(this).each(function() {
        equalHeightAdjust($(this).find('li')); //Run it on each listitem
        });
        } else {
        equalHeightAdjust($(this)); //Run default equal height function
        }*/
    }
    //Load if list has only a col4 thumb view
    $(window).load(function () {
        if ($('.products ul.gridview:first').hasClass("listview")) {
        } else if ($('ul.gridview').is(':visible')) {
            $('.products ul.gridview:first').equalHeight();
        } else if ($('.testimonials').is(':visible')) {
            $('.testimonials blockquote').equalHeight();
        }
    });

    $('.equalHeight, .gridview').equalHeight();
    /******************************************** 
    #Teaser truncate '...'
    ********************************************/
    $.fn.showhide = function () {
        fullText = $(this).html(); //Get full HTML of 
        teasText = fullText.substring(0, 40) + "..."; //Cut down html  to xxx characters (teaser version)
        $(this).html(teasText); //Replace with new teaser version
    }; //end function

    $('#videos h3 a').each(function () { //On each of the #videos headings...
        $(this).showhide(); //Run showhide function
    });
    /******************************************** 
    #Select Option Jump
    ********************************************/
    $('select.jump').change(function () {
        window.location = $(this).attr('value');
    });
    /******************************************** 
    #Testimonials Rotator
    ********************************************/
    $('.testimonials blockquote:first-child').show();
    $(function () {
        $('.testimonials blockquote:gt(0)').hide();
        setInterval(function () {
            $('.testimonials blockquote:first-child').fadeOut()
			 .next().fadeIn()
			 .end().appendTo('.testimonials');
        },
		  15000);
    });
    /******************************************** 
    #Carousel
    ********************************************/
    /////Carousel Function + Smart Columns
    $.fn.carousel = function () {

        var rotatorLi = $(this).find("ul.rotator li").width();
        var rotatorSum = $(this).find("ul.rotator li").size();
        var carousel = $(".carousel").width();

        var rotatorMaxLi = Math.floor(carousel / rotatorLi); //See how many lists can fit in the carousel viewport
        var rotatorSlideSum = Math.ceil(rotatorSum / rotatorMaxLi); //See how many slides (sections viewable in carousel viewport) we will need

        var adjustLi = (carousel / rotatorMaxLi); //Perfect width that would fit in carousel viewport
        var adjustRotator = (adjustLi * rotatorSum); //Get width of adjusted rotator

        var lastSlideSum = Math.floor(adjustRotator / carousel); //Get the whole number of slides that can fit in carousel (for remainder of slides)
        var lastSlide = (carousel * lastSlideSum) - adjustRotator; //Get the distance of the remaining slides

        //Get tallest list item in carousel (prevents truncation)
        var tallest = 0;
        $(this).find("ul.rotator li").each(function () {
            var rotatorLiHeight = $(this).height();
            if (rotatorLiHeight > tallest) {
                tallest = rotatorLiHeight + 20; //20 takes in consideration of padding 10px 0;
            }
        });
        $(this).find(".carousel").css({ 'padding-bottom': '10px' }); //Adjust Height of Carousel

        $(this).find("ul.rotator li").css({ 'width': adjustLi }); //Adjust width
        $(this).find("ul.rotator").css({ 'width': adjustRotator }); //Adjust width


        var sum = 0; //Set Count for clicks

        if (carousel < adjustRotator) { //If the list is bigger than the carousel viewport
            $(this).find("a.right-scroll").click(function () {
                if (sum < (rotatorSlideSum - 1)) {
                    sum++;
                    $(this).parent().find("a.left-scroll").removeClass("deactive");
                    switch (sum) {
                        case rotatorSlideSum: //on the last slide...
                            $(this).addClass("deactive");
                            break;
                        case rotatorSlideSum - 1: //second to last slide...
                            $(this).addClass("deactive");
                            if (lastSlide < -1) {
                                $(this).parent().find("ul.rotator").animate({ marginLeft: "+=" + lastSlide }, 250);
                            }
                            else {
                                $(this).parent().find("ul.rotator").animate({ marginLeft: "-=" + carousel }, 250);
                            }
                            break;
                        default: //on click else
                            $(this).parent().find("ul.rotator").animate({ marginLeft: "-=" + carousel }, 250);
                            break;
                    }
                }
                return false;
            }); //end switch case

            $(this).find("a.left-scroll").addClass("deactive");
            $(this).find("a.left-scroll").click(function () {
                if (sum > 0) {
                    sum--;
                    $(this).parent().find("a.right-scroll").removeClass("deactive");
                    switch (sum) {
                        case 0: //if back to original slide...
                            if (lastSlide < -1 && rotatorSlideSum == 2) {
                                $(this).parent().find("ul.rotator").animate({ marginLeft: "-=" + lastSlide }, 250);
                            }
                            else {
                                $(this).parent().find("ul.rotator").animate({ marginLeft: "+=" + carousel }, 250);
                            }
                            $(this).addClass("deactive");
                            break;
                        case rotatorSlideSum - 2: //1st click back from the last slide...
                            if (lastSlide < -1) {
                                $(this).parent().find("ul.rotator").animate({ marginLeft: "-=" + lastSlide }, 250);
                            }
                            else {
                                $(this).parent().find("ul.rotator").animate({ marginLeft: "+=" + carousel }, 250);
                            }
                            break;
                        default:
                            $(this).parent().find("ul.rotator").animate({ marginLeft: "+=" + carousel }, 250);
                            break;
                    }

                }
                return false;
            }); //end switch case
        } else { //if there is only one slide...
            $(this).find("a.right-scroll, a.left-scroll").addClass("deactive");
        } //end if carasouel statement
    }; //end function


    ////Trigger Carousel + Component Functions
    $('.carousel_placement').each(function () { //for each carousel run the following code...
        tabID = $(this).attr('id'); //get the ID of the tab content
        $('#' + tabID).find("div[class^='carousel']").carousel(); //run the carousel function on that ID
    });
    /******************************************** 
    #TABS
    ********************************************/
    function tabbedNavigation() {
        var tabItems = [];
        var locationHash = location.hash;
        $("ul.tabs li a").each(function () {
            var items = $(this).attr("href");
            tabItems.push(items);
        });
        if (locationHash === "") {
            //If its a manufacture page first tab should not be automatically selected
            if ($('#manpage').is(':visible')) {
            } else {
                $("ul.tabs").each(function () {
                    $("li:first", this).addClass("active").show(); //Activate first tab
                });
            }
            if ($('#brands').is(':visible')) {
            } else { //if not only show first content container
                //When page loads...
                $(".tab_content").hide(); //Hide all content
                $(".tab_container").each(function () {
                    $(".tab_content:first", this).show(); //Show first tab content
                });
            }
        }
        else {
            var tabItemsIndex = jQuery.inArray(locationHash, tabItems);

            if (tabItemsIndex != -1) {
                var targetedTab = $("ul.tabs li a[href=" + locationHash + "]");
                var targetedTabContent = $(".tab_content" + locationHash);

                targetedTabContent.parent().find(".tab_content").each(function () {
                    $(this).hide();
                }); //Hide all content
                targetedTab.parent().siblings().removeClass("active");
                targetedTab.parent().addClass("active");
                targetedTabContent.fadeIn();
            }
            else {//Don't do anything if the href doesn't point to a tab (like an anchor link)
            }
        }
        //On Click Event
        $("ul.tabs li").click(function () {
            /*$("ul.tabs li").removeClass("active"); //Remove any "active" class
            $(this).addClass("active"); //Add "active" class to selected tab*/
            var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
            /*$(".tab_content").hide(); //Hide all tab content
            $(activeTab).fadeIn(); //Fade in the active ID content*/

            if (activeTab == "#activeAll") { //Shows all content for all brands
                location.href = "";
            } else {
                location.href = activeTab;
            }
            return false;
        });
    };
    //Vertical Tabs on Homepage
    $(" ul.nav li:first").addClass("vert_selecttab").show(); //Activate first tab
    $(".vert_tabcontent:first").show(); //Show first tab content

    $('#store ul.nav li a').each(function () {
        var cont_ID = $(this).attr('href');
        if ($(cont_ID).html().trim()) {
        } else {
            $(this).parent().addClass('deactive');
        }
    });

    //On Click Event
    $("ul.nav li").live('click', function () {

        if (!$(this).hasClass('deactive')) {
            $("ul.nav li").removeClass("vert_selecttab"); //Remove any "active" class
            $(this).addClass("vert_selecttab"); //Add "active" class to selected tab
            $(".vert_tabcontent").hide(); //Hide all tab content
            var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
            $(activeTab).show(); //Fade in the active ID content
        }
        return false;
    });

    var hasTabs = $("ul.tabs").size();
    if (hasTabs >= 1) {

        var checkTabLink = $(".tabs li a").attr("href").search(/^\//);

        if (checkTabLink == -1) {
            var lastHash = '';
            function pollHash() {
                if (lastHash !== location.hash) {
                    lastHash = location.hash;
                    // hash has changed, so do stuff:
                    tabbedNavigation(); //We look at the URL to see if we need to show a specific slide.
                }
            }
            setInterval(pollHash, 1000);
            tabbedNavigation();
            if ($("#map").size >= 1) {
                map.checkResize();
            }
        }
    }
    /******************************************** 
    #MISC 
    ********************************************/
	//Removes empty dotted lines
	var prodTools = $('.prodtools').text().replace(/[ \t\r\n]/gim,"");
	if(prodTools == ""){
		$('.prodtools').css('border','none');
	}
    //#col4 adjustment on 4th list item
    $('ul.col4 li:nth-child(4n+4), ul.col3 li:nth-child(3n+3),  .thumbs img:last').css({ 'margin-right': '0' }); //kills right margin 

    $('#content .products ul.col4 li:nth-child(4n+1)').css({ 'clear': 'both' }); //col4 gridview
    $('#content .products ul.col4 li:nth-child(3n+1)').css({ 'clear': 'none' }); //col4 gridview

    //Filter Label Animation and Fade
    //$('img.findit').animate({ top: '-85px', opacity: '1' }, 500);

    //IEfix for Tree list
    $('ul.tree li:last-child').css({ 'background-position': 'left -6px', 'background-repeat': 'no-repeat' });

    //Input tooltip
    $('.formtip').focus(function () {
        if (this.value == this.defaultValue) {
            $(this).attr({ value: '' });
        }
        $(this).addClass('focused');
    }).blur(function () {
        if (this.value == '') {
            this.value = this.defaultValue;
            $(this).removeClass('focused');
        }
    });

    $('a[rel=prettyPhoto]').prettyPhoto({ theme: 'facebook' });

    //Fix IE6 :first-child on topnav
    $('ul#topnav > li > a:first-child').addClass('topnav_li_a');

    $('.col50:nth-child(2n+1):not(.intro)').css({ 'margin-right': '10px' });
    $('.col50:nth-child(2n+2):not(.intro)').css({ 'margin-left': '10px' });

    $('.intro .col50:first').css({ 'margin': '0 10px 0 0' });
    $('.intro .col50:eq(1)').css({ 'margin': '0 0 0 10px' });
	//Removes double "Your Selection" message on the left nav
	var SubHeadingNav = $('.filter_selection_subheading').size();
	if(SubHeadingNav >= 2){
		$('.filter_selection_subheading').eq(1).remove();
	}
	var itemAddedToCart_ProductName = $('.prodDesc h2').text().replace(/ by .*/gim,'');
	var itemAddedToCart_ProductManufacturer = $('.prodDesc h2').text().replace(/^.* by /gim,'');
	$('.prodDesc h2 a').text(itemAddedToCart_ProductName);
	$('.prodManufacturer').text('By '+itemAddedToCart_ProductManufacturer);
    /******************************************** 
    #Toggle
    ********************************************/
    //Hide (Collapse) the toggle containers on load
    $(".toggle_container").hide();
    $('.sidecol ul.filter .toggle_container:first').show().parent().find('strong').addClass('active');

    //Switch the "Open" and "Close" state per click
    $(".trigger").click(function () {
        var triggerTarget = $(this).attr("rel");
        if (triggerTarget) {
            //This takes a string with the format: show=string1,string2,stringX&hide=string1,string2,stringX
            //using this format we can show or hide several targeted elements. ~Brenda

            var triggerTargetShow = triggerTarget.replace(/&hide=.*/, "").replace("show=", "");
            var triggerTargetHide = triggerTarget.replace(/.*hide=/, "");

            var splitTargetHide = triggerTargetHide.split(",");
            for (i = 0; i < splitTargetHide.length; i++) {
                $(splitTargetHide[i]).slideUp();
            }

            var splitTargetShow = triggerTargetShow.split(",");
            for (j = 0; j < splitTargetShow.length; j++) {
                $(splitTargetShow[j]).show().removeClass("invis").slideDown();
            }

            return false;
        }
        else {
            $(this).toggleClass("active");
            $(this).next(".toggle_container").slideToggle("fast");
            if ($('#checkout').is(':visible')) {
                return true;
            } else {
                return false;
            }
        }
    });
	 /******************************************** 
    #Toggle V2
    ********************************************/    
	//Hide 
    $('ul.attributes_bottom').css({'display':'none'});
	
	//$('.toggle_attribute_view').text("View More").src('/images/icons/arrow-down.png');

	/*if ($('ul.attributes_top li:first-child').hasClass('active')) {
      $('toggle_attribute_view').css({'display':'none'});
    }*/
	
		$('.toggle_attribute_view').toggle(						   
			function () {
				$(this).addClass('active');
				$(this).next('ul.attributes_bottom').slideDown();
				$(this).text("Hide");
				;}, 
			function () {
				$(this).removeClass('active');
				$(this).next('ul.attributes_bottom').slideUp();
				$(this).text("View More");
		});
    /******************************************** 
    #Accordion
    ********************************************/
    $(".accordion .content").hide();
    $(".accordion h3:first").addClass("open").next().show();
    $(".accordion h3").click(function () {
        if ($(this).hasClass("open")) {
        } else {
            $(".accordion h3").removeClass("open");
            $(".accordion .content").slideUp();
            $(this).next().slideToggle();
        }
        $(this).addClass("open");
        return false;
    });
    /******************************************** 
    #Switch View
    ********************************************/
    //Function to adjust listview/thumbview
    $.fn.switchView = function () {
        var thisTabContent = $(this).parents(".maincol"); //Find active .tab_content - Changed to .maincol when we removed tabs on Nov 2011

        if ($(this).val() == 'thumbs') {//This is the gridview

            $(thisTabContent).find('ul#ulPartTypes').removeClass('listview').addClass("gridview").equalHeight();
            $(this).parent().find('label').removeClass('listview');

            if ($(thisTabContent).attr('id') == ('videos')) {
                $('#videos h3').each(function () { //On each of the #videos headings...
                    $(this).find('a').showhide();
                });
            }

        } else {//This is the listview		
            $(thisTabContent).find('ul.gridview.col3 li:nth-child(3n+1)').removeClass("clear");
            $(thisTabContent).find('ul.gridview li').css("height", "auto");
            $(thisTabContent).find('ul#ulPartTypes').removeClass('gridview').addClass("listview");
            $(this).parent().find('label').addClass('gridview');
            if ($(thisTabContent).attr('id') == ('videos')) {
                $('#videos h3').each(function () { //On each of the #videos headings...
                    $(this).find('a').html($(this).find('a').attr('title'));
                });
            }
        }
    }; //end function

    //Detect if listview/thumbnail is default
    $.fn.detectSwitchView = function () {
        if ($(this).find("ul#ulPartTypes").hasClass("listview")) {
            $(".switchview select").val('details');
        } else {
            $(".switchview select").val('thumbs');
        }
    }
    //Run detect on first tab content
    $('.tab_content:first').detectSwitchView();

    //On Select Change
    $(".switchview select").change(function () {
        $(this).switchView();
    });
    /******************************************** 
    #Product Thumb Viewer
    ********************************************/
    $(".thumbs a:first-child").addClass("active");
    $(".thumbs a").click(function () {
        var mainImage = $(this).attr("href"); //Find Image Name
        $(".thumbs a").removeClass("active");
        $(this).addClass("active");
        $(".lrg_view").attr({ href: mainImage + '&w=600' }).find("img").attr({ src: mainImage + '&w=301' });
        return false;
    });
    /******************************************** 
    #On Sale Now Page 
    ********************************************/
    //Sort Promo with Cat ID /*--Special Deals Page--*/
    $("#catidselector select").change(function () {
        $("ul.col1 li, .js_message").fadeOut('fast');
        var catidVal = $(this).val(); //Get Cat ID
        //var catName = $("#catidselector select :selected").text(); Unused variable
        if ($("li").hasClass("catid_" + catidVal)) { //If selection matches cat ID
            $("li.catid_" + catidVal).fadeIn('fast');
        } else if (catidVal == '-1') { //If selection is default
            $("li").show();
        }
    });
    /******************************************** 
    #Peek-a-Boo Banner - Sticky Footer Ad
    ********************************************/
	if ($('.globalbanner').size() > 0) {
        $('.globalbanner').fadeIn();
        $('.globalbanner').hover(function () {
            $(this).stop().animate({ bottom: 0 }, { duration: 200, easing: 'easeInOutCirc' });
        }, function () {
            $(this).stop().animate({ bottom: -110 }, { duration: 200, easing: 'easeInOutCirc' });
        });
        $('.globalbanner a.btn').click(function () {
            $(this).parent().parent().hide();
            saveCookie('tgbanner', '1', '480'); //add cookie
            return false;
        });
        //check if cookie tgbanner exists
        if (document.cookie.indexOf('tgbanner') > -1) {
            $('.globalbanner a.btn').parent().parent().hide();
        }
    }
    /******************************************** 
    #Popups // Custom Popups for inline markup + images
    ********************************************/
    $('a.poplight[href^=#]').click(function () {
        var popID = $(this).attr('name'); //Get Popup Name
        var popURL = $(this).attr('href'); //Get Popup href to define size

        //Pull Query & Variables from href URL
        var query = popURL.split('?');
        var dim = query[1].split('&');

        //Fade in the Popup then set width
        $('#' + popID).fadeIn().css({ 'width': Number(dim[0].split('=')[1]) });

        //Define margin for center alignment (vertical + horizontal)
        var popMargTop = ($('#' + popID).height() + 40) / 2;
        var popMargLeft = ($('#' + popID).width() + 40) / 2;

        //Apply Margin to Popup
        $('#' + popID).css({
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft
        });
        //Fade in Background
        $('body').append('#fade');
        $('#fade').fadeIn();

        return false;
    });

    function processPopImage() {
        var popMargTop = ($('img.view_lrg').height() + 40) / 2;
        var popMargLeft = ($('img.view_lrg').width() + 40) / 2;
        $('#poplight').css({
            'width': $('img.view_lrg').width(),
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft,
            'visibility': 'visible'
        });
    }


    //IMAGES
    $('a.poplight[href*=.jpg] , a.poplight[href*=.gif] , a.poplight[href*=.png]').click(function () {
        $('#poplight').remove();

        var popURL = $(this).attr('href');
        var img = new Image();
        $('.bodywrap').append('<div id="fade"></div>');
        $('#fade').css('filter', 'alpha(opacity=80)').fadeIn().after('<div id="preload"><img src="/images/misc/ajax-loader.gif" alt="Loading..." /></div><div id="poplight"><a href="#" class="close"><img src="/images/buttons/close_pop.png" class="btn_close" title="Close" /></a><img src="' + popURL + '" class="view_lrg" /></div>');

        $(img).load(function () {
            $('#preload').fadeOut().remove();
            processContent();
        }).attr('src', popURL);

        return false;
    });

    $('a.close, #fade').live('click', function () {
        $('#fade , .popup_block').fadeOut();
        $('#poplight , #preload, #fade').remove();
        return false;
    });
    /************************************************************************************************************************************ 
    #CHECKOUT
    ************************************************************************************************************************************/
    /******************************************** 
    #International Shipping  / Checkout  Step 1
    ********************************************/
    $(".validate_NONUS").hide();
    $.fn.countryDetect = function () {
        var countrySelect = $('.country_select option:selected').val();
        $(".validate_US, .validate_NONUS").hide();
        if (countrySelect == '0') {
        } else if (countrySelect == 'US') {
            $(".validate_US").fadeIn();
        } else {
            $(".validate_NONUS").fadeIn();
        }
    }
    $(".country_select select:selected").countryDetect(); //Run if already selected
    $(".country_select select").change(function () { // Run when option changes
        $(this).countryDetect();
    });
    /******************************************** 
    #Terms Printing - Checkout Step 2
    ********************************************/
    //Hides everything but the terms and conditions (for print only)
    $(".print_trigger").click(function () {
        $("#checkout").addClass('hidePrint');
        var terms = $(this).next().text();
        $('#content').append("<div class='showPrint'></div>");
        $('.showPrint:first').html("<h1>Promotional Terms</h1>" + terms);
        return true;
    });
    //brings back default print settings when billing section is closed
    $('.billing a').click(function () {
        $("#checkout").removeClass('hidePrint');
        $('.showPrint').remove();

    });
    /********************** 
    For Hard Parts Image Map - Highlight 
    **********************/
    $("area").click(function () {
        var anchorID = $(this).attr("href");
        var anchorIDfloat = parseFloat(anchorID.substring(1));
        $("ul.partlist li").removeClass("highlight");
        $("ul.partlist li.partnum_" + anchorIDfloat).addClass("highlight");
    });
    /******************************************** 
    #Tables 
    ********************************************/
    $("table.tabdata").filter(function () {
        /* Apply THead Background*/
        $("thead tr:last-child th", this).css("background", "#f1f1f1 url('/images/theme/tbl_th_bg.jpg') repeat-x bottom");
        /* Remove Extra Borders */
        $("tbody tr:first-child td", this).css("border-top", "none");
        $("tbody tr td:last-child, thead tr th:last-child", this).css("border-right", "none");
    });
    /* Apply odd Class - Only Works on Simple Tables*/
    $("table.tabdata:not(.no-odd)").each(function () {
        $("tbody tr:odd", this).addClass("odd");
    });
    /******************************************** 
    JK Two Link
    ********************************************/
	var JKWrapper = parseInt($('.jeep_jk2007').size(),10);
	if(JKWrapper == 1){//Does the hover only when the dropdown jeep is on screen
		var JKJeep = $('.jeep_jk2007');
		var JKJeepLink = new Array();
		var JKJeepHoverHTML = '<div class="jkwrapper"><div class="jkhover invis">';
		JKJeep.next('p').find('a').each(function(index){
			JKJeepLink[index] = '<a href="'+$(this).attr('href')+'">'+$(this).text()+'</a>&nbsp;&nbsp;';
			JKJeepHoverHTML += JKJeepLink[index];
		});
		JKJeepHoverHTML += '</div><img src="'+JKJeep.attr('src')+'"/></div>';
		JKJeep.before(JKJeepHoverHTML);
		$('.jeep_jk2007').remove();
		function showJKOptions(){
			$('.jkhover').removeClass('invis').show();
		}
		function hideJKOptions(){
			$('.jkhover').hide();
		}
		var JKHoverConfig ={
				sensitivity:2,
				over: showJKOptions, // function = onMouseOver callback (REQUIRED)
				timeout: 800, // number = milliseconds delay before onMouseOut
				out: hideJKOptions // function = onMouseOut callback (REQUIRED)
		}
		$('.jkwrapper').hoverIntent(JKHoverConfig);
	}
    /******************************************** 
    Lightbox
    ********************************************/
    //Var Browser is at the beggining of the document.
    var lightboxAnimation = true;
    if ((browser.match(/iPhone/i)) || (browser.match(/iPad/i)) || (browser.match(/maemo/i)) || (browser.match(/android/i)) || (browser.match(/webos/i)) || (browser.match(/MSIE 6/i)) || (browser.match(/MSIE 7/i)) || (browser.match(/MSIE 8/i))) {
        lightboxAnimation = false;
		var lightboxWidth;//Fixes an issue with IE not respecting the DIVs width
		$('.lightbox_container').each(function (){
			lightboxWidth = parseInt($(this).width(),10)+20;
			$(this).css("width", lightboxWidth);
		});
    }
    $(".vehicle_lightbox_wrapper, .closeLightbox").live("click", function () {
        var errorsOnPage;
        var buttonAction;
        var growlNotificationSize;
		var url_parameter = location.search.replace(/^\?/gim,'').replace(/=/gim,'').replace(/\d.*/gim,'');
        //Pickup in store code
        var pickInStoreDropdown = $('.dropdown_lightbox').size();
        if (pickInStoreDropdown >= 1) {
            var prevDropdownVal = $('.dropdown_lightbox').attr('rel');
            $('.dropdown_lightbox').val(prevDropdownVal);
        }

        function hideGrowlNotification() {
            $(".growl_notification").parent().hide();
        }

        function hide(buttonAction) {
            errorsOnPage = $(".lightbox_container .errormsg").size();
            //alert("Errors: "+errorsOnPage+" | Action: "+buttonAction);
            if (errorsOnPage === 0 || buttonAction === "cancel") {
                $(".filter_lightbox").find(".info").removeClass("invis");
                var YMMFiltersSize = $(".filter_lightbox").size();
                if (YMMFiltersSize === 1) {
                    $("body").removeClass("filter_lightbox");
                    $(".filterwrap").parent().addClass("dropdown_container");
                    $(".vehicle_details").next("p").hide();
                }
                clearInterval(YMMLightboxScreenPosition);
                if (lightboxAnimation === true) {
                    $(".vehicle_lightbox_wrapper").fadeOut().animate({ opacity: 0.7 });
                    $(".lightbox_container:not(#ymm_filter.lightbox_container)").animate({ top: -99999 }, { duration: 4000, complete: function () { $(this).hide() } });
					if(url_parameter=="ppe"){
						window.location.href = "shoppingcart.aspx";
					}
                }
                else {
                    $(".vehicle_lightbox_wrapper").hide().css("opacity", "0.7");
                    $(".lightbox_container:not(#ymm_filter.lightbox_container)").hide();
					var lightboxWidth;//Fixes an issue with IE not respecting the DIVs width
					$('.lightbox_container').each(function (){
						$(this).css('width', 'auto');
					});
					if(url_parameter=="ppe"){
						window.location.href = "shoppingcart.aspx";
					}
                }
                growlNotificationSize = $(".growl_notification").size();
                if (growlNotificationSize >= 1) {
                    setTimeout(hideGrowlNotification, 5000);
                }
                clearInterval(verifyFormHasBeenProcessed);
                //$(".vehicle_lightbox_wrapper").remove();
            }
        }

        if ($(this).attr("alt")) {
            buttonAction = $(this).attr("alt").toLowerCase();
        }
        else {
            buttonAction = "cancel";
        }
        if (buttonAction === "save" || buttonAction === "submit") {

            var hiddenInputValue;
            var verifyFormHasBeenProcessed;

            verifyFormHasBeenProcessed = setInterval(function () {
                hiddenInputValue = parseInt($(".lightbox_container input#ctl00_ContentPlaceHolder1_hf_BillingAddress_CreateEdit_IsSPD, .lightbox_container #ctl00_ContentPlaceHolder1_pDetailD_partFitment_IsSPD").attr("value"), 10);
                if (hiddenInputValue === 1) {//Error on Page
                    if ($(".lightbox_container.partdetail")) {//Part Detail Error Handling
                        errorsOnPage = $(".lightbox_container.partdetail .errormsg").size();
                        //alert("Errors: "+errorsOnPage);
                        if (errorsOnPage === 0) {
                            clearInterval(verifyFormHasBeenProcessed);
                            $(".lightbox_container #ctl00_ContentPlaceHolder1_pDetailD_partFitment_IsSPD").attr("value", "0");
                            hide(buttonAction);
                        }
                    }
                    else {
                        clearInterval(verifyFormHasBeenProcessed);
                        hide(buttonAction);
                    }
                }
            }, 100);
        }
        else {
            hide(buttonAction);
        }
        //return false;
    });
    function lightboxSlideOnScreen(getLightboxTarget) {
        var screenWidth;
        var screenHeight;
        var screenScrollPosition;
        var lightboxWidth;
        var lightboxHeight;
        var lightboxTopPoss;
        var lightboxLeftPoss;
		
		//Remove vs_image_list and class=or if vs_image_list is empty
		var vs_image_list = $('.vs_image_list').text().replace(/[ \t\r\n]/gim,"");
		if(vs_image_list == ""){
			$('.vs_image_list, .or').remove();
			$('.filter_lightbox .lightbox_container#ymm_filter').css('width','auto');
		}

        function lightBoxGetPosition(getLightboxTarget) {
            screenWidth = $(window).width();
            screenHeight = $(window).height();
            screenScrollPosition = jQuery(window).scrollTop();
            lightboxWidth = $("#" + getLightboxTarget + ".lightbox_container").width();
            lightboxHeight = $("#" + getLightboxTarget + ".lightbox_container").height();
            lightboxTopPoss = (((screenHeight - 200) - lightboxHeight) / 2) + screenScrollPosition;
            lightboxLeftPoss = (screenWidth - lightboxWidth) / 2;
            return screenWidth, screenHeight, screenScrollPosition, lightboxWidth, lightboxHeight, lightboxTopPoss, lightboxLeftPoss;
        }
        lightBoxGetPosition(getLightboxTarget);
        $(".lightbox_container").hide();
        $("#" + getLightboxTarget + ".lightbox_container").css({ "left": lightboxLeftPoss });
        $("#" + getLightboxTarget + ".lightbox_container").css({ "top": screenScrollPosition - lightboxHeight });
        $("#" + getLightboxTarget + ".lightbox_container:first").show();

        if (lightboxAnimation === true) {
            $("#" + getLightboxTarget + ".lightbox_container:first").stop().animate({ top: lightboxTopPoss });
        }
        else {
            $("#" + getLightboxTarget + ".lightbox_container:first").stop().css("top", lightboxTopPoss).show();
        }

        YMMLightboxScreenPosition = setInterval(function () {
            lightBoxGetPosition(getLightboxTarget);
            if (lightboxAnimation === true) {
                $(".vehicle_lightbox_wrapper").css({ "width": screenWidth, "height": screenHeight });
                $("#" + getLightboxTarget + ".lightbox_container:first").stop().animate({ "top": lightboxTopPoss, "left": lightboxLeftPoss });
            }
        }, 100);
    };
    $(".openLightbox").live("click", function () {
        getLightboxTarget = $(this).attr("rel");
        $(".vehicle_lightbox_wrapper").hide().css("opacity", "0.7").fadeIn();
        $(".lightbox_container").hide();
        lightboxSlideOnScreen(getLightboxTarget);
        //return false;
    });
    /*---------------------- PICK UP IN-STORE - START ------------------------------------*/
    var listofCountries = ['US', 'CA', 'MX'];
    var countryDropdown = $('#ctl00_ContentPlaceHolder1_ddlCountry');

    countryDropdown.live('change', function () {
        var countryDropdownValue = $(this).val();
        var dropdownIndex = jQuery.inArray(countryDropdownValue, listofCountries);
        if (dropdownIndex == -1) {
            countryDropdown.parents('li').next().hide();
            countryDropdown.parents('li').next().next().hide();
            $('li.international').fadeIn();
        }
        else {
            countryDropdown.parents('li').next().fadeIn();
            countryDropdown.parents('li').next().next().fadeIn();
            $('li.international').hide();
        }
    });

    $('select.dropdown_lightbox').live("click", function () {
        var prevDropdownValue = $(this).val();
        if (prevDropdownValue != 'PIS|0') {
            $(this).attr('rel', prevDropdownValue);
        }
    });
    $('.dropdown_lightbox').live('change', function () {
        var dropdownValue = $(this).val();
        if (dropdownValue == "PIS|0") {
            getLightboxTarget = "storepickup";
            $(".vehicle_lightbox_wrapper").hide().css("opacity", "0.7").fadeIn();
            $(".lightbox_container").hide();
            lightboxSlideOnScreen(getLightboxTarget);
        }
    });
	
    var YMMLightBoxSize = $(".filter_lightbox").size();
    if (YMMLightBoxSize >= 1) {
        lightboxSlideOnScreen(".lightbox_container");
    }
    /******************************************** 
    Search Filter 
    ********************************************/
    $(".filter_lightbox .searchfilter ul li").hide();
    $(".filter_lightbox .searchfilter ul li:first-child , .searchfilter").fadeIn('slow');
    $(".filter_lightbox .searchfilter ul").each(function () {
        $(this).wrap('<div class="filterwrap" />');
    });

    $(".filter_lightbox .searchfilter ul li:first-child, .dropdown_container .searchfilter ul li:first-child").click(function () {
        $(".filter_lightbox .searchfilter ul li, .dropdown_container .searchfilter ul li").hide();
        $(".filter_lightbox .searchfilter ul li:first-child, .dropdown_container .searchfilter ul li:first-child").show();
        $(".filter_lightbox .searchfilter ul, .dropdown_container .searchfilter ul").removeClass('dropdown').parent().removeClass('overlap');
        $(this).addClass('firstchild').parent().addClass('dropdown').find("li").show().parent().parent().addClass('overlap');
        return false;
    });

    $(".filter_lightbox .searchfilter ul li:not(:first-child), .dropdown_container .searchfilter ul li:not(:first-child)").click(function () {
        window.location = $(this).find("a").attr("href"); return false;
    });

    $(document).click(function () { //Click anywhere and...
        $(".filter_lightbox .searchfilter ul li, .dropdown_container .searchfilter ul li").hide();
        $(".filter_lightbox .searchfilter ul li:first-child, .dropdown_container .searchfilter ul li:first-child").show();
        $(".filter_lightbox .searchfilter ul, .dropdown_container .searchfilter ul").removeClass('dropdown');
    });
    $(".filter_lightbox .searchfilter ul li, .dropdown_container .searchfilter ul li").click(function (e) {
        e.stopPropagation(); //Prevents the subpanel ul from closing on click
    });

    //Check if filter exists, if not pull out the accordion
    $('.filter_lightbox .acc_container').each(function () {
        if ($(this).find('.filter_lightbox .crumb:empty').length) {
            if ($(this).find('.filter_lightbox .searchfilter').length) {
            } else {
                $(this).prev().hide();
            }
        }
    });
    //Left nav filter accordion **Hide more than 7**Updated Jan 2012
    $('.products ul.filter li strong').toggle(function () {
        $(this).addClass('active');
        $(this).parents('.searchfilter ul').find('li').not(':first').slideUp();
		$(this).parents('ul.attributes_top').next('.toggle_attribute_view').hide();
		$(this).parents('ul.attributes_top').next('.toggle_attribute_view').next('ul.attributes_bottom').hide();

    }, function () {
		$(this).removeClass('active');
        $(this).parents('.searchfilter ul').find('li').not(':first').slideDown();
		$(this).parents('ul.attributes_top').next('.toggle_attribute_view').show();
			
			if( $(this).parents('ul.attributes_top').next('.toggle_attribute_view').hasClass('active') ) {
				$(this).parents('ul.attributes_top').next('.toggle_attribute_view').next('ul.attributes_bottom').show();
			} 
    });
});       //Jquery EOF
