$(function(){
	dav.adjust_site();
	
	$('ul#nav a').click(function(e){
		var href = $(this).attr('href');
		
		if($(href).length){
			dav.scroll_to_section(href);
			
			$(this).parent()
				   .addClass('selected')
				   .siblings('li.item')
				   .removeClass('selected');
		}
		
		try{
			e.preventDefault();
		}catch(exc){
			return false;
		}
	});
	
	$('.scroll-pane').jScrollPane();
	$('.scroll-pane-arrows').jScrollPane({
		showArrows: true,
		horizontalGutter: 10
	});
				
	$('.scroll-pane').each(function(){
		$(this).jScrollPane({
			showArrows: $(this).is('.arrow')
		});
		
		var api = $(this).data('jsp');
		var throttleTimeout;
		$(window).bind('resize',
			function(){
				if ($.browser.msie) {
					if (!throttleTimeout) {
						throttleTimeout = setTimeout(
							function()
							{
								api.reinitialise();
								throttleTimeout = null;
							},
							50
						);
					}
				} else {
					api.reinitialise();
				}
			}
		);
	})
});

$(window).resize(function(){
	dav.adjust_site();
});
