$.fn.navaccord = function(options){
	
	var opts = $.extend({}, $.fn.navaccord.defaults, options);
	
	$.fn.navaccord.defaults = {
		subarrow: '/templates/__custom/img/subarrow.jpg',
		subarrowactive: '/templates/__custom/img/subarrowactive.jpg'
	};

	var url = window.location.pathname;
	$(".SideCategoryListClassic ul").children("li").each(function() {
		if( $(this).find("ul").length > 0 ) {
			$(this).addClass("dropable")
		}
		$(".dropable ul li").each(function() {
			if( $(this).find("ul").length > 0 ) {
				$(this).addClass("dropable")
			}
		});
	});

	$(".dropable").prepend("<div class='subarrow'></div>");
	$(".dropable").children("ul").addClass("child").hide();
	
	$(".subarrow").css({ "position":"absolute", "top":"6px", "right":"0px" });
	$(".dropable").css("position","relative");
	$(".dropable .child").css("display","none");
	
	$(".dropable").each(function() {
		$(this).children("a").click(function() {
			$(this).parent(".dropable").children(".child").toggle(300).parent(".dropable").toggleClass("expand").children("a").toggleClass("active")
		});
	});
	
	// Scopes the dropdown on the product page
	if ($("#ProductBreadcrumb").length > 0 ) {
		var active = $("#ProductBreadcrumb ul li:nth-child(2) a").html()
		$(".SideCategoryListClassic ul li a").each(function() {
			if ($(this).html() == active) {
				$(this).parent(".dropable").toggleClass("expand").children(".child").toggle()
			}
		});
	}
	
	$(".SideCategoryListClassic").find("a").each(function() {
		if ($(this).attr("href") == window.location.pathname || $(this).attr("href") == window.location) { 
			$(this).parents(".dropable").toggleClass("expand").children(".child").toggle()
		}
	});
	
	$(".dropable").children("a").removeAttr("href");
};
