<?xml version="1.0" encoding="UTF-8"?>
<Module>
    <ModulePrefs 
      title="NALENND NPA/NXX Geolocator"
      directory_title ="NALENND NPA/NXX Geolocator"
      title_url="http://www.quentinsagerconsulting.com/npanxx_phonecodes.htm" 
      author="Quentin Sager Consulting, Inc." 
      author_location ="United States" 
      author_email="qsc.feedback@gmail.com"
      author_affiliation="quentinsagerconsulting.com"
      height="300" 
      width ="320" 
      description="Find the center of the geographic service area for any North American telephone number and whether the number is wireless or landline based on the area code and at least the first three digits of the telephone number."
      screenshot="http://www.quentinsagerconsulting.com/google/nalennd_gadget.jpg"  
      thumbnail="http://www.quentinsagerconsulting.com/google/nalennd_gadget_thumb.jpg"  
      category="tools"
      category2="technology"
      >
    </ModulePrefs>
    <Content type="html">
        <![CDATA[ 
<html>
<head>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAT3DQNfoUR3n0eXD9SjWgpBSzAeXp-NufJ6LVuks1h6rGswBF7RR8EZxfI9sImB--vqhLgLFUW2EjyA" type="text/javascript"></script>
<script type="text/javascript">	
var map__MODULE_ID__= null;

function dogooglemap(){
    if (GBrowserIsCompatible()) {
        map__MODULE_ID__ = new GMap2(document.getElementById("gmap"));
        map__MODULE_ID__.addControl(new GSmallZoomControl());
        map__MODULE_ID__.addControl(new GMapTypeControl());
        map__MODULE_ID__.setCenter(new GLatLng(38.87,-77.022),10);
        }
    }

function getdata(odom,field){
var data = odom.getElementsByTagName(field);
return (data.length > 0) ? data.item(0).firstChild.nodeValue:null;}

function doquery()
    {
    if ((document.frmsubmit.q.value == null) || (document.frmsubmit.q.value == ""))
		document.frmsubmit.q.focus();
    else
        {
        sturl = 'http://www.quentinsagerconsulting.com/google/nalennd_gadget.php?q=' + document.frmsubmit.q.value;

	    _IG_FetchXmlContent(sturl,function(response)
            {
            var html = "";

            if (response == null || typeof(response) != "object" || response.firstChild == null) 
                {           
                html = "<i>Server communication error.</i>";
                }
            else
                {
		        var state       = getdata(response,'state');
		        var city        = getdata(response,'city');
		        var ltype       = getdata(response,'type');
		        var latitude    = getdata(response,'latitude');
		        var longitude   = getdata(response,'longitude');
		        var serr        = getdata(response,'error');

		        if (serr)    html += '<i style="color:red;">' + serr + '</i>';
		        if (ltype)   html += ltype + ": ";
		        if (city && state)    html += city + " "+ state + " ";
		        if (latitude && longitude)
		            {
		            if (map__MODULE_ID__ != null)
                        {
                        var mypoint = new GLatLng(latitude,longitude);
		                map__MODULE_ID__.setCenter(mypoint,11);
                        map__MODULE_ID__.addOverlay(new GMarker(mypoint,{title: html, draggable:false, clickable:false }));
                        }
		            }
                }

            if (html)
		        _gel('content_div').innerHTML = html;
            } ); 
        }
    return false;
	}
	
function checknumber(number)
    {
    var pattern = "0123456789";
    var index = 0;
    var len = number.value.length;
    while ((index < len) && (len != 0))
        {
        if (pattern.indexOf(number.value.charAt(index)) == -1)
            {
            if (index == len-1)
                number.value = number.value.substring(0, len-1);
            else if (index == 0)
                number.value = number.value.substring(1, len);
            else 
                number.value = number.value.substring(0, index)+number.value.substring(index+1, len);
            index = 0;
            len = number.value.length;
            }
        else
            index++;
        }
    }

function checkenter(e)
    {
    var kc = 0;
    
    if (window.event)
        kc = window.event.keyCode;
	else if (e) 
	    kc = e.which;

	return (kc == 13) ? doquery():true;
	}
</script> 
<style type="text/css">
html {min-height: 100%;width:100%;background: #FFF;}
body {height:100%;width:100%;color:#FFF;background-color: #000;font:normal 80% Verdana, Arial, sans-serif;}
div  {clear:both;}
img  {border:0px;}
div a {font-size:80%;color:#FFF;}
div a:link {color:#FFF;}
div a:visited {color:#FFF;}
div a:hover {color:#FFF;}
</style>
</head>
<body onunload="GUnload();">
<div style="margin:5px;">
<img src="http://www.quentinsagerconsulting.com/google/nalennd.jpg" width="165" height="37" alt="NALENND Telecom Databases" style="float:left;"/>
<a href="http://www.quentinsagerconsulting.com/" target="_blank">Quentin Sager Consulting</a>
<div style="text-align:right;"><form name="frmsubmit" method="get" style="margin:0px;">Find Telephone Number&nbsp;<input type="text" name="q" size="8" maxlength="15" onkeyup = "checknumber(this)" onkeypress="return checkenter(event);" /><input type="button" name="submit" onclick="return doquery();" value="Go" /></form></div>
<div id="gmap" style="width:100%; height:200px; background: #FFF;"></div>
<div id="content_div">&nbsp;</div>
</div>
<script type="text/javascript">dogooglemap();</script>
</body>
</html>
]]>
</Content>
</Module>
