function checkMessage() {

	name = $("#txtName").val();
	email = $("#txtEmail").val();
	message = $("#txtMessage").val();
	
	nameError = $("#errorContactsName");
	emailError = $("#errorContactsEmail");
	messageError = $("#errorContactsMessage");
	
	errors = 0;
	
	if ($.trim(name).length == 0) {
		$(nameError).show();
		errors++;
	}
	else {
		$(nameError).hide();
	}
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)) {
		$(emailError).show();
		errors++;
	}
	else {
		$(emailError).hide();
	}
	
	if ($.trim(message).length == 0) {
		$(messageError).show();
		errors++;
	}
	else {
		$(messageError).hide();
	}
	
	if (!errors) $("#formContacts").submit();
}


$(document).ready(function() {
	
	$(".menuItem").parent().hover(
								  
		function() {
			$(".menuItem.selected").remove();
			
			slider = $(this).children(".slider");
			
			if ($(slider).html()) {
				menuItem = $(this).children(".menuItem");
				selectedItem = $(menuItem).clone().addClass("selected").insertBefore($(menuItem));
				
				if ($(slider).width() < $(this).width()) {
					$(slider).children("table").css("width", ($(this).width() + 8));
				}
				if ($(slider).is(":hidden")) {
					$(menuItem).addClass("hover");
					$(slider).show();
				}
			}
			else {
				$(".slider").hide();
			}
		},
		function() {

			$(slider).hide();
			$(slider).prev(".menuItem").removeClass("hover"); 
			$(slider).parent().removeClass("hover"); 
			$(".menuItem.selected").remove();
		}
	);

	$(document).click(function() { $(".slider").hide(); });

	$("#sltCount").change(function() { $("#formNewsCount").submit(); });
	
	$("#catalogList").children("li").each(function() {
		
		arrow = $(this).find(".arrow");

		if ($(this).children("ul").is(":visible")) {
			$(arrow).addClass("down");
		}
	});
	
	$("#sltSection").change(function() { location.href = "/catalog/section/" + $(this).val(); });
	$("#sltBrand").change(function() { location.href = "/catalog/brand/" + $(this).val(); });
	
	$("#btnSend").click(function() { checkMessage(); });
	
	/*
	$("a.root").click(function() {
		
		target = $(this);
		root = $(target).parents("li");
		slider = $(root).children("ul");
		arrow = $(root).find(".arrow");
		
		if ($(slider).html()) {
			if ($(slider).is(":visible")) {
				$(slider).slideUp(200, function() { $(arrow).removeClass("down") });
			}
			else {
				$(arrow).addClass("down");
				$(slider).slideDown(200);
			}
		}
	});
	*/
});
