<?xml version="1.0" encoding="UTF-8" ?>
<Module>
	<ModulePrefs
		title="National Geographic POD"
		title_url="http://lava.nationalgeographic.com/pod/"
		directory_title="National Geographic Photo of the Day"
		description="National Geographic Photo of the Day. More detailed documentation at http://wiki.drbeagle.com/national-geographic-photo-of-the-day-gadget"
		author="Cameron Hall"
		author_email="drbeagledotcom+modulefeedback@gmail.com"
		screenshot="http://drbeagledotcom.googlepages.com/ngpod.png"
		thumbnail="http://drbeagledotcom.googlepages.com/ngpodtb.png"
		>
		<Require feature="dynamic-height" />
		<Require feature="analytics" />
	</ModulePrefs>
	<UserPref name="FSZ" 
		display_name="Font Size" 
		datatype="string" 
		default_value="8" 
		required="true" />
	<UserPref name="MXH" 
		display_name="Max Height" 
		datatype="string" 
		default_value="300" 
		required="true" />
	<Content type="html">
		<![CDATA[
<div
	id="NatGeoPOD"
	style="
		margin: 0px auto;
		text-align: center;
	">
</div>
<p
	id="theWidth"
	style="
		font-size: 8px;
		font-weight: bold;
		margin: 0 auto;
		text-align: center;
	">
</p>
	<script type="text/javascript">
		var pod = "http://photography.nationalgeographic.com/photography/photo-of-the-day";
		var base = "http://photography.nationalgeographic.com";
		var html = "";
		var htmlp = "";
		var maxHeight = 0;
		
		function getPOD(maxH, fontSize) {
			maxHeight = maxH;
			_gel('theWidth').style.fontSize = fontSize;
			htmlp += '<a href="'+pod+'archive/" style="font-size: '+fontSize * .75+'; font-weight: normal;" ';
			htmlp += ' text-decoration: none; target="_blank">POD Archive</a> - ';
			_IG_FetchContent(pod, function (responseText) {
				if (responseText == "") {
					html += '<a href="'+pod+'" target="_blank">';
					html += '<img id="ngpodimg" src="http://drbeagledotcom.googlepages.com/ngpoderror.png" onload="reSize();" border="0"></a><br />';
					htmlp += 'Gadget Error, check back later'
					_gel('NatGeoPOD').innerHTML = html;
					return;
				} else {
					var c = responseText;
					RegExp.multiline = true;
					///staticfiles/NGS/NGKids/Media/Image/Photo/two-wolves-play-fight-513237-ga.jpg : 20081016
					var regExp = /\/staticfiles\/NGS\/Shared\/StaticFiles\/Photography\/Images\/POD\/[a-zA-Z]+\/[a-zA-Z0-9._%\-]+\.jpg/;
					var imgA = regExp.exec(c);
					var imgL = base+imgA[0];
					html += '<a href="'+pod+'" target="_blank">';
					html += '<img id="ngpodimg" src="'+imgL+'" onload="reSize();" border="0"></a><br />';
					_gel('NatGeoPOD').innerHTML = html;
					RegExp.multiline = true;
					var regExpb = /<div class="summary">[\n\s]+<h3>[a-zA-Z0-9._%\-,\s]+<\/h3>/;
					var info = regExpb.exec(responseText);
					var end = info[0].length - 5;
					htmlp += info[0].substring(26, end);
				}
			});
		}
		function reSize(){
				var x = _gel('ngpodimg');
	      var p = _gel('theWidth');
				var maxWidth = p.offsetWidth;
				var pWidth = maxWidth/x.width;
				var pHeight = maxHeight/x.height;
				var w = 10;
				var h = 10;
				if(pWidth <= pHeight){
					var w = parseInt(x.width * pWidth);
					var h = parseInt(x.height * pWidth);
				}else{
					var w = parseInt(x.width * pHeight);
					var h = parseInt(x.height * pHeight);
				}
				x.width = w;
				x.height = h;
				_gel('theWidth').innerHTML = htmlp;
				_IG_AdjustIFrameHeight();
		}
		
		_IG_RegisterOnloadHandler(getPOD("__UP_MXH__", "__UP_FSZ__"));
		_IG_Analytics("UA-1238140-1", "/ngpod");
		_IG_AdjustIFrameHeight();
	</script>
		]]>
	</Content>
</Module>