$(document).ready( function() {
	$('div#menu > ul > li').click( function(e) {
		document.location.href=$(this).children('a').attr('href');
	});

	$('div#menu > ul > li > ul > li' ).click( function(e) {
		document.location.href=$(this).children('a').attr('href');
	});

	$('div#menu > ul > li > a').click( function(e) {
		e.stopPropagation();
	});

	$('div#menu > ul > li > ul > li > a').click( function(e) {
		e.stopPropagation();
	});

	$('div#menu > ul > li').hover(
		function() {
			$(this).addClass( 'selected' )

			if( $(this).children('a').attr('href') == 'javascript:void(0);' ) {
				$(this).css( 'cursor', 'default' );
			} else {
				$(this).css( 'cursor', 'pointer' );
			}

			$(this).children('a').hover( function() {
				if( $(this).attr('href') == 'javascript:void(0);' ) {
					$(this).css( 'cursor', 'default' );
				} else {
					$(this).css( 'cursor', 'pointer' );
				}
			});


			$(this).children( 'ul' ).fadeIn(150);
			$(this).children( 'ul' ).children( 'li' ).hover(
				function() {
					$(this).css( 'cursor', 'pointer' );
					$(this).css( 'background', 'white' );
					$(this).children( 'a' ).css( 'color', 'black' );
				},
				function() {
					$(this).css( 'background', 'black' );
					$(this).children( 'a' ).css( 'color', 'white' );
				}
			)
		},
		function() {
			$(this).removeClass( 'selected' )
			$(this).children( 'ul' ).fadeOut(150);
		}
	);
});
