function details_show(id) {
  document.getElementById('div_'+id).style.display='block';
  document.getElementById('minus_'+id).style.display='inline';
}

function details_close(id) {
  document.getElementById('div_'+id).style.display='none';
  document.getElementById('minus_'+id).style.display='none';
}

function showMapForAll(language, city, file, field, value1,markercolor1, value2,markercolor2, value3,markercolor3, value4,markercolor4, value5,markercolor5, value6,markercolor6) {

if (location.hostname == "localhost") document.getElementsByTagName("script")[1].src = "http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAsHrxfXhOdSUsR3OpfkdakBRUorI6tTVEKUqHCW5b6uTPt9UAuhRZ5NIPQU5ccaDNMzRsgWa6kcqn4w";

if (GBrowserIsCompatible()) {

  // variable to collect the html which will eventually be placed in the sidebar
  var sidebar_html = "";
   
  // arrays to hold copies of the markers and html used by the sidebar
  var gmarkers = [];
  var htmls = [];
  var i = 0;

  // create the map
  var map = new GMap2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());	
  map.addControl(new GScaleControl());
  map.addControl(new GMapTypeControl()); 
  map.setCenter(new GLatLng(0,0),0); /* setCenter call is necessary, but values still unknown */

  // Create a base icon for all of our markers
  var baseIcon = new GIcon();
  baseIcon.shadow = "";
  baseIcon.iconSize = new GSize(15, 15);  
  baseIcon.iconAnchor = new GPoint(0, 19);
  baseIcon.infoWindowAnchor = new GPoint(15, 1);

  // function for creating numbered markers
  function createMarker(index,point,markercolor,name,address,address_pt,description,freedays,open,website_self,website_other1,website_other1_title) {

    var number = index + 1;
    var icon   = new GIcon(baseIcon);
    icon.image         = 'icons/'+markercolor+number+'.png';
    icon.printImage    = 'icons/'+markercolor+number+'.gif';
    icon.mozPrintImage = 'icons/'+markercolor+number+'.gif';
    var marker = new GMarker(point, icon, name);

    // save the info we need to use later for the sidebar
    gmarkers[i] = marker;
    htmls[i] = name;
   
    // event listener for info window
     GEvent.addListener(marker, "click", function() { gmarkers[i].openInfoWindowHtml(htmls[i]); } );

    // add a line to the sidebar html //
    if (number < 10) leadingcero = "&nbsp;"; else leadingcero = ""; 
    var numbercolumn = '<span class="letter number '+freedays+'">'+leadingcero+number+'</span>';
    var icon_minus   = '<img class="minus" id="minus_'+number+'" src="icons/minus.gif" onclick="details_close('+number+');" />';
    var sightname    = '<span class="name" onclick="details_show('+number+');"><strong>'+name+'</strong></span>';
    var sightaddress = '<span class="address">'+address+'</span>';
    
    var line1  = '<div class="name">'+numbercolumn+icon_minus+sightname+sightaddress+'</div>';
    var line2  = '<div class="description">'+description+'</div>';
    var line3  = '<div class="address_pt">'+address_pt+'</div>';
    var line4  = '<div class="open">'+open+'</div>';
    if (website_self)   website_self   = '<span class="website_self"><a href="'+website_self+'" title="'+website_self+'" target="new">portfolio</a></span>';
    var line5  = '<div class="websites">'+website_self+'</div>';

    sidebar_html += line1+'<div class="dropdown" id="div_'+number+'">'+line2+line3+line4+line5+'</div>';
    
    i++;
   
    return marker;
  }

  var sidebar_html = "";

  // start with an empty GLatLngBounds object 
  var bounds = new GLatLngBounds();


  // define the function that will process the text file
  process_it = function(doc) {
    // split the document into lines
    lines = doc.split("\n");
    for (var i=0; i<lines.length; i++) {
      if (lines[i].length > 1) {
        // split each line into parts separated by | and use the contents
        parts = lines[i].split("|");
        var lat             = parseFloat(parts[0]);
        var lng             = parseFloat(parts[1]);
        var point           = new GLatLng(lat,lng);
        var name            = parts[2];
        var address         = parts[3];
        var address_pt      = parts[4];
        var description     = parts[5];
   //      var freedays        = parts[6];	
   //       var open    	    = parts[7];	
        var website_self    = parts[8];
        var website_other1  = parts[7];
        var website_other1_title = parts[9];

        ////////////////////////////////////////////////////////////////////
        // determine marker color
        if (parts[field] == value1) var markercolor = markercolor1;
        if (parts[field] == value2) var markercolor = markercolor2;
        if (parts[field] == value3) var markercolor = markercolor3;
        if (parts[field] == value4) var markercolor = markercolor4;
	if (parts[field] == value5) var markercolor = markercolor5;
        if (parts[field] == value6) var markercolor = markercolor6;
    
        // create the marker
        var marker = createMarker(i,point,markercolor,name,address,address_pt,description,website_self,website_other1,website_other1_title);
        map.addOverlay(marker);

        // each time a point is found, extent the bounds to include it
        bounds.extend(point);
      }
    }

    // put the assembled sidebar_html contents into the sidebar div
    document.getElementById("map_sidebar").innerHTML = sidebar_html;

    // determine the zoom level from the bounds
    map.setZoom(map.getBoundsZoomLevel(bounds));

    // determine the centre from the bounds 
    var clat = ((bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2 ) + 0.000200;
    var clng =  (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
    map.setCenter(new GLatLng(clat,clng));
  }          
          
  GDownloadUrl(file, process_it);
}
}
// Partly based on code provided by the Blackpool Community Church Javascript Team (www.econym.demon.co.uk/googlemaps/)


