var navTimer = null;
var activeElement = null;
var initSearch = true;

$(document).ready( function() {


    $("#hoofd-navigatie .multilevel").mouseover(function() {
        $(this).addClass("hovering");
        var countedWidth = $(document).width();
        newcountedWidth = countedWidth - 21;
        
        var leftovers = (countedWidth - 985) / 2;
        leftovers = countedWidth - 985 - leftovers;
        
        var position = $(".uitklap", this).position();
        
        var subright;
        if(leftovers >= "150"){
            subright = leftovers-100;
            subright = subright+"px";

            $("#hoofd-navigatie .uitklap .subnavigatie").css({ "margin-right": subright});
        }
        newLeft = "-"+leftovers+"px";
        
        $(".uitklap", this).css({ "right": newLeft, "width": countedWidth  });
        $("html").css({"overflow-x":"hidden"});
    });
    
    $("#hoofd-navigatie .multilevel").mouseout(function() {
        $(this).removeClass("hovering");
    });  
		
   
   //add png fix;
   $('.ttlogo').ifixpng();   
});
	
	/* einde document.ready */


function initMenu() {
    $('.archiveLinksContainerStyle ol.slidepanel').hide();

    var parent = $('.archiveLinksContainerStyle ol.slidepanel a.active').parent().parent()[0];	

    if (parent == undefined)
    {
      $('.archiveLinksContainerStyle div:first ol.slidepanel').show();
      $('.archiveLinksContainerStyle div:first .yearbutton').addClass('active');
    }
    else
    {
      $(parent).show();
      $(parent).prev().addClass('active');
    }

    $('.archiveLinksContainerStyle .yearbutton').click(

	function() {
	    $('.archiveLinksContainerStyle div div.yearbutton').removeClass('active');

	    $(this).addClass('active');

	    var checkElement = $(this).next();
	    if ((checkElement.is('.slidepanel')) && (checkElement.is(':visible'))) {
	        return false;
	    }
	    if ((checkElement.is('.slidepanel')) && (!checkElement.is(':visible'))) {
	        $('.archiveLinksContainerStyle ol.slidepanel:visible').slideUp('normal');
	        checkElement.slideDown('normal');
	        return false;
	    }
	});
}
$(document).ready(function() { initMenu(); });
