
function Start() {

	var obj = $('ul#Menu');

	var fadeInTime = 200; // in milliseconds
	var fadeOutTime = 300; // in milliseconds

	$(obj).find('li ul li:has(ul) > a').prepend('<span class="menu-sub-indicator"> &raquo;</span>');

	$(obj).find('li ul').attr('fadeState', 'none');
	$(obj).find('li').hover(
        function() {
        	if ($(this.getElementsByTagName('ul')[0]).attr('fadeState') == 'fadeOut') {
        		$(this.getElementsByTagName('ul')[0]).stop(true, true);
        		$(this.getElementsByTagName('ul')[0]).attr('fadeState', 'none')
        	}

        	if ($(this.getElementsByTagName('ul')[0]).attr('fadeState') == 'none') {
        		$(this.getElementsByTagName('ul')[0]).attr('fadeState', 'fadeIn');
        		$(this.getElementsByTagName('ul')[0]).fadeIn(fadeInTime, function() {
        			$(this).attr('fadeState', 'none')
        		});
        		// Custom for Drop Down / hover
        		$(this).addClass('thisOver');
        		$(this).find('a.top').addClass('thisOver');
        		$(this).find('a.top').append('<div class="corner"></div>');
        	}
        	$(this).addClass('over');
        },
        function() {
        	if ($(this.getElementsByTagName('ul')[0]).attr('fadeState') == 'fadeIn') {
        		$(this.getElementsByTagName('ul')[0]).stop(true, true);
        		$(this.getElementsByTagName('ul')[0]).attr('fadeState', 'none');
        	}

        	if ($(this.getElementsByTagName('ul')[0]).attr('fadeState') == 'none') {
        		$(this.getElementsByTagName('ul')[0]).attr('fadeState', 'fadeOut');
        		$(this.getElementsByTagName('ul')[0]).fadeOut(fadeOutTime, function() {
        			$(this).attr('fadeState', 'none')
        			// Custom for Drop Down / hover
        			$(this).parent().removeClass('thisOver');
        			$(this).parent().find('a.top').removeClass('thisOver');
        			$(this).parent().find('a.top div.corner').remove();
        		});
        		// Custom for Drop Down / hover
        		$(this).find('a.top div.corner').css('background-position', 'right -35px');
        	}
        	$(this).removeClass('over');
        }
    );

	$(obj).find('li.item ul').each(function() {
		$(this).find('li:last').css('border-bottom', '0px');
	});

	$(obj).find('li ul:empty').css('visibility', 'hidden');

}

$(document).ready(function() {

	// add store categories to the menu under "Products":
	pixelsilk.renderSkin('[' + '[ProductsMenuItems]' + ']', function(theHtml) {
		$('#Menu li.item').find("a:contains('Products')").after(theHtml);
		$('#Menu li.item').find("a:contains('Products')").parent().find('ul:first').attr('fadestate', 'none');
	});

	pixelsilk.renderSkin('[' + '[Menu1]' + ']', function(html) {
		$('#subNavigation').html(html);
		var sections = $('#subNavigation div');
		var topElements = $('#Menu li.item');
		for (z = 0; z < sections.length; z++) {
			var li = topElements[z];
			var lihtml = li.innerHTML;
			li.innerHTML = lihtml + sections[z].innerHTML;
		}
		Start();
	});

});
