function wwfEarthHourLightsOff_GetPageHeight(){
	
	var yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
	}
	
	var windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}	
	
	return Math.max(windowHeight, yScroll);
}

function wwfEarthHourLightsOff_DoFSCommand(command, args) {
	var setStyle = function(elem, style) {
		for (prop in style) elem.style[prop] = style[prop];
	}
	if (command == 'lightbox') {
		var overlay = document.createElement("div");
		document.body.appendChild(overlay);
		setStyle(overlay, {
			position: 'absolute', top: 0, left: 0, zIndex: 900, width: '100%',
			height: wwfEarthHourLightsOff_GetPageHeight() + 'px',
			backgroundColor: '#000000',	opacity: '0.8', filter: ' alpha(opacity=80)'
		});
		
		var lightboxPosition = document.createElement("div");
		document.body.appendChild(lightboxPosition);
		setStyle(lightboxPosition, {
			position: 'absolute', top: '88px', zIndex: 910, width: '100%'
		});
		lightboxPosition.align = 'center';
		
		var lightbox = document.createElement("div");
		lightboxPosition.appendChild(lightbox);
		setStyle(lightbox, {
			width: '592px', height: '480px', margin: 'auto',
			backgroundColor: '#000000', position: 'relative'
		})
		lightbox.onclick = function(e) {
			if (!e) var e = window.event;
			e.cancelBubble = true;
			if (e.stopPropagation) e.stopPropagation();
		}
		
		var closeButton = document.createElement('img');
		closeButton.src = 'http://static.wwf.org.uk/earthhour/earthhour_close.gif';
		closeButton.width = 25;
		closeButton.height = 25;
		setStyle(closeButton, {
			position: 'absolute', top: '-12px', right: '-12px', cursor: 'pointer'
		});
		lightbox.appendChild(closeButton);
		closeButton.onclick = function() {
			document.body.removeChild(overlay);
			document.body.removeChild(lightboxPosition);
		}

		var iframe = document.createElement('iframe');
		iframe.src = 'http://static.wwf.org.uk/earthhour/earthhour.html?utm_source=sites&utm_medium=switchclick&utm_campaign=ls';
		iframe.width = 592;
		iframe.height = 480;
		iframe.style.border = '0px';
		iframe.border = 0;
		iframe.frameBorder = 0;

		lightbox.appendChild(iframe);

		overlay.onclick = function() {
			document.body.removeChild(overlay);
			document.body.removeChild(lightboxPosition);
		}

		lightboxPosition.onclick = function() {
			document.body.removeChild(overlay);
			document.body.removeChild(lightboxPosition);
		}
	}
};
document.write('<div style="position: absolute; top: 0px; right: 0px; z-index:899; padding:0; margin:0; border: none;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="120" height="100" id="wwfEarthHourLightsOff" align="middle"><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent"><param name="allowFullScreen" value="false" /><param name="movie" value="http://static.wwf.org.uk/earthhour/earthhour.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="http://static.wwf.org.uk/earthhour/earthhour.swf" quality="high" bgcolor="#ffffff" width="120" height="100" name="wwfEarthHourLightsOff" swLiveConnect="true" wmode="transparent" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /></object></div>');

