<?xml version="1.0" encoding="UTF-8"?>
<Module>
	<ModulePrefs title="Domain Geographic Location"
		directory_title="Domain Geographic Location"
		title_url="http://www.codazzle.com"
		description="Displays Geographic Location (Geolocation) of a Domain or IP Address on Google Maps"
		author="Amit Chauhan"
		author_affiliation="Codazzle, Inc."
		author_email="codazzle.feedback+domainlocation@gmail.com"
		author_location="Fremont, CA"
		author_link="http://www.codazzle.com"
		screenshot="http://www.codazzle.com/domloc/images/screenshot.png"
		thumbnail="http://www.codazzle.com/domloc/images/thumbnail.png"
		height="50" >
		<Require feature="dynamic-height"/>
	</ModulePrefs>
	<Content type="html"><![CDATA[
	<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAP2_dbvYvFKAzXF68PnUCIhSosDVG8KKPE1-m51RBrvYughuyMxS6O122mDIM4ZpdX2HJliLGoemkgg"
	type="text/javascript"></script>
	<style>
		body
		{
			font-family: Tahoma, Arial, Helvetica, Times New Roman;
			font-weight:normal;
			font-size:12px;
		}
		.domain_prompt
		{
			display:inline;
			font-size:12px;
		}
		.bold
		{
			font-weight:bold;
		}
		input
		{
			border: 1px solid #DF0009;
			font-family: Tahoma, Arial, Helvetica, Times New Roman;
			font-size:12px;
		}
		input:hover
		{
			background: #FFFCDF;
		}
		.button
		{
			color: #000;
			border: 1px solid #006;
			background: #DFEEFF;
			background: #FFD77F;
			font-family: Tahoma, Arial, Helvetica, Times New Roman;
			font-weight:bold;
			font-size:12px;
		}
		.button:hover
		{
			border: 1px solid #006;
			background: #9FCBFF;
			background: #FD8A00;
		}
		#msg
		{
			font-weight:bold;
			display:none;
			visibility:hidden;
		}
		#input_wrapper
		{
			margin-top: 3px;
			padding: 3px;
			display:block;
			background: #EFFEFF;
			border: 1px solid #005FCF;
			width: 98%;
		}
		#map_wrapper
		{
			margin-top: 3px;
			padding: 3px;
			visibility:hidden;
			display:none;
			background: #EFFEFF;
			border: 1px solid #005FCF;
			height: 250px;
			width: 98%;
		}
		#map_details
		{
			position: absolute;
			visibility:visible;
			display:none;
			height: 250px;
			width: 0%;
			border: 1px solid #005FCF;
		}
		#map_canvas
		{
			position: relative;
			float:right;
			visibility:hidden;
			display:none;
			height: 250px;
			width: 100%;
			border: 1px solid #005FCF;
		}
	</style>
	<form name="form1" id="form1" onSubmit="getLocation (); return false;">
		<div id="input_wrapper">
			<div class="bold">Enter domain name or ip address to display server location on the map.</div>
			<div class="domain_prompt">http://</div>
			<input type="text" value="" name="domainName" id="domainName" size="30" />
			<input type="button" class="button" name="submitButton" value="Go" onClick="getLocation ();"/>
		</div>
		<div id="msg"></div>
		<div id="map_wrapper">
			<div id="map_details">test</div>
			<div id="map_canvas"></div>
		</div>
	</form>
	<br/>
	<script type="text/javascript">
		_IG_AdjustIFrameHeight();

		function GeoLocData ()
		{
			this.city = '';
			this.region = '';
			this.country = '';
			this.countryCode = '';
			this.lat = '';
			this.lon = '';
		}

		function show (divId, inline)
		{
			divId.style.visibility='visible'; 
			if (inline) 
				divId.style.display='inline'; 
			else 
				divId.style.display='block'; 
		} 
		
		function hide (divId) 
		{
			divId.style.visibility='hidden'; 
			divId.style.display='none'; 
		} 
		
		function getGeoLocData (geodata) 
		{
			var geoLocData = new GeoLocData (); 
			geoLocData.city = geodata.getAttribute ("city"); 
			geoLocData.region = geodata.getAttribute ("region_name"); 
			geoLocData.country = geodata.getAttribute ("country_name");
			geoLocData.countryCode = geodata.getAttribute ("country_code");
			geoLocData.lat = geodata.getAttribute ("latitude");
			geoLocData.lon = geodata.getAttribute ("longitude");
			return geoLocData;
		}

		function getLocation () 
		{
			var d = document.getElementById ("domainName").value;
			_gel ("map_canvas").innerHTML='';
			_gel ("msg").innerHTML='';
			hide (_gel ("msg"));
			//hide (_gel ("map_canvas"));
			//hide (_gel ("map_wrapper"));
			//_IG_AdjustIFrameHeight();
			_IG_FetchXmlContent("http://www.codazzle.com/domloc/getdetails.jsp?domainName="+d, fillDetails);
		}

		function fillDetails (response) 
		{
			GUnload ();
			if (response == null || typeof(response) != "object" || response.firstChild == null) 
			{
				_gel("msg").innerHTML = "<i>Invalid Domain Entered.</i>"; 
				hide (_gel ("map_canvas"));
				hide (_gel ("map_wrapper"));
				show (_gel ("msg"));
				_IG_AdjustIFrameHeight();
				return;
			}

			var geodata = response.getElementsByTagName ("geodata").item (0);
			var geoLocData = getGeoLocData (geodata);
			if (GBrowserIsCompatible()) 
			{
				show (_gel ("map_wrapper"));
				show (_gel ("map_canvas"), true);
				
				_IG_AdjustIFrameHeight();
				
				var map = new GMap2(_gel("map_canvas"));
				var center = new GLatLng(geoLocData.lat, geoLocData.lon);
				map.setCenter(center, 9);
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
				
				// Create a base icon for all of our markers that specifies the 
				// shadow, icon dimensions, etc. 
				var baseIcon = new GIcon(G_DEFAULT_ICON);
				baseIcon.shadow = "http://www.google.com/mapfiles/shadow50x.png";
				baseIcon.iconSize = new GSize(20, 34);
				baseIcon.shadowSize = new GSize(37, 34);
				baseIcon.iconAnchor = new GPoint(9, 34);
				baseIcon.infoWindowAnchor = new GPoint(9, 2);
				
				var markerOptions = { icon:baseIcon, draggable: false};
				var marker = new GMarker(center, markerOptions);
				map.addOverlay(marker);
				var msg = geoLocData.city + ",<br/>" + geoLocData.region + ",<br/>" + geoLocData.country + " (" + geoLocData.countryCode + ")";
				GEvent.addListener(marker, "click", function () { marker.openInfoWindowHtml(msg);}); 
				marker.openInfoWindowHtml(msg); 
			} 
		} 
	</script> ]]>
	</Content> 
</Module> 