   //<![CDATA[

    var sidebar_html = "";
    var gmarkers = [];
    var htmls = [];
    var i = 0;
    var map;		
    var gicons = [];
     // arrays to hold variants of the info window html with get direction forms open
    var to_htmls = [];
    var from_htmls = [];
	
    gicons["casino"] = new GIcon(G_DEFAULT_ICON, "http://img0.eurobet.com/gc2/fileadmin/templates/img/B/map_icon_g.png");
    gicons["casino"].iconSize = new GSize(18, 26);
    gicons["casino"].shadowSize = new GSize(0, 0);

function QueryString() {
	// PROPERTIES
	this.arg = new Array;
	this.status = false;
	
	// METHODS
	this.clear = Clear; 
	this.get = Get;
	this.getAll = GetAll;
	this.getStatus = GetStatus;
	this.read = Read;
	this.set = Set;
	this.write = Write;
	
	// FUNCTIONS
	
	// Clears the array, this.arg, of all query string data
	function Clear()
	{	this.arg = new Array;
	}
	
	// Returns a named value from the query string
	function Get(sName)
	{	return this.arg[sName];
	}
	
	// Return all data as an associative array
	function GetAll()
	{	return this.arg;
	}
	
	function GetStatus()
	{	return this.status;
	}
	
	// Reads the query string into an array named this.arg
	function Read(sUrl) 
	{	var aArgsTemp, aTemp, sQuery;
		// You can pass in a URL query string
		if(sUrl)
		{	sQuery = sUrl.substr(sUrl.lastIndexOf("?")+1, sUrl.length);
		}
		// Or read it from the browser location
		else
		{	sQuery = window.location.search.substr(1, window.location.search.length);
		}
		// Check that query string exists and contains data
		// If not (length < 1) then return
		if(sQuery.length < 1) {return;}
		// Else set this.status to true and proceed
		else {this.status = true;}
		//
		aArgsTemp = sQuery.split("&");	
		for (var i=0 ; i<aArgsTemp.length; i++)
		{	aTemp = aArgsTemp[i].split("=");
			this.arg[aTemp[0]] = aTemp[1];
		}
	}
	
	// Overwrites an existing named value in the array, this.arg
	// You can also pass null to delete from array
	function Set(sName,sValue)
	{	if (sValue == null) {delete this.arg[sName];}
		else {this.arg[sName] = sValue;}
	}
	
	// Writes out a string from the data in this.arg array
	// This string can be used to pass a new query string to the browser
	// when navigating to the next page. This allows a page
	// to create and pass data to another page via JavaScript.
	function Write()
	{	var sQuery = new String(""); 
		for (var sName in this.arg)
		{	if (sQuery != "") {sQuery += "&";}
			if (this.arg[sName]) {sQuery += sName + "=" + this.arg[sName];}
		}
		if (sQuery.length > 0) {return "?" + sQuery;}
		else {return sQuery;}
	}
}

	function createMap(){
	    if (GBrowserIsCompatible()) {
      	    // This function picks up the click and opens the corresponding info window
      	    // create the map
      	    map = new GMap2(document.getElementById("map"));
//			map.addMapType(G_NORMAL_MAP);
	    map.addControl(new GLargeMapControl());
	    map.addControl(new GMapTypeControl());
	    map.setCenter(new GLatLng(53.8538,-2.5682983), 6);    
	}
     	else {
           alert("Sorry, the Google Maps API is not compatible with this browser");}
	}

//(point,label,html,icontype);
      function createTabbedMarker(point,name,html,icontype) {		
		 html2 = "Directions to " + name + "<br>"; 

		var marker = new GMarker(point, gicons[icontype]);
		 // The info window version with the "to here" form open
        to_htmls = html2 + '<h2>Directions To here</h2> - <a href="javascript:fromhere(' + i + ')">From here</a>' +
           '<br>Start address:<form action="http://maps.google.co.uk/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + 
                  // "(" + name + ")" + 
           '"/>';
		   
        // The info window version with the "to here" form open
        from_htmls = html2 + '<br>Directions: <a href="javascript:tohereTabbed(' + i + ')">To here</a> - <b>From here</b>' +
           '<br>End address:<form action="http://maps.google.co.uk/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" + 
           '"/>';
        // The inactive version of the direction info
        html2 = html2 + '<br> <a href="javascript:tohereTabbed('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';

        			 GEvent.addListener(marker, "click", function() {
          		 				 marker.openInfoWindowTabsHtml([new GInfoWindowTab("Address",html), new GInfoWindowTab("Directions",html2)]);
        			 			  });
							 gmarkers[i] = marker;
               return marker;
      } 

	function changeSize()
	{
		parent.window.resizeTo(1000,800);		
		parent.window.moveTo(self.screen.width,self.screen.height);
	}
	
	function createMarker(point,name,html,icontype,type) {
      	var marker = new GMarker(point, gicons[icontype]);
					 
					 // The info window version with the "to here" form open
        to_htmls[i] = '<form action="http://maps.google.co.uk/maps" method="get">' +
	    '<h2>Direction to ' + name + '</h2> enter your current location ' +           
	    '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" />' +
           '<INPUT value="Get Directions" onClick="changeSize()" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + "(" + name + ")" + 
           '"/>';
	 //alert(to_htmls[i])
	 if (type == "single"){document.getElementById("to_place").innerHTML = to_htmls[i]}		   
        // The info window version with the "to here" form open
        from_htmls[i] =  '<form action="http://maps.google.co.uk/maps" method="get"> '+ 
	       '<h2>Direction from ' + name + '</h2> enter your target location' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" />' +
           '<INPUT value="Get Directions" onClick="changeSize()" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() + "(" + name + ")" + 
           '"/>';
	 //alert(from_htmls[i]);
   		if (type == "single") {document.getElementById("from_place").innerHTML = from_htmls[i]}
		
        // The inactive version of the direction info
        //html = html + '<br>Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        			 GEvent.addListener(marker, "click", function() {
          		 				marker.openInfoWindowHtml(html);
        			 			  });
							 gmarkers[i] = marker;
               htmls[i] = html;               
               i++;
               return marker;
       }
			
	function myclick(i) {				 
      				 gmarkers[i].openInfoWindowHtml(htmls[i]);
				 myzoomfix(16);
				// map.setCenter(new GLatLng(gmarkers[i].getAttribute("lng"),gmarkers[i].getAttribute("lat")),4,G_NORMAL_MAP)							 
	}      

	// functions that open the directions forms
      function tohereTabbed(i) {
        gmarkers[i].openInfoWindowTabsHtml([new GInfoWindowTab("Address",html), new GInfoWindowTab(to_htmls)])
//		(to_htmls);
      }
      function fromhereTabbed(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls);
      }

	// functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls);
      }
	  
    function myzoom(a) {      	
      				map.setZoom(map.getZoom() + a);
	}
			
	function myzoomfix(a) {      	
      				 map.setZoom(a);
	}

	function readMapShort(url) {
		var myQuery = new QueryString();
		myQuery.read();
		if(myQuery.getStatus()){
		var QueryData = myQuery.get("mapId");
		//	
		}
		var bounds = new GLatLngBounds();
         var request = GXmlHttp.create();
        request.open("GET", url, true);		
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            var xmlDoc = request.responseXML;
            // obtain the array of markers and loop through it
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            
            // hide the info window, otherwise it still stays open where the removed marker used to be
            //map.getInfoWindow().hide();
            

            for (i=0; i<gmarkers.length; i++) {
              map.removeOverlay(gmarkers[i]);
            }
            // empty the array
            gmarkers = [];	     
			i = QueryData;          

              var lng = parseFloat(markers[i].getAttribute("lat"));
              var lat = parseFloat(markers[i].getAttribute("lng"));
              var point = new GLatLng(lat,lng);
              var html = markers[i].getAttribute("html");			
			  html = html + "<br><a class='casinoTitles' href='" + markers[i].getAttribute("link") + "'>" + markers[i].getAttribute("label") + " DETAILS</a>";
			  document.getElementById("lower_bar").innerHTML = html
              var label = markers[i].getAttribute("label");
              var icontype = markers[i].getAttribute("icontype");
			  bounds.extend(point);
			  map.setZoom(map.getBoundsZoomLevel(bounds));
			  var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
              var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
              map.setCenter(new GLatLng(clat,clng),15);
		      var infoTabs = [
					  new GInfoWindowTab("Tab #1", label),
					  new GInfoWindowTab("Tab #2", html)
			  ];

              var marker = createMarker(point,label,html,icontype,"single");
              //var marker = createTabbedMarker(point,label,html,icontype);
			  
			  //gmarkers[i].openInfoWindowHtml(htmls[i]);
              map.addOverlay(marker);
			  map.setCenter(lng,lat);					    
			  //map.centerAndZoom(new GLatLng(gmarkers[i].getAttribute("lng"),gmarkers[i].getAttribute("lat")),4);
          }
        }	
		  request.send(null);		  
	}
	
	function readMap(url) {
		var bounds = new GLatLngBounds();
        var request = GXmlHttp.create();
       
        
        
        request.open("GET", url, true);		
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            var xmlDoc = request.responseXML;
            //   alert(request.responseText);
            // obtain the array of markers and loop through it
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            
            // hide the info window, otherwise it still stays open where the removed marker used to be
            map.getInfoWindow().hide();
            
            // clear all existing markers
            // (currently theres a bug in clearOverlays that criples the info window
            // but removing them one-by-one is OK)
            for (i=0; i<gmarkers.length; i++) {
              map.removeOverlay(gmarkers[i]);
            }
            // empty the array
            gmarkers = [];

            // reset the sidebar
            sidebar_html="";
            //sidebar_html="<font style='text-decoration: none; color: white; font-weight: bold; font-size:12;'>List of Bingo Clubs</font><br>";
	     
          
            for (var i = 0; i < markers.length; i++) {

              var lng = parseFloat(markers[i].getAttribute("lat"));
              var lat = parseFloat(markers[i].getAttribute("lng"));
              var point = new GLatLng(lat,lng);
              var html = markers[i].getAttribute("html");
		html = html + "<br><a class='casinoTitles' href='" + markers[i].getAttribute("link") + "'>" + markers[i].getAttribute("label") + " DETAILS</a>";
              var label = markers[i].getAttribute("label");
              var icontype = markers[i].getAttribute("icontype");
			  if (i != 31){  bounds.extend(point);	}
		var infoTabs = [
				  new GInfoWindowTab("Tab #1", label),
				  new GInfoWindowTab("Tab #2", html)
		];

              var marker = createMarker(point,label,html,icontype,"main");
              map.addOverlay(marker);
            }
			map.setZoom(map.getBoundsZoomLevel(bounds));
			var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
            var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
            map.setCenter(new GLatLng(clat,clng));
						//map.setCenter(new GLatLng(parseFloat(markers[0].getAttribute("lng")), parseFloat(markers[0].getAttribute("lat"))), 9);
            // put the assembled sidebar_html contents into the sidebar div
            //sidebar_html= sidebar_html + "<br><BR><font style='text-decoration: none; color: white; font-weight: bold; font-size:12;'>Map Navigation</font><Br><br><a href='javascript:myzoom(5)' class='BingoNav'>Zoom +5</a><br> <a href='javascript:myzoom(1)' class='BingoNav'>Zoom +1</a><br> <a href='javascript:myzoom(-1)' class='BingoNav'>Zoom -1</a><br>           <a href='javascript:myzoom(-5)' class='BingoNav'>Zoom -5</a><br>";
						//document.getElementById("advHolderRightCol").innerHTML = sidebar_html;
          }
        }
        request.send(null);
      }  
    //]]>
