var map;
var gdir;
var geocoder = null;
//var lat=13;
//var lon=55;
var center = new GLatLng(16,54);
var zoom=2
var umzumbe = new GLatLng(-30.61615639127009, 30.537630915641784);
var uoptions ="<strong>Umzumbe</strong><br>School voor Ziyanda <a href='http://www.annovyn.org/2006_12_Ziyanda/ziyanda.html'>lees meer</a>";
var simian = new GLatLng(47.504562, 22.084408);
var soptions = "<strong>Simian</strong><br>2002/10 het eerste huis <a href='http://www.annovyn.org/2002_10_simian%20huis/simian.htm'>lees meer</a><br>2002/11 voedselhulp <a href='http://www.annovyn.org/2002_11voedselhulp/voedselpakketten.htm'>lees meer</a><br>2002/12 schoenen <a href='http://www.annovyn.org/2002_12_schoenen/schoenenactie2002.htm'>lees meer</a><br>2004/10 Huis Santa Geza <a href='http://www.annovyn.org/2004_10_santa_geza/gatdicht.htm'>lees meer</a><br>2005/01 Huis Maria en Gy&ouml;rgy <a href='http://www.annovyn.org/2005_01_gati/gati.htm'>lees meer</a><br>2006/01 Tiener moeder <a href='http://www.annovyn.org/2005_01_tiener_moeders/tiener_moeders.htm'>lees meer</a><br>2005/06 Onderkomen voor gezin in Simian <a href='http://www.annovyn.org/2005_06_plastic_hut/plastic_huis.htm'>lees meer</a>";	
var tarcea = new GLatLng(47.46316179, 22.17470169);
var taoptions = "<strong>Tarcea</strong><br>2002/11 voedselhulp <a href='2002_11 voedselhulp/voedselpakketten.htm'>lees meer</a><br>2004/12 Multifunctioneel gebouw Tarcea <a href='2004_01_mfg_tarcea/mfgtarcea.htm'>lees meer</a><br>2004/11 Een huis voor Tibor en Ildik&oacute; <a href='2004_11_varga/huis%20tarcea2.htm'>lees meer</a><br>2004/11 Jur Koops trapt voor huizen <a href='2004_11_rezmuves/rezmuves.htm'>lees meer</a><br>2005/11 Huis voor Stefan en Luddvica <a href='2005_01_stefan/stefan.htm'>lees meer</a>";
var cheseru = new GLatLng(47.4228320488, 22.079690551);
var coptions = "<strong>Cheseru</strong><br>2002/11 voedselhulp <a href='2002_11 voedselhulp/voedselpakketten.htm'>lees meer</a><br>2002/12 schoenen <a href='2002_12_schoenen/schoenenactie2002.htm'>lees meer</a>";
var nemato = new GLatLng(-33.565482, 26.891935);
var neoptions ="<strong>Nelson Mandela Township Port Alfred </strong><br>2005/05 Voetballertjes in Zuid Afrika <a href='http://www.annovyn.org/2005_05_nemato/nemato.htm'>lees meer</a>";
var told = new GLatLng(47.1209, 21.64375);
var tooptions = "<strong>Told</strong><br>4002/01 Alexandra <a href='http://www.annovyn.org/2004_01_alexandra/Alexandra.htm'>lees meer</a>";
var schagen = new GLatLng(52.800478,4.8058317);
var scoptions = "<strong>Schagen </strong><br>2005/09 Laptop voor Gor <a href='http://www.annovyn.org/initiatieven/initiatieven.htm#59'>lees meer</a>"
var diosig = new GLatLng(47.3077,22.01631111);
var dioptions = "<strong>Diosig </strong><br>2006/07 1ste huis <a href='http://www.annovyn.org/2006_07_Diosig_1ste_huis/Diosig_1st_huis.html'>lees meer</a><br>2006/08 2e huis <a href='http://www.annovyn.org/2006_08_Diosig_2e_huis/diosig_2e_huis.html'>lees meer</a><br>2006/08 3e huis <a href='http://www.annovyn.org/2006_07_Diosig_3e_huis/diosig_3e_huis.html'>lees meer</a><br>2006/09 4e huis <a href='http://www.annovyn.org/2006_09_Diosig_4e_huis/diosig_4e_huis.html'>lees meer</a><br>2006/10 5e huis <a href='http://www.annovyn.org/2006_10_Diosig_5e_huis/diosig_5e_huis.html'>lees meer</a>";
var deaj = new GLatLng(46.3511163,24.404582977);
var deoptions = "<strong>Deaj</strong><br>2008/10 dagje uit <a href='http://www.annovyn.org/initiatieven/initiatieven.htm#64'>lees meer</a><br>2009/01 37 kinderen krijgen 5 halve dagen bijles <a href='http://www.annovyn.org/2009_01_deaj_bijles/2009_01_deaj_bijles.html'>lees meer</a><br>2009/09 met 57 kinderen op schoolreis <a href='http://www.annovyn.org/2009_09_reis/2009_09_reis.htm'>lees meer</a><br>2010/01 film- en fotoverslag <a href='http://www.annovyn.org/2010_01_reis/2010_01_reis_verslag.htm'>lees meer</a><br>2010/03 film- en fotoverslag <a href='http://www.annovyn.org/2010_03_reis/2010_03_reis_verslag.htm'>lees meer</a>";
var stjohns = new GLatLng(-31.622343,29.546324);
var sjoptions = "<strong>Port St. Johns </strong><br> 2009/11 Sisonke school <a href='http://www.annovyn.org/2009_11_sisonke/sisonke.htm'>Lees meer</a> "
var myIcon = new GIcon(G_DEFAULT_ICON, "images/stann.png");

function init() {       
  function createMarker(point,html) {
        var marker = new GMarker(point,{icon:myIcon});
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      } 
	map = new GMap2(document.getElementById("kaart"),{size: new GSize(640, 480)});
	map.setCenter(center,zoom);
	//svOverlay = new GStreetviewOverlay();
   //map.addOverlay(svOverlay);
	//map.setMapType(G_NORMAL_MAP);
	//map.setMapType(G_SATELLITE_MAP);
	map.setMapType(G_HYBRID_MAP);
	//map.setMapType(G_PHYSICAL_MAP);
	//map.setUIToDefault();
	var customUI = map.getDefaultUI();
	customUI.controls.scalecontrol=true;
	customUI.controls.largemapcontrol3d=false;
	customUI.controls.smallzoomcontrol3d=false;
	customUI.controls.maptypecontrol=false;
	customUI.controls.menumaptypecontrol=true;
	map.setUI(customUI);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.addOverlay(createMarker(umzumbe,uoptions));
	map.addOverlay(createMarker(simian,soptions));
	map.addOverlay(createMarker(tarcea,taoptions));
	map.addOverlay(createMarker(cheseru,coptions));
	map.addOverlay(createMarker(told,tooptions));
	map.addOverlay(createMarker(nemato,neoptions));
	map.addOverlay(createMarker(schagen,scoptions));
	map.addOverlay(createMarker(diosig,dioptions));
	map.addOverlay(createMarker(deaj,deoptions));
	map.addOverlay(createMarker(stjohns,sjoptions));
}


window.onload = function()
{
	init();
}
window.onunload = function()
{
	GUnload();
}
/*
			map.openInfoWindow(map.getCenter(), document.createTextNode("Hier wonen wij"));
			//plaatsen van een marker
			var point = new GLatLng(lat, lon);
    		map.addOverlay(new GMarker(point));
*/

/*

// kml gebruiken
function initialize() {
  if (GBrowserIsCompatible()) {
    geoXml = new GGeoXml("http://mapgadgets.googlepages.com/cta.kml");
    map = new GMap2(document.getElementById("map_canvas")); 
    map.setCenter(new GLatLng(41.875696,-87.624207), 11); 
    map.addControl(new GLargeMapControl());
    map.addControl(new GLargeMapControl());
    map.addOverlay(geoXml);
  }
} 

function toggleMyKml() {
  if (toggleState == 1) {
    map.removeOverlay(geoXml);
    toggleState = 0;
  } else {
    map.addOverlay(geoXml);
    toggleState = 1;
  }
}

*/



/*

GEvent.addListener(map, "click", getAddress);
geocoder = new GClientGeocoder();

function getAddress(overlay, latlng) {
  if (latlng != null) {
    address = latlng;
    geocoder.getLocations(latlng, showAddress);
  }
}
function showAddress(response) {
  map.clearOverlays();
  if (!response || response.Status.code != 200) {
    alert("Status Code:" + response.Status.code);
  } else {
    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],
                        place.Point.coordinates[0]);
    marker = new GMarker(point);
    map.addOverlay(marker);
    marker.openInfoWindowHtml(
    '<b>orig latlng:</b>' + response.name + '<br/>' + 
    '<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
    '<b>Status Code:</b>' + response.Status.code + '<br>' +
    '<b>Status Request:</b>' + response.Status.request + '<br>' +
    '<b>Address:</b>' + place.address + '<br>' +
    '<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
    '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
  }
}
*/

/*
	var message = ["ennemaborg","ons huis"];
    // Creates a marker at the given point
    // Clicking the marker will hide it
    function createMarker(latlng, number) {
      var marker = new GMarker(latlng);
      marker.value = number;
      GEvent.addListener(marker,"click", function() {
        var myHtml = "</b><br/>" + message[number];
        map.openInfoWindowHtml(latlng, myHtml);
      });
      return marker;
  }
     var latlng = new GLatLng(53.1910, 7.0);
    map.addOverlay(createMarker(latlng, 0));
	    var latlng = new GLatLng(53.191030, 7.019098);
   map.addOverlay(createMarker(latlng, 1));
*/

/*
    GEvent.addListener(map,"click", function(overlay,latlng) {
      if (overlay) {
        // ignore if we click on the info window
        return;
      }
      var tileCoordinate = new GPoint();
      var tilePoint = new GPoint();
      var currentProjection = G_NORMAL_MAP.getProjection();
      tilePoint = currentProjection.fromLatLngToPixel(latlng, map.getZoom());
      tileCoordinate.x = Math.floor(tilePoint.x / 256);
      tileCoordinate.y = Math.floor(tilePoint.y / 256);
      var myHtml = "Latitude: " + latlng.lat() + "<br/>Longitude: " + latlng.lng();  
      map.openInfoWindow(latlng, myHtml);
    });
*/

/*

//route maken
var map;
var gdir;
var geocoder = null;
var addressMarker;

function initialize() {
  if (GBrowserIsCompatible()) {      
    map = new GMap2(document.getElementById("map_canvas"));
    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", handleErrors);

    setDirections("San Francisco", "Mountain View", "en_US");
  }
}

function setDirections(fromAddress, toAddress, locale) {
  gdir.load("from: " + fromAddress + " to: " + toAddress,
            { "locale": locale });
}

function handleErrors(){
 if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
   alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
 else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
   alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
 
 else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
   alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
   
 else if (gdir.getStatus().code == G_GEO_BAD_KEY)
   alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

 else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
   alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
  
 else alert("An unknown error occurred.");
}

function onGDirectionsLoad(){ 
    // Use this function to access information about the latest load()
    // results.

    // e.g.
    // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
  // and yada yada yada...
}

*/


