<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Virtual Neighborhood" category="Tools" render_inline="optional"
scrolling="false" author="Shankar Mohan - elocalfinder.com" directory_title="US Virtual Neighborhood"
author_link="http://www.elocalfinder.com/AboutLocalFinder.aspx"
author_email="shankarpm@gmail.com" author_affiliation="eLocalFinder.com"
title_url ="http://www.elocalfinder.com"
author_location="Avenel , NJ" screenshot="http://hosting.gmodules.com/ig/gadgets/file/111340096305477476494/VNGGImageSnap.JPG" singleton="false"
height ="375" width ="900"
thumbnail="http://www.elocalfinder.com/Images/VNGGImageThumb.JPG"
description ="US Virtual Neighborhood - View your important local business and needs around your neighborhood when you do local search for a zipcode or city , state in US">
</ModulePrefs>
<Content type="html">

<!-- ALm6fM1WJkwzX_3xsu7PsihtmLGlyqZm6lwrkVC9jJgiWDA51KSaxOEuYsK2NmUT_1cDdBKaRBYOz_EjZYvS22d8k1ratL7wZTN2F1OHfjBn7jkMVFtkfMjonmJA5npcWGq_ebyhUuL_6O4NqEwL3r2UT7jIEbEMRtUtQrul54jE58qzfcexRNk= -->
<![CDATA[<div id="content_div"></div>

<div id = 'DivSearchBox' style="position:relative;">
<div id = 'DivSearchBoxLabel' style = "font-size: 13px;"> Enter ZipCode or City,State [<a href = "http://elocalfinder.com" style="left:1px;position:relative;font-size: 13px;" target ="_top">Powered by eLocalFinder.com</a> ]</div>
<input id="TextZipcode" type="text" style="width: 200px" onkeydown="ClickSearchButton(event)"/>
<input id="ButtonSearch" type="button" value="Search" onclick = "CallBusiness()"  style="top:15px;position:absolute;"/> 
</div>

<div id="map_canvas" style="width: 510px; height: 335px;left:125px;position:relative;"></div>
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;sensor=false&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
type="text/javascript"></script>
<div id="DivtableBusiness" style ="OVERFLOW-Y:scroll;position:absolute;width: 125px;left:1px;top:40px;height:335px" >

</div>
<script type="text/javascript">
  function ClickSearchButton(event)
  {
  if(event.which || event.keyCode)
    {
      if ((event.which == 13) || (event.keyCode == 13)) 
        {
         document.getElementById('ButtonSearch').click();         
         return false;
         }
    } 
    else {
    return true
    }; 
  }
  
var geocoder;
var baseIcon;
var businessName;
var map;
var BusinessNameArray
var DicBusAddress;
var DicAdressToBus;
var DicBusNameToCategory;
var DicImageNames;
var tableHtml;
var VImageName = null;
var DisplayInfoWindowFlag = false;
var GGlocationPath = 'http://hosting.gmodules.com/ig/gadgets/file/111340096305477476494/';

function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37, -79),3);
map.setUIToDefault();
geocoder = new GClientGeocoder();
baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.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 mapTypeControl = new GMapTypeControl();
         var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(270, 2));     
         var topRight1 = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(470, 10));
         //map.addControl(new GMapTypeControl(), topRight);
         //map.addControl(new GSmallMapControl(),topRight1);
}
DicImageNames = new Object(); 
DicImageNames['Restaurants'] = 'restaurent.jpg';
DicImageNames['Malls'] = 'mall.jpg';
DicImageNames['Hospitals'] = 'hospital.gif';
DicImageNames['Dentists'] = 'dental.jpg';
DicImageNames['Schools'] = 'school.gif';
DicImageNames['Banks'] = 'bank.png';  
DicImageNames['Day_Care_Centers'] = 'childcare.gif';
DicImageNames['Post_Offices'] = 'postoffice.jpg';
DicImageNames['Florists'] = 'flower.png';
DicImageNames['Gyms'] = 'gym.gif';
DicImageNames['Electronics'] = 'electronics.jpg';
DicImageNames['Park'] = 'park.gif';
DicImageNames['Apartments'] = 'apartment.jpg';
DicImageNames['SuperMarkets'] = 'supermarket.png';
DicImageNames['Movie_Theatre'] = 'Movie.jpg';
DicImageNames['Theme_Parks'] = 'ThemePark.png';
DicImageNames['Airports'] = 'airport.jpg';
DicImageNames['Train_Station'] = 'train.jpg';
DicImageNames['Rental_Car'] = 'rentalcar.jpg';
DicImageNames['Gas_Station'] = 'gas.gif';
DicImageNames['Beauty_Salon'] = 'Beauty.gif';
DicImageNames['Realtors'] = 'realtor.jpg'; 

} 
 
function DisplayAddress(businessCat , add, bName) {

VImageName = DicImageNames[businessCat];
BusinessNameArray = null;
DisplayInfoWindowFlag = true;

var phoneInd = add.indexOf("("); 
  if(phoneInd > 0)
      businessName = bName + "</BR>" + add.substring(phoneInd ,phoneInd+15);// alert(businessName);
   else 
      businessName = bName;
      
showLocation(add, 15);
}

function showLocation(address, zoom) {
geocoder.getLocations(address, addAddressToMap);
}

function addAddressToMap(response) {
// map.clearOverlays();

if (!response || response.Status.code != 200) {
//alert("Sorry, we were unable to geocode that address");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);

// if(BusinessNameArray != null)
// { //alert(BusinessNameArray[BusinessNameArrayIndex]);
// businessName = BusinessNameArray[BusinessNameArrayIndex++];
// }

marker = createMarker(point, place.address);
map.addOverlay(marker);

  if (businessName != null && businessName.length > 0)
    map.setCenter(point , 11);
 
   if (businessName != null && businessName.length > 0 && DisplayInfoWindowFlag == true) {
           map.setCenter(point , 15);          
            marker.openInfoWindowHtml('<font style="color: blue;font-size: 13px;font-weight: bold;">' + businessName + '</font><br><font style="color: black;font-weight: normal;font-size: 12px;">' 
            + place.address + '</font>');   
                   
        }
  }


}


function createMarker(point, popuptext) {

var letteredIcon = new GIcon(baseIcon);

// Set up our GMarkerOptions object
markerOptions = { icon: letteredIcon };//, title: businessName };
var marker = new GMarker(point, markerOptions);
//alert('CM ' + businessName);
if (popuptext.length > 3)
{
var busTit = null;
if (BusinessNameArray != null)
{
if (DicAdressToBus[popuptext.substring(0, 7)] != null)
busTit = DicAdressToBus[popuptext.substring(0, 7)];
else if (DicAdressToBus[popuptext.substring(0, 5)] != null)
busTit = DicAdressToBus[popuptext.substring(0, 5)];
else if (DicAdressToBus[popuptext.substring(0, 3)] != null)
busTit = DicAdressToBus[popuptext.substring(0, 3)];

//letteredIcon.image = 'http://hosting.gmodules.com/ig/gadgets/file/111340096305477476494/restaurent.jpg';//DicImageNames['Restaurants'];
 
letteredIcon.image = GGlocationPath + DicImageNames[DicBusNameToCategory[busTit]];//'restaurent.jpg';
if (busTit == null)
busTit = "";
else {

}
}
else {
busTit = businessName;
}
GEvent.addListener(marker, "click", function() {
//alert(marker.getTitle()); //marker.openInfoWindowHtml("<b>" + popuptext + "</b>");
marker.openInfoWindowHtml('<font style="color: blue;font-size: 13px;font-weight: bold;">' + busTit + '</font><br><font style="color: black;font-weight: normal;font-size: 12px;">'
+ popuptext + '</font>');

});
}
 if (VImageName != null)
        letteredIcon.image = GGlocationPath + VImageName;
 
return marker;
}

function displayMenu() {
BusinessNameArray = new Array();
BusinessNameArrayIndex = 0;
var BusinessAddressArray = new Array();
 
// XML breakfast menu data
//var url = "http://doc.examples.googlepages.com/breakfast-data.xml";
//var url = "http://hosting.gmodules.com/ig/gadgets/file/111340096305477476494/business.xml";
var url = "http://www.elocalfinder.com/VNFeed.aspx?location=" + document.getElementById('TextZipcode').value.replace(/ /g, "%20");
//alert(url);
var prefs = new _IG_Prefs(__MODULE_ID__);

_IG_FetchXmlContent(url, function (response) {
if (response == null || typeof(response) != "object" || response.firstChild == null) {
_gel("content_div").innerHTML = "<i>Invalid data.</i>";
return;
}
var html = "<div style='padding: 5px;background-color: #ccf;font-family:Arial, Helvetica;" +
"text-align:left;font-size:90%'>";// +test </div>";
// var title = response.getElementsByTagName("menu").item(0).getAttribute("title");
// var itemList = domdata.getElementsByTagName("menu").item(0).getAttribute("title");

var itemList = response.getElementsByTagName("Business");

tableHtml ="<table >";
 
DicBusAddress = new Object();
DicAdressToBus = new Object();
DicBusNameToCategory = new Object();
BusinessNameArray = new Array();
var arrayIndex=0;
var busIndex = 0;
if(itemList.length == 0)
  {
    alert('Please enter a valid city or zipcode in USA. For example: Chicago , IL or 10006');
  }
      for (var i = 0; i < itemList.length ; i++)
      {
        var nodeList = itemList.item(i).childNodes;
        for (var j = 0; j < nodeList.length ; j++)
          {
            var node = nodeList.item(j);
              if (node.nodeName.length > 0)
                {
                  if(node.nodeName == 'Restaurants')
                    {
                        var Business = node.firstChild.nodeValue.split("@#");
                        for (var k = 0; k < Business.length; k++)
                          {           
                             var BusNameAddress= Business[k].split("#$"); 
                            // alert(BusNameAddress.length);                                          
                            if(BusNameAddress.length > 1)
                              {      
                               var businessCatHeader = false;
                                if(busIndex==0)
                                   businessCatHeader = true;
                                DecodeBusinessAddress(BusNameAddress,busIndex,node.nodeName,businessCatHeader);
                                busIndex++;
                              }
                          }
                     }
                     else
                     {
                       var BusNameAddress= node.firstChild.nodeValue.split("#$");
                       DecodeBusinessAddress(BusNameAddress,busIndex,node.nodeName,true);                      
                       busIndex++;
                     }
              }
          }
      }
 
  tableHtml += "</table>";
  document.getElementById('DivtableBusiness').innerHTML = tableHtml ;
//alert(tableHtml);
for (i = 0; i < BusinessNameArray.length; i++) {
 var name = BusinessNameArray[i];
//alert(name);
var address = DicBusAddress[BusinessNameArray[i]]; // alert(name + " " + address);
showLocation(address, 9);
}
//_gel('content_div').innerHTML = html;
});//response
  
var captionText = "Enter ZipCode or City,State [<a href = 'http://elocalfinder.com/LocalSearch.aspx?location=" + document.getElementById('TextZipcode').value + "&ad=Hotels+Real_Estate' target ='_top' style='left:1px;position:relative;font-size: 13px;'>Powered by eLocalFinder.com</a> ]";
 document.getElementById('DivSearchBoxLabel').innerHTML = captionText;
}

function DecodeBusinessAddress(BusNameAddress,busIndex,businessCat,businessCatHeader)
{
//if(busIndex == 0)
{
   var BusName= BusNameAddress[0].replace(/&#39;/g, "`");
   var BusCatText = "";
      if(businessCatHeader == true)
       BusCatText = businessCat.replace(/_/g, " ") + "</BR>";
   var BusDispAddress = BusNameAddress[1].replace("(", "</BR>(");
   tableHtml += "<tr onMouseOut = \"style.backgroundColor = '#F2F9FF';\" onmouseover=\"style.backgroundColor = '#D4D0C8';" + 
     "javascript:DisplayAddress('" + businessCat + "','" + BusNameAddress[1] + "','" + BusName + "');" + 
     "\"><td width='110' style='font-size: 13px; font-family: Arial; font-style: normal;'><font style='color: #800000;font-weight: bold; font-size: 14px'>" + BusCatText + "</font>" + 
     "<font style='color: #0000FF;font-weight: bold;'>" + BusNameAddress[0] + "</font> </BR>" + BusDispAddress + "</td></tr>"; 
}
BusinessNameArray[busIndex] = businessName = BusNameAddress[0];
DicBusNameToCategory[BusNameAddress[0]] = businessCat;
//var address = BusinessAddressArray[j] = BusNameAddress[1];
//showLocation(address ,9); // html += address + "</div>"; // alert(businessName);
DicBusAddress[BusNameAddress[0]] = BusNameAddress[1];
        if (BusNameAddress[1].length > 3) {
            var incrInd = 3;
            while (1) {
              if (DicAdressToBus[BusNameAddress[1].substring(0, incrInd)] == null)
              {
                DicAdressToBus[BusNameAddress[1].substring(0, incrInd)] = BusNameAddress[0];
                break;
              }
            else
              incrInd = incrInd + 2;

                if (incrInd == 7) 
                     break;//to prevent from infinite loop
            }//while
        }//if
}
  
  initialize();
function CallBusiness()
{
displayMenu();
//_IG_RegisterOnloadHandler(displayMenu);
}
</script>
]]>
</Content>
</Module>


