/* Filename: globals.js
 * This file is part of the gRaDF Semantic Web browsing tool.
 * Copyright (C) 2006  Marcus Cobden
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 * (or see the file gpl.txt)
 * 
 * 	Description:
 * This file creates and sets global variables and effectively bootstraps the entire system into working.
 * 
 *	Classes:
 * none
 * 
 * 	Version information:
 * $HeadURL: svn+ssh://mc1204@svn.ugforge.ecs.soton.ac.uk/projects/grdf/code/branches/serverside/js/globals.js $
 * $Date: 2007-06-30 00:07:34 -0700 (Sat, 30 Jun 2007) $
 * $Author: mc1204 $
 * $Rev: 139 $
 */
var init = function()
{
	// Debug setup
	window.gLOG = function(message, section)	{ if(window.MenuHandler != null) MenuHandler.debugMenu.gLOG(message, section);};
	window.gWARN = function(message, section)	{ if(window.MenuHandler != null) MenuHandler.debugMenu.gWARN(message, section);};
	window.gERROR = function(message, section)	{ if(window.MenuHandler != null) MenuHandler.debugMenu.gERROR(message, section);};
	
	// Graphing setup
	var graphID = 'svgCanvas';
	window.gOptions = new GOptions();
	window.gPlotter = new GPlotter(graphID, gOptions);
	
	// Knowlege base
	window.kBase = new KBase();
	
	// Document Manager
	window.dMngr = new DMngr(kBase);
	
	// Graph User Interface
	window.nodeView = new NodeView(kBase, dMngr);
	window.URIMngr = new URIMngr(graphID, gOptions, kBase, dMngr);

	// Menu handling setup
	window.MenuHandler = new MenuMngr();

	/* END SETUP */
	
	/*window.setTimeout(function(){
		MenuHandler.uriMenu.add('http://id.ecs.soton.ac.uk/UoS');
		MenuHandler.docMenu.loadDocument('http://id.ecs.soton.ac.uk/UoS');
		MenuHandler.uriMenu.add('http://id.ecs.soton.ac.uk/UoS/ECS');
		MenuHandler.docMenu.loadDocument('http://id.ecs.soton.ac.uk/UoS/ECS');
	},1000);*/

};

	// Safari/WebKit
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            init(); // call the onload handler
        }
    }, 10);
} else {
	// Everything else.
	if (document.addEventListener) {
	    document.addEventListener("DOMContentLoaded", init, false);
	}
}