﻿var BB_Count=document.getElementById("BB_Count").value;
//var marker = new Array(BB_Count);
 function initialize(a1) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        var main_left=document.getElementById("BB_Map1").value;
        var main_right=document.getElementById("BB_Map2").value;
        map.setCenter(new GLatLng(main_left,main_right), 10);
        map.setUIToDefault();

        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        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);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index,j) {
        	//alert(index);
          // Create a lettered icon for this point using our icon class
          
          if (index !='0')	{
          var letter = String.fromCharCode("A".charCodeAt(0) + index-1);
          var PI_Title=eval('document.scenic.PI_Title_'+index+'.value'); //PI_Title
          }
          if (index =='0'){
          	  var PI_Title=document.getElementById("BB_Name").value;
          }
	          var letteredIcon = new GIcon(baseIcon);
			if (index=='0')		letteredIcon.image ="http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";
	        else 	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() {
            marker.openInfoWindowHtml('<div style="background-color:#FFFFCC;height:auto; width:200px;font-size:14px;color:#CC9900">' + PI_Title + '</div>'); //alerte
          });
            if (index==j)	marker.openInfoWindowHtml('<div style="background-color:#FFFFCC;height:auto; width:200px;font-size:14px;color:#CC9900">' + PI_Title + '</div>'); //alerte
          return marker;
        }
var BB_Count=document.getElementById("BB_Count").value;
//alert(BB_Count);
map.addOverlay(createMarker(new GLatLng(main_left,main_right), 0,a1));
        // Add 10 markers to the map at random locations
        for (var i = 1; i <= BB_Count; i++) {
        map1=eval('document.scenic.PI_Map1_'+i+'.value'); //map1
		map2=eval('document.scenic.PI_Map2_'+i+'.value'); //map2
          map.addOverlay(createMarker(new GLatLng(map1,map2), i,a1));
        }
      }
    }
