/**
 * @fileOverview Initialisation of the global KfW object
 * @version 0.1
 * @author Michael Schieben <michael@twoantennas.com>
 *
 * Rules for Javascript inclusion on the website
 * In header:
 * 1. kfw.js
 * In footer:
 * 1. jQuery
 * 2. 3rd-party jQuery Plugins
 * 3. Custom jQuery Plugins
 * 4. kfw.global.js
 * 5. kfw.*.js
 */

/*jslint browser: true, plusplus: false, undef: true */
/*global window: true, KfW: true, jQuery: true */

/**
 * See (http://jquery.com/).
 * @name jQuery
 * @class 
 * See the jQuery Library (http://jquery.com/) for full details.
 */

/**
 * Shortcut for window.console.log in Debug mode
 */
function pr(s) {
	if (window.console && window.console.log && KfW.DEBUG) {
		window.console.log(s);
	}
}

/**
 * KfW
 * @name KfW
 * Holds all functions for KfW website
 */
var KfW = {};
KfW.DEBUG = true;

KfW.Settings = {};

/**
 * Initializers are functions that are called on domready under
 * certain conditions. Use addInitializers to add functions to
 * the stack. Use Initializers to decrease bindings to
 * jQuerys build in domready event.
 *
 * @param f function to be called on domready
 * @param conditionOrSection undefined | function | boolean | String | Array
 * 0) if conditionOrSection is undefined f is called
 * 1) if conditionOrSection is of type function, this function
 * is evaluated on document.ready event und must return true or false
 * 2) if conditionOrSection is of type boolean and true function f
 * is called on document.ready, passing false makes no sense at all
 * 3) if conditionOrSection is of type String the function f is
 * called when <body> has the classname conditionOrSection. 
 * 4) if conditionOrSection is of type Array the function f is
 * called when <body> has one of the classnames given in
 * conditionOrSection.
 * @see KfW.initizalize()
 * @see KfW.isSection()
 */

KfW.Initializers = [];

KfW.addInitializer = function (f, conditionOrSection) {
	if (conditionOrSection === undefined) {
		conditionOrSection = true;
	}
	if (typeof conditionOrSection === "function" || typeof conditionOrSection === "boolean") {
		KfW.Initializers.push([f, conditionOrSection]);
	} else {
		KfW.Initializers.push([f, function () { 
			return KfW.isSection(conditionOrSection);
		}]);
	}
};
