$(document).ready(function() {

	$("#navigation .item").click(function() {
		var sub = $(this).parent().children('.sub');
		
		if(sub.css('display') != "block") {
			$('.sub').hide();
			sub.children('.subLeft').children('.categories').hide();
			sub.children('.subLeft').children('.choiceText').show();
			sub.children('.subRight').hide();
			sub.unbind('mouseleave');
			sub.show('slide', function() {
				$(this).one('mouseleave', function() {
					$(this).hide('slide');
				});
			});
		}
	});
});

function showBrands(element) {
	var brands = $(element).parent().parent().children('.subRight');
	var categories = $(element).parent().children('.categories');
	var choiceText = $(element).parent().children('.choiceText');
	
	if(categories.css('display') != "none") {
		categories.hide('blind', 800, function() {
			choiceText.show('blind', 800);
		});
	}
	
	if(brands.css('display') != "block") {
		brands.show('slide');
	}
	//$('#navigation .subRight').one('mouseout', function() {
	//	$(this).parent().hide('slide');
	//}); 

}

function showCategories(element) {
	var brands = $(element).parent().parent().children('.subRight');
	var categories = $(element).parent().children('.categories');
	var choiceText = $(element).parent().children('.choiceText');
	
	if(brands.css('display') != "none") {
		brands.hide('fold');
	}
	
	if(categories.css('display') != "block") {
		choiceText.hide('blind', 800, function() {
			categories.show('blind', 800);
		});
	}
	//$('#navigation .subLeft').one('mouseout', function() {
	//	$(this).parent().hide('slide');
	//});
}

function openURL(url) {
	document.location.href = url;
}
