var myWidth = 0, myHeight = 0;
function determineInnerSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
}

function adjustLayout() {
	var newHeight = "433px";
	determineInnerSize();
	if (myHeight < 700) {
		newHeight = (window.myHeight - 275) + "px";
	}
	$("#contentDiv").css({height: newHeight});
	$("#contentDiv>div").css({height: newHeight});
}

function shouldBlockScroll() {
	var menu = getObject("menu")
	// check if CSS enabled (cross-browser)
	if (document.defaultView) {
		return document.defaultView.getComputedStyle(menu, null).getPropertyValue("text-align") == "right";
	} else {
		return menu.currentStyle['textAlign'] == "right";
	}
	
	return false;
}

/* above code is legacy, below is jQuery */

$(document).ready(function() {
	adjustLayout();
	
	$(window).scroll(function() {
		if (shouldBlockScroll()) {
			window.scrollTo(0, 0);
		}
	});
	
	/* scrollpane effect for page content section */
	var scrollPane;
	if ($().jScrollPane) {
		scrollPane = $("#contentDiv>div").jScrollPane({
			scrollbarWidth: 33,
			scrollbarMargin: 10,
			verticalDragMinHeight: 74,
			verticalDragMaxHeight: 74,
			animateDuration: 200,
			animateEase: 'swing'
		}).data('jsp');
	}
	
	$(window).resize(function() {
		adjustLayout();
	});
	
	$('.jspScrollable').focus(function() {
		$(this).blur();
	});
	
	$('a[href^="#"]').click(function() {
		var hash = $(this).attr('href');
		scrollPane.scrollToElement($(hash), true, true);
		window.location.hash = hash;
		return false;
	})
});
