﻿
////////




	
	document.write('<link href="/Css/PowerMap.css" rel="stylesheet"/>');
	
	DataFloat.Agora.RealMap = function(divMap){
        
        $AgoraLog.WriteLog('[DataFloat.Agora.RealMap] - Initializing');

        $('#' + divMap).addClass('Agora_PowerMap');

        //Private Properties (Suppose to be private)
        this.DrawAreaLayer = new VEShapeLayer();
        this.DivMap = divMap;
		this.FncEndDraw = null;
		
		
		
		
		
		
        
        //Public Properties
        this.DefaultElementImage    = this.PinObject("/Images/agora_map_element.png");
        this.DefaultElementImageOn  = this.PinObject("/Images/agora_map_element_on.png");
        this.DefaultZoom            = 9;
		this.DrawAreas				= null;
		this.DeleteDrawArea			= null;
		this.DrawMode               = false;
		this.AutoResize             = false;
		this.OnMapChangeCenter      = false;
        this.VirtualMap = new VEMap(divMap);
		this.PinManager = new VEShapeLayer();;
        
        //Events
        this.OnElementMOver     = null;
        this.onElementClick     = null;
        this.onElementClickUp   = null;
        this.onElementMouseOut  = null;
        this.onElementWheel     = null;
        
        
        
		
		this.g_tempPoints = null;
		this.g_tempShape = null;
		this.g_areaStyle = 'font-family:Verdana;font-weight:bold;font-size:10px;text-decoration:none;background-color:#000000;color:#FFFFFF';
        this.g_shapePoints = new Array();
        
        
        //Load
        this.VirtualMap.AttachEvent("onresize", DataFloat.Agora.RealMap.Static.OnResize);
        
        $AgoraLog.WriteLog('[DataFloat.Agora.RealMap] - Completed');
    }
    
    //STATIC
        DataFloat.Agora.RealMap.Static = function(){};
        DataFloat.Agora.RealMap.Static.OnResize = function(e){
            //$('#' + _divMap).css('width', 'auto');
            //HAVE TO FIGURE OUT BECAUSE THE ON RESIZE CALL A Global Variable
        }
        
        
    
    //STATIC
        
        
        //AddShapeLayer;
		
		//DataTypes
		
			DataFloat.Agora.RealMap.prototype.PinObject = function(pinId, html, latitude, longitude, mlsNumber, description, cssClass, title){
			    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.PinObject] - Initializing');
			    cssClass = (cssClass == null) ? 'DefaultPin' : cssClass;
				this.PinId 		= pinId;
				this.Html 		= (html == null) ? '<div id=\'Agora_Pin_{0}\' class=\'' + cssClass + '\'><div>{0}</div></div>' : '<div class=\'' + cssClass + '\'><div>' + html + '</div></div>';
				this.Latitude 	= latitude;
				this.Longitude 	= longitude;
				this.MlsNumber  = mlsNumber;
				this.Title = title;
				this.Description = description;
				
				$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.PinObject] - Completed');
			}
			
		
		
		//DataTypes
		
        
        window.onresize = function(){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.window.onresize] - Initializing');
            if (this.AutoResize){
                this.VirtualMap.Resize($('#' + this.DivMap).width(), $('#' + this.DivMap).height());
                
                }
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.window.onresize] - Completed');
        }
        
        
        
        DataFloat.Agora.RealMap.prototype.HigligthPin = function (index){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.PinObject] - Initializing');
            $('#Agora_Pin_' + index).addClass('DefaultPin_Active');
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.PinObject] - Completed');
        }
        
        DataFloat.Agora.RealMap.prototype.RemoveHigligth = function(index){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.RemoveHigligth] - Initializing');
            $('#Agora_Pin_' + index).removeClass('DefaultPin_Active');
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.RemoveHigligth] - Completed');
        }
        
        DataFloat.Agora.RealMap.prototype.RemoveAllHigligth = function(){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.RemoveAllHigligth] - Initializing');
            $('.DefaultPin_Active').removeClass('DefaultPin_Active');
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.RemoveAllHigligth] - Completed');
        }
        
        DataFloat.Agora.RealMap.prototype.NewBox = function(id, msg, type){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.NewBox] - Initializing');
            if (type == DataFloat.Agora.IU.BoxStyle.Alert){
                return DataFloat.Agora.Util.StringFormat('<table class="Agora_Map_Box_Table" cellpadding="0" cellspacing="0"><tr><td width="6" background="/Css/MapSearch/agora_map_box_bg_left.gif"><img src="/Images/ran_img_clear.gif" width="6" /></td><td background="/Css/MapSearch/agora_map_box_bg_center.gif"><table><tr><td valign="middle" align="center"><img src="/Css/MapSearch/agora_map_box_ico_alert.gif" /></td><td>&nbsp;&nbsp;&nbsp;</td><td valign="middle"><div id="{0}">{1}</div></td></tr></table></td><td height="40" width="6" background="/Css/MapSearch/agora_map_box_bg_right.gif"><img src="/Images/ran_img_clear.gif" width="6" /></td></tr></table>', id, msg);
            }else if(type == DataFloat.Agora.IU.BoxStyle.NoStyle){
                return DataFloat.Agora.Util.StringFormat('<div class="alertdiv" id="alertdiv" style="visibility: visible;"><div class="alerttitle" id="alerttitle"><div onclick="HideAlert();" class="alertclose" id="alertclose"> </div></div><div class="alerttext" id="alerttext"></div></div>');
            }
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.NewBox] - Completed');
        }
        
        DataFloat.Agora.RealMap.prototype.NewFixedBox = function(id, msg, type){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.NewFixedBox] - Initializing');
            if (type == DataFloat.Agora.IU.BoxStyle.Alert){
                return DataFloat.Agora.Util.StringFormat('<table class="Agora_Map_Box_Table" cellpadding="0" cellspacing="0" width="212"><tr><td width="212" height="6"><img src="/Css/MapSearch/agora_map_box_bg_2_top.gif" width="212" height="6" /></td></tr><tr><td width="212" background="/Css/MapSearch/agora_map_box_bg_2_bg.gif"><table><tr><td width="10">&nbsp;</td><td valign="middle" align="center" width="24"><img src="/Css/MapSearch/agora_map_box_ico_alert.gif" /></td><td width="10">&nbsp;</td><td valign="middle" width="168" align="center"><div id="{0}">{1}</div></td></tr></table></td></tr><tr><td width="212" height="6"><img src="/Css/MapSearch/agora_map_box_bg_2_bottom.gif" width="212" height="6" /></tr></table>', id, msg);
            }else if (DataFloat.Agora.IU.BoxStyle.Neutral){
                return DataFloat.Agora.Util.StringFormat('<table class="Agora_Map_Box_Table" cellpadding="0" cellspacing="0" width="212"><tr><td width="212" height="6"><img src="/Css/MapSearch/agora_map_box_bg_2_top.gif" width="212" height="6" /></td></tr><tr><td width="212" background="/Css/MapSearch/agora_map_box_bg_2_bg.gif"><table><tr><td width="10">&nbsp;</td><td valign="middle" width="192" align="center"><div id="{0}">{1}</div></td><td width="10">&nbsp;</td></tr></table></td></tr><tr><td width="212" height="6"><img src="/Css/MapSearch/agora_map_box_bg_2_bottom.gif" width="212" height="6" /></tr></table>', id, msg);
            }
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.NewFixedBox] - Completed');
        }
        

		DataFloat.Agora.RealMap.prototype.NewItem = function(PropertyObjecy, fncOnEachPinInsert, fncOnFinishPopulate){
			
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.NewItem] - Initializing');
			
			if(PropertyObjecy.length == undefined) {
				
				PropertyObjecy = [PropertyObjecy];
			}
			
			if (this.OnMapChangeCenter) {
			
				this.OnMapChangeCenter = false;
                for (var i=0; i<PropertyObjecy.length; i++)
                {
                    if (PropertyObjecy[i].Latitude!=undefined && PropertyObjecy[i].Latitude!=null)
                    {
				        this.VirtualMap.SetCenterAndZoom(new VELatLong(PropertyObjecy[i].Latitude, PropertyObjecy[i].Longitude), this.DefaultZoom);
				        break;
				    }
				}
			}
			
			for (iI=0;iI<PropertyObjecy.length;iI++) {
				
				var oPosition = new VELatLong(PropertyObjecy[iI].Latitude, PropertyObjecy[iI].Longitude);
				var oPoint = new VEShape(VEShapeType.Pushpin, oPosition);
				oPoint.Id = PropertyObjecy[iI].PinId;
				oPoint.MlsNumber = PropertyObjecy[iI].MlsNumber;
				oPoint.SetCustomIcon(DataFloat.Agora.Util.StringFormat(PropertyObjecy[iI].Html, iI+1));
				oPoint.AgoraStatus = 'off';
				oPoint.Position = iI;
				oPoint.SetTitle(PropertyObjecy[iI].Title);
				oPoint.SetDescription(PropertyObjecy[iI].Description);
				if (fncOnEachPinInsert != null && fncOnEachPinInsert != undefined)
				fncOnEachPinInsert(oPoint, PropertyObjecy);
				this.PinManager.AddShape(oPoint);
			}
			
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.NewItem] - Completed');
		}
		
		
		DataFloat.Agora.RealMap.prototype.StartDraw = function(onFncDrawEnd)
		{
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.StartDraw] - Initializing');
		    
		    
        
		    try
		    {

				this.FncEndDraw = onFncDrawEnd;
		        this.g_shapePoints = new Array();
		        this.g_tempShape = null;
		        this.g_tempPoints = null;
		        
		        //Copying the variables/methods used on events to Global Level
		        DataFloat.Agora.Global.MapObjectCurrentInstance = this;
		        this.VirtualMap.AttachEvent('onclick', this.drawPolygonMouseClick);
		        this.VirtualMap.AttachEvent('onmousemove', this.drawPolygonMouseMove);
				$('#' + this.DivMap).css('cursor','crosshair');
		        this.DrawMode = true;
		        
		    }
			catch(e)
			{
				$AgoraLog.WriteLog('ve_AreaMapSearch.js::drawArea: ' + e.description); 
			}
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.StartDraw] - Completed');
		}
		
		DataFloat.Agora.RealMap.prototype.drawPolygonMouseClick = function(e)
		{
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.drawPolygonMouseClick] - Initializing');
		    
		    
		    try
		    {
		        cursorX = e.mapX;
				cursorY = e.mapY;		
				
				DataFloat.Agora.Global.MapObjectCurrentInstance.g_shapePoints.push(DataFloat.Agora.Global.MapObjectCurrentInstance.VirtualMap.PixelToLatLong(new VEPixel(cursorX, cursorY)));
		        
		        if (e.rightMouseButton && DataFloat.Agora.Global.MapObjectCurrentInstance.g_shapePoints.length >= 3)
		        {
	
		            try
		            {
		                DataFloat.Agora.Global.MapObjectCurrentInstance.VirtualMap.DetachEvent('onmousemove', DataFloat.Agora.Global.MapObjectCurrentInstance.drawPolygonMouseMove);
		                DataFloat.Agora.Global.MapObjectCurrentInstance.VirtualMap.DetachEvent('onclick', DataFloat.Agora.Global.MapObjectCurrentInstance.drawPolygonMouseClick);
		                DataFloat.Agora.Global.MapObjectCurrentInstance.DrawAreaLayer.DeleteShape(DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempShape);
		            }
		            catch(e){}
		
		            var newDrawArea = new VEShape(VEShapeType.Polygon, DataFloat.Agora.Global.MapObjectCurrentInstance.g_shapePoints);
		            try{DataFloat.Agora.Global.MapObjectCurrentInstance.DrawAreaLayer.AddShape(newDrawArea);}catch(e){}
		            

		            DataFloat.Agora.Global.MapObjectCurrentInstance.SetDraw(newDrawArea, 'New Area', DataFloat.Agora.Global.MapObjectCurrentInstance);
		            
					DataFloat.Agora.Global.MapObjectCurrentInstance.UpdateDrawPoints();
					DataFloat.Agora.Global.MapObjectCurrentInstance.DrawMode = false;
					
					
					
					if (DataFloat.Agora.Global.MapObjectCurrentInstance.FncEndDraw != null && DataFloat.Agora.Global.MapObjectCurrentInstance.FncEndDraw != undefined)
						DataFloat.Agora.Global.MapObjectCurrentInstance.FncEndDraw(newDrawArea)

		        }
		        else
		        {
		            $('#' + DataFloat.Agora.Global.MapObjectCurrentInstance.DivMap).css('cursor','crosshair');
		        }
		    }
			catch(e)
			{
			    $AgoraLog.WriteLog('EGN_VEMapsearch.js::drawPolygonMouseClick: ' + e.description); 
			}
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.drawPolygonMouseClick] - Completed');
		}
		
		DataFloat.Agora.RealMap.prototype.drawPolygonMouseMove = function(e)
		{
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.drawPolygonMouseMove] - Initializing');

            
			$('#' + DataFloat.Agora.Global.MapObjectCurrentInstance.DivMap).css('cursor','crosshair');
		    try
		    {
			    DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempPoints = DataFloat.Agora.Global.MapObjectCurrentInstance.g_shapePoints.slice(0, DataFloat.Agora.Global.MapObjectCurrentInstance.g_shapePoints.length);

			    if (DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempPoints.length >= 1)
			    {
			        cursorX = e.mapX;
			        cursorY = e.mapY;   
		            DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempPoints.push(DataFloat.Agora.Global.MapObjectCurrentInstance.VirtualMap.PixelToLatLong(new VEPixel(cursorX, cursorY)));
		            try
		            {
		                DataFloat.Agora.Global.MapObjectCurrentInstance.DrawAreaLayer.DeleteShape(DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempShape);
		            }
		            catch(e){$AgoraLog.WriteLog()}
		
		            if (DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempPoints.length >= 2)
		            {
		                DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempShape = new VEShape(VEShapeType.Polyline, DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempPoints);
		                DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempShape.HideIcon();
		                try{
		                    DataFloat.Agora.Global.MapObjectCurrentInstance.DrawAreaLayer.AddShape(DataFloat.Agora.Global.MapObjectCurrentInstance.g_tempShape);
		                }catch(e){}
		                
		                DataFloat.Agora.Global.MapObjectCurrentInstance.DrawAreaLayer.Show();
		            }
		   	    }
		    }
			catch(e)
			{
			    //alert('_virtualMapsearch.js::drawPolygonMouseMove: ' + e.description); 
			}
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.drawPolygonMouseMove] - Completed');
		}
		
		DataFloat.Agora.RealMap.prototype.PreLoadDraw = function(arrDraw, onNewDraw)
		{
		    for(iLoadD=0;iLoadD<arrDraw.length;iLoadD++){
		        var drawTitle = unescape(arrDraw[iLoadD].Title);
		        var currentDrawPoints = new Array();
		        for (iCurrentDrawPoint=0;iCurrentDrawPoint<arrDraw[iLoadD].LatLong.length;iCurrentDrawPoint++){
		            currentDrawPoints.push(new VELatLong(arrDraw[iLoadD].LatLong[iCurrentDrawPoint].Lat, arrDraw[iLoadD].LatLong[iCurrentDrawPoint].Long));
		        }
                
                var shapeDraw = new VEShape(VEShapeType.Polygon, currentDrawPoints);
                this.DrawAreaLayer.AddShape(shapeDraw);
                this.SetDraw(shapeDraw, drawTitle);
                if (onNewDraw)
                    onNewDraw(shapeDraw);
            }
		}
		
		DataFloat.Agora.RealMap.prototype.SetDraw = function(objectDraw, drawTitle, currentIntance)
		{
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.SetDraw] - Initializing');
		    
		    $this = DataFloat.Agora.Util.IsEmptyOrNull(currentIntance) ? this : currentIntance; //Trick
			var g_lineColor = new VEColor(0,0,255,0.5);
			var g_fillColor = new VEColor(0,128,0,0.3);	
			

			objectDraw.SetTitle(drawTitle);
			if ($this.DeleteDrawArea != null && $this.DeleteDrawArea != undefined){
				objectDraw.SetDescription('<a href="javascript:void(0)" onclick="$this.DeleteDrawArea.apply($this, [\'' + objectDraw.GetID() + '\'])">Remove this Area</a>');
				//objectDraw.SetDescription('<a href="javascript:void(0)" onclick="' + $this.DeleteDrawArea + '(\'' + objectDraw.GetID() + '\', \'' + drawTitle + '\')">Remove this Area</a>');
			}
			objectDraw.SetCustomIcon('<span style="' + $this.g_areaStyle + '"><nobr>' + drawTitle + '</nobr></span>');

			$('#' + $this.DivMap).css('cursor','url(http://maps.live.com/cursors/grab.cur)');	
			$this.DrawAreaLayer.Show();
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.SetDraw] - Completed');
		}
		
		DataFloat.Agora.RealMap.prototype.DeleteArea = function(areaId)
		{
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.DeleteArea] - Initializing');
		    try
		    {
				var objShape = this.DrawAreaLayer.GetShapeByID(areaId);
				if (!objShape) return;
				this.DrawAreaLayer.DeleteShape(objShape);
				this.UpdateDrawPoints();
		    }
			catch(e)
			{
			    $AgoraLog.WriteLog('_virtualMapsearch.js::deleteMarketArea: ' + e.description); 
			}
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.DeleteArea] - Completed');
		}
		
		DataFloat.Agora.RealMap.prototype.ClearAll = function(pinLayer){
		    //I have to extend to be able to pass the "Layer Manager" who the user wants to clear up
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.ClearAll] - Initializing');
		    try{

                
                var internalPinLayer = (pinLayer) ? pinLayer : this.PinManager;
                
		        if (internalPinLayer)
		        {	
		            while(internalPinLayer.GetShapeCount()>0){
		                for (var i = 0; i < internalPinLayer.GetShapeCount(); i++)
		                    internalPinLayer.DeleteShape(internalPinLayer.GetShapeByIndex(i));   
		            }
		        }
		    }
			catch(e) 
			{ 
				$AgoraLog.WriteLog('_virtualMapsearch.js::__Agora__ClearAll: ' + e.description); 
			}
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.ClearAll] - Completed');
		}
		
		
		DataFloat.Agora.RealMap.prototype.UpdateDrawPoints = function()
		{
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.UpdateDrawPoints] - Initializing');
		    try
		    {
				this.DrawAreas = new Array();
				
				
		        if (this.DrawAreaLayer)
		        {	
		            for (var i = 0; i < this.DrawAreaLayer.GetShapeCount(); i++)
		            {
		                var LatLongPoints = [];
		                var curShape = this.DrawAreaLayer.GetShapeByIndex(i);
		                var curAnchor = curShape.GetIconAnchor();
						GUID  = curShape.GetID();
						Title = escape(curShape.GetTitle());
						Latitude = curAnchor.Latitude;
						Longitude = curAnchor.Longitude;
						
		                var curPoints = curShape.GetPoints();
						TotalPoints = curPoints.length;
						
		                for (var j = 0; j < curPoints.length - 1; j++)
							LatLongPoints[j] = {'Lat':curPoints[j].Latitude, 'Long':curPoints[j].Longitude};
				
		            this.DrawAreas.push({'Guid':GUID,'Title':Title,'TotalPoints':TotalPoints,'Latitude':Latitude,'Longitude':Longitude,'LatLong':LatLongPoints});
					}
					
		        }
		    }
			catch(e) 
			{ 
				$AgoraLog.WriteLog('_virtualMapsearch.js::saveArea: ' + e.description); 
			}
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.UpdateDrawPoints] - Completed');
		}
		
		DataFloat.Agora.RealMap.prototype.GetAllDraw = function(){
		    $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.GetAllDraw] - Initializing');
			this.UpdateDrawPoints();
			return this.DrawAreas;
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.GetAllDraw] - Completed');
		}
		
        
        //This code has been placed in a function because in the future will be more flexlible and the user will be able to pass some fixed parameters that will impact into the layout
        DataFloat.Agora.RealMap.prototype.AddHtmlContent = function(Content){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.AddHtmlContent] - Initializing');
            $('#' + this.DivMap).append(Content);
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.AddHtmlContent] - Completed');
        }
		
		DataFloat.Agora.RealMap.prototype.AddMessage = function(Id, Message, Css){
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.AddMessage] - Initializing');
			var sDiv = '<div id="' + Id + '" class="AgoraMessage ' + Css + '">' + Message + '</div>';
            $('#' + this.DivMap).append(sDiv);
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.AddMessage] - Completed');
        }

        DataFloat.Agora.RealMap.prototype.LoadMap = function(){
            $AgoraLog.WriteLog('[DataFloat.Agora.RealMap.LoadMap] - Initializing');
            if (this.onElementClick != null)
                this.VirtualMap.AttachEvent("onclick", this.onElementClick);
                
            if (this.OnElementMOver != null)
                this.VirtualMap.AttachEvent("onmouseover", this.OnElementMOver);
                
                
            if (this.onElementMouseOut != null)
                this.VirtualMap.AttachEvent("onmouseout", this.onElementMouseOut);
             
            if (this.onElementClickUp != null)
                 this.VirtualMap.AttachEvent("onmouseup", this.onElementClickUp);
                        
            if (this.onElementWheel != null)
                 this.VirtualMap.AttachEvent("onmousewheel", this.onElementWheel);
                
                
                
            this.VirtualMap.LoadMap();
            this.VirtualMap.AddShapeLayer(this.PinManager);
			this.VirtualMap.AddShapeLayer(this.DrawAreaLayer);
			$AgoraLog.WriteLog('[DataFloat.Agora.RealMap.LoadMap] - Completed');
        }
    
    
    Array.prototype.toAgoraAreaSearch = function(){
        var aLatLong = this;
        var aOutput = new Array();
        var iO = 0;
        var iI;
        var aOutputLatLong;
        //How many draws?
        for(iO;iO<aLatLong.length;iO++)
        {
            aOutputLatLong = null;
            aOutputLatLong = new Array();
            //Getting the draw's points
            for(iI=0;iI<aLatLong[iO].LatLong.length;iI++){
                aOutputLatLong.push((aLatLong[iO].LatLong[iI].Lat + ',' + aLatLong[iO].LatLong[iI].Long));
            }
            aOutput.push(aOutputLatLong.join('|'));
        }
        return (aOutput.join("?"));
    }
	

        document.write('<' + 'script');
        document.write(' language="javascript"');
        document.write(' type="text/javascript"');
        document.write(' src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6">');
        document.write('</' + 'script' + '>');

