/*$(document).observe("dom:loaded", function() {

	var urlParts = window.location.pathname.slice(1).replace(".html", "").split("/");
	$$("#nav > li a").each(function(elem, iterator) {
		
		// Parse URL into a domain and path.
		var path = (/(?:[\w]\/)([^\/].*)/).exec($(elem).readAttribute("href").replace(".html", ""));
		var matches = 0;
		if(path && path[1])
		{
			path = path[1].split("/");
			
			var i, j, k = 0;
			for(i = 0, j = urlParts.length; i < j; i++) {
				if(urlParts[i] && urlParts[i] == path[i])
					k++;
			}
			matches = k ? k : matches;
		}
		else
		{
			if(!path && urlParts && iterator == 0)
			{
				// This is the Home link.
				$(elem)
					.addClassName("link_active")
					.up("li")
					.addClassName("link_active")
					.addClassName("home_link_active");
			}
		}
		
		if(matches > 0)
		{
			$(elem)
				.addClassName("link_active")
				.up("li")
				.addClassName("link_active");
				
			if(!window.logme) window.logme = [];
			window.logme[window.logme.length] = [elem, matches, path, urlParts];
		}
	});


});
*/
(function($) {

	$(function() {
	
		if($.browser.msie)
		{
			$("#newsletter-validate-detail").css("left", "370px");
		}
	
		var url = window.location.href;
		var firstUrlPart = url.replace("http://", "")
			.replace("fab.nl", "")
			.replace(".html", "")
			.replace("customer/account/", "customer_account_")
			.split("/");
		
		for(var i = 0; i < firstUrlPart.length; i++)
		{
			if(firstUrlPart[i].length && firstUrlPart[i] != "index.php")
			{
				firstUrlPart = firstUrlPart[i];
				break;
			}
		}
		if(typeof firstUrlPart == "object")
		{
			firstUrlPart = "";
		}
		
		$("#nav, .footer_links, .toplinks").find("a").each(function() {
		
			var href = $(this).attr("href");
			var firstHrefPart = href.replace("http://", "")
				.replace("fab.nl", "")
				.replace(".html", "")
				.replace("customer/account/", "customer_account_")
				.split("/");
			
			for(var i = 0; i < firstHrefPart.length; i++)
			{
				if(firstHrefPart[i].length > 1 && firstHrefPart[i] != "index.php")
				{
					firstHrefPart = firstHrefPart[i];
					break;
				}
			}
			
			if(typeof firstHrefPart == "object")
			{
				firstHrefPart = "";
			}
			
			if(firstUrlPart == firstHrefPart)
			{
				setLinkActive(this);
			}
			
			if(firstUrlPart == "fab-by-danie" ||
			firstUrlPart == "fab-for-men" ||
			firstUrlPart == "fab-for-mom" ||
			firstUrlPart == "fab-mini")
			{
				if(firstHrefPart == "fab-for-women")
				{
					setLinkActive(this);
				}
			}
		
		});
		
	});

})(jQuery);

function setLinkActive(element)
{
	jQuery(element).addClass("active").parent("li").addClass("active");
}
