		
		var map = null;
		var alat;
		var along;
		var zoomsave;
		var pinID=10000;
		var pinClickID=100;
		var finding = false;
		var GlobalWhereClick="";
		var NoPointAdded=false;
		var GlobalTheName;
		var GlobalWidth;
		var GlobalHeight;
		var PUBID="pub-2987628421258007";
      var pushpinOnMap = false;
      var ClickLat;
      var ClickLong;
      var ZoomL;
      var StopHoverWhileAdd=false;
      var LoginFlag=false;
      var element;
      var atest=-1;
      var NoXflag=false;
      var pin;
      
      function OnPageLoad()
      {
      // If the browser is Firefox get the version number
        var ffv = 0;
        var ffn = "Firefox/"
        var ffp = navigator.userAgent.indexOf(ffn);
        if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));
        // If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG
        if (ffv >= 1.5) {
            Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }
        }

        map = new VEMap('myMap');
        map.LoadMap(new VELatLong(33.94, -118.41), 2, 'r', false);
        window_onresize();
        map.AttachEvent("onclick", MouseClick);
        map.AttachEvent("onchangeview", ViewChange);
        map.AttachEvent("onmouseover",PinHover);
        ToServerReportLoad();
      }


    //function window_onbeforeunload() {
        //ToServerReportHyperLink();
    //}

		
		function DoItrStart() {
		
			//alert("Hello");
			map = new VE_MapControl(34.246886, -119.210288, 100, 'r', "absolute", 10, 10, 700, 365);
			document.body.appendChild(map.element);
			zoomsave=100;
			alat=34.246886;
			along =-119.210288;
		}
		
		function new_window(url,whichone) { 

            if (whichone == 0)
            {
                var link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=250,height=300,left=40,top=50"); 
            }
            else
            {
                var link = window.open(url,"Link","toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,left=40,top=50"); 
            }    

        } 

		function StartIt() {
		    map = new VEMap('myMap');
            map.LoadMap(new VELatLong(-33.7939, 151.1093), 10, 'r', false);
		}

		function DoItr() {
			//alert("Hello");
			map = new VE_MapControl(alat, along, zoomsave, 'r', "absolute", 10, 10, 700, 365);
			document.body.appendChild(map.element);
		}
		function DoIta() {
			//alert("Hello");
			//var map = null;
			map = new VE_MapControl(alat, along, zoomsave, 'a', "absolute", 10, 10, 700, 365);
			document.body.appendChild(map.element);
		}
		function DoIth() {
			//alert("Hello");
			//var map = null;
			map = new VE_MapControl(alat, along, zoomsave, 'h', "absolute", 10, 10, 700, 365);
			document.body.appendChild(map.element);
		}
		function AddPin(wow) {
			//alert("Hello");
			var asingle;
			var bsingle;
			//var wow;
			
			//wow= 'Hello world';
			//var map = null;
			//map = new VE_MapControl(34.246886, -119.210288, 16, 'h', "absolute", 10, 10, 700, 365);
			//document.body.appendChild(map.element);
			asingle = map.GetCenterLatitude();
			bsingle = map.GetCenterLongitude();
			alat = asingle;
			along = bsingle;
			var pushpinelement = map.AddPushpin('pin',  asingle, bsingle, 40, 15, 'pin', wow, 5);
			pushpinelement.title = "Hello";
		}

		function AddOne(wow1,wow2) {
			var asingle;
			var bsingle;
			
           pin = new VEPushpin(pinID,new VELatLong(wow1,wow2),'images/BlueCar.gif','My pushpin','super');	
           VEPushpin.ShowDetailOnMouseOver = true;
           
            //VEPushpin.OnMouseOverCallback = function(x, y, title, details)
            //{
            //   alert('your mouse is at : ' + x + ', ' + y +                
            //   ' and you can display the details from title: ' + unescape(title) +                
            //   ' and details: ' + unescape(details));           
            //}
		
           map.AddPushpin(pin);
			asingle = map.GetCenterLatitude;
			bsingle = map.GetCenterLongitude;
			alat= asingle;
			along = bsingle;
			pinID++;
		}
		
		function AddPinMore(wow1,wow2,wow3) {
			//alert("Hello");
			var asingle;
			var bsingle;
			//var wow;
			
			//wow= 'Hello world';
			//var map = null;
			//map = new VE_MapControl(34.246886, -119.210288, 16, 'h', "absolute", 10, 10, 700, 365);
			//document.body.appendChild(map.element);
			//asingle = map.GetCenterLatitude();
			//bsingle = map.GetCenterLongitude();
			//alat = asingle;
			//along = bsingle;
			var pushpinelement = map.AddPushpin('pin',  wow1, wow2, 40, 15, 'pin', "", 5);
			asingle = map.GetCenterLatitude;
			bsingle = map.GetCenterLongitude;
			alat= asingle;
			along = bsingle;
			pushpinelement.title = wow3;
		}
		
		function AddPinMoreZ(theuser,wow1,wow2,wow3) {
			//alert("Hello");
			var asingle;
			var bsingle;
			//var wow;
			
			//wow= 'Hello world';
			//var map = null;
			//map = new VE_MapControl(34.246886, -119.210288, 16, 'h', "absolute", 10, 10, 700, 365);
			//document.body.appendChild(map.element);
			//asingle = map.GetCenterLatitude();
			//bsingle = map.GetCenterLongitude();
			//alat = asingle;
			//along = bsingle;
           pin = new VEPushpin(pinID,new VELatLong(wow1,wow2),'images/BlueCar.gif',theuser,wow3);			
           var pushpinelement = map.AddPushpin(pin);
			asingle = map.GetCenterLatitude;
			bsingle = map.GetCenterLongitude;
			alat= asingle;
			along = bsingle;
			//pushpinelement.title = wow3;
			pinID++;
		}
		
		function AddPinMoreZClick(TheName,Desc) {
		
		        finding = false;
		        pushpinOnMap=false;
		        if (NoPointAdded == false){
		            map.DeletePushpin(pinClickID);
                    pin = new VEPushpin(pinClickID,new VELatLong(ClickLat,ClickLong),'images/BlueCar.gif',TheName,Desc);			
		        }
		        else
		        {
		            pin = new VEPushpin(pinClickID,map.GetCenter(),'images/BlueCar.gif',TheName,Desc);
		        }
               map.AddPushpin(pin);
		       pinClickID++;
		        NoPointAdded=false;
		}
		
		function ResetStationaryID(){
		    pinClickID=100;
		}
		function NoX(){
		    NoXflag=true;
		}

		function NoXclear(){
		    NoXflag=false;
		}

		function LoginIsTrue(){
		    LoginFlag=true;
		}
		function MapResize(Awidth,Aheight){
		    map.Resize(Width(),Height())
		}
		function window_onresize() {
            map.Resize(Width(),Height()); 
        }

        function Width()
        {
            var x;
            if (self.innerHeight) // all except Explorer
            {
                x = self.innerWidth;
            }
            else if (document.documentElement && document.documentElement.clientHeight)
            // Explorer 6 Strict Mode
            {
                x = document.documentElement.clientWidth;
            }
            else if (document.body) // other Explorers
            {
                x = document.body.clientWidth;
            }
            if (x-410 <=0)  
                {return 576;} 
            else 
                {GlobalWidth=x-410;
                if (GlobalWidth < 576 )
                {GlobalWidth = 576;}
                ToServerWidth();
                return GlobalWidth;}

        }
        function Height()
        {
            var y;
            if (self.innerHeight) // all except Explorer
            {
                y = self.innerHeight;
            }
            else if (document.documentElement && document.documentElement.clientHeight)
            // Explorer 6 Strict Mode
            {
                y = document.documentElement.clientHeight;
            }
            else if (document.body) // other Explorers
            {
                y = document.body.clientHeight;
            }
            if (y-200 <=0)  {return 568;} 
            else 
                {
                    GlobalHeight = y-200;
                    if (GlobalHeight  < 568 ) {GlobalHeight = 568;}
                    ToServerHeight();
                    return GlobalHeight;}
            
        }


		
		function AddPinMoreZClickLLZ(TheName,Desc,XLat,XLong,Xzoom,Xicon,XiconLink) 
		{
		        var astring
		        
		        var XXLat = Number(XLat);
		        var XXLong = Number(XLong);
                var s=map.GetMapStyle();
                 var m=map.GetMapMode()
                 if (s==null) s = document.getElementById('styleMenu').value;
                if (s==VEMapStyle.Birdseye || m==VEMapMode.Mode3D)
                {
                    map.SetMapStyle(VEMapStyle.Road);
                }
		        
		        if (Xicon == "")
		            astring = XiconLink;
		            
		        else
		            astring = Xicon;
		            
		        pushpinOnMap=false;
		        finding = false;
		        if (NoPointAdded == false){
		            try{
		                //map.DeletePushpin(pinClickID);
		                map.DeleteShape(pin);
		                //var pin = new VEPushpin(pinClickID,new VELatLong(XLat,XLong),astring,TheName,Desc);
                        pin = new VEShape(VEShapeType.Pushpin,new VELatLong(XXLat, XXLong));
                        pin.SetCustomIcon(astring);
                        pin.SetTitle(TheName);
                        pin.SetDescription(Desc);
                        map.AddShape(pin);
                        /////VEPushpin.ShowDetailOnMouseOver = false;            
                        /////VEPushpin.OnMouseOverCallback = PinHover;
                        
                    }
		            catch(e)
		            {
                        pin = new VEShape(VEShapeType.Pushpin,new VELatLong(XXLat, XXLong));
                        pin.SetCustomIcon(astring);
                        pin.SetTitle(TheName);
                        pin.SetDescription(Desc);
                        map.AddShape(pin);
		                /////pin = new VEPushpin(pinClickID,new VELatLong(XLat,XLong),astring,TheName,Desc);
                        /////VEPushpin.ShowDetailOnMouseOver = false;            
                        /////VEPushpin.OnMouseOverCallback = PinHover;
                     }
		        }
		        else
		        {
		                pin = new VEShape(VEShapeType.Pushpin,map.GetCenter());
                        pin.SetCustomIcon(astring);
                        pin.SetTitle(TheName);
                        pin.SetDescription(Desc);
                        map.AddShape(pin);

		                /////pin = new VEPushpin(pinClickID,map.GetCenter(),astring,TheName,Desc);
                        /////VEPushpin.ShowDetailOnMouseOver = false;            
                        /////VEPushpin.OnMouseOverCallback = PinHover;
		        }
               /////map.AddPushpin(pin);
               /////element = document.getElementById(pinClickID);
               /////element.onclick = EventHandlerOnClick;

		       pinClickID++;
		        NoPointAdded=false;
		        
		}
		
		function EventHandlerOnClick(e)
        {
            var pin = map.GetShapeByID(e.elementID);
            xtitle = pin.Title;
            xdetails = pin.Notes;

            if (e!=null)
            {
                //document.getElementById(e.currentTarget.id + "_" + map.GUID).onmouseover();
                xx=xx;

                 ToServerUpdateFloat(xx,yy,xtitle,xdetails);
            } else
            {
                atest = 33;
                ToServerUpdateFloat(xx,yy,xtitle,xdetails);

                //document.getElementById(window.event.srcElement.id).onmouseover();
            }
        }

		function DeletePinForAdding() {
		        var astring
		            
		        pushpinOnMap=false;
		        finding = false;
	            /////map.DeletePushpin(pinClickID);
		        map.DeleteShape(pin);
	            pinClickID++;
		        NoPointAdded=false;
		}
		
		function AddPinMoreZClickLLZ_Disp(TheName,Desc,XLat,XLong,Xzoom,Xicon,XiconLink) {
		        var astring
		        
                var s=map.GetMapStyle();
                 var m=map.GetMapMode()
                if (s==VEMapStyle.Birdseye || m==VEMapMode.Mode3D)
                {
                    map.SetMapStyle(VEMapStyle.Road);
                }
		        
		        if (Xicon == "")
		            astring = XiconLink;
		        else
		            astring = Xicon;
		            
		        pushpinOnMap=false;
		        finding = false;
		        
		        
                pin = new VEShape(VEShapeType.Pushpin,new VELatLong(XLat, XLong));
                pin.SetCustomIcon(astring);
                pin.SetTitle(TheName);
                pin.SetDescription(Desc);
                map.AddShape(pin);
		        
		        
		          /////pin = new VEPushpin(pinClickID,new VELatLong(XLat,XLong),astring,TheName,Desc);
                  /////VEPushpin.ShowDetailOnMouseOver = false;            
                  /////VEPushpin.OnMouseOverCallback = PinHover;
                  
                /////map.AddPushpin(pin);
                /////element = document.getElementById(pinClickID);
                /////element.onclick = EventHandlerOnClick;

		        pinClickID++;
		        NoPointAdded=false;
		        
		}
		
        function DoAlert(x,y,text,text2,text3) 
        { 
            var allText;
            var d=document.getElementById("alertdiv") 
            d.style.display="inline"; 
            d.style.left = x;
            d.style.top = y;
            allText = text + "<BR>Hello<BR> yahoo! <a href=\"http://www.cnn.com\"  target=\"_blank\">CNN</a>" +
                        "<BR>" + text2 + "<BR>" + text3 + "<BR>" +
                        "<a href=\"javascript:ToServer();\">Edit this point</a> | ";
            allText = "<h6 align=\"center\"><em>" + text2 + "</em></h6>" + text3 + "<BR>" +
                        "<a href=\"javascript:ToServer();\">Edit this point</a> | " + "<BR>" + 
                        "Links:<BR>" +
                        "<a href=\"http://www.cnn.com\"  target=\"_blank\">CNN</a>";
            d.innerHTML = allText;
            //d.style.top =400;
            setTimeout(function() {document.getElementById("alertdiv").style.display="none";} , 20000); 
        } 
		var xx;
		var yy
		var xtitle;
		var xdetails;
		//yikes//
		function PinHover(e)       /////(x, y, title, details)
		{
		   // check to see if we have hovered over a pushpin
           if(e.elementID!=null)
           {
                var x = e.mapX;
                var y = e.mapY;

                /////GlobalTheName=unescape(title);
               GlobalTheName=pin.Title;
		       // DoAlert(x,y,'x and y:' + x + " " + y, unescape(title), unescape(details) );
		       if (StopHoverWhileAdd==false)
		       {
		            if ( isNaN(x) || isNaN(y) )
		            {
		                xx=-1;
		            }
		            else
		            {
		                xx=x;
		                yy=y
		                /////xtitle = unescape(title);
		                /////xdetails = unescape(details);
		                xtitle = pin.Title;
		                xdetails = pin.Notes;
		                
		                //ToServerUpdateFloat(x,y,unescape(title),unescape(details));
		            }
		       }
               //alert('your mouse is at : ' + x + ', ' + y +                
               //' and you can display the details from title: ' + unescape(title) +                
               //' and details: ' + unescape(details));	
	
           }
           return true;
        }
		
		function MapFind(Awhere){
		    GlobalWhereClick=Awhere;
		    finding = true;
		    /////map.FindLocation(Awhere);
		    map.Find(null,Awhere);
		}

      function ViewChange(e)
      {
        var asingle;
        var bsingle;
            if (finding)
            {
                FindCompleted();
            }
            try{
                
                if (atest == 33)
                {
                    SetZoomLevelLocation(ClickLat,ClickLong,ZoomL);
                }
                else
                {
                    var center = new VELatLong(map.GetCenter());
                    ClickLat = center.Latitude.Latitude;
                    ClickLong = center.Latitude.Longitude;
                    ZoomL= map.GetZoomLevel();
                    if (ZoomL >= 1)
                        doVC();
                }
                
            }
            catch(e)
            {
                asingle=1;
            }
       }

//yikes//
     function MouseClick(e)
      {
        if (e.elementID == null)
        {
            if (e.rightMouseButton)
            {
            if (NoXflag == false)
            {
                if (pushpinOnMap){
                    /////map.DeletePushpin(pinClickID);
		            map.DeleteShape(pin);
                }
                StopHoverWhileAdd=true
           
                //var pin = new VEPushpin(pinClickID, 
                //  new VELatLong(e.view.LatLong.Latitude, e.view.LatLong.Longitude), 
                //  'images/RedMark.gif', 
                //  'Name your point', 
                //  'Describe your point and then select one of our icons. Add the point and then do it again. Share this map with your friends.'
                // );
           
                var s=map.GetMapStyle();
                var m=map.GetMapMode(); 
     
                if (s==VEMapStyle.Birdseye || m==VEMapMode.Mode3D)
                {
                }
                else
                {
                    //Get the pixel coordinates of where the map was clicked
                    var x = e.mapX;
                    var y = e.mapY;
                    var pixel = new VEPixel(x, y);
                    var latlong = map.PixelToLatLong(pixel);
                    //Round the coordinates to 5 decimal places
                    var latitude = Math.round(10000*latlong.Latitude)/10000;
                    var longitude = Math.round(10000*latlong.Longitude)/10000;

                    pin = new VEShape(VEShapeType.Pushpin,new VELatLong(latitude, longitude));
                    //var pin = new VEPushpin(pinClickID, 
                    //    new VELatLong(e.view.LatLong.Latitude, e.view.LatLong.Longitude), 
                    //    'images/RedMark.gif', 
                   //     '', 
                    //    ''
                   //     );
                    pin.SetCustomIcon('images/RedMark.gif');
            
                        ClickLat=latitude;
                        ClickLong=longitude;  
                        ZoomL = e.zoomLevel;
                        //map.AddPushpin(pin);
                        map.AddShape(pin);
                        /////pinClickID= pin.GetID();

                        pushpinOnMap=true;
                        NoPointAdded = false;
                        doAdd();
                }
             }
             }
         }
         else
         {
           EventHandlerOnClick(e);

         }
      }
      
      

        function FindCompleted()
        {
            NoPointAdded = true;          
            //AddPinMoreZClick(GlobalWhereClick,"Your Description");
        }
		
		function MoveCenterNow() {
			var asingle;
			var bsingle;
			asingle = map.GetCenterLatitude();
			bsingle = map.GetCenterLongitude();
			alat= asingle;
			along = bsingle;
			map.SetCenter(alat + .02, along + .02 );
		}
		
		function SetCenterNow(wow1,wow2) {
			var asingle;
			var bsingle;
			map.SetCenter(new VELatLong(wow1,wow2));
			asingle = map.GetCenterLatitude;
			bsingle = map.GetCenterLongitude;
			alat= asingle;
			along = bsingle;
		}
		
		function SetTheZoom(tzoom){
		var x = parseFloat(tzoom);
		    map.SetZoomLevel(x);
		}
		function MyZoomIn() {
			//var asingle;
			//var bsingle;
			//asingle = map.GetCenterLatitude();
			//bsingle = map.GetCenterLongitude();
			map.ZoomIn();
			zoomsave=map.zoomLevel;
			alat = map.GetCenterLatitude;
			along = map.GetCenterLongitude;
		}
		
		function MyZoomOut() {
			//var asingle;
			//var bsingle;
			//asingle = map.GetCenterLatitude();
			//bsingle = map.GetCenterLongitude();
			map.ZoomOut();
			zoomsave=map.zoomLevel();
			//alat = map.GetCenterLatitude();
			//along = map.GetCenterLongitude();
		}
		function SetZoomLevelLocation(alat,along,azoom){
		        var s=map.GetMapStyle();
		        
		        var m=map.GetMapMode()
                if (s==VEMapStyle.Birdseye || m==VEMapMode.Mode3D)
                {
                    map.SetMapStyle(VEMapStyle.Road);
                }
            map.SetCenterAndZoom(new VELatLong(alat,along),azoom);
            /////var pnt = new VELatLong(alat, along); 
		    /////map.SetCenter(pnt)
		    /////map.SetZoomLevel(azoom);
		    NoPointAdded = true;  
		    
		}
		function DeleteAll() {
		    //map.DeleteAllPushpins();
		    map.DeleteAllShapes();
		}
    function doclientalert()
    {
         alert("Hello");
    }
    function ToServer()
    {
	    pwBeginCallServerFunction("FromClient", "addResult", null, false,GlobalTheName);
    }
    function ToServerWidth()
    {
	    pwBeginCallServerFunction("MapWidth_client", "addResult", null, false,GlobalWidth);
    }
    function ToServerHeight()
    {
	    pwBeginCallServerFunction("MapHeight_client", "addResult", null, false,GlobalHeight);
    }
    function doAdd()
    {
	    pwBeginCallServerFunction("Add", "addResult", null, false,ClickLat,ClickLong,ZoomL);
    }
    function doVC()
    {
        //if (ClickLat != 0 || ClickLong != 0)
        //{
            if ( ClickLat==0 ) ClickLat="0";
            if ( ClickLong==0 ) ClickLong="0";
	        pwBeginCallServerFunction("VC", "addResult", null, false,ClickLat,ClickLong,ZoomL);
	    //}
    }

    function ToServerUpdateFloat(x,y,text2,text3)
    {
        if (text3=="")
        {
         text3="1";
         }
        var m=map.GetMapMode(); 
        if( m!=VEMapMode.Mode3D)
        {
	        pwBeginCallServerFunction("UpdateFloat", "addResult", null, false,x,y,text2,text3);
	    }
    }
    function ToServerReportLoad()
    {
	    pwBeginCallServerFunction("MapHasReloaded", "addResult", null, false,"Start");
    
    }
    function ToServerReportHyperLink()
    {
	    //pwBeginCallServerFunction("HyperLinkedOut", "addResult", null, false,"AnotherPage");
    
    }
    function ToServerTest(x)
    {
        pwBeginCallServerFunction("UpdateTest", "addResult", null, false,x);
    }
    function addResult(pwRsCallbackResponse)
    {
        StopHoverWhileAdd=false
        atest=-1;
    }
