$(document).ready(function() {

	$(".twirler").click( function(e) {
		var par = $(this).parent();
		if(par.hasClass("open")) {
			$($(this).attr("href")).slideUp();
			par.removeClass("open");		
		} else {
			$($(this).attr("href")).slideDown();
			par.addClass("open");
			
		}
		e.preventDefault();
	});
	
	// set the menu item to active for the current page, if possible
	var thisPage = location.pathname;
	var thisPage = thisPage.substring(thisPage.lastIndexOf('/') + 1);

  	if ( thisPage ) {
  	
  	// mark the nav's LI as selected, open ITs parent
     $('#navigation ul li a[href="' + thisPage + '"]').parent().addClass('selected').parent().parent().slideDown().addClass("open");      
    // or, for top-level items, open the children up
     $('#navigation li a.primary[href="' + thisPage + '"]').parent().addClass('selected').addClass('open').find('ul').slideDown()

	}

   // ie6 specific
   if ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined)) {	
	/* hover for IE6 */

	$("#navigation ul li").hover( 
	  function() {
		$(this).removeClass("off");	  
		$(this).addClass("hover");
      }, 
      function() {
		$(this).removeClass("hover");
		$(this).addClass("off");
		
      }
    );
   
  	 DD_belatedPNG.fix('#navigation a');
   }
});
