function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function bodyHeight() {
	if (self.innerHeight) {
		return self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else if (document.body) {
		return document.body.clientHeight;
	}
}


function fix_footer() {
  var footer = document.getElementById("footer");
  if(!footer)
    footer = document.createElement("div");
  var body = document.getElementById("body");
  var wrapper = document.getElementById("wrapper");
  footer.id = 'footer';
  footer.innerHTML = '<a href="/impressum">Impressum</a> |  &copy; 2008 red cursor';
  body.appendChild(footer);
  // alert(body.offsetHeight +"<"+ bodyHeight());
  if(body.offsetHeight >= bodyHeight() - 100) {
    footer.style.position = 'relative';
    footer.style.bottom   = '0';
  } else {
    footer.style.position = 'absolute';
    footer.style.bottom   = '0';
  }
}

function register_resize_event() {
  window.onresize = function() {
    fix_footer();
  };
}

//  || (body.offsetHeight+100 < bodyHeight())
