$(document).ready(
	function(){

// Process small menu
	$counter = 1;
	$max = $("ul.nav-menu-small > li").size();
	$("ul.nav-menu-small > li").each(function (i) {
		
		if ($counter != $max) {
			$(this).append('<span class="seperator">|</span>');
		}
		$counter++;
	});
	// Process main menu
	$counter = 0;
	$("ul.nav-menu > li").each(function (i) {
		
		$(this).addClass('menu-paint-'+$counter);
		$element = $(this).find(".sub-menu").addClass('sub-'+$counter)
		if (!$element.parent().hasClass('current-menu-item') && !$element.parent().hasClass('current-menu-parent')) {
			$element.hide();
		}
		$counter++;
	});
	
	// Process footer menu
	$counter = 1;
	$max = $("ul.nav-menu-footer > li").size();
	$("ul.nav-menu-footer > li").each(function (i) {
		
		if ($counter != $max) {
			$(this).append('<span class="seperator">|</span>');
		}
		$counter++;
	});
	
	function dropdown(i) {
		$(".menu-paint-"+i).hover(
			function () {
			// Clear all
			$("#nav-menu .sub-menu").hide();
			
			// Hover the menu the mouse points on
			$(this).addClass("hover");
			$(this).find(".sub-"+i).show();
			}, 
			function () {
				if (!$(this).hasClass('current-menu-item') && !$element.parent().hasClass('current-menu-parent')) {
					$(this).removeClass("hover");
					$(this).find(".sub-"+i).hide();
					
					$("#nav-menu .current-menu-item").find('.sub-menu').show();
					$("#nav-menu .current-menu-parent").find('.sub-menu').show();
				}
			}
		);

	}
	
	dropdown(0);
	dropdown(1);
	dropdown(2);
	dropdown(3);
	dropdown(4);
	dropdown(5);

});

$(document).ready(
	function(){
		$('#items').innerfade({
			speed: 1000,
			timeout: 5000,
			type: 'random_start',
			containerheight: '510px'
		});
	}
);
