public static string GenerateHtml(DataAccessLayer DAL)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html><head>");
            sb.AppendLine(String.Format("<title>TwoTrails Draw For Web Browsers (Project: {0})</title>",DAL.GetProjectID()));
            sb.AppendLine(@"<style type=""text/css"">");
            sb.AppendLine(CSS);
            sb.AppendLine(CSSTREE);
            sb.AppendLine("</style>");
            sb.AppendLine(@"<script src=""https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false""></script>");
            sb.AppendLine("<script>");
            sb.AppendLine(JQUERY);
            sb.AppendLine(JSTREE);
            sb.AppendLine();
            sb.AppendLine(JSGEOM);
            sb.AppendLine();
            sb.AppendLine(JSGEO);
            sb.AppendLine();
            sb.AppendLine(JSINIT);
            sb.AppendLine();

            sb.AppendLine("function create(){");

            sb.AppendLine("function makeMapListener(window, map, markers) {");
            sb.AppendLine("\treturn function() { window.open(map, markers); };");
            sb.AppendLine("}");
            sb.AppendLine();

            sb.AppendLine("var bounds = new google.maps.LatLngBounds();");
            sb.AppendLine("function AutoCenter(coordList) {");
            sb.AppendLine("for(var i=0; i < coordList.length; i++){");
            sb.AppendLine("\tif(coordList[i].lat() != 0 && coordList[i].lng() != 0)");
            sb.AppendLine("\t{");
            sb.AppendLine("\t\tbounds.extend(coordList[i]);");
            sb.AppendLine("}}}");
            sb.AppendLine();

            sb.AppendLine("function FitMap(boundary) {");
            sb.AppendLine("map.fitBounds(boundary);");
            sb.AppendLine("}");
            sb.AppendLine();

            //html for tree
            StringBuilder jst = new StringBuilder();

            string id = String.Empty;
            int _id = 1;

            if (DAL.GetPolyCount() > 0)
            {
                jst.AppendLine("<ul>");

                List<TtPoint> points, tmpPoints;
                List<string> checkedPolys = new List<string>();
                bool hasWaypoints = false, hasMiscPoints;

                string idAdjBnd, idUnadjBnd, idAdjNav, idUnadjNav, idAdjBndPt, idUnadjBndPt,
                    idAdjNavPt, idUnadjNavPt, idWayPt, idMiscAdjPt, idMiscUnadjPt, idAllPt;

                foreach (TtPolygon poly in DAL.GetPolygons())
                {
                    jst.AppendLine(String.Format("<li class=\"jstree-open\">{0}<ul>", poly.Name));

                    points = DAL.GetPointsInPolygon(poly.CN);

                    if (points.Count > 0)
                    {
                        hasWaypoints = (points.Where(p => p.op == TwoTrails.Engine.OpType.WayPoint).Any());
                        hasMiscPoints = (points.Where(p => p.op == TwoTrails.Engine.OpType.SideShot && !p.OnBnd).Any());

                        StringBuilder coordArray = new StringBuilder();
                        StringBuilder pmArray = new StringBuilder();
                        StringBuilder infoArray = new StringBuilder();

                        TtPoint tmpPoint;
                        double lat, lon;

                        TtMetaData meta = DAL.GetMetaDataByCN(Engine.Values.EmptyGuid);
                        if (meta == null)
                            meta = DAL.GetMetaData()[0];

                        int zone = meta.Zone;

                        #region Adjusted Boundary

                        tmpPoints = points.Where(p => p.IsBndPoint()).ToList();

                        if (tmpPoints.Count > 0)
                        {
                            idAdjBnd = GetId(ref _id);
                            checkedPolys.Add(idAdjBnd);
                            idAdjBndPt = GetId(ref _id);
                            //checkedPolys.Add(idAdjBndPt);
                            jst.AppendLine(String.Format("<li>Adj Boundary<ul><li id =\"{0}\">Polygon</li><li id=\"{1}\">Points</li></ul></li>", idAdjBnd, idAdjBndPt));

                            coordArray.AppendFormat("var {0} = [", GetCoordId(idAdjBnd));
                            pmArray.AppendFormat("var {0} = [", GetPlacemarkId(idAdjBnd));
                            infoArray.AppendFormat("var {0} = [", GetInfoId(idAdjBnd));

                            for (int i = 0; i < tmpPoints.Count - 1; i++)
                            {
                                tmpPoint = tmpPoints[i];

                                TtUtils.UTMtoLatLon(tmpPoint.AdjX, tmpPoint.AdjY, zone, out lat, out lon);

                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                    lat, lon, tmpPoint.PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, true));
                            }

                            TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].AdjX, tmpPoints[tmpPoints.Count - 1].AdjY, zone, out lat, out lon);
                            coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                            pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                            infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], true));

                            coordArray.AppendLine("];");
                            pmArray.AppendLine("];");
                            infoArray.AppendLine("];");

                            sb.AppendLine(coordArray.ToString());
                            sb.AppendLine(pmArray.ToString());
                            sb.AppendLine(infoArray.ToString());

                            sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idAdjBnd)));
                            sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                            sb.AppendLine("}");
                            sb.AppendLine();

                            sb.AppendLine(String.Format("objlist.push(new GPoly(\"{0}\", map, true, {1}, '#{2}', {3}, 3, '#{2}', {4}));",
                                idAdjBnd, GetCoordId(idAdjBnd), AdjBoundaryColor, BoundaryOpacity, PolygonOpacity));
                            sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idAdjBndPt, GetPlacemarkId(idAdjBnd)));
                            sb.AppendLine();

                            sb.AppendLine("AutoCenter(coord);");
                            sb.AppendLine();
                        }
                        #endregion

                        #region Adjusted Navigation
                        tmpPoints = points.Where(p => p.IsNavPoint()).ToList();

                        if (tmpPoints.Count > 0)
                        {
                            coordArray = new StringBuilder();
                            pmArray = new StringBuilder();
                            infoArray = new StringBuilder();

                            idAdjNav = GetId(ref _id);
                            idAdjNavPt = GetId(ref _id);
                            jst.AppendLine(String.Format("<li>Adj Navigation<ul><li id =\"{0}\">Path</li><li id=\"{1}\">Points</li></ul></li>", idAdjNav, idAdjNavPt));

                            coordArray.AppendFormat("{0} = [", GetCoordId(idAdjNav));
                            pmArray.AppendFormat("{0} = [", GetPlacemarkId(idAdjNav));
                            infoArray.AppendFormat("{0} = [", GetInfoId(idAdjNav));

                            for (int i = 0; i < tmpPoints.Count - 1; i++)
                            {
                                tmpPoint = tmpPoints[i];

                                TtUtils.UTMtoLatLon(tmpPoint.AdjX, tmpPoint.AdjY, zone, out lat, out lon);

                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                    lat, lon, tmpPoint.PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, true));
                            }

                            TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].AdjX, tmpPoints[tmpPoints.Count - 1].AdjY, zone, out lat, out lon);
                            coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                            pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                            infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], true));

                            coordArray.AppendLine("];");
                            pmArray.AppendLine("];");
                            infoArray.AppendLine("];");

                            sb.AppendLine(coordArray.ToString());
                            sb.AppendLine(pmArray.ToString());
                            sb.AppendLine(infoArray.ToString());

                            sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idAdjNav)));
                            sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                            sb.AppendLine("}");
                            sb.AppendLine();

                            sb.AppendLine(String.Format("objlist.push(new GPath(\"{0}\", map, false, {1}, '#{2}', {3}));",
                                idAdjNav, GetCoordId(idAdjNav), AdjNavigationColor, NavigationOpacity));
                            sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idAdjNavPt, GetPlacemarkId(idAdjNav)));
                            sb.AppendLine();
                        }
                        #endregion

                        #region Unadjusted Boundary
                        tmpPoints = points.Where(p => p.IsBndPoint()).ToList();
                        if (tmpPoints.Count > 0)
                        {
                            coordArray = new StringBuilder();
                            pmArray = new StringBuilder();
                            infoArray = new StringBuilder();

                            idUnadjBnd = GetId(ref _id);
                            idUnadjBndPt = GetId(ref _id);
                            jst.AppendLine(String.Format("<li>UnAdj Boundary<ul><li id =\"{0}\">Polygon</li><li id=\"{1}\">Points</li></ul></li>", idUnadjBnd, idUnadjBndPt));

                            coordArray.AppendFormat("{0} = [", GetCoordId(idUnadjBnd));
                            pmArray.AppendFormat("{0} = [", GetPlacemarkId(idUnadjBnd));
                            infoArray.AppendFormat("{0} = [", GetInfoId(idUnadjBnd));

                            for (int i = 0; i < tmpPoints.Count - 1; i++)
                            {
                                tmpPoint = tmpPoints[i];

                                TtUtils.UTMtoLatLon(tmpPoint.UnAdjX, tmpPoint.UnAdjY, zone, out lat, out lon);

                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                    lat, lon, tmpPoint.PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, false));
                            }

                            TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].UnAdjX, tmpPoints[tmpPoints.Count - 1].UnAdjY, zone, out lat, out lon);
                            coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                            pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                            infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], false));

                            coordArray.AppendLine("];");
                            pmArray.AppendLine("];");
                            infoArray.AppendLine("];");

                            sb.AppendLine(coordArray.ToString());
                            sb.AppendLine(pmArray.ToString());
                            sb.AppendLine(infoArray.ToString());

                            sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idUnadjBnd)));
                            sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                            sb.AppendLine("}");
                            sb.AppendLine();

                            sb.AppendLine(String.Format("objlist.push(new GPoly(\"{0}\", map, false, {1}, '#{2}', {3}, 3, '#{2}', {4}));",
                                idUnadjBnd, GetCoordId(idUnadjBnd), UnAdjBoundaryColor, BoundaryOpacity, PolygonOpacity));
                            sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idUnadjBndPt, GetPlacemarkId(idUnadjBnd)));
                            sb.AppendLine();
                        }
                        #endregion

                        #region Unadjusted Navigation
                        tmpPoints = points.Where(p => p.IsNavPoint()).ToList();

                        if (tmpPoints.Count > 0)
                        {
                            coordArray = new StringBuilder();
                            pmArray = new StringBuilder();
                            infoArray = new StringBuilder();

                            idUnadjNav = GetId(ref _id);
                            idUnadjNavPt = GetId(ref _id);
                            jst.AppendLine(String.Format("<li>UnAdj Navigation<ul><li id =\"{0}\">Path</li><li id=\"{1}\">Points</li></ul></li>", idUnadjNav, idUnadjNavPt));

                            coordArray.AppendFormat("{0} = [", GetCoordId(idUnadjNav));
                            pmArray.AppendFormat("{0} = [", GetPlacemarkId(idUnadjNav));
                            infoArray.AppendFormat("{0} = [", GetInfoId(idUnadjNav));

                            for (int i = 0; i < tmpPoints.Count - 1; i++)
                            {
                                tmpPoint = tmpPoints[i];

                                TtUtils.UTMtoLatLon(tmpPoint.UnAdjX, tmpPoint.UnAdjY, zone, out lat, out lon);

                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                    lat, lon, tmpPoint.PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, false));
                            }

                            TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].UnAdjX, tmpPoints[tmpPoints.Count - 1].UnAdjY, zone, out lat, out lon);
                            coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                            pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                            infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], false));

                            coordArray.AppendLine("];");
                            pmArray.AppendLine("];");
                            infoArray.AppendLine("];");

                            sb.AppendLine(coordArray.ToString());
                            sb.AppendLine(pmArray.ToString());
                            sb.AppendLine(infoArray.ToString());

                            sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idUnadjNav)));
                            sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                            sb.AppendLine("}");
                            sb.AppendLine();

                            sb.AppendLine(String.Format("objlist.push(new GPath(\"{0}\", map, false, {1}, '#{2}', {3}));",
                                idUnadjNav, GetCoordId(idUnadjNav), UnAdjNavigationColor, NavigationOpacity));
                            sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idUnadjNavPt, GetPlacemarkId(idUnadjNav)));
                            sb.AppendLine();
                        }
                        #endregion

                        #region MiscPoints
                        if (hasMiscPoints)
                        {
                            tmpPoints = (points.Where(p => p.op == TwoTrails.Engine.OpType.SideShot && !p.OnBnd)).ToList();

                            if (tmpPoints.Count > 0)
                            {
                                coordArray = new StringBuilder();
                                pmArray = new StringBuilder();
                                infoArray = new StringBuilder();

                                #region Adjusted
                                idMiscAdjPt = GetId(ref _id);
                                idMiscUnadjPt = GetId(ref _id);
                                jst.AppendLine(String.Format("<li>Misc Points<ul><li id =\"{0}\">Adjusted</li><li id=\"{1}\">Unadjusted</li></ul></li>", idMiscAdjPt, idMiscUnadjPt));

                                coordArray.AppendFormat("{0} = [", GetCoordId(idMiscAdjPt));
                                pmArray.AppendFormat("{0} = [", GetPlacemarkId(idMiscAdjPt));
                                infoArray.AppendFormat("{0} = [", GetInfoId(idMiscAdjPt));

                                for (int i = 0; i < tmpPoints.Count - 1; i++)
                                {
                                    tmpPoint = tmpPoints[i];

                                    TtUtils.UTMtoLatLon(tmpPoint.AdjX, tmpPoint.AdjY, zone, out lat, out lon);

                                    coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                    pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                        lat, lon, tmpPoint.PID);
                                    infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, true));
                                }

                                TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].AdjX, tmpPoints[tmpPoints.Count - 1].AdjY, zone, out lat, out lon);
                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], true));

                                coordArray.AppendLine("];");
                                pmArray.AppendLine("];");
                                infoArray.AppendLine("];");

                                sb.AppendLine(coordArray.ToString());
                                sb.AppendLine(pmArray.ToString());
                                sb.AppendLine(infoArray.ToString());

                                sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idMiscAdjPt)));
                                sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                                sb.AppendLine("}");
                                sb.AppendLine();

                                sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idMiscAdjPt, GetPlacemarkId(idMiscAdjPt)));
                                sb.AppendLine();
                                #endregion

                                #region Unadjsuted

                                coordArray.AppendFormat("{0} = [", GetCoordId(idMiscUnadjPt));
                                pmArray.AppendFormat("{0} = [", GetPlacemarkId(idMiscUnadjPt));
                                infoArray.AppendFormat("{0} = [", GetInfoId(idMiscUnadjPt));

                                for (int i = 0; i < tmpPoints.Count - 1; i++)
                                {
                                    tmpPoint = tmpPoints[i];

                                    TtUtils.UTMtoLatLon(tmpPoint.UnAdjX, tmpPoint.UnAdjY, zone, out lat, out lon);

                                    coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                    pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                        lat, lon, tmpPoint.PID);
                                    infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, false));
                                }

                                TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].UnAdjX, tmpPoints[tmpPoints.Count - 1].UnAdjY, zone, out lat, out lon);
                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], false));

                                coordArray.AppendLine("];");
                                pmArray.AppendLine("];");
                                infoArray.AppendLine("];");

                                sb.AppendLine(coordArray.ToString());
                                sb.AppendLine(pmArray.ToString());
                                sb.AppendLine(infoArray.ToString());

                                sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idMiscUnadjPt)));
                                sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                                sb.AppendLine("}");
                                sb.AppendLine();

                                sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idMiscUnadjPt, GetPlacemarkId(idMiscUnadjPt)));
                                sb.AppendLine();
                            }
                            #endregion
                        }
                        #endregion

                        #region Waypoints
                        if (hasWaypoints)
                        {
                            tmpPoints = points.Where(p => p.op == TwoTrails.Engine.OpType.WayPoint).ToList();

                            if (tmpPoints.Count > 0)
                            {
                                coordArray = new StringBuilder();
                                pmArray = new StringBuilder();
                                infoArray = new StringBuilder();

                                idWayPt = GetId(ref _id);
                                jst.AppendLine(String.Format("<li id=\"{0}\">Waypoints</li>", idWayPt));

                                coordArray.AppendFormat("{0} = [", GetCoordId(idWayPt));
                                pmArray.AppendFormat("{0} = [", GetPlacemarkId(idWayPt));
                                infoArray.AppendFormat("{0} = [", GetInfoId(idWayPt));

                                for (int i = 0; i < tmpPoints.Count - 1; i++)
                                {
                                    tmpPoint = tmpPoints[i];

                                    TtUtils.UTMtoLatLon(tmpPoint.AdjX, tmpPoint.AdjY, zone, out lat, out lon);

                                    coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                                    pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                        lat, lon, tmpPoint.PID);
                                    infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, true));
                                }

                                TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].AdjX, tmpPoints[tmpPoints.Count - 1].AdjY, zone, out lat, out lon);
                                coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                                pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                                infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], true));

                                coordArray.AppendLine("];");
                                pmArray.AppendLine("];");
                                infoArray.AppendLine("];");

                                sb.AppendLine(coordArray.ToString());
                                sb.AppendLine(pmArray.ToString());
                                sb.AppendLine(infoArray.ToString());

                                sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idWayPt)));
                                sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                                sb.AppendLine("}");
                                sb.AppendLine();

                                sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idWayPt, GetPlacemarkId(idWayPt)));
                                sb.AppendLine();
                            }
                        }
                        #endregion

                        #region All Points
                        coordArray = new StringBuilder();
                        pmArray = new StringBuilder();
                        infoArray = new StringBuilder();

                        idAllPt = GetId(ref _id);
                        jst.AppendLine(String.Format("<li id=\"{0}\">All Points</li>", idAllPt));

                        coordArray.AppendFormat("{0} = [", GetCoordId(idAllPt));
                        pmArray.AppendFormat("{0} = [", GetPlacemarkId(idAllPt));
                        infoArray.AppendFormat("{0} = [", GetInfoId(idAllPt));

                        tmpPoints = points;

                        for (int i = 0; i < tmpPoints.Count - 1; i++)
                        {
                            tmpPoint = tmpPoints[i];

                            TtUtils.UTMtoLatLon(tmpPoint.AdjX, tmpPoint.AdjY, zone, out lat, out lon);

                            coordArray.AppendFormat("new google.maps.LatLng({0}, {1}),", lat, lon);
                            pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }}),",
                                lat, lon, tmpPoint.PID);
                            infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }}),", GetPointInfo(tmpPoint, true));
                        }

                        TtUtils.UTMtoLatLon(tmpPoints[tmpPoints.Count - 1].AdjX, tmpPoints[tmpPoints.Count - 1].AdjY, zone, out lat, out lon);
                        coordArray.AppendFormat("new google.maps.LatLng({0}, {1})", lat, lon);
                        pmArray.AppendFormat("new google.maps.Marker({{position : new google.maps.LatLng({0}, {1}), map : null, title : 'Point {2}' }})", lat, lon, tmpPoints[tmpPoints.Count - 1].PID);
                        infoArray.AppendFormat("new google.maps.InfoWindow({{ content : '{0}' }})", GetPointInfo(tmpPoints[tmpPoints.Count - 1], true));

                        coordArray.AppendLine("];");
                        pmArray.AppendLine("];");
                        infoArray.AppendLine("];");

                        sb.AppendLine(coordArray.ToString());
                        sb.AppendLine(pmArray.ToString());
                        sb.AppendLine(infoArray.ToString());

                        sb.AppendLine(String.Format("for(var i=0; i < {0}.length; i++){{", GetCoordId(idAllPt)));
                        sb.AppendLine(String.Format("\tgoogle.maps.event.addListener(pm[i], 'click', makeMapListener(info[i], map, pm[i]));"));
                        sb.AppendLine("}");
                        sb.AppendLine();

                        sb.AppendLine(String.Format("objlist.push(new GMarkers(\"{0}\", map, false, {1}));", idAllPt, GetPlacemarkId(idAllPt)));
                        sb.AppendLine();
                        #endregion

                        //map move listener for utmXYZ
                        sb.AppendLine(@"google.maps.event.addListener(map, 'mousemove', function(event){var ll=new LatLng(event.latLng.lat(), event.latLng.lng());var utm=ll.toUTMRef();document.getElementById('utmX').innerHTML=""UTM X: ""+utm.easting.toFixed(2);document.getElementById('utmY').innerHTML=""UTM Y: ""+utm.northing.toFixed(2);document.getElementById('zone').innerHTML=""Zone: ""+utm.lngZone;});");
                        //poly move listener for utmXYZ -poly overrides map so it needs a listener
                        sb.AppendLine(@"for(var i=0;i<objlist.length;i++){if(objlist[i].type == 'gpoly'){google.maps.event.addListener(objlist[i].poly, 'mousemove', function(event){var ll=new LatLng(event.latLng.lat(), event.latLng.lng());var utm=ll.toUTMRef();document.getElementById('utmX').innerHTML=""UTM X: ""+utm.easting.toFixed(2);document.getElementById('utmY').innerHTML=""UTM Y: ""+utm.northing.toFixed(2);document.getElementById('zone').innerHTML=""Zone: ""+utm.lngZone;});}}");

                        sb.AppendLine();
                        sb.AppendLine("FitMap(bounds);");
                    }
                    else
                    {
                        jst.AppendLine("<li>No Points</li>");
                    }

                    jst.AppendLine("</ul></li>");
                }
                jst.AppendLine("</ul>");

                sb.AppendLine("}");

                sb.AppendLine("function treeLoaded(event, data) {");
                sb.Append("\tdata.instance.select_node([");

                if (checkedPolys.Count > 0)
                {
                    for (int i = 0; i < checkedPolys.Count - 1; i++)
                    {
                        sb.AppendFormat("'{0}',", checkedPolys[i]);
                    }

                    sb.AppendFormat("'{0}'", checkedPolys[checkedPolys.Count - 1]);
                }

                sb.AppendLine("]);");
                sb.AppendLine("}");
            }
            else
            {
                jst = null;
                sb.AppendLine("}");
            }

            sb.AppendLine("</script>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");
            sb.AppendLine(@"<div id=""map-canvas""></div>");
            sb.AppendLine(@"<div id=""loc"">");
            sb.AppendLine(@"<div id=""utmX"" class=""utm""></div>");
            sb.AppendLine(@"<div id=""utmY"" class=""utm""></div>");
            sb.AppendLine(@"<div id=""zone""></div>");
            sb.AppendLine(@"</div>");
            sb.AppendLine(@"<div id=""menu"" class=""dropSheet"">");
            sb.AppendLine(@"<div id=""innerdiv"">");
            sb.AppendLine(@"<div id=""title"" style=""text"">Polygons</div>");

            if (jst != null)
            {
                sb.AppendLine(@"<div id=""jstree_div"">");
                sb.AppendLine(jst.ToString());
                sb.AppendLine("</div>");
            }
            else
            {
                sb.AppendLine("No Polygons");
            }

            sb.AppendLine("</div>");
            sb.AppendLine("</div>");
            sb.AppendLine("</body>");
            sb.AppendLine("</html>");

            return sb.ToString();
        }