/* Scrolling stuff */

function scrollUp (content, window)
{
	var crntTop = stripPX(document.getElementById(content).style.marginTop);
	
	crntTop += 52;
	
	moveBar (content, window, crntTop);
}

function scrollDown (content, window)
{
	var crntTop = stripPX(document.getElementById(content).style.marginTop);
	
	crntTop -= 52;
	
	moveBar (content, window, crntTop);
}

function moveBar (content, window, newpos)
{
	var wnd = document.getElementById(window);
	var cnt = document.getElementById(content);
	
	if (newpos > 0) { newpos = 0; }
	if (cnt.offsetHeight + newpos < wnd.offsetHeight) {
		if (cnt.offsetHeight <= wnd.offsetHeight) {
			newpos = 0;
		} else {
			newpos = 0 - (cnt.offsetHeight - wnd.offsetHeight); 
		}
	}
	
	cnt.style.marginTop = newpos + "px";
	//alert(newpos + " - " + cnt.offsetHeight + " - " + wnd.offsetHeight);
}

function stripPX (s)
{
	var ret;
	if (s.indexOf("px") > 0 || s.indexOf("pt") > 0) {
		return parseInt(s.substring(0, s.length - 2));
	} else {
		ret = parseInt(s);
		
		if (isNaN(ret)) { return 0; } else { return ret; }
	}
}
