// Make sure you have the following entries in the css
// html{height:100%}; 



// This Function returns the Height in px of the Whole Browser Window.
function GetBrowserWindowHeight() {
	 myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myHeight = document.body.clientHeight;
	  }
	  return myHeight;
}
 
// This Function returns the Height in px of the Whole Inner Browser Window, 
// the One which is 'inside' with Scroller if bigger then the normal Window.
function GetBrowserScrollWindowHeight() { 
	var BrowserScrollWindowHeight=0;
	BrowserScrollWindowHeight=document.body.scrollHeight;
	//alert(document.body.scrollHeight);
	return BrowserScrollWindowHeight;
}
 
// this function returns the coordinates of selected Element
function GetElementCoordinantes(element) {
	var ElementCoordinantes = null;
	ElementCoordinantes = element.getCoordinates;
	return ElementCoordinantes;
}
 
function setFooter() {	
	var windowHeight = GetBrowserWindowHeight(); // gets browser window height
	var windowScrollHeight = GetBrowserScrollWindowHeight(); // gets browser inner window height
	//alert(windowScrollHeight + "<=" + windowHeight);
	if (windowScrollHeight<=windowHeight)	{ // this checks if our browser window is the same as browser inner window
		var bodyElement = $$('body')[0];
		bodyElement.setStyle('height', '100%')
		$('footer').setStyle('position', 'absolute'); // if so it sets the position to absolute
		$('footer').setStyle('bottom', '0');
		$('footer').setStyle('left', '0');
		$('page').setStyle('height', '100%');
	}
	if (windowScrollHeight>windowHeight) { 	
		// if the content is longer then the actual broswser window 
		$('footer').setStyle('position', 'relative');           // we set the footer Position to relative and animate it to bottom 0 from actual position
	}
}




// this fires the event after the Page is loaded
window.addEvent('load', function() {
	setFooter();
});

