if ( typeof(gs) == 'undefined' )
{
	var gs = {};
}
if ( typeof(gs.classs) == 'undefined' )
{
	gs.classs = {};
}
if ( typeof(gs.classs.Embedder) == 'undefined' )
{
	gs.classs.Embedder = function()
	{
		this.signalCheckInterval = 250;
		this.defaultHeight = 200;
		this.IFrameClass = 'gsEmbedder';
		this.className = 'Embedder';

		this.init = function(iframeId, baseIFrameLocation)
		{
			if ( window.location.protocol == 'file:' )
			{
				document.write('<p class="error">This content is only visible when loaded from a web server</p>');
				return true;
			}

			if ( baseIFrameLocation.indexOf('?') == -1 )
			{
				baseIFrameLocation += '?';
			}

			baseIFrameLocation += '&id=' + encodeURIComponent(iframeId);
			baseIFrameLocation += '&loc=' + encodeURIComponent('http://' + document.domain);

			var channelURL = false;
			var h = window.location.protocol + '//' + window.location.host;

			// find a url we can borrow for the channel
			var imgs = document.getElementsByTagName('img');
			for ( var i = 0; imgs[i]; i++ )
			{
				if ( imgs[i].src.indexOf('#') == -1 )
				{
					switch ( true )
					{
					case (imgs[i].src.substr(0, h.length) == h):

						channelURL = imgs[i].src;
						break;

					case (imgs[i].src.substr(0, '/'.length) == '/'):

						channelURL = h + imgs[i].src;
						break;

					case (imgs[i].src.indexOf('://') == -1):

						channelURL = h + window.location.pathname;
						var p = channelURL.lastIndexOf('/');
						if ( p != (channelURL.length - 1) )
						{
							channelURL = channelURL.substr(0, p + 1);
						}
						channelURL += imgs[i].src;
						break;
					}

					if ( channelURL )
					{
						break;
					}
				}
			}
			if ( channelURL )
			{
				baseIFrameLocation += '&chan=' + encodeURIComponent(channelURL);
			}

			baseIFrameLocation += '#';

			var prefix = '#' + iframeId + '_';
			var hash = '';
			var iframeLocation = baseIFrameLocation;
			if ( window.location.hash.substr(0, prefix.length) == prefix )
			{
				hash = window.location.hash.substr(prefix.length);
				iframeLocation += hash;
			}

			document.write('<iframe id="' + iframeId + '" name="' + iframeId + '" class="' + this.IFrameClass + '" src="' + iframeLocation + '" onload="this.baseIFrameLocation = \'' + baseIFrameLocation + '\'; this.lastHash=\'' + hash + '\'; window.gs.' + this.className + '.initIFrame(this, ' + window.frames.length + ');" width="100%" frameborder="0" marginheight="0" marginwidth="0" scrolling="hidden" height="' + this.defaultHeight + '" style="margin: 0; padding: 0; border: 0; visibility: hidden;" allowtransparency="true"></iframe>'); 

		};

		this.getNewIFrameId = function()
		{
			var baseId = 'gs';
			var n = '';
			while ( document.getElementById(baseId + n) )
			{
				if ( n == '' )
				{
					n = 1;

				} else
				{
					n++;
				}
			}

			return (baseId + n);
		};

		this.initIFrame = function(iframe, frameNum)
		{
			iframe.getWindow = function()
			{
				try
				{
					if ( typeof(iframe.contentWindow) != 'undefined' )
					{
						return iframe.contentWindow;
					}

					if ( typeof(window.frames[iframe.name]) != 'undefined' )
					{
						return window.frames[iframe.name];
					}

					if ( typeof(window.frames[frameNum]) != 'undefined' )
					{
						return window.frames[frameNum];
					}

				} catch ( e )
				{
					// window not ready
				}

				return false;
			};

			iframe.getGSAPIMiddle = function()
			{
				var w = iframe.getWindow();

				try
				{
					if ( w && (typeof(w.gsAPIMiddle) != 'undefined') )
					{
						return w.gsAPIMiddle;
					}

				} catch ( e )
				{
					// gsAPIMiddle not ready
				}

				return false;
			};

			iframe.getChannel = function()
			{
				var w = iframe.getWindow();

				try
				{
					if ( w && (w.frames.length == 2) && (typeof(w.frames['channel']) != 'undefined') && (('' + w.frames['channel'].location) != '') )
					{
						return w.frames['channel'];
					}

				} catch ( e )
				{
					// channel not ready
				}

				return false;
			};

			iframe.style.visibility = 'visible';
			this.checkForSignal(this, iframe);
		};

		this.checkForSignal = function(this2, iframe)
		{
			var prefix = '#' + iframe.id + '_';
			var foundHash = false;
			switch ( true )
			{
			case (window.location.hash == ''):

				var hash = '';
				foundHash = true;
				break;

			case (window.location.hash.substr(0, prefix.length) == prefix):

				var hash = window.location.hash.substr(prefix.length);
				foundHash = true;
				break;
			}
			if ( foundHash && ((typeof(iframe.lastHash) == 'undefined') || (iframe.lastHash != hash)) )
			{
				iframe.getWindow().location.replace(iframe.baseIFrameLocation + hash);
				iframe.lastHash = hash;
			}

			var channel = iframe.getChannel();
			if ( channel )
			{
				if (channel.location.hash.substring(0, prefix.length) == prefix) 
				{
					var hash = channel.location.hash;
					var signal = hash.substring(prefix.length);

					if ( signal != iframe.lastSignal )
					{
						iframe.lastSignal = signal;
						var scrollX = (document.documentElement && document.documentElement.scrollLeft)?document.documentElement.scrollLeft:(document.body.scrollLeft?document.body.scrollLeft:window.pageXOffset);
						var scrollY = (document.documentElement && document.documentElement.scrollTop)?document.documentElement.scrollTop:(document.body?document.body.scrollTop:window.pageYOffset);

						var property = signal.substring(0, signal.indexOf('_'));
						var value = signal.substring(property.length + 1);

						this2.handleSignal(iframe, property, value);

						window.scrollTo(scrollX, scrollY);
					}
				}
			}
			else if (w = iframe.getWindow())
			{
				try {
					if ( w.pageYOffset && (w.pageYOffset != iframe.lastSignal) )
					{
						iframe.lastSignal = w.pageYOffset;
						// workaround for opera, which doesnt allow reading the channel iframe location but does make the scroll offset available
						iframe.style.height = ((iframe.style.height ? parseInt(iframe.style.height) : parseInt(iframe.height)) + parseInt(iframe.getWindow().pageYOffset)) + 'px';
					}
					else
					{
						this.setFixedHeight();
					}
				} catch (e) {
					this.setFixedHeight(iframe);
				}
			}
			else
			{
				this.setFixedHeight(iframe);
			}
			

			window.clearTimeout(iframe.signalCheckTimer);
			iframe.signalCheckTimer = window.setTimeout(function(e) { this2.checkForSignal(this2, iframe); }, this2.signalCheckInterval); 
		};

		this.setFixedHeight = function(iframe)
		{
			// couldnt get channel nor set via workaround above - fall back to fixed height
			iframe.style.height = '500px';
			//iframe.scrolling = 'yes';
			//iframe.setAttribute('scrolling', 'yes');
			//for (var i = 0, n = iframe.attributes.length; i < n; ++i) {
			//	if (iframe.attributes[i].name == 'scrolling') {
			//		iframe.attributes[i].value = 'yes';
			//		break;
			//	}
			//}
		};

		this.handleSignal = function(iframe, property, value)
		{
			switch ( property )
			{
			case 'height':

				iframe.style.height = parseInt(value) + (document.all ? 50 : 75) + 'px';
				break;

			case 'history':

				window.location.hash = '#' + iframe.id + '_' + value;
				break;
			}
		};
	};
}
if ( typeof(gs.Embedder) == 'undefined' )
{
	gs.Embedder = new gs.classs.Embedder();
}
gs.Embedder.init(gs.Embedder.getNewIFrameId(), 'http://groupspaces.com/imperialentrepreneurs/embed/iniframe/middle?u=url%3Dhttp%253A%252F%252Fgroupspaces.com%252Fimperialentrepreneurs%252Fembed%252Fsubscribe');