var counterLeftmenu = 0;
$(document).ready(function() {
	var macDetails = $(".macTitle").not("#l1t").parents(".macTitleContainer").next();
	var macExtend = $(".macTitle").not("#l1t").parent().find(".macShower");
	macDetails.each(function() {
		$(this).hide();
	});
	macExtend.show();
	
	$('ul#nav a').each(function() {
		counterLeftmenu += 1;
		$(this).addClass("l" + counterLeftmenu);
	});
	
	$('.servicesSelector li a, ul#nav a').each(function() {
		$(this).click(function() {
			var this_id = $(this).attr('class');
			var macDetails = $("#"+this_id+"t").parents(".macTitleContainer").next();
			$(".macProductsContainer").not(macDetails).hide();
			$(".macShower").show();
			$("#"+this_id+"t").parent(".macTitleContainer").find(".macShower").fadeOut(500);
			if (macDetails.is(":hidden")) {
				macDetails.slideDown(200);
			}
		});
	});
	
	$(".macTitle, .macShower").click(function() {
		var macDetails = $(this).parents(".macTitleContainer").next();
		if (macDetails.is(":hidden")) {
			$(".macProductsContainer").slideUp(200);
			$(".macShower").fadeIn(500);
			macDetails.slideDown(200);
			$(this).parent().find(".macShower").fadeOut(500);
		} else {
			macDetails.slideUp(200);
			$(this).parent().find(".macShower").fadeIn(500);
		}
	});
	
	$(".goToTop, .goToTop2").click(function() {
		$.scrollTo({top:'0', left:'0'}, 1000);
		return false;
	});
	
	if ('undefined' === typeof window.console) {
		window.console = {
			log: function () {
				void(0);
			}
		};
	}

	var sect = unescape(location.hash);
	if ('#' === sect.charAt(0)) {
		sect = sect.substring(1, sect.length);
	}
	if ('string' === typeof sect && sect.length > 0) {
		$('a[name="' + sect + '"]').trigger('click');
		location.href = location.href;
	}
});
