connect(window, 'onDOMload', 
	function(){

		// Set a slight delay for this to give the cookie a chance to be updated
		// in the browser if it's being set by the response that returns this page.
		window.setTimeout(function() {
			var login_cookie = getUserIdFromCookie (true);
	
			if (login_cookie) {
				// Get a list of trusted domains that we want to share our login details with.
				var req = doJSONRequest('/vortexuser_get_trusted_domains', {});
				req.addBoth(function (partners) {
					
					if (!partners) return;
					
					// Fetch our login cookie and send it off to the trusted domains so we're
					// pre-logged in there.
					var req;
					var domain;
					var img;
					
					for (var i=0; i<partners.length; i++) {
						domain = partners[i];	
						img = new Image();
						img.src = 'http://' + domain + '/vortexuser_login?VortexLogin=' + login_cookie;
					}
				});
			}
		}, 500);		
	}
);