if (typeof GS == 'undefined') GS={};
if (typeof GS.EmbedWidget == 'undefined') GS.EmbedWidget={
	guid:1,
	transport:{},
	bootstrap:function(){
		var head = document.getElementsByTagName('head')[0] || document.documentElement,
			script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = 'http://media.groupspaces.com/js/easyXDM/easyXDM.min.js';
		head.insertBefore(script, head.firstChild);
		//if (typeof console == 'undefined') window.console = {log:function(){}};
		//console.log('BOOTSTRAP COMPLETE');
		GS.EmbedWidget.bootstrap = function(){};
	},
	create: function(remote_url){
		var id='gs_embed_widget_'+(GS.EmbedWidget.guid++);
		//console.log('Creating new element here with ID '+id);
		document.write('<div id="'+id+'"></div>');
		GS.EmbedWidget.requireXDM(function() {
			GS.EmbedWidget.transport[id] = new easyXDM.Socket({
				remote: remote_url,
				container: id,
				props: {width: '100%', 'allowTransparency': 'allowTransparency', 'scrolling': 'no'},
				onMessage: function(m,o) {
					this.container.getElementsByTagName('iframe')[0].style.height = m + 'px';
				}
			});
		});
		return id;
	},
	requireXDM: function(f) {
		if (typeof easyXDM != 'undefined') {
			//console.log('EasyXDM initialised');
			f(); return;
		}
		window.setTimeout(function(){GS.EmbedWidget.requireXDM(f);}, 10);
	}
};

if (window.addEventListener) {
	window.addEventListener('load', GS.EmbedWidget.bootstrap, false);
} else if (window.attachEvent) {
	window.attachEvent('onload', GS.EmbedWidget.bootstrap);
} else {
	var oldf = window.onload;
	window.onload = function() { GS.EmbedWidget.bootstrap(); if (oldf) oldf(); };
}

var wid_id=GS.EmbedWidget.create('http://groupspaces.com/LondonStudentAssembly/embed/container?e=subscribe');

