$(function() {
	
	var current = null;
	// hide all the sub-menus
	$("span.menu-toggle").next().hide();
	
	// add a link nudging animation effect to each link
    	$("#menuSx a, #menuSx span.menu-toggle").hover(function() {
    	
        $(this).stop().animate( {
			marginLeft:"7px",
			fontSize:"112%"

        }, 300);
    }, function() {
    	
        $(this).stop().animate( {
			marginLeft:"0px",
			fontSize:"100%"
        }, 300);
    });
	
	// set the cursor of the toggling span elements
	$("span.menu-toggle").css("cursor", "pointer");
	
	// add a click function that toggles the sub-menu when the corresponding
	// span element is clicked
	$("span.menu-toggle").click(function() {
	
		if($(this).children("a").attr("href")!='#') {
				$(this).attr({rel:$(this).children("a").attr("href")});
				$(this).children("a").attr({
					href:'#'
				});
			}
		
		

		$(this).next().toggle(1000);
		
		
		
		if(current && current!=this) {
			$(current).next().toggle(1000);
			
		}
		
		if(current && current==this) {
			$(this).children("a").attr({
				href: $(this).attr("rel")
			});
		}	
		current = this;
		
		
		
	});
	
});
