/* usr-lib.js v.1.4 */

var picNum = 0;

function getPicNum( status )
{
	if( status == 0 ) picNum = Math.floor( Math.random() * 2 );

	return picNum;
}

function setCurrentPage( position )
{
	document.getElementById( "selected" ).style.marginTop = position;
	document.getElementById( "selected" ).style.visibility = "visible";
}

function setLayout( page_id )
{
	var rawHeight = document.getElementById("main").clientHeight;
	var menuHeight = document.getElementById("menu").clientHeight;
	var menuHeight_5 = document.getElementById("menu-5").clientHeight;
	
	/* Pages with sidebar */
	if( ! page_id ) {
		
		var sidebarHeight = document.getElementById("primary").clientHeight;
		
		/* Set the y position of sidebar */
		document.getElementById("primary").style.marginTop = -( rawHeight - sidebarHeight ) + 120 + "px";
		
		if( ( rawHeight - sidebarHeight ) <= menuHeight ) {
			if( sidebarHeight <= menuHeight ) {
				document.getElementById("menu-5").style.height = ( sidebarHeight + 120 ) - menuHeight + menuHeight_5 + "px";
			}
			else {
				document.getElementById("main").style.height = "625px";
			}
		}
		else {
			if( ( rawHeight - sidebarHeight ) <= ( sidebarHeight + 120 ) ) {
				document.getElementById("menu-5").style.height = ( sidebarHeight + 120 ) - menuHeight + menuHeight_5 + "px";
			}
			else {
				document.getElementById("menu-5").style.height = ( rawHeight - sidebarHeight ) - menuHeight + menuHeight_5 + "px";
			}
		}
	}
	/* Pages without sidebar */
	else {
		if( rawHeight <= menuHeight ) {
			document.getElementById("main").style.height = "625px";
		}
		else {
			document.getElementById("menu-5").style.height = rawHeight - menuHeight + menuHeight_5 + "px";
		}
	}
}
