 //The fallowing function is a call to add new elements to the tblDealers array
 function AddDealer(Cnt,DealerID, CRID, SAID, DealerName, Telephone, Distance, Products, Longitude, Latitude, StoreCount, Address, Street, City, State, Zip, URL)
 {
   
    arrDealers[Cnt] = new objDealers(Cnt,DealerID, CRID, SAID, DealerName, Telephone, Distance, Products, Longitude, Latitude, StoreCount, Address, Street, City, State, Zip, URL); 
    
    
 }


 //define the objDealer object
 function objDealers(Cnt,DealerID, CRID, SAID, DealerName, Telephone, Distance, Products, Longitude, Latitude, StoreCount, Address, Street, City, State, Zip, URL)
 {
 this.OrderID       = Cnt;
 this.DealerID      = DealerID;
 this.CRID          = CRID;
 this.SAID          = SAID;
 this.DealerName    = DealerName;
 this.Telephone     = Telephone;
 this.Distance      = Distance;
 this.Products      = Products; 
 this.Longitude     = Longitude;
 this.Latitude      = Latitude;
 this.StoreCount    = StoreCount;
 this.Address       = Address;
 this.Street        = Street;
 this.City          = City;
 this.State         = State;
 this.Zip           = Zip;
 this.URL           = URL;
 }


 //This is the product object
 function objProduct(ProductId, ProductName, ProductDescription)
 {
 this.ProductID = ProductID;
 this.ProductName = ProductName;
 this.ProductDescription = ProductDescription;
 }
 


//populate the divDealer from the xml string
function BuildDealers()
{
    if(intTotalResults == 0)
    {
        return;
    }
    
    BuildDealerObjects();
    //Use the obDealers that was builet by the previous procdure call and build the table
    BuildDealerTable(0);
    // Display the first store information to the right of the map
    GetStoreInfo(1);

}

function ClearMap(Start)
{
    var Cnt=0;
    for(var i=Start;i < arrDealers.length; i++)   
    {
        if(Cnt == StoreCnt)
            {
                break;
            }
        arrMarkers[Cnt].RemoveMarker();
        Cnt = Cnt + 1;
    }
}


function BuildDealerObjects()
{

if(intTotalResults == 0)//exit if nothing was found. Don't try to load an empty XML file.
{
 
 return;
    
}

 var objDealers = document.getElementById("txtDealers");
 
 var str = objDealers.value;
 
 var dr = str.split("[Row]");
 
 
    for(var i=0; i<dr.length; i++) //loop thru each dealer row
    {
        var r = dr[i].split("[Column]");
 
        for(var x=0; x<r.length; x++) //loop thru each column in the dealer row
        {
            var strColVal = r[x].split("::::");
            if (strColVal[0] == "Dealer_Id")
            {
                var DealerID = strColVal[1];
            }
            if (strColVal[0] == "CR")
            { 
                var CRID = strColVal[1];
            }
            if (strColVal[0] == "SAID")
            {
                var SAID = strColVal[1];
            }
            if (strColVal[0] == "Dealer")
            {
                var DealerName = strColVal[1];
            }
            if (strColVal[0] == "Phone")
            {
                var Telephone = strColVal[1];
            }
            if (strColVal[0] == "Distance")
            {
                var Distance  = strColVal[1];
            }
            if (strColVal[0] == "Dealer_Id")
            {
                DealerID = strColVal[1];
            }
            
            if (strColVal[0] == "ProductDisplay")
            {
                var Products = strColVal[1];
            }
            if (strColVal[0] == "Longitude")
            {
                var Longitude = strColVal[1];
            }
            if (strColVal[0] == "Latitude")
            {
                var Latitude = strColVal[1];
            }
            if (strColVal[0] == "StoreCount")
            {
                var StoreCount = strColVal[1];
            }
            if (strColVal[0] == "Address")
            {
                var Address = strColVal[1];
            }
            if (strColVal[0] == "Street")
            {
                var Street = strColVal[1];
            }
            if (strColVal[0] == "City")
            {
                var City = strColVal[1];
            }
            if (strColVal[0] == "State")
            {
                var State = strColVal[1];
            }
            if (strColVal[0] == "Zip")
            {
                var Zip = strColVal[1];
            }
            if (strColVal[0] == "URL")
            {
                var URL = strColVal[1];
            }
                                                            
                                    
        }
        AddDealer(i,DealerID, CRID, SAID, DealerName, Telephone, Distance, Products, Longitude, Latitude, StoreCount, Address, Street,City,State,Zip,URL);

    }
   

}
         function isZip(s) 
            {

                // Check for correct zip code
                reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
    
                if (!reZip.test(s)) 
                    {
                        return false;
                    }

                return true;
            }

 function initialize(lng,lat,zoom,productid,zip,range,googlekey) 
 {

      SearchLng = lng;
      SearchLat = lat;
      SearchRange = range;
      ProductID = productid;
      Zip       = zip;
      googleKey = googlekey;
      //var sourcescript = document.getElementById("SourceScript");    
      //sourcescript.src = "http://maps.google.com/maps?file=api&amp;v=2.95&amp;key=" + googlekey;
      if(!isZip(zip))
      {
      var tgmap = document.getElementById("map_canvas");
      tgmap.style.visibility = "hidden";
      tblFrom.style.visibility = "hidden";
      
      }
      if (GBrowserIsCompatible()) 
        {
            //Create map
            map = new GMap2(document.getElementById("map_canvas"));
            //Set map coordinates
            map.setCenter(new GLatLng(lat,lng), zoom);
            // add sitellite, hybrid controls to map
            map.addControl(new GMapTypeControl());
            // add zoom control
            map.addControl(new GLargeMapControl());
            // add map view
            //map.addControl(new GOverviewMapControl());
            
            //map.enableScrollWheelZoom()
           
            /*
            //Add center marker as a little star
            var latlng = new GLatLng(lat, lng);
            var icon = new GIcon(G_DEFAULT_ICON);
            icon.image = 'images/star.png';
            icon.iconSize = new GSize(32, 32);
            icon.iconAnchor = new GPoint(16, 16);
            icon.infoWindowAnchor = new GPoint(25, 7);
            opts = {"icon": icon };//, "clickable": true,"title": "letter A","labelText": "A","labelOffset": new GSize(-6, -10)};
            //var marker = new LabeledMarker(latlng, opts);
            var marker = new GMarker(latlng, opts);
            map.addOverlay(marker);
           */
        }
       /* 
       var lm1 = document.getElementById("LM1");
      lm1.src="js/labeledmarker_packed.js";
      var lm2 = document.getElementById("LM2");
      lm2.src="js/labeledmarker.js";
      */
  }

function ToggleImage(cnt)
{
//before anything. restore the currently selected item to its default (Red callout with white text

var oSelectedTD = document.getElementById("TDStore" + SelectedStore);
//do table
oSelectedTD.style.backgroundImage = "url(Images/iconA_red.jpg)";
oSelectedTD.className = "cls2a";
//do callout(marker) on map
var oSelectedMarker = arrMarkers[SelectedStore - 1];
oSelectedMarker.RemoveMarker();
oSelectedMarker.Icon.image = "Images/iconA_red.png";
oSelectedMarker.ClassName = "MarkerA";
oSelectedMarker.AddMarker();




//do table
var oTD = document.getElementById("TDStore" + cnt ); //background='Images/iconA_red.jpg'
if(oTD.className == "cls2a")
    {
        oTD.style.backgroundImage = "url(Images/iconA_blue.jpg)";
        oTD.className = "cls2b";
    }
else
    {
        oTD.style.backgroundImage = "url(Images/iconA_red.jpg)";
        oTD.className = "cls2a";
    }
    
//do callout(marker) on map
arrMarkers[cnt - 1].Icon.image = "Images/iconA_blue.png";
arrMarkers[cnt - 1].ClassName = "MarkerB";
arrMarkers[cnt - 1].AddMarker();
    
SelectedStore = cnt;
ProductCallouts(cnt-1);
//arrMarkers[cnt - 1].StoreMarker.openInfoWindowHtml("<Table width='200px'><TR><TD><B>Products:</B><I>" + arrMarkers[cnt - 1].Products + "</I></TD></TR></Table>");
}

function objMarker(lat,lng,Cnt, Products, Image, ClassName, LabelNbr)
{
this.LatLng         = new GLatLng(lat,lng);
this.Products       = Products;
this.Count          = Cnt;
this.Icon           = new GIcon();
this.Icon.image     = Image;
this.Icon.iconSize       = this.Icon.iconSize = new GSize(21, 35);
this.Icon.iconAnchor     = new GPoint(16, 14);
this.Icon.infoWindowAnchor = new GPoint(25, 7);
this.ClassName      = ClassName;
this.LabelNbr       = LabelNbr;

// align the font inside the callouts.
var fontPos;
if(this.LabelNbr < 10)
    {
        fontPos = new GSize(-8, -9);
    }

 if(this.LabelNbr > 9)
            {
                if(this.LabelNbr > 99)
                    {
                        fontPos = new GSize(-13, -9);
                    }
                else
                    {
                        fontPos = new GSize(-11, -9);
                    }
                
            }

this.FontPos        = fontPos;
this.StoreMarker    = null;
this.AddMarker      = addMarker;
this.RemoveMarker   = removeMarker;

}
/*
* LabeledMarker Class, v1.1
*
* Copyright 2007 Mike Purvis (http://uwmike.com)
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*       http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This class extends the Maps API's standard GMarker class with the ability
* to support markers with textual labels. Please see articles here:
*
*       http://googlemapsbook.com/2007/01/22/extending-gmarker/
*       http://googlemapsbook.com/2007/03/06/clickable-labeledmarker/
*/

/**
 * Constructor for LabeledMarker, which picks up on strings from the GMarker
 * options array, and then calls the GMarker constructor.
 *
 * @param {GLatLng} latlng
 * @param {GMarkerOptions} Named optional arguments:
 *   opt_opts.labelText {String} text to place in the overlay div.
 *   opt_opts.labelClass {String} class to use for the overlay div.
 *     (default "LabeledMarker_markerLabel")
 *   opt_opts.labelOffset {GSize} label offset, the x- and y-distance between
 *     the marker's latlng and the upper-left corner of the text div.
 */
function LabeledMarker(latlng, opt_opts){
  this.latlng_ = latlng;
  this.opts_ = opt_opts;

  this.labelText_ = opt_opts.labelText || "";
  this.labelClass_ = opt_opts.labelClass || "LabeledMarker_markerLabel";
  this.labelOffset_ = opt_opts.labelOffset || new GSize(0, 0);
  
  this.clickable_ = opt_opts.clickable || true;
  this.title_ = opt_opts.title || "";
  this.labelVisibility_  = true;
   
  if (opt_opts.draggable) {
  	// This version of LabeledMarker doesn't support dragging.
  	opt_opts.draggable = false;
  }
  
  GMarker.apply(this, arguments);
}


// It's a limitation of JavaScript inheritance that we can't conveniently
// inherit from GMarker without having to run its constructor. In order for 
// the constructor to run, it requires some dummy GLatLng.
LabeledMarker.prototype = new GMarker(new GLatLng(0, 0));

/**
 * Is called by GMap2's addOverlay method. Creates the text div and adds it
 * to the relevant parent div.
 *
 * @param {GMap2} map the map that has had this labeledmarker added to it.
 */
LabeledMarker.prototype.initialize = function(map) {
  // Do the GMarker constructor first.
  GMarker.prototype.initialize.apply(this, arguments);
  
  this.map_ = map;
  this.div_ = document.createElement("div");
  this.div_.className = this.labelClass_;
  this.div_.innerHTML = this.labelText_;
  this.div_.style.position = "absolute";
  this.div_.style.cursor = "pointer";
  this.div_.title = this.title_;
  
  map.getPane(G_MAP_MARKER_PANE).appendChild(this.div_);

  if (this.clickable_) {
    /**
     * Creates a closure for passing events through to the source marker
     * This is located in here to avoid cluttering the global namespace.
     * The downside is that the local variables from initialize() continue
     * to occupy space on the stack.
     *
     * @param {Object} object to receive event trigger.
     * @param {GEventListener} event to be triggered.
     */
    function newEventPassthru(obj, event) {
      return function() { 
        GEvent.trigger(obj, event);
      };
    }
  
    // Pass through events fired on the text div to the marker.
    var eventPassthrus = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout'];
    for(var i = 0; i < eventPassthrus.length; i++) {
      var name = eventPassthrus[i];
      GEvent.addDomListener(this.div_, name, newEventPassthru(this, name));
    }
  }
}

/**
 * Move the text div based on current projection and zoom level, call the redraw()
 * handler in GMarker.
 *
 * @param {Boolean} force will be true when pixel coordinates need to be recomputed.
 */
LabeledMarker.prototype.redraw = function(force) {
  GMarker.prototype.redraw.apply(this, arguments);
  
  // Calculate the DIV coordinates of two opposite corners of our bounds to
  // get the size and position of our rectangle
  var p = this.map_.fromLatLngToDivPixel(this.latlng_);
  var z = GOverlay.getZIndex(this.latlng_.lat());
  
  // Now position our div based on the div coordinates of our bounds
  this.div_.style.left = (p.x + this.labelOffset_.width) + "px";
  this.div_.style.top = (p.y + this.labelOffset_.height) + "px";
  this.div_.style.zIndex = z; // in front of the marker
}

/**
 * Remove the text div from the map pane, destroy event passthrus, and calls the
 * default remove() handler in GMarker.
 */
 LabeledMarker.prototype.remove = function() {
  GEvent.clearInstanceListeners(this.div_);
  if (this.div_.outerHTML) {
    this.div_.outerHTML = ""; //prevent pseudo-leak in IE
  }
  if (this.div_.parentNode) {
    this.div_.parentNode.removeChild(this.div_);
  }
  this.div_ = null;
  GMarker.prototype.remove.apply(this, arguments);
}

/**
 * Return a copy of this overlay, for the parent Map to duplicate itself in full. This
 * is part of the Overlay interface and is used, for example, to copy everything in the 
 * main view into the mini-map.
 */
LabeledMarker.prototype.copy = function() {
  return new LabeledMarker(this.latlng_, this.opt_opts_);
}


/**
 * Shows the marker, and shows label if it wasn't hidden. Note that this function 
 * triggers the event GMarker.visibilitychanged in case the marker is currently hidden.
 */
LabeledMarker.prototype.show = function() {
  GMarker.prototype.show.apply(this, arguments);
  if (this.labelVisibility_) {
    this.showLabel();
  } else {
    this.hideLabel();
  }
}


/**
 * Hides the marker and label if it is currently visible. Note that this function 
 * triggers the event GMarker.visibilitychanged in case the marker is currently visible.
 */
LabeledMarker.prototype.hide = function() {
  GMarker.prototype.hide.apply(this, arguments);
  this.hideLabel();
}


/**
 * Sets the visibility of the label, which will be respected during show/hides.
 * If marker is visible when set, it will show or hide label appropriately.
 */
LabeledMarker.prototype.setLabelVisibility = function(visibility) {
  this.labelVisibility_ = visibility;
  if (!this.isHidden()) { // Marker showing, make visible change
    if (this.labelVisibility_) {
      this.showLabel();
    } else {
      this.hideLabel();
    }
  }
}


/**
 * Returns whether label visibility is set on.
 * @return {Boolean}  
 */
LabeledMarker.prototype.getLabelVisibility = function() {
  return this.labelVisibility_;
}


/**
 * Hides the label of the marker.
 */
LabeledMarker.prototype.hideLabel = function() {
  this.div_.style.visibility = 'hidden';
}


/**
 * Shows the label of the marker.
 */
LabeledMarker.prototype.showLabel = function() {
  this.div_.style.visibility = 'visible';
}


function addMarker()
{
Opts = {"icon": this.Icon,"clickable":true,"labelText":this.LabelNbr,"labelClass":this.ClassName,"labelOffset":this.FontPos};
var marker                  = new LabeledMarker(this.LatLng, Opts); 
this.StoreMarker = marker;
var strProducts = this.Products;
var intCount    = this.Count;
var intLabelNbr    = this.LabelNbr
GEvent.addListener(this.StoreMarker, "click", function() {marker.openInfoWindowHtml("<Table width='200px'><TR><TD><B>Products:</B><I>" + strProducts + "</I></TD></TR></Table>"); ToggleImage(intCount); GetStoreInfo(intLabelNbr); });
map.addOverlay(this.StoreMarker); 
}


function removeMarker()
{
map.removeOverlay(this.StoreMarker); 
}


function GetStoreInfo(Cnt)
{

Cnt = Cnt - 1;
//get the dealer requested
var strTable = "<Table width='100%' border='0' >";

strTable += "<TR>";
strTable += "<TD colspan='4' class='cls1'>";
strTable += "To: " + arrDealers[Cnt].DealerName;
strTable += "</TD>";
strTable += "</TR>";
strTable += "<TR>";
strTable += "<TD class='cls6' style='width:20%'>";
strTable += "Street:";
strTable += "</TD>";
strTable += "<TD class='cls7' colspan='3'>";
strTable += arrDealers[Cnt].Street;
strTable += "</TD>";
strTable += "<TR><TD class='cls6' style='width:20%'>";
strTable += "City:";
strTable += "</TD>";
strTable += "<TD class='cls7' colspan='3'>";
strTable += arrDealers[Cnt].City;
strTable += "</TD></TR>";

strTable += "<TR><TD class='cls6' style='width:20%'>";
strTable += "State:";
strTable += "</TD>";
strTable += "<TD class='cls7' >";
strTable += arrDealers[Cnt].State;
strTable += "</TD>";

strTable += "<TD class='cls6' style='width:20%'>";
strTable += "Zip:";
strTable += "</TD>";
strTable += "<TD class='cls7' >";
strTable += arrDealers[Cnt].Zip;
strTable += "</TD>";

strTable += "</TR>";

strTable += "<TR>";
strTable += "<TD colspan='1' class='cls6'>";
strTable += "Telephone";
strTable += "</TD>";
strTable += "<TD colspan='3' class='cls7' align='Left'>";
strTable += arrDealers[Cnt].Telephone;
strTable += "</TD>";
strTable += "</TR>";
if(arrDealers[Cnt].StoreCount > 1)
    {
        var strLink = "frmDSdetailResults.aspx?CR=" + arrDealers[Cnt].CRID + "&lng=" + arrDealers[Cnt].Longitude + "&lat=" + arrDealers[Cnt].Latitude + "&SearchLng=" + SearchLng + "&SearchLat=" + SearchLat + "&SearchRange=" + SearchRange  + "&Zip=" + Zip + "&ProductID=" + ProductID + "&GUID=" + document.getElementById("txtGUID").value + "&DealerID=" + arrDealers[Cnt].DealerID ;
        var strRef="<a href='" + strLink +  "'>Click here to see all " + arrDealers[Cnt].StoreCount + " " + arrDealers[Cnt].DealerName + " locations" + "</a>";
        strTable += "<TR>";
        strTable += "<TD class='cls6' colspan='3'>";
        strTable += strRef;
        strTable += "<TD>";
        strTable += "</TR>";        
    }

if(arrDealers[Cnt].URL != 'Not Available')
{
strTable += "<TR>";
strTable += "<TD class='cls6' ><a href='http://";
strTable += arrDealers[Cnt].URL + "' target='_blank'>" + arrDealers[Cnt].URL + "</a>";
strTable += "</TD>";

strTable += "</TR>";
}

strTable += "</TR>";

strTable += "<Table>";
var objStoreInfo = document.getElementById("StoreInfo");
objStoreInfo.innerHTML = strTable;

document.getElementById("txtDealerID").value = arrDealers[Cnt].DealerID;
document.getElementById("txtDealerLng").value = arrDealers[Cnt].Longitude;
document.getElementById("txtDealerLat").value = arrDealers[Cnt].Latitude;
document.getElementById("txtLng").value = SearchLng;
document.getElementById("txtLat").value = SearchLat;
}
function Next()
{
   //initialize(SearchLng,SearchLat,10);
    var i;
    SelectedStore = 1;
    map.clearOverlays();
    i = CurrentPage * StoreCnt;
    
    if(i <= intTotalResults)
        {
            BuildDealerTable(i);           
            CurrentPage = CurrentPage + 1;
            GetStoreInfo(i+1);
            ProductCallouts(0);
            //arrMarkers[0].StoreMarker.openInfoWindowHtml("<Table width='200px'><TR><TD><B>Products:</B><I>" + arrMarkers[0].Products + "</I></TD></TR></Table>");
            if(CurrentPage * StoreCnt >= intTotalResults)
                    {
                        document.getElementById("Next").style.visibility = 'hidden';
                        document.getElementById("Next2").style.visibility = 'hidden';
                        document.getElementById("Previous").style.visibility = 'visible';
                        document.getElementById("Previous2").style.visibility = 'visible';
                    } 
           document.getElementById("Previous").style.visibility = 'visible';
           document.getElementById("Previous2").style.visibility = 'visible';
        }

    
    
    
    // Display the first store information to the right of the map
    //GetStoreInfo(1);
    
}

function Previous()
{
   //initialize(SearchLng,SearchLat,10);
    var i;
    SelectedStore = 1;
    map.clearOverlays();
    CurrentPage = CurrentPage - 1;
    i = (CurrentPage-1) * StoreCnt;
    BuildDealerTable(i);           
    GetStoreInfo(i+1);
    ProductCallouts(0);
    //arrMarkers[0].StoreMarker.openInfoWindowHtml("<Table width='200px'><TR><TD><B>Products:</B><I>" + arrMarkers[0].Products + "</I></TD></TR></Table>");
    if(CurrentPage == 1)
         {
           document.getElementById("Previous").style.visibility = 'hidden';
           document.getElementById("Previous2").style.visibility = 'hidden';
           document.getElementById("Next").style.visibility = 'visible';
           document.getElementById("Next2").style.visibility = 'visible';
         } 
    document.getElementById("Next").style.visibility = 'visible';
    document.getElementById("Next2").style.visibility = 'visible';
}
function PrintNavigation()
{
var str ="";
var str2 ="";
var objResults = document.getElementById("results");
var objResults2 = document.getElementById("results2");
str += "<span id='Previous'class='Previous' style='visibility:hidden' onclick='Previous();'>&laquo;Previous</span>&nbsp;&nbsp;<span id='spResults'>Your search returned " + (intTotalResults + 1) + " results.&nbsp;" + " </span> <span id='Next' class='Next' onclick='Next();'>Next&raquo;</span> ";
str2 += "<span id='Previous2' class='Previous' style='visibility:hidden' onclick='Previous();'>&laquo;Previous</span>&nbsp;&nbsp;<span id='spResults2'>Your search returned " + (intTotalResults + 1) + " results.&nbsp;" + " </span> <span id='Next2' class='Next' onclick='Next();'>Next&raquo;</span> ";
objResults.innerHTML =str;
objResults2.innerHTML =str2;
}
function Results(TotalResults)
{
intTotalResults = TotalResults;
if(intTotalResults == 0)
{
 
 results.innerHTML = "Your search returned 0 results. Please try using a different zip code."
 return;
    
}
else
{
PrintNavigation();
}


if((intTotalResults + 1) <= StoreCnt) //if there are no more than the total store allowed per page than hide the Next>> link. The user ndoes not need to see next page since there will be nothting to show.   
    {
       document.getElementById("Next").style.visibility ='hidden';
       document.getElementById("Next2").style.visibility ='hidden';
    }
}

function ProductCallouts(nbr)
{
arrMarkers[nbr].StoreMarker.openInfoWindowHtml("<Table width='200px'><TR><TD class='callout1'>Products:</td><td class='callout2'>" + arrMarkers[nbr].Products + "</TD></TR></Table>");
}


function BuildDealerTable(Start)
{

    var strTable="";
    var oDealer;
    var Cnt=0; //insure that the loop does not exceed the amount of stores allowed in the page
    //build the header right bellow the map: "Store Name and Address -------- Telephone"
    strTable += "<Table Width='100%' >";
    strTable += "<TR>";
    strTable += "<TD class='cls1' style='width:80%'>Store Name and Address</TD>";
    strTable += "<TD class='cls1' style='width:20%'>Telephone</TD>";
    strTable += "</TR>";
    //End of header below map
    
    
    

    //loop thru all stores starting at the requested position
    for(var i=Start;i < arrDealers.length; i++) 
        {
            //exit the loop if reached more than allowed per page. 
            var objDivDealer = document.getElementById("divDealer");
            objDivDealer.innerHTML ="";
            if(Cnt == StoreCnt)
                {
                    break;
                }
            strTable +="<TR>";    
            strTable +="<TD class='cls4' style='Width:80%'>";
          //get the store
            var oDealer = arrDealers[i];
            strTable += getStore(oDealer,Cnt+1,i+1);
            //Add marker on the map
            if(Cnt ==0)
                {
                    arrMarkers[Cnt] = new objMarker(oDealer.Latitude,oDealer.Longitude,Cnt+1,oDealer.Products,'Images/iconA_blue.png','MarkerB',i+1)
                    arrMarkers[Cnt].AddMarker();

                }
            else
                {
                    arrMarkers[Cnt] = new objMarker(oDealer.Latitude,oDealer.Longitude,Cnt+1,oDealer.Products,'Images/iconA_Red.png','MarkerA',i+1)
                    arrMarkers[Cnt].AddMarker();    

                    
                
                }
                
            //AddMarker(oDealer.Longitude,oDealer.Latitude,i+1,oDealer.Products);
            //keep trak of how many stores have been placed on the page
            strTable +="</TD>";
            strTable +="<TD class='cls4'>";
            strTable += oDealer.Telephone;
            strTable +="</TD>";
            strTable +="</TR>";
            Cnt = Cnt + 1;
        }
        objDivDealer.innerHTML = strTable;
      
}



function getStore(oDealer,cnt,StoreOrderID)
{

    var strTable = "<Table border='0' width='100%'cellspacing='0' cellpadding='0' class='StoreTable' >";        
    strTable += "<TR>";
    if(cnt == 1 )
    {
    strTable +="<TD onclick='ToggleImage(" + cnt + ");GetStoreInfo(" + StoreOrderID + ")' id=TDStore" + cnt  + " class='cls2b' style='width:5%;Height:49px; background-repeat:no-repeat; background-position:center top; padding-top:5px' background='Images/iconA_blue.jpg' valign='top' align='center'>" + StoreOrderID + "</TD>";
    }
    else
    {
    strTable +="<TD onclick='ToggleImage(" + cnt + ");GetStoreInfo(" + StoreOrderID + ")' id=TDStore" + cnt  + " class='cls2a' style='width:5%;Height:49px; background-repeat:no-repeat; background-position:center top; padding-top:5px' background='Images/iconA_red.jpg' valign='top' align='center' >" + StoreOrderID + "</TD>";
    }
    
    strTable += "<TD><Table width='100%' border='0'><TR>"
    strTable +="<TD valign='top' ><span class='cls3' style='cursor:pointer' onclick='ToggleImage(" + cnt + ");GetStoreInfo(" + StoreOrderID + ")'>" + oDealer.DealerName + ":</span><span class='cls4'>" + " " +  oDealer.Address + "</Span></TD>";
    strTable += "</TR>";
    if(oDealer.URL != 'Not Available')
        {
            strTable += "<TR>";
            strTable += "<TD class='cls5' ><a href='http://";
            strTable += oDealer.URL + "' target='_blank'>" + oDealer.URL + "</a>";
            strTable += "</TD>";
            strTable += "</TR>";
        }
    strTable += "<TR>";
    strTable +="<TD class='cls5' colspan='3'>" + oDealer.Products + "</TD>";
    strTable += "</TR>";
        if(oDealer.StoreCount > 1)
        {
            var strLink = "frmDSdetailResults.aspx?CR=" + oDealer.CRID + "&lng=" + oDealer.Longitude + "&lat=" + oDealer.Latitude + "&SearchLng=" + SearchLng + "&SearchLat=" + SearchLat + "&SearchRange=" + SearchRange + "&Zip=" + Zip + "&ProductID=" + ProductID + "&GUID=" + document.getElementById("txtGUID").value + "&DealerID=" + oDealer.DealerID;
            var strRef="<a href='" + strLink +  "'>Click here to see all " + oDealer.StoreCount + " " + oDealer.DealerName + " locations" + "</a>";
            strTable += "<TR>";
            strTable += "<TD class='cls5' colspan='3'>";
            strTable += strRef;
            strTable += "<TD>";
            strTable += "</TR>";        
        }
    strTable += "</TR></Table></TD>"
        strTable += "<TR>";
    strTable +="<TD class='cls5' colspan='3'>&nbsp;</TD>";
    strTable += "</TR>";
    strTable += "</Table>";   
    
    return strTable;

}