var arrMarkers=new Array();

function getMarkerData(params)
	{

	var poiurl='/php/poidata.php';
 
 $.ajax({
	 url:poiurl,
	 type: "get",
	 data: params,
	 dataType: "json",
	 error: function(xhr, desc, exceptionobj) {
		 alert("There was a problem loading the map data. Please try again later.");
	 },
	 success:function(json)
	 { 
			 //now we have an array of poi
			$.each(json.poi, function(i,poiItem)
			{
	
				var tmpAddress='';
				tmpAddress=addAddressLine(poiItem.strAddress1) + addAddressLine(poiItem.strTown) + isEmpty(poiItem.strPostCode);
				arrMarkers.push([poiItem.strCategory,poiItem.decLat,poiItem.decLng,poiItem.strName,tmpAddress,poiItem.strTelephone,poiItem.strBookingURL,poiItem.lngpoiID]);
			
			});
	
			 addMarkersToMap();
	 }
 });
		
	}//end get markerdata
	
	
	function addMarkersToMap() {
	for (i=0;i<arrMarkers.length;i++)
		{
		var html="<p><strong>" + arrMarkers[i][3] + "</strong></p><p>" + arrMarkers[i][4] + "<br>Tel: " + arrMarkers[i][5] + "</p>";
		if(arrMarkers[i][6]!=''&&arrMarkers[i][6]!=null)
		{
			if(arrMarkers[i][0]=='Hotel')
			{
				html+="<p><a href='hotels-abergavenny.htm#" + arrMarkers[i][0] + arrMarkers[i][7] + "'>More info and book online</a></p>";
			}
			else if (arrMarkers[i][0]=='Guesthouse')
			{
				html+="<p><a href='guesthouses.htm#" + arrMarkers[i][0] + arrMarkers[i][7] + "'>More info and book online</a></p>";
			}
		}
		else {
			if(arrMarkers[i][0]=='Hotel')
			{
				html+="<p><a href='hotels-abergavenny.htm#" + arrMarkers[i][0] + arrMarkers[i][7] + "'>More details...</a></p>";
			}
			else if (arrMarkers[i][0]=='Guesthouse')
			{
				html+="<p><a href='guesthouses.htm#" + arrMarkers[i][0] + arrMarkers[i][7] + "'>More details...</a></p>";
			}
			else if (arrMarkers[i][0]=='Camping')
			{
				html+="<p><a href='campsites.htm#" + arrMarkers[i][0] + arrMarkers[i][7] + "'>More details...</a></p>";
			}
														 
		}
		var point=new GLatLng(arrMarkers[i][1], arrMarkers[i][2]);
		var marker=createMarker(point,html,arrMarkers[i][3]);
			
			map.addOverlay(marker);
		}
	}
	
	 function createMarker(point,html,title) {
        var marker = new GMarker(point,{title:title});
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }
