var obj = null;

var slideupspeed = 10;
var slidedownspeed = 300;
var slideuptimeout = 450;
function checkHover() {
	if (obj) {
		obj.parent().find('ul').slideUp(slideupspeed);	
		obj.attr({style: ""});
	}
} 

$(document).ready(function() {


	
        $("#TopNav").superfish({ 
            delay:       1000,                            // one second delay on mouseout 
            animation:   {height:'show'},  // fade-in and slide-down animation 
            speed:       300,                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: true                            // disable drop shadows 
        }); 
    
	
	
	// Collapse everything but the first menu:
	$("#NewsArch ul").hide();
	$("#archselected").parent().parent().parent().parent().find(".m").show();
	$("#archselected").parent().slideDown(0);
	
	// Expand or collapse:
	$("#NewsArch .ya").click(function() {
	    $(this).parent().siblings().find(".m").slideUp("fast");
	    $(this).parent().find(".m").slideToggle(300);
	});
	$("#NewsArch .ma").click(function() {
	    $(this).parent().parent().siblings().find("ul").slideUp("fast");
		$(this).parent().find(".i").slideToggle("fast");
	});
	
	/* OLD
	$('#TopNav > li').hover(function() {
	$(this).attr({style: "background-position-y:-68px;"});
		if (obj) {obj.attr({style: ""});
		obj.parent().find('ul').slideUp(slideupspeed);
			$(this).find('ul').slideDown(slidedownspeed);
			obj = null;
		}
		$(this).find('ul').slideDown(slidedownspeed);
	}, function() {
		obj = $(this);
		setTimeout(
			"checkHover()",
			slideuptimeout);
	});
	*/
});

//$(this).attr({style: "background-position: 0px 120px;"});

	//alert('cheese');
