/* author:	Richard Schmid, infolox GmbH, http://www.infolox.de */

var stl_location = gsRelPath+"IQ3/jss/STL/";
document.writeln("<scr"+"ipt src='"+stl_location+"STL.js'></scr"+"ipt>");

LoadIQ3 = function(){
	var sRel = gsRelPath + "IQ3/jss/";
	//STL.load(sRel+"prototype.js");
	STL.load(sRel+"Config.js");
	STL.load(sRel+"DataCont.js");
	STL.load(sRel+"GUICont.js");
	STL.load(sRel+"InputFormCont.js");
	STL.load(sRel+"SuggLogic.js");
	STL.load(sRel+"CardsSelectLogic.js");
	STL.load(sRel+"Calculator.js");
	STL.load(sRel+"InputSolutionFinder.js");
	
	var all_are_loaded = function(){
		var objects = ["Config", "DataCont", "GUICont", "InputFormCont", "SuggLogic", "CardsSelectLogic", "Calculator"];
		for( var i=0; i < objects.length; i++ ){
			eval( "var type_of_obj = typeof "+objects[i] );
			if( type_of_obj == "undefined" ){
				return false;
			}
		}
		return true;
	};
	
	var on_all_loaded = function(){
		GUICont.inst().load();
		Calculator.inst();
	};
	
	var wait_load = function(){
		var time_out = window.setTimeout(
			function(){
				window.clearTimeout( time_out );
				if( all_are_loaded() ){
					on_all_loaded();
				} else {
					wait_load();
				}
			}, 100
		);
	};
	
	if( all_are_loaded() ){
		on_all_loaded();
	} else {
		wait_load();
	}
};

