/**************************************************************************
Peter Wright	03/06/2008		Start up manager	v2
**************************************************************************/
var Sum = {
	functions:[],
	flashes:[],
	gallerys:[],
	beforeafters:[],
	dir:"/includes/js/",
	sources:[],
	swfobject:'',
	init:function() {
		if(window.addEventListener) { window.addEventListener("load",this.exec,false) }
		else if(window.attachEvent) { window.attachEvent("onload",this.exec) }
		else {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);
		}
		this.init();
	},
	exec:function()	{
		for(var i=0;i<Sum.functions.length;  i++)
		{
			eval(Sum.functions[i]);
		}
		Sum.execFlashQue(Sum.swfobject);
	},
	add:function(func) {
		this.functions[this.functions.length]=func;
		this.init();
	},
	flash:function(obj) {
		this.flashes[this.flashes.length] = obj;
		//this.execFlashQue();
	},
	execFlashQue:function(swfobject) {
		if((typeof swfobject) == "object") {
			this.swfobject = swfobject;
		}
		for(var i=0;  i<this.flashes.length;  i++)
		{
			if((typeof this.flashes[i]) == "object" && (typeof this.swfobject) == "object")
			{
				obj = this.flashes[i];
				obj.flashvars = ((typeof obj.flashvars) != "object") ? 'null' : obj.flashvars;
                obj.params = ((typeof obj.params) != "object") ? 'null' : obj.params;
                obj.attr = ((typeof obj.attr) != "object") ? 'null' : obj.attr;
				switch(obj.func)
				{
					case 'registerObject' :this.swfobject.registerObject(obj.id, obj.version, obj.ei);
						break;
					case 'embedSWF' :this.swfobject.embedSWF(obj.file, obj.id, obj.width, obj.height, obj.version, obj.ei, obj.flashvars, obj.params, obj.attr);
						break;
				}
				this.flashes[i] = null;
			}
		}
	}
};
Sum.load();