	//function called on body onLoad to load basic Map in the div
	var Ship_Icon = new GIcon();
    Ship_Icon.image = icon_ship;
   // Ship_Icon.iconSize = new GSize(32,32);
    Ship_Icon.iconAnchor = new GPoint(8,8);
    Ship_Icon.infoWindowAnchor = new GPoint(7,7);

	var FlagGreen = new GIcon();
    FlagGreen.image = icon_gflag;
   // FlagGreen.iconSize = new GSize(16,16);
    FlagGreen.iconAnchor = new GPoint(4,16);
    FlagGreen.infoWindowAnchor = new GPoint(7,7);

	var FlagRed = new GIcon();
    FlagRed.image = icon_rflag;
  //  FlagRed.iconSize = new GSize(16,16);
    FlagRed.iconAnchor = new GPoint(4,16);
    FlagRed.infoWindowAnchor = new GPoint(7,7);

	var color_path = [];
	color_path[0] = "#ff0000";
	color_path[1] = "#ff0ff0";
	color_path[2] = "#00ff00";
	color_path[3] = "#ff00ff";




	// global arrays to hold copies of the markers and html used by the Name of 'Ship Line'
	var gmarkers = [];
    var htmls = [];
	var closers = [];

	// This function picks up the click on the name of "Ship Line"
    function myclick(i) 
	{
		  gmarkers[i].openInfoWindowTabsHtml([new GInfoWindowTab("Description",htmls[i]), new GInfoWindowTab("Get Closer",closers[i])],{maxWidth:350,autoScroll:true});
    }



//function called on Load of the Map so that Port is located on it, param shows the thing to be displayed maybe a Port or an AOI
    function load_Paths(filename) 
	{
		var date_sel = document.cal_form.date_sel.value;
		var date_params = date_sel.split("/");
		var param_date = date_params[2]+"-"+date_params[0]+"-"+date_params[1];

		filename = filename+"?date="+param_date;
		 if (GBrowserIsCompatible()) {

    		var map = new GMap2(document.getElementById("map"));
	        map.addControl(new GLargeMapControl());
		    map.addControl(new GMapTypeControl());	
			map.addControl(new GScaleControl()); 
			map.setCenter(new GLatLng(initial_lat,initial_lng), initial_zoom);
			plot_points_dynamic(filename,map);
//			GEvent.addListener(map, "moveend", function(){plot_points_aoi(filename,map);});	 
      }
    }
	var bounds=null;
	bounds = new GLatLngBounds(); 

	//function to plot the port on the Map
	function plot_points_dynamic(filename,map)
	{
		//alert(filename);
			GDownloadUrl(filename, function(data) {	
		    var xml = GXml.parse(data);
		    var trips = xml.documentElement.getElementsByTagName("trip");			
			map.clearOverlays();  //get rid of existing markers
			for (var t = 0; t < trips.length; t++) 
			{
				var child = trips[t].childNodes;
				var points_polyline = "[";
				for (j=0;j<child.length;j++)
				{ 
					var id = child[j].getAttribute("id");
					var cruise_line = child[j].getAttribute("cruise_line");
					var ship_line = child[j].getAttribute("ship_line");
					var country_name = child[j].getAttribute("country_name");
					var port_name = child[j].getAttribute("port_name");
					var port_id = child[j].getAttribute("port_id");
					var lat = child[j].getAttribute("lat");
					var lng = child[j].getAttribute("lng");
					var icon = child[j].getAttribute("icon");
					var shipid = child[j].getAttribute("shipid");
					var cruiseid = child[j].getAttribute("cruiseid");
					var desc = child[j].getAttribute("desc");
					
					var point = new GLatLng(parseFloat(lat),parseFloat(lng));
					if(j!=0)
					{
						points_polyline =  points_polyline + ",";
					}
					points_polyline = points_polyline + "new GLatLng( " +lat+","+lng+")";
					if(icon != "")
					{
						var marker = createMarker(id,point,cruise_line, ship_line, icon, shipid,country_name,port_name, port_id, desc,cruiseid);
						map.addOverlay(marker);				
					}
					bounds.extend(point);
					zoom_level_bound = map.getBoundsZoomLevel(bounds);
					map.setCenter(bounds.getCenter(), zoom_level_bound);
				}//end of Marker loop 
				points_polyline =  points_polyline + "]";

				points_polyline= eval(points_polyline);
				var polyOptions = {geodesic:true};
				var polygon_line = new GPolyline(points_polyline, color_path[t], 3, .5, polyOptions ); 
				map.addOverlay(polygon_line); 			
			}//end of trip loop	
		 });

	}
	
	//Plot Ship Marker
    function createMarker(id,point,cruise_line,ship_line,  icon, shipid,country_name,port_name, port_id,desc,cruiseid) 
	{		

		var marker = new GMarker(point, eval(icon));
	    //Description tab starts
		 var html = description_tab_shipindex(ship_line, cruise_line, shipid,country_name,port_name, port_id,desc,cruiseid); 
    	//Description tab ends

		//Get Closer Tab starts
		var closer =  get_closer_tab_ship(ship_line, country_name, "ship",cruiseid,shipid);
		//Get Closer Tab ends

	    GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowTabsHtml([new GInfoWindowTab("Description",html), new GInfoWindowTab("Get Closer",closer)],{maxWidth:350,autoScroll:true});
    //   marker.openInfoWindowHtml(html);

      });

	  gmarkers[id] = marker;
      htmls[id] = html;
	  closers[id] = closer;
      return marker;
    }




	
   //]]>