(function($) {
	
	$.fn.topmenu = function(lang, docroot) {
		var elm = this;

		return $(elm).find(".menu").each(function() {
			var sub = $(this).find(".sub");
			var file = sub.text();
			sub.html('');
			$.get(lang + "/menu/" + file + '.html', function(data) {
				sub.html(data).find(".subcontent span").click(function() {
					var url = $(this).find("small").text();
					if (/http:\/\//.test(url)) {
						var w = $(window).width();
						var h = $(window).height();
						var x = (screen.width - w)/2;
						var y = (screen.height - h)/2;
						var w = window.open(url, "window", "width=" + w + "px,height=" + h + "px,scrollbars=yes,menubar=yes,toolbar=yes,left=" + x + "px,top=" + y + "px");
						w.focus();
					}
					else document.location.href = "http://" + docroot + '/' + url;
				});
			});

			$(this).mouseenter(function() {
				sub.fadeIn(150);
			}).mouseleave(function() {
				sub.hide();
			});
		});

		return elm;
	}


	$(function() {
		$("a").focus(function() { this.blur() });
		
		// BRANDS
		// --------------------------------------------------------------------------
		$("ul.scroller li").mouseover(function() {
			$(this).siblings().removeClass("active").end().addClass("active");
		});
	});
	
})(jQuery);
