var map;
function doKMLMap(taal,huiscode,lat,long,zoom) {
	if (taal=="en") domain = "co.uk";
	else domain = taal;
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("gmap_kml")); 
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl());
		map.setCenter(new GLatLng(lat,long),zoom);
		//map.addOverlay(new GGeoXml("http://www.eurorelais."+domain+"/poi/"+huiscode+".kml"));
		map.addOverlay(new GGeoXml("http://qtimehome.multiminded.nl/js/google_points.php?huiscode="+huiscode+"&taal="+taal));
	}
}

//<![CDATA[
	
var gmarkers=[];
var html;
var map;

function load() {
	// Toon de kaart en set de extra controls
	map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(0,0), 5); // dit laten staan ook al wordt het later nog een keer gedefinieerd, anders werkt het niet
	map.setMapType(G_HYBRID_MAP);	
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());

	// Overzichtskaartje
	var ovcontrol = new GOverviewMapControl(new GSize(110,110)); 
	map.addControl(ovcontrol);

	//  Cause the overview to be positioned AFTER IE sets its initial position
	setTimeout("positionOverview(480,365)",1);
	  
	//  Change the overview map type AFTER the overview finishes initializing
	ovmap = ovcontrol.getOverviewMap();
	setTimeout("ovmap.setMapType(G_NORMAL_MAP);",1); 	
}

function loadHb() {
	
	// Toon de kaart en set de extra controls
	map = new GMap2(document.getElementById("huismap"));
	
	//  ========Overzichtskaartje ==========
	var ovcontrol = new GOverviewMapControl(new GSize(110,110)); 
	map.addControl(ovcontrol);
	
	// ======== get a reference to the GMap2 ===========
	ovmap = ovcontrol.getOverviewMap();
	
	//  ======== Cause the overview to be positioned AFTER IE sets its initial position ======== 
	setTimeout("positionOverviewHb(430,243)",1);
		
	//  ======== change the overview map type AFTER the overview finisges initializing =====
	setTimeout("ovmap.setMapType(G_SATELLITE_MAP);",1);  
	
	map.setCenter(new GLatLng(0,0),0);
	bounds = new GLatLngBounds();
}

//  ======== Creeer de verschillende iconen ==========
// huisicoon resultatenlijst
var icon = new GIcon();
icon.image = "http://www.eurorelais.com/img/zoeken/maps/huisje_klein.gif";
icon.shadow = "http://maps.google.com/mapfiles/kml/pal2/icon48s.png";
icon.iconSize = new GSize(17, 17);
icon.shadowSize = new GSize(17, 17);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);

// huisicoon huisbeschrijvingspagina
iconhb = new GIcon();
iconhb.image = "http://www.eurorelais.com//img/zoeken/maps/iconen_kaart/huisje_groot.png";
iconhb.shadow = "http://www.eurorelais.com//img/zoeken/maps/iconen_kaart/huisje_groots.png";
iconhb.iconSize = new GSize(32, 32);
iconhb.shadowSize = new GSize(56, 32);
iconhb.iconAnchor = new GPoint(16, 32);
iconhb.infoWindowAnchor = new GPoint(16, 0);

// luchthavens
var icon_19 = new GIcon();
icon_19.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon19.png";
icon_19.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon19s.png";
icon_19.iconSize = new GSize(32, 32);
icon_19.shadowSize = new GSize(56,32);
icon_19.iconAnchor = new GPoint(16, 32);
icon_19.infoWindowAnchor = new GPoint(16, 0);

// golfbanen
var icon_18 = new GIcon();
icon_18.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon18.png";
icon_18.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon18s.png";
icon_18.iconSize = new GSize(32, 32);
icon_18.shadowSize = new GSize(56,32);
icon_18.iconAnchor = new GPoint(16, 32);
icon_18.infoWindowAnchor = new GPoint(16, 0);

// attracties
var icon_12 = new GIcon();
icon_12.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon12.png";
icon_12.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon12s.png";
icon_12.iconSize = new GSize(32, 32);
icon_12.shadowSize = new GSize(56,32);
icon_12.iconAnchor = new GPoint(16, 32);
icon_12.infoWindowAnchor = new GPoint(16, 0);

// dierentuinen
var icon_13 = new GIcon();
icon_13.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon13.png";
icon_13.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon13s.png";
icon_13.iconSize = new GSize(32, 32);
icon_13.shadowSize = new GSize(56,32);
icon_13.iconAnchor = new GPoint(16, 32);
icon_13.infoWindowAnchor = new GPoint(16, 0);

//  nationale parken
var icon_14 = new GIcon();
icon_14.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon14.png";
icon_14.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon14s.png";
icon_14.iconSize = new GSize(32, 32);
icon_14.shadowSize = new GSize(56,32);
icon_14.iconAnchor = new GPoint(16, 32);
icon_14.infoWindowAnchor = new GPoint(16, 0);

// musea
var icon_15 = new GIcon();
icon_15.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon15.png";
icon_15.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon15s.png";
icon_15.iconSize = new GSize(32, 32);
icon_15.shadowSize = new GSize(56,32);
icon_15.iconAnchor = new GPoint(16, 32);
icon_15.infoWindowAnchor = new GPoint(16, 0);

// wellness
var icon_16 = new GIcon();
icon_16.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon16.png";
icon_16.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon16s.png";
icon_16.iconSize = new GSize(32, 32);
icon_16.shadowSize = new GSize(56,32);
icon_16.iconAnchor = new GPoint(16, 32);
icon_16.infoWindowAnchor = new GPoint(16, 0);

// recreatieplassen
var icon_17 = new GIcon();
icon_17.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon17.png";
icon_17.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon17s.png";
icon_17.iconSize = new GSize(32, 32);
icon_17.shadowSize = new GSize(56,32);
icon_17.iconAnchor = new GPoint(16, 32);
icon_17.infoWindowAnchor = new GPoint(16, 0);

// badplaatsen
var icon_20 = new GIcon();
icon_20.image = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon20.png";
icon_20.shadow = "http://www.eurorelais.com/img/zoeken/maps/iconen_kaart/icon20s.png";
icon_20.iconSize = new GSize(32, 32);
icon_20.shadowSize = new GSize(56,32);
icon_20.iconAnchor = new GPoint(16, 32);
icon_20.infoWindowAnchor = new GPoint(16, 0);

//  ======== Functie om met behulp van checkboxes te bepalen of markers wel of niet getoond moeten worden ==========
function toggleMarkers(soort){

   map.closeInfoWindow();
   if (document.getElementById(soort).checked==false) { //verberg
	  for (var i=0;i<gmarkers.length;i++) {
		 if (gmarkers[i].type==soort)  {
		 
			map.removeOverlay(gmarkers[i]);
		 }
	  }
   } 
   else { // tooon
	  for (var i=0;i<gmarkers.length;i++) {
		 if (gmarkers[i].type==soort)  {
			map.addOverlay(gmarkers[i]);
		 }
	  }
   }
}

function toggleCities(soort){
 if (document.getElementById(soort).checked==false) { //verberg
	  map.setMapType(G_SATELLITE_TYPE);
	  ovmap.setMapType(G_MAP_TYPE);
   } 
   else { // tooon
	  map.setMapType(G_HYBRID_TYPE);
	  ovmap.setMapType(G_MAP_TYPE)
   }


}

function printHuispuntStart (huiscode,huisnaam,sterren,huisimage,huisinformatie,bbh) {
	
	huisinfo =	"	<tr>";
	huisinfo += "		<th class=\"huiscode\" colspan=\"3\">"+huiscode+"&nbsp;&nbsp;"+sterren+"</th>";
	huisinfo += "	</tr>";
	huisinfo += "	<tr>";
	huisinfo += "		<td class=\"foto\" width=\"128\" ><img src=\""+huisimage+"\" alt=\"\" title=\"\"></td>";
	huisinfo += "		<td class=\"huisinfo\" colspan=\"2\" >"+huisinformatie+"</td>";
	huisinfo += "	</tr>";
	huisinfo += "	<tr>";
	huisinfo += "		<td colspan=\"3\" class=\"beschikbaarheid\"><span class=\"omlijnd\">"+bbh+"</span></td>";
	huisinfo += "	</tr>";
	
	return huisinfo;
	
}

function printPeriod (periode,prijs,meerinfo ){
	
	per =	"	<tr>";
	per += "		<td>" + periode + "</td>";
	per += "		<td width=\"145\">" + prijs + "</td>";
	per += "		<td width=\"133\">" + meerinfo + "</td>";
	per += "	</tr>";
	
	return per;
	
}

//  ======== Functie om de icons te plaatsen ==========
function createMarker(point,icon, html, soort) {
	
	// FF 1.5 fix
	html = '<div style="white-space:nowrap;">' + html + '</div>';
	var marker = new GMarker(point, icon);

	gmarkers.push(marker);
	marker.type = soort;
	
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindowHtml(html);
	});
	return marker;
	
}

function createMarkerHb(point,icon, html, soort) {
	
	// FF 1.5 fix
	html = '<div style="white-space:nowrap;">' + html + '</div>';
	var marker = new GMarker(point, icon);
	gmarkers = new Array();
	gmarkers.push(marker);
	marker.type = soort;
	map.addOverlay(marker);
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindowHtml(html);
	});
	return marker;
	
}

//  ======== Functie om het overzichtskaartje te positioneren ========
function positionOverview(x,y) {
	var omap=document.getElementById("map_overview");
	omap.style.left = x+"px";
	omap.style.top = y+"px";
		
	// == restyling ==
	omap.firstChild.style.border = "3px solid #FFFFCC";
	omap.firstChild.firstChild.style.left="0px";
	omap.firstChild.firstChild.style.top="0px";
	omap.firstChild.firstChild.style.right="0px";
	omap.firstChild.firstChild.style.bottom="0px";
	omap.firstChild.firstChild.style.width="130px";
	omap.firstChild.firstChild.style.height="130px";
 }

function positionOverviewHb(x,y) {
	
	var omap=document.getElementById("huismap_overview");
	omap.style.left = x+"px";
	omap.style.top = y+"px";
	
	// == restyling ==
	omap.firstChild.style.border = "3px solid #FFFFCC";
	omap.firstChild.firstChild.style.left="0px";
	omap.firstChild.firstChild.style.top="0px";
	omap.firstChild.firstChild.style.right="0px";
	omap.firstChild.firstChild.style.bottom="0px";
	omap.firstChild.firstChild.style.width="130px";
	omap.firstChild.firstChild.style.height="130px";
 }

function printPOIHb(poi_longitude,poi_latitude,poi_name,poi_address,poi_postcode,poi_plaats,poi_url,poi_type_num,poi_icon) {
				
		var point = new GLatLng(poi_latitude,poi_longitude);
		var html = "<div style=\"border:1px solid #CCCCCC;width:200px;\">";
		html += "		<strong>" + poi_name + "</strong><br />";
		html += "		"+ poi_address +"<br />";
		html += "		"+ poi_postcode +"&nbsp;"+ poi_plaats +"<br />";
		html += "		<a href=\""+ poi_url +"\" target=\"_blank\">"+ poi_url +"</a><br />";
		html += "	</div>";
		marker = createMarkerHb(point,poi_icon,html,poi_type_num);			
}

function printHouse (huis_long,huis_lat) {
	
	var point = new GLatLng(huis_lat,huis_long);
	var marker = new GMarker(point, iconhb);
	map.addOverlay(marker);		
	
}

//]]>
