﻿var _subList = "";
var jsonBusPoints = null;
var first = 0;
var Buschecked = true;
function LoadBusinessCats() {
    url = "ashx/GetPointsCategory.ashx?rnd=" + Math.random();
    $.getJSON(url, function (json) {
        var _html = "";

        for (_i = 0; _i < json.NewDataSet.Table.length; _i++) {
            if (first == 0) {
                _subList += json.NewDataSet.Table[_i].pk_id + ",";
            }
            if (_subList.indexOf(json.NewDataSet.Table[_i].pk_id) > -1)
                _html += "<input  checked='checked'  type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table[_i].Type + "' id='" + json.NewDataSet.Table[_i].pk_id + "' />" + json.NewDataSet.Table[_i].Type + "<br/>";
            else
                _html += "<input type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table[_i].Type + "' id='" + json.NewDataSet.Table[_i].pk_id + "' />" + json.NewDataSet.Table[_i].Type + "<br/>";
        }
        if (_html == "") {
            if (first == 0) {
                _subList += json.NewDataSet.Table.pk_id + ",";
            }
            try {
                if (_subList.indexOf(json.NewDataSet.Table.pk_id) > -1)
                    _html += "<input  checked='checked'  type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table.Type + "' id='" + json.NewDataSet.Table.pk_id + "' />" + json.NewDataSet.Table.Type + "<br/>";
                else
                    _html += "<input type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table.Type + "' id='" + json.NewDataSet.Table.pk_id + "' />" + json.NewDataSet.Table.Type + "<br/>";
            }
            catch (err) { }
        }
        if (first == 0) {
            first = 1;
            showBusinessPointsNoClose();
        }
        $("#businessPointsList").html(_html);
    });
}
function ShowBusinessCats() {
    //$("#BusinessPoints").dialog();
    //businessPointsList
    //{ "NewDataSet": {"Table": {"pk_id": "1", "Type": "Trudon" } }}

    url = "ashx/GetPointsCategory.ashx?rnd=" + Math.random();
    $.getJSON(url, function (json) {
        var _html = "";

        for (_i = 0; _i < json.NewDataSet.Table.length; _i++) {
            if (first == 0) {
                _subList += json.NewDataSet.Table[_i].pk_id + ",";
            }
            if (_subList.indexOf(json.NewDataSet.Table[_i].pk_id) > -1)
                _html += "<input  checked='checked'  type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table[_i].Type + "' id='" + json.NewDataSet.Table[_i].pk_id + "' />" + json.NewDataSet.Table[_i].Type + "<br/>";
            else
                _html += "<input type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table[_i].Type + "' id='" + json.NewDataSet.Table[_i].pk_id + "' />" + json.NewDataSet.Table[_i].Type + "<br/>";
        }
        if (_html == "") {
            if (first == 0) {
                _subList += json.NewDataSet.Table.pk_id + ",";
            }
            try {
                if (_subList.indexOf(json.NewDataSet.Table.pk_id) > -1)
                    _html += "<input  checked='checked'  type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table.Type + "' id='" + json.NewDataSet.Table.pk_id + "' />" + json.NewDataSet.Table.Type + "<br/>";
                else
                    _html += "<input type='checkbox' class='clsCheck' value='" + json.NewDataSet.Table.Type + "' id='" + json.NewDataSet.Table.pk_id + "' />" + json.NewDataSet.Table.Type + "<br/>";
            }
            catch (err) { }
        }
        if (first == 0) {
            first = 1;
            showBusinessPointsNoClose();
        }
        $("#businessPointsList").html(_html);
    });
    try {
        $('#BusinessPoints').modal();
    }
    catch (err) {

    }
    $('#BusinessPoints').modal();
}

function HideBusModal() {
    $.modal.close();
}
function ShowBusPointsPan() {
    if (_subList != "") {
        g_map.removeGroupOverlay("Business");
        var p_scale = g_map.getZoomLevel();

        var _list = "";

        _list += _subList;

        _list = _list.substring(0, _list.length - 1);
        var oBoundingBox = g_map.getBoundingBox();
        var oSouthWestCoords = oBoundingBox.getSouthWest();
        var oNorthEastCoords = oBoundingBox.getNorthEast();
        var _url = "ashx/GetPointsByCategoryBB.ashx?";
        _url = _url + "TopLat=" + oNorthEastCoords.latitude();
        _url = _url + "&TopLon=" + oNorthEastCoords.longitude();
        _url = _url + "&BottomLat=" + oSouthWestCoords.latitude();
        _url = _url + "&BottomLon=" + oSouthWestCoords.longitude();
        _url = _url + "&list=" + _subList;
        _url = _url + "&rndd=" + Math.random();
        $.getJSON(_url, function (json) {


            var _icount = 0;
            for (_i = 0; _i < json.NewDataSet.Table.length; _i++) {
                jsonBusPoints = json;
                _icount = _icount + 1;
                var _iconAnchor = new AGPoint(-10, -55);
                var myHTMLObj = new Image();
                myHTMLObj.setAttribute("id", _i);
                myHTMLObj.style.zIndex = 1;
                myHTMLObj.setAttribute("src", "images/blankPin_trudon_medium.png");
                myHTMLObj.setAttribute("title", json.NewDataSet.Table[_i].BusinessName);
                myHTMLObj.setAttribute("alt", _i);
                var _iconSize = new AGSize(42, 55);
                var opts = new AGHTMLOverlayOptions(_iconAnchor, _iconSize);

                var newCoord = new AGCoord(parseFloat(json.NewDataSet.Table[_i].lat), parseFloat(json.NewDataSet.Table[_i].lon));
                var htmlOverlay = new AGHTMLOverlay(myHTMLObj, newCoord, opts);
                g_map.addOverlay(htmlOverlay, "Business");

                // register mouse event
                AGEvent.addListener(htmlOverlay, "onclick", HTMLOverlayClickedbus1);
            }
            if (_icount == 0) {
                try {
                    jsonBusPoints = json;
                    _icount = _icount + 1;
                    var _iconAnchor = new AGPoint(-10, -55);
                    var myHTMLObj = new Image();
                    myHTMLObj.setAttribute("id", _icount);
                    myHTMLObj.style.zIndex = 1;
                    myHTMLObj.setAttribute("src", "images/blankPin_trudon_medium.png");
                    myHTMLObj.setAttribute("title", json.NewDataSet.Table.BusinessName);

                    var _iconSize = new AGSize(42, 55);
                    var opts = new AGHTMLOverlayOptions(_iconAnchor, _iconSize);

                    var newCoord = new AGCoord(parseFloat(json.NewDataSet.Table.lat), parseFloat(json.NewDataSet.Table.lon));
                    var htmlOverlay = new AGHTMLOverlay(myHTMLObj, newCoord, opts);
                    g_map.addOverlay(htmlOverlay, "Business");

                    // register mouse event
                    AGEvent.addListener(htmlOverlay, "onclick", HTMLOverlayClickedbus);


                }
                catch (err) { }
            }
        });
    }

}
function showBusinessPoints() {

    g_map.removeGroupOverlay("Business");
    var p_scale = g_map.getZoomLevel();

    var _list = "";
    $('.clsCheck').each(function (id, obj) {

        if (obj.checked) {
            _list += obj.id + ",";
        }
    });

    _subList = _list.substring(0, _list.length - 1);
    var oBoundingBox = g_map.getBoundingBox();
    var oSouthWestCoords = oBoundingBox.getSouthWest();
    var oNorthEastCoords = oBoundingBox.getNorthEast();
    var _url = "ashx/GetPointsByCategoryBB.ashx?";
    _url = _url + "TopLat=" + oNorthEastCoords.latitude();
    _url = _url + "&TopLon=" + oNorthEastCoords.longitude();
    _url = _url + "&BottomLat=" + oSouthWestCoords.latitude();
    _url = _url + "&BottomLon=" + oSouthWestCoords.longitude();
    _url = _url + "&list=" + _subList;
    _url = _url + "&rnd=" + Math.random();
    $.getJSON(_url, function (json) {


        var _icount = 0;
        for (_i = 0; _i < json.NewDataSet.Table.length; _i++) {
            jsonBusPoints = json;
            _icount = _icount + 1;
            var _iconAnchor = new AGPoint(-10, -55);
            var myHTMLObj = new Image();
            myHTMLObj.setAttribute("id", _i);
            myHTMLObj.style.zIndex = 1;
            myHTMLObj.setAttribute("src", "images/blankPin_trudon_medium.png");
            myHTMLObj.setAttribute("title", json.NewDataSet.Table[_i].BusinessName);
            myHTMLObj.setAttribute("alt", _i);
            var _iconSize = new AGSize(42, 55);
            var opts = new AGHTMLOverlayOptions(_iconAnchor, _iconSize);

            var newCoord = new AGCoord(parseFloat(json.NewDataSet.Table[_i].lat), parseFloat(json.NewDataSet.Table[_i].lon));
            var htmlOverlay = new AGHTMLOverlay(myHTMLObj, newCoord, opts);
            g_map.addOverlay(htmlOverlay, "Business");

            // register mouse event
            AGEvent.addListener(htmlOverlay, "onclick", HTMLOverlayClickedbus1);
        }
        if (_icount == 0) {
            try {
                jsonBusPoints = json;
                _icount = _icount + 1;
                var _iconAnchor = new AGPoint(-10, -55);
                var myHTMLObj = new Image();
                myHTMLObj.setAttribute("id", _icount);
                myHTMLObj.style.zIndex = 1;
                myHTMLObj.setAttribute("src", "images/blankPin_trudon_medium.png");
                myHTMLObj.setAttribute("title", json.NewDataSet.Table.BusinessName);

                var _iconSize = new AGSize(42, 55);
                var opts = new AGHTMLOverlayOptions(_iconAnchor, _iconSize);

                var newCoord = new AGCoord(parseFloat(json.NewDataSet.Table.lat), parseFloat(json.NewDataSet.Table.lon));
                var htmlOverlay = new AGHTMLOverlay(myHTMLObj, newCoord, opts);
                g_map.addOverlay(htmlOverlay, "Business");

                // register mouse event
                AGEvent.addListener(htmlOverlay, "onclick", HTMLOverlayClickedbus);


            }
            catch (err) { }
        }
    });

    $.modal.close();
}

function CheckAllPoints() {
    $('.clsCheck').each(function (id, obj) {

        obj.checked = true;
    });
}
function CheckNoPoints() {
    $('.clsCheck').each(function (id, obj) {

        obj.checked = false;
    });
}
function showBusinessPointsNoClose() {
    g_map.removeGroupOverlay("Business");
    var p_scale = g_map.getZoomLevel();


    var _list = "";
    $('.clsCheck').each(function (id, obj) {

        if (obj.checked) {
            _list += obj.id + ",";
        }
    });

    _subList = _list.substring(0, _list.length - 1);
    var oBoundingBox = g_map.getBoundingBox();
    var oSouthWestCoords = oBoundingBox.getSouthWest();
    var oNorthEastCoords = oBoundingBox.getNorthEast();
    var _url = "ashx/GetPointsByCategoryBB.ashx?";
    _url = _url + "TopLat=" + oNorthEastCoords.latitude();
    _url = _url + "&TopLon=" + oNorthEastCoords.longitude();
    _url = _url + "&BottomLat=" + oSouthWestCoords.latitude();
    _url = _url + "&BottomLon=" + oSouthWestCoords.longitude();
    _url = _url + "&list=" + _subList;
    $.getJSON(_url, function (json) {


        var _icount = 0;
        for (_i = 0; _i < json.NewDataSet.Table.length; _i++) {
            jsonBusPoints = json;
            _icount = _icount + 1;
            var _iconAnchor = new AGPoint(-10, -55);
            var myHTMLObj = new Image();
            myHTMLObj.setAttribute("id", _i);
            myHTMLObj.style.zIndex = 1;
            myHTMLObj.setAttribute("src", "images/blankPin_trudon.png");
            myHTMLObj.setAttribute("title", json.NewDataSet.Table[_i].BusinessName);
            myHTMLObj.setAttribute("alt", _i);
            var _iconSize = new AGSize(32, 42);
            var opts = new AGHTMLOverlayOptions(_iconAnchor, objectSize);

            var newCoord = new AGCoord(parseFloat(json.NewDataSet.Table[_i].lat), parseFloat(json.NewDataSet.Table[_i].lon));
            var htmlOverlay = new AGHTMLOverlay(myHTMLObj, newCoord, opts);
            g_map.addOverlay(htmlOverlay, "Business");

            // register mouse event
            AGEvent.addListener(htmlOverlay, "onclick", HTMLOverlayClickedbus1);
        }
        if (_icount == 0) {
            try {
                jsonBusPoints = json;
                _icount = _icount + 1;
                //                       var _iconAnchor = new AGPoint(-10, -55);
                //                       var _iconSize = new AGSize(32, 42);
                //                       var myHTMLObj = document.createElement('div');
                //                       myHTMLObj.style.zIndex = 1;
                //                       myHTMLObj.innerHTML = "<img class='clsBus' style='z-index:1' src='images/blankPin_trudon.png' title='" + json.NewDataSet.Table.BusinessName + "' />";
                //                       var _options = new AGHTMLOverlayOptions(_iconAnchor, _iconSize);
                //                       var myHTMLOverlay = new AGHTMLOverlay(myHTMLObj, new AGCoord(parseFloat(json.NewDataSet.Table.lat), parseFloat(json.NewDataSet.Table.lon)), _options);
                //                       g_map.addOverlay(myHTMLOverlay, "Business");
                //                       AGEvent.addListener(myHTMLOverlay, "onclick", ShowBubblePopupBusinessNoID);

                var _iconAnchor = new AGPoint(-10, -55);
                var myHTMLObj = new Image();
                myHTMLObj.setAttribute("id", _icount);
                myHTMLObj.style.zIndex = 1;
                myHTMLObj.setAttribute("src", "images/blankPin_trudon.png");
                myHTMLObj.setAttribute("title", json.NewDataSet.Table.BusinessName);

                var _iconSize = new AGSize(32, 42);
                var opts = new AGHTMLOverlayOptions(_iconAnchor, objectSize);

                var newCoord = new AGCoord(parseFloat(json.NewDataSet.Table.lat), parseFloat(json.NewDataSet.Table.lon));
                var htmlOverlay = new AGHTMLOverlay(myHTMLObj, newCoord, opts);
                g_map.addOverlay(htmlOverlay, "Business");

                // register mouse event
                AGEvent.addListener(htmlOverlay, "onclick", HTMLOverlayClickedbus);




            }
            catch (err) { }
        }
    });


}
function HTMLOverlayClickedbus(oLatLong, caller) {
    var obj = caller.getObject();

    ShowBubblePopupBusinessNoID();
}
function HTMLOverlayClickedbus1(oLatLong, caller) {
    var obj = caller.getObject();

    ShowBubblePopupBusiness(obj.alt);
}
function HookPopupBusiness(id) {
    return function (oCoord) {
        //alert("Record: " + id + "\nLat, Lon: " + oCoord.latitude() + ", " + oCoord.longitude());
        ShowBubblePopupBusiness(id);
    }
}
function HookPopup(id) {
    return function (oCoord) {
        //alert("Record: " + id + "\nLat, Lon: " + oCoord.latitude() + ", " + oCoord.longitude());
        ShowBubblePopup(id);
    }
}

function ShowBubblePopupBusiness(id) {
    iWidth = 450;
    height = 450;
    //{ "NewDataSet": { "Table": [ {"Address": "24 South Boulevard, Block F Eastgate Park, Bruma", "Branch": "Johannesburg", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(011) 6776830", "fk_TypeID": "1", "lat": "-26.178822", "lon": "28.11277", "pk_id": "2", "Tel": "(011) 6776000", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "Unit 13, 1st Floor\u000a5 Bauhinia Street, Cambridge Park\u000aHighvield Techno Park, Centurion", "Branch": "Pretoria", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(012) 663-3699", "fk_TypeID": "1", "lat": "-25.879365", "lon": "28.182341", "pk_id": "4", "Tel": "(012) 678-9800", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "6th Floor, Edward Nathan Sonnenberg House (ENS House), 2 Lower Loop Street, Foreshore", "Branch": "Cape Town", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(021) 425-3809", "fk_TypeID": "1", "lat": "-33.915192", "lon": "18.426766", "pk_id": "5", "Tel": "(021) 408-1700", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "174 Florida Road, 2nd Floor, Morningside.", "Branch": "Durban", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(031) 303-7901", "fk_TypeID": "1", "lat": "-29.832641", "lon": "31.016694", "pk_id": "6", "Tel": "(031) 365-0100", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "17th Avenue, TDS House, Walmer Park", "Branch": "Port Elizabeth", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(041) 368-5511", "fk_TypeID": "1", "lat": "-33.954051", "lon": "25.613549", "pk_id": "7", "Tel": "(041) 503-9600", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "29 Tecoma Street, Berea, East London.", "Branch": "East London", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(043) 727-0122", "fk_TypeID": "1", "lat": "-32.989993", "lon": "27.91204", "pk_id": "8", "Tel": "(043) 705-6600", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "94 Palm Park, Kellner Street, Westdene", "Branch": "Bloemfontein & Northern Cape", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(051) 448-0342", "fk_TypeID": "1", "lat": "-29.105952", "lon": "26.208143", "pk_id": "9", "Tel": "(051) 411-8800", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "5th Floor, Sanlam Centre, Independence Avenue, Windhoek", "Branch": "Namibia", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(+00264) 61 383959", "fk_TypeID": "1", "lat": "-22.558904", "lon": "17.082481", "pk_id": "10", "Tel": "(+00264) 61 383950", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" } ] }}
    $(".bottomArrow").each(function () {
        $(this).hide();

    }
    );
    coord = new AGCoord(parseFloat(jsonBusPoints.NewDataSet.Table[id].lat), parseFloat(jsonBusPoints.NewDataSet.Table[id].lon));
    bubbleString = "<p style='font-size:12pt;font-weight:bold;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table[id].BusinessName + "</p><br/><br/>";
    if (jsonBusPoints.NewDataSet.Table[id].Branch != "")
        bubbleString += "<table valign='top'  cellpadding='2' cellspacing='2'><tr><td style='font-size:8pt;font-weight:bold;font-family:arial;' width='150px'>Branch</ td><td width='250px' style='font-size:8pt;font-weight:normal;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table[id].Branch + "</td><td rowspan='7' valign='bottom'><img style='width:100px;' src='images/" + jsonBusPoints.NewDataSet.Table[id].logo + "'/></td></tr>";
    if (jsonBusPoints.NewDataSet.Table[id].Address != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Address</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table[id].Address + "</a></td></tr>";
    if (jsonBusPoints.NewDataSet.Table[id].Website != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Website</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'><a href='" + jsonBusPoints.NewDataSet.Table[id].Website + "' target='_blank'>" + jsonBusPoints.NewDataSet.Table[id].Website + "</a></td></tr>";
    if (jsonBusPoints.NewDataSet.Table[id].CCNumber != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Customer Care</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'> " + jsonBusPoints.NewDataSet.Table[id].CCNumber + "</td></tr>";
    if (jsonBusPoints.NewDataSet.Table[id].Tel != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Tel Number</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'> " + jsonBusPoints.NewDataSet.Table[id].Tel + "</td></tr>";
    if (jsonBusPoints.NewDataSet.Table[id].fax != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Fax Number</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'> " + jsonBusPoints.NewDataSet.Table[id].fax + "</td></tr>";
    if (jsonBusPoints.NewDataSet.Table[id].TradingHours != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Trading Hours</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table[id].TradingHours + "</td></tr>";
    bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Customer Care</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'><a href='mailto:customercare@trudon.co.za' >customercare@trudon.co.za</a></td></tr>";
    bubbleString += "</table>";
    bubbleString += "<br/><p style='font-size:8pt;font-weight:bold;font-family:arial;'><a style='font-size:8pt;font-family:arial;' href='javascript:{}' onclick='directions.AddDirection(" + jsonBusPoints.NewDataSet.Table[id].lat + "," + jsonBusPoints.NewDataSet.Table[id].lon + ",\"" + jsonBusPoints.NewDataSet.Table[id].BusinessName + "\");'>Get Directions&nbsp;&nbsp;</a></p>";

    ShowBubble(1, parseInt(height), parseInt(iWidth), 10, 30, parseFloat(jsonBusPoints.NewDataSet.Table[id].lat), parseFloat(jsonBusPoints.NewDataSet.Table[id].lon), g_map, bubbleString)
    //    _options = new AGInfoDisplayOptions();
    //    _options.width = parseInt(iWidth);
    //    _options.height = parseInt(height);
    //    _options.pixelOffset = new AGPoint(0, -30);
    //    g_map.openInfoDisplayHTML(coord, bubbleString, _options);
    var _info = g_map.getInfoDisplay();

}
function ShowBubblePopupBusinessNoID() {
    $(".bottomArrow").each(function () {
        $(this).hide();

    }
    );
    iWidth = 450;
    height = 450;
    //{ "NewDataSet": { "Table": [ {"Address": "24 South Boulevard, Block F Eastgate Park, Bruma", "Branch": "Johannesburg", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(011) 6776830", "fk_TypeID": "1", "lat": "-26.178822", "lon": "28.11277", "pk_id": "2", "Tel": "(011) 6776000", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "Unit 13, 1st Floor\u000a5 Bauhinia Street, Cambridge Park\u000aHighvield Techno Park, Centurion", "Branch": "Pretoria", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(012) 663-3699", "fk_TypeID": "1", "lat": "-25.879365", "lon": "28.182341", "pk_id": "4", "Tel": "(012) 678-9800", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "6th Floor, Edward Nathan Sonnenberg House (ENS House), 2 Lower Loop Street, Foreshore", "Branch": "Cape Town", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(021) 425-3809", "fk_TypeID": "1", "lat": "-33.915192", "lon": "18.426766", "pk_id": "5", "Tel": "(021) 408-1700", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "174 Florida Road, 2nd Floor, Morningside.", "Branch": "Durban", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(031) 303-7901", "fk_TypeID": "1", "lat": "-29.832641", "lon": "31.016694", "pk_id": "6", "Tel": "(031) 365-0100", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "17th Avenue, TDS House, Walmer Park", "Branch": "Port Elizabeth", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(041) 368-5511", "fk_TypeID": "1", "lat": "-33.954051", "lon": "25.613549", "pk_id": "7", "Tel": "(041) 503-9600", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "29 Tecoma Street, Berea, East London.", "Branch": "East London", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(043) 727-0122", "fk_TypeID": "1", "lat": "-32.989993", "lon": "27.91204", "pk_id": "8", "Tel": "(043) 705-6600", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "94 Palm Park, Kellner Street, Westdene", "Branch": "Bloemfontein & Northern Cape", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(051) 448-0342", "fk_TypeID": "1", "lat": "-29.105952", "lon": "26.208143", "pk_id": "9", "Tel": "(051) 411-8800", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" }, {"Address": "5th Floor, Sanlam Centre, Independence Avenue, Windhoek", "Branch": "Namibia", "BusinessName": "Trudon(Pty) Ltd", "CCNumber": "0860 93 5569", "fax": "(+00264) 61 383959", "fk_TypeID": "1", "lat": "-22.558904", "lon": "17.082481", "pk_id": "10", "Tel": "(+00264) 61 383950", "TradingHours": "Mon-Fri                        07:45-15:45", "Website": "http:\/\/www.trudon.co.za" } ] }}

    coord = new AGCoord(parseFloat(jsonBusPoints.NewDataSet.Table.lat), parseFloat(jsonBusPoints.NewDataSet.Table.lon));
    bubbleString = "<p style='font-size:12pt;font-weight:bold;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table.BusinessName + "</p><br/><br/>";
    if (jsonBusPoints.NewDataSet.Table.Branch != "")
        bubbleString += "<table valign='top'  cellpadding='2' cellspacing='2'><tr><td style='font-size:8pt;font-weight:bold;font-family:arial;' width='150px'>Branch</ td><td width='250px' style='font-size:8pt;font-weight:normal;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table.Branch + "</td><td rowspan='7' valign='bottom'><img style='width:100px;' src='images/" + jsonBusPoints.NewDataSet.Table.logo + "'/></td></tr>";
    if (jsonBusPoints.NewDataSet.Table.Address != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Address</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table.Address + "</a></td></tr>";
    if (jsonBusPoints.NewDataSet.Table.Website != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Website</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'><a href='" + jsonBusPoints.NewDataSet.Table.Website + "' target='_blank'>" + jsonBusPoints.NewDataSet.Table.Website + "</a></td></tr>";
    if (jsonBusPoints.NewDataSet.Table.CCNumber != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Customer Care</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'> " + jsonBusPoints.NewDataSet.Table.CCNumber + "</td></tr>";
    if (jsonBusPoints.NewDataSet.Table.Tel != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Tel Number</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'> " + jsonBusPoints.NewDataSet.Table.Tel + "</td></tr>";
    if (jsonBusPoints.NewDataSet.Table.fax != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Fax Number</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'> " + jsonBusPoints.NewDataSet.Table.fax + "</td></tr>";
    if (jsonBusPoints.NewDataSet.Table.TradingHours != "")
        bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Trading Hours</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'>" + jsonBusPoints.NewDataSet.Table.TradingHours + "</td></tr>";
    bubbleString += "<tr><td style='font-size:8pt;font-weight:bold;font-family:arial;'>Customer Care</ td><td  style='font-size:8pt;font-weight:normal;font-family:arial;'><a href='mailto:customercare@trudon.co.za' >customercare@trudon.co.za</a></td></tr>";
    bubbleString += "</table>";
    bubbleString += "<br/><p style='font-size:8pt;font-weight:bold;font-family:arial;'><a style='font-size:8pt;font-family:arial;' href='javascript:{}' onclick='directions.AddDirection(" + jsonBusPoints.NewDataSet.Table.lat + "," + jsonBusPoints.NewDataSet.Table.lon + ",\"" + jsonBusPoints.NewDataSet.Table.BusinessName + "\");'>Get Directions&nbsp;&nbsp;</a></p>";

    ShowBubble(1, parseInt(height), parseInt(iWidth), 10, 30, parseFloat(jsonBusPoints.NewDataSet.Table.lat), parseFloat(jsonBusPoints.NewDataSet.Table.lon), g_map, bubbleString)
    //    _options = new AGInfoDisplayOptions();
    //    _options.width = parseInt(iWidth);
    //    _options.height = parseInt(height);
    //    _options.pixelOffset = new AGPoint(0, -30);
    //    g_map.openInfoDisplayHTML(coord, bubbleString, _options);
    var _info = g_map.getInfoDisplay()

}
