// JavaScript Document



function adjustLayout()
{
	//alert('entered');
	//determine if there is a rightBar so that we can adjust complete page
	var textDocObj = document.getElementById('text');
	if(textDocObj != null) //if this is an inside page
	{  
		adjustInside();
	}
	
	else   //there is no rightBar
	{
		adjustMain();	
	}
	adjustFooter();	
}

function adjustInside()
{
	
	var rightBarDocObj = document.getElementById('rightBar');
	var textDocObj = document.getElementById('text');
	
	//var rbTop = rightBarDocObj.offsetTop //get Top position of the rightbar.
	rightBarDocObj.style.top = -10 + 'px';

}

function adjustMain()
{
	//alert('main');
}

function adjustFooter()
{
	//alert('footer');
	//check for some versions of IE and Avant
	var footerDocObj = document.getElementById('footer');
	if (footerDocObj.offsetLeft > - 225)
	{
		footerDocObj.style.left = - 225 + 'px';
	}
	
	var textDocObj = document.getElementById('text');
	if(textDocObj != null) //if this is inside
	{
		var textDocObj = document.getElementById('text');
		var rbDocObj = document.getElementById('rightBar');
		if((rbDocObj.offsetHeight - 50) > textDocObj.offsetHeight) //rightBar is longest
		{
				footerDocObj.style.top = textDocObj.offsetHeight - 100 +'px';
		}
		else //text is longest
		{
			footerDocObj.style.top = textDocObj.offsetHeight - 250 +'px';
		}
		//alert("rightBar Height: " + rbDocObj.offsetHeight);
		//alert("text Height: " + textDocObj.offsetHeight);
	}
	else //this is the index page
	{	
		var bookDocObj = document.getElementById('book');
		var rbDocObj = document.getElementById('rightBar');
		var textShortDocObj = document.getElementById('text-short');

		if(rbDocObj.offsetHeight > bookDocObj.offsetHeight + 200) //plus distance from top
		{ 
			if(rbDocObj.offsetHeight > 400)
			{
				//if the rightbar is pushing down the footer
				footerDocObj.style.top =  textShortDocObj.offsetHeight - 100 + 'px';
			}
			else
				footerDocObj.style.top =  textShortDocObj.offsetHeight - 100 + 'px';
			//alert('not books');
		}
		else
		{
			//if the books are pushing down the footer
			footerDocObj.style.top = bookDocObj.offsetHeight - 430 + 'px';
			//alert('books');
		}
	}	
}