﻿   var laid;

   
    function load() {
    
    var inval=document.getElementById("hidPositions").value;
    
    //alert(inval);
    
    var arrLattLong = new Array();
    if(inval!="")
    {
    arrLattLong=inval.split('/');
    }
  
    

      if (GBrowserIsCompatible())
      
      {
        var map = new GMap2(document.getElementById("map"));
    //alert(inval);
        if(inval!="")
        {
         var arrLLStart=arrLattLong[0].split(':');
        map.setCenter(new GLatLng(Number(arrLLStart[0]),Number(arrLLStart[1])), 15);
         }
         else
         {
              map.setCenter(new GLatLng(50.771094,-90.480591),4 );
         }
        
         map.addControl(new GSmallMapControl());
        //map.addControl(new GMapTypeControl());

       // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon();
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        
        function createMarker(point, index) {
          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);
          GEvent.addListener(marker, "click", function() { 
          var msg="<b>"+document.getElementById("name"+letter).innerHTML  + "</b><br></br>" + document.getElementById("add"+letter).innerHTML ; 
          marker.openInfoWindowHtml(msg);

            if(laid){
                laid.className ="mark";
                 laid=document.getElementById("t"+letter);
                laid.className ="markRed";}
            else
            {
                laid=document.getElementById("t"+letter);
                laid.className ="markRed";
            }
            location.href="#"+letter;
          var y= getY(document.getElementById("t"+letter));
        var x= 0;
            
            window.scrollTo(0, y-50); 
          });
          return marker;
        }

    
     if(inval!="")
        {
        for (var i = 0; i < arrLattLong.length; i++) {
        
           
            var arrLL = new Array();
           arrLL=arrLattLong[i].split(':');
           
          var latlng = new GLatLng(Number(arrLL[0]),Number(arrLL[1]));
          map.addOverlay(createMarker(latlng, i));
      
      }}
      }
      
    }
    
    
    function loadMapB(long,lat,mapdiv,divmap,letter) {

      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById(divmap));
        map.setCenter(new GLatLng(lat,long), 15);
         var point = new GLatLng(lat,long);
       map.addOverlay(new GMarker(point));
       document.getElementById('sname').innerHTML=document.getElementById("name"+letter).innerHTML;
      
      var msg="<b>"+document.getElementById("name"+letter).innerHTML  + "</b>"; 
      msg+="<br>"+document.getElementById("addr"+letter).innerHTML;
        msg+="<br><b><a style='color:blue' target='_new' href='http://maps.google.com/maps?daddr="+lat+","+long+"&saddr='>Click here to get Directions</a></b>";
  map.openInfoWindowHtml(map.getCenter(),msg)
      
 document.getElementById(mapdiv).style.visibility='visible';
var mouse= getY(document.getElementById("name"+letter));
var mouseX= getX()-560;
 
 document.getElementById(mapdiv).style.top=mouse+'px';
 document.getElementById(mapdiv).style.left=mouseX+'px';
      }
  }
  
  function loadMapC(long,lat,mapdiv,divmap,letter) {

      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById(divmap));
        map.setCenter(new GLatLng(lat,long), 15);
         var point = new GLatLng(lat,long);
       map.addOverlay(new GMarker(point));
       document.getElementById('sname').innerHTML=document.getElementById("lblName").innerHTML;
      
      var msg="<b>"+document.getElementById("lblName").innerHTML  + "</b>"; 
      msg+="<br>"+document.getElementById("lblAddress").innerHTML;
        msg+="<br><b><a style='color:blue' target='_new' href='http://maps.google.com/maps?daddr="+lat+","+long+"&saddr='>Click here to get Directions</a></b>";
  map.openInfoWindowHtml(map.getCenter(),msg)
      
 document.getElementById(mapdiv).style.visibility='visible';
var mouse= getY(document.getElementById("landm"));
var mouseX= getX()-560;
 document.getElementById(mapdiv).style.top=mouse+'px';
 document.getElementById(mapdiv).style.left=mouseX+'px';
      }
  }
  
     function loadMap(long,lat,mapdiv,divmap,letter) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById(divmap));
    
        map.setCenter(new GLatLng(lat,long), 15);
         var point = new GLatLng(lat,long);
       map.addOverlay(new GMarker(point));
       document.getElementById('sname').innerHTML=document.getElementById("name"+letter).innerHTML;
      var msg="<b>"+document.getElementById("name"+letter).innerHTML  + "</b><br></br>" + document.getElementById("add"+letter).innerHTML ; 
       
        msg+="<br><b><a style='color:blue' target='_new' href='http://maps.google.com/maps?daddr="+lat+","+long+"&saddr='>Click here to get Directions</a></b>";
  map.openInfoWindowHtml(map.getCenter(),msg)
      
 document.getElementById(mapdiv).style.visibility='visible';
var mouse= getY(document.getElementById("t"+letter));
var mouseX= getX()-560;
 
 document.getElementById(mapdiv).style.top=mouse+'px';
 document.getElementById(mapdiv).style.left=mouseX+'px';
      }
  }
    
 function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function getX( )
{ 
var iReturnValue;
if( typeof( window.innerWidth ) == 'number' ) {
    
    iReturnValue = window.innerWidth;
    
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    
    iReturnValue = document.documentElement.clientWidth; 
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
     
    iReturnValue = document.body.clientWidth; 
  } 
return iReturnValue;
}

