/*
 * File			: Main document loader/init file.
 * 				  The only global is the namespace
 */
$(document).ready(function(){
	
	// Check namespace
	if (window['_tfo']) {
        alert('ERROR namespace is already initialised.');
        return false;
    }
	
	// Build our namespace
	window._tfo = {};
    
	// Constants
	_tfo.c = {
		"DEBUG"		: true
	}
	
	_tfo.log = function(v_msg){
		if (console && this.c.DEBUG){
			console.log(v_msg);
		}
	} // _log()
	
	// Externalise links
	$('a.popup, a[data-external="true"]').attr('target', '_blank');
	
});

//////////////////////////////////////////////////////////////////////////////////
//Scope bind function - allows binding of external objects as "this" in functions
//We use this to fix the "bug" in javascript that doesnt assign the class to "this"
//for private functions, and also for overriding "this" in event handlers.
if (!Function.prototype.bind) {
	Function.prototype.bind = function (obj) {
		var method = this, temp = function () {
			return method.apply(obj, arguments);
		};
		return temp;
	}
}
