// JavaScript Document

var footer, footerHeight, content, contentHeight, header, headerHeight, menu, menuHeight, originalContentHeight;



function snapToBottom(){
	if(document.getElementById('footerContainer')){
		footer = document.getElementById('footerContainer');
		footerHeight = footer.clientHeight;
	}
	
	if(document.getElementById('contentContainer')){
		content = document.getElementById('contentContainer');
		contentHeight = content.clientHeight;
	}
	
	if(document.getElementById('headerContainer')){
		header = document.getElementById('headerContainer');
		headerHeight = header.clientHeight;
	}
	
	if(document.getElementById('menuContainerContainer')){
		menuCont = document.getElementById('menuContainerContainer');
		menuHeight = menuCont.clientHeight;
	}
	
	winHeight = getWindowHeight();
	totalElemHeight = headerHeight+menuHeight+contentHeight+footerHeight;
	
	if(winHeight>totalElemHeight){
		footer.style.position = 'absolute';
		footer.style.bottom = '0px';
		newContentHeight = winHeight-(headerHeight+menuHeight+footerHeight);
		content.style.height = newContentHeight.toString()+'px';
	}else{
		footer.style.position = 'relative';
	}
	
}

function getWindowHeight()
{
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		h = window.innerHeight;
	}
	return h;
}

