// JavaScript Document
ReadyList.push(function() {
	var fixable = !($.browser.msie && parseInt($.browser.version) < 7);
	if (fixable) {
		var html = $("html").get(0);
		var foot = $("#footer").get(0);
		var cutoff = 0;
		var visibleAmt = 100;
		var hiddenAmt = (foot.clientHeight-visibleAmt);
		var unfixed = true;
		if (html.scrollHeight > html.clientHeight) {
			var fixFoot = function() {
				if ($.browser.webkit) {
					//avoid a bizare webkit bug
					//atomicnoggin.ca/test/WebkitFixedBug.html
					foot.className = '';
					window.setTimeout(function() {foot.className='fixed';},0);
				}
				else {
					foot.className = 'fixed';
				}
				unfixed = false;
			};
			var unfixFoot = function() {
				foot.className = 'sticky';
				unfixed = true;
			};
			var check = function() {
				var scrollTop = window.pageYOffset || html.scrollTop;
				if(scrollTop >= cutoff) {
					unfixFoot();
				}
				else if (unfixed) {
					fixFoot();
				}
				//foot.innerHTML = 'html.clientHeight = ' + html.clientHeight +
				//'; html.scrollHeight = ' + html.scrollHeight + '; cuttoff = ' + cutoff + '; scrollTop = ' + scrollTop;
			}
			var size = function() {
				//visibleAmt;
				hiddenAmt = (foot.clientHeight-100);
				cutoff = html.scrollHeight - (html.clientHeight+hiddenAmt);
				unfixed = true;
			}
			size();
			check();
			$(window).scroll(check).resize(size);
		}
	}
});

