/*
 * Mittels der try/catch Konstruktion wird sichergestellt, das der Code im
 * Catch-Block nur einmal ausgeführt wird.
 */
try {
	if (DEFINE_CND_COMPANY != true) {
		throw new Exception();
	}
} catch(exc) {
	DEFINE_CND_COMPANY=true;
//--- Quellcode hier rein

//--- Including von weiteren JavaScript-Dateien---------------------------------

CndCompany = function() {
}

/*
 * Pfad zu den Framework JS-Dateien
 */
CndCompany.scriptPath='n.a.';
var scripts = document.getElementsByTagName("script");
for (var i=scripts.length-1; i>=0; i--) {
	if (scripts[i].src.match(/CndCompany.js$/)) {
		CndCompany.scriptPath = scripts[i].src.replace(/CndCompany.js$/, '');
		break;
	}
}

/**
 * Base 64 'Datensatz' anlegen
 */
b64s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
b64 = [];f64 =[];
for (var i=0; i<b64s.length ;i++) {
	b64[i] = b64s.charAt(i);
	f64[b64s.charAt(i)] = i;
}
CndCompany.b64 = b64;
CndCompany.f64 = f64;

/*
 * Array mit bereits eingebundenen Dateien (Pfadangabe);
 */
CndCompany.included=new Array();

/*
 * Methode bindet übergebene JavaScript-Datei ein.
 * @param String path  Pfad zur JS-Datei
 */
CndCompany.include = function(path) {
	CndCompany.included[path]=path;
	document.writeln('<' + 'script src="' +path+ '" type="text/javascript" language="javascript"' + '><' + '\/script>');
}

/*
 * Methode bindet übergebene JavaScript-Datei ein. Wiederholtes Einbinden wird 
 * unterbunden.
 * @param String path  Pfad zur JS-Datei
 */
CndCompany.include_once = function(path) {
	try {
		if (CndCompany.included[path] != path) {
			CndCompany.include(path);
		}
	} catch(exc) {
		CndCompany.include(path);
	}
}

/*
 * Methode legt eine Maske über die Seite, bis diese komplett geladen ist.
 * @param String Nachricht
 */
CndCompany.onLoadProtect=null;
CndCompany.protectSiteOnLoad = function(message) {
	var scripts = document.getElementsByTagName("script");
	var base = null;
	for (var i=scripts.length-1; i>=0; i--) {
		if (scripts[i].src.match(/CndCompany.js$/)) {
			base = scripts[i].src.replace(/CndCompany.js$/, '');
			break;
		}
	}

	try {
		/*
		* Tricky - aber absolut genial ;-)
		* wenn die oben geladenen Bibliotheken noch nicht geparst sind,
		* den eigenen Methodenaufruf noch mal in den HTML-Quelltext schreiben
		* und Methode (vorerst) verlassen.
		* So werden die Bibliotheken geparst und stehen beim 2. Aufruf dieser
		* Methode zur Verfügung
		*/
		if (Dialog) {
			CndCompany.onLoadProtect = Dialog.info(message, {width:250, height:100, showProgress: true, className: "alphacube"}); 
			
			if (window.onload) {
				var onload = '' + window.onload;
				onload = onload.replace(/\}$/, 'CndCompany.onLoadProtect.close();CndCompany.onLoadProtect.destroy();delete CndCompany.onLoadProtect;}');
				eval('window.onload='+onload);
			} else {
				window.onload=function(){CndCompany.onLoadProtect.close();CndCompany.onLoadProtect=null;};
			}
		} else {
			throw new Exception();
		}
	} catch (ex) {
		CndCompany.include_once(base + 'prototype/prototype.js');
		CndCompany.include_once(base + 'xilinus/window.js');
		CndCompany.include_once(base + 'scriptaculous/scriptaculous.js');
		document.write('\n<script type="text/javascript" language="javascript" >CndCompany.protectSiteOnLoad("' + message + '")</script>');
	}

}

}//--- Schließende Klammer vom try/catch ---------------------------------------

