// $Id: default.js 16 2007-09-25 16:37:30Z hweber $

function replaceFooter () {
	// Höhe der einzelnen Elemente ermitteln
	var headHeight		= document.getElementById('head').offsetHeight;
	var boxHeight		= document.getElementById('box').offsetHeight;
	var nav2Height		= document.getElementById('nav2').offsetHeight;
	var contentHeight	= document.getElementById('content').offsetHeight;
	var infoHeight		= document.getElementById('info').offsetHeight;

	// Für den Inhalt verfügbare Höhe ermitteln
	var availableHeight	= boxHeight - headHeight;

	// Für den Inhalt benötigte Höhe ermitteln
	var needHeight		= ( nav2Height > contentHeight )	? nav2Height	: contentHeight;
	needHeight			= ( needHeight > infoHeight )		? needHeight	: infoHeight;

	// Wenn die benötigte Höhe nicht vorhanden, diese anpassen
	if ( needHeight > availableHeight) {
		document.getElementById('box').style.height = needHeight + headHeight + 5 + 'px';
	}
}

/**
 * ready.js
 *
 * Author: Torben Brodt <[email]t.brodt@gmail.com[/email]>
 * Summary: Cross-browser wrapper for DOMContentLoaded
 * Updated: 07/09/2009
 * License: MIT / GPL
 * Version: 1.1
 *
 * URL:
 * [url]http://www.easy-coding.de[/url]
 * [url]http://jquery.com/dev/svn/trunk/jquery/MIT-LICENSE.txt[/url]
 * [url]http://jquery.com/dev/svn/trunk/jquery/GPL-LICENSE.txt[/url]
 *
 * Full Description:
 * A page has loaded after all external resources like images have been loaded.
 * Should all scripts wait for that? a better bevaviour is to wait for the dom content being ready.
 *
 * This script has workarounds for all the big browsers meaning the major versions of firefox, internet explorer, opera, safari and chrome.
 * You can use it without risk, since the normal "onload" behavior is the fallback solution.
 *
 * Most of the source is lended from jquery
 */
var ready = new (function () {
	var readyBound = 0, d = document, w = window, t = this, x;
	t.isReady = 0;
	t.readyList = [];
 
	function bindReady() {
		if ( readyBound ) return;
		readyBound = 1;
 
		// Mozilla, Opera and webkit nightlies currently support this event
		if ( d.addEventListener ) {
			// Use the handy event callback
			x = "DOMContentLoaded";
			d.addEventListener( x, function(){
				d.removeEventListener( x, arguments.callee, false );
				ready.ready();
			}, false );
 
		// If IE event model is used
		} else if ( d.attachEvent ) {
			// ensure firing before onload,
			// maybe late but safe also for iframes
			x = "onreadystatechange";
			d.attachEvent(x, function(){
				if ( d.readyState === "complete" ) {
					d.detachEvent( x, arguments.callee );
					ready.ready();
				}
			});
 
			// If IE and not an iframe
			// continually check to see if the document is ready
			if ( d.documentElement.doScroll && w == w.top ) (function(){
				if ( t.isReady ) return;
 
				try {
					// If IE is used, use the trick by Diego Perini
					// [url]http://javascript.nwbox.com/IEContentLoaded/[/url]
					d.documentElement.doScroll("left");
				} catch( error ) {
					setTimeout( arguments.callee, 0 );
					return;
				}
 
				// and execute any waiting functions
				ready.ready();
			})();
		}
 
		// A fallback to window.onload, that will always work
		w.onload = ready.ready; // TODO: compliant? t.event.add( window, "load", t.ready );
	};
 
	// Handle when the DOM is ready
	t.ready = function() {
		// Make sure that the DOM is not already loaded
		if ( !t.isReady ) {
			// Remember that the DOM is ready
			t.isReady = 1;
 
			// If there are functions bound, to execute
			if ( t.readyList ) {
				// Execute all of them
				for(var i=0; i<t.readyList.length; i++) {
					t.readyList[i].call( w, t );
				};
 
				// Reset the list of functions
				t.readyList = null;
			}
 
			// Trigger any bound ready events
			d.loaded = true; // TODO: compliant? this(document).triggerHandler("ready");
		}
	};
 
	// adds funtion to readyList if not ready yet, otherwise call immediately
	t.push = function(fn) {
		// Attach the listeners
		bindReady();
 
		// If the DOM is already ready
		if ( t.isReady )
			// Execute the function immediately
			fn.call( w, t );
 
		// Otherwise, remember the function for later
		else
			// Add the function to the wait list
			t.readyList.push( fn );
 
		return t;
	};
})();

// Funktionen Starten, nachdem das DOM geladen wurde
// (ist vor dem onload-Eregnis der Browser )
ready.push(function() {
	replaceFooter();	// Fußzeile neu platzieren
	searchHighlight();	// Suchergebnisse hervorheben
});