/* http://kesto.org/app/kesto.js      Kesto Frontend Logic
   Copyright (c) 2005-2006 Johannes Vockeroth

 This software is provided as-is, without express or implied warranty.
 Permission to use, copy, modify, distribute or sell this software, with or
 without fee, for any purpose and by any individual or organization, is hereby
 granted, provided that the above copyright notice and this paragraph appear
 in all copies. Distribution as a part of an application or binary must
 include the above copyright notice in the documentation and/or other materials
 provided with the application or distribution.
*/

// globals
var language = new Array(); // used for initial translation and translations by locallang()
var myCrossDomainJSResponse = new Array(); // used by loadCrossDomainJS() - has to appear in localization files
var myCachedForms = new Array(); // used by loadCachedForms() -- dropped by clear cache button
var UIXHTMLContent = null; // UI XHTML Content - will be overwritten by kesto.xhtml and contains the XHTML-base for the UI
document.language = null; // User Interface Language (ISO code)
if (!applicationPath) var applicationPath = document.getElementsByTagName('script')[0].src.substring(0,
	document.getElementsByTagName('script')[0].src.indexOf('kesto.js')); // home URI of Kesto application, default: http://kesto.org/app/

if (!adapterURI) var adapterURI = applicationPath + 'adapter.php';

// Load default additional components
function addScript(filename) {
         headNode = document.getElementsByTagName('head')[0];
         headNode.appendChild(document.createElement('script'));
         headNode.lastChild.setAttribute('type','text/javascript');
         headNode.lastChild.setAttribute('charset','UTF-8');
         headNode.lastChild.setAttribute('src',applicationPath + filename);
}

addScript('prototype.js');		// Prototype API library (for $() and AJAX)
addScript('rijndael.js');		// Rijndael AES encryption library
addScript('tools.js');           	// helper functions
addScript('secureio.js');		// password file encryption, decryption, load/save
addScript('i18n/en.kesto.js');     	// default english localization
addScript('interface.xhtml.php');  	// UI XHTML Content - basic interface structure
addScript('interface.js');		// user interface behaviour

// The rest of Initialization will be done, if document and default components are loaded.
loadUserInterface = function() { loginSafeUI = new UserInterface('kestoBox', UIXHTMLContent); }
if (window.addEventListener) window.addEventListener('load', loadUserInterface, false);
	else if (window.attachEvent) window.attachEvent('onload', loadUserInterface);