// Daro Custom Huge Menu
// Uses a modified version of jquery.treeview plugin. Plus code below scrolls
// the page to keep the menu visable. 


jQuery(document).ready(function(){
	
	// Initilize Menu
	jQuery(".accordion").treeview({
		animated: "fast",
		collapsed: true,
		unique: true
	});	

		jQuery(".accordion").css({opacity: 0});
		jQuery(".accordion").css({visibility: "visible"}).animate({opacity:100});

	// On click of top level search for the new position of the div after animation
	// then scroll to there to keep menu visable. 
	if (navigator.userAgent.indexOf('MSIE') !=-1 || navigator.userAgent.indexOf('iPad') !=-1  || navigator.userAgent.indexOf('iPhone') !=-1 )
	{

	}
	else {
	jQuery("a.level-top").click(function () { 
		findstring =  'a[href$="' + this + '"]';
		setTimeout("if(jQuery(findstring).offset().top < jQuery(window).scrollTop()) {jQuery('html,body').animate({ scrollTop: jQuery(findstring).offset().top }, { duration: 'fast', easing: 'swing'})}",400)
		//alert("Window:" + jQuery(window).scrollTop() + " Item: " + jQuery(findstring).offset().top);		
		return false;


	});
	}




});
