/**************************************************************************
	Peter Wright		03/06/2008
	Start up manager	v2
 **************************************************************************/
 //	Add Functions to array
	var Sum = {
		functions:[],
		flashes:[],
        dir:"scripts/",
		sources:[
            {language:'JavaScript', type:'text/javascript', src:'swfobject.js'}
		],
		init:function() {
			window.onload = this.exec;
		},
		load:function() {
			head = document.getElementsByTagName("head");
			for(i in this.sources) {
				var script 		= document.createElement('script');
				script.language	= this.sources[i].language;
		        script.type		= this.sources[i].type;
		        script.src		= this.dir + this.sources[i].src;
				head[0].appendChild(script);
			}
		},
		exec:function() {
			//	'this' will be the object that called exec, eg. window and not Sum
			//	therefore we must specify 'Sum' and not 'this' when referencing
			//	local variables
			for(var i=0; i<Sum.functions.length; i++) {
				eval(Sum.functions[i]);
			}
		},
		add:function(func) {
			this.functions[this.functions.length]=func;
			//	Running init here means that we don't need to
			//	run it manually, and also means it only runs if
			//	items have been added to it
			this.init();
		},
		flash:function(obj) {
			this.flashes[this.flashes.length] = obj;
		},
		execFlashQue:function(swfobject) {
			for(var i=0; i<this.flashes.length; i++) {
				obj = this.flashes[i];
				switch(obj.func) {
					case 'registerObject' :
						swfobject.registerObject(obj.id, obj.version, obj.ei);
						break;
					case 'embedSWF' :
						flashvars = obj.flashvars ? obj.flashvars : null;
                        params = obj.params ? obj.params : null;
                        attrs = obj.attrs ? obj.attrs : null;
						swfobject.embedSWF(obj.file, obj.id, obj.width, obj.height, obj.version, obj.ei, flashvars, params, attrs);
						break;
				}
				alert(obj.file + "Should have been loaded");
			}
		}
	}
	//	Load external scripts
	Sum.load();
