	   	var map;								//The GMap2 google map object.
			var tooltip;						//Div used as a tooltip for GMap markers.
			var default_zoom = 7;		//The default zoom lvl to start the map with.
			var position_markers;		//Array with the current position markers.
			var route_lines;
			var data = new Array(14);
			data[0]  = "20-06-2011";
			data[1]  = "10-07-2011";
			data[2]  = "11-07-2011";
			data[3]  = "12-07-2011";
			data[4]  = "13-07-2011";
			data[5]  = "14-07-2011";
			data[6]  = "15-07-2011";
			data[7]  = "16-07-2011";
			data[8]  = "17-07-2011";
			data[9]  = "18-07-2011";
			data[10]  = "19-07-2011";
			data[11]  = "20-07-2011";
			data[12] = "21-07-2011";
			data[13] = "22-07-2011";
			data[14] = "23-07-2011";
			data[15] = "24-07-2011";
			data[16] = "25-07-2011";
			data[17] = "26-07-2011";
			data[18] = "27-07-2011";
			data[19] = "28-07-2011";
			data[20] = "29-07-2011";
			data[21] = "30-07-2011";
			data[22] = "31-07-2011";
			data[23] = "01-08-2011";
			data[24] = "02-08-2011";
			data[25] = "03-08-2011";
			data[26] = "04-08-2011";
			data[27] = "05-08-2011";
			data[28] = "06-08-2011";
			data[29] = "07-08-2011";
			data[30] = "08-08-2011";
			data[31] = "09-08-2011";
			data[32] = "10-08-2011";
			data[33] = "11-08-2011";
			data[34] = "12-08-2011";
			data[35] = "13-08-2011";
			data[36] = "14-08-2011";
			data[37] = "15-08-2011";
			data[38] = "16-08-2011";
			data[39] = "17-08-2011";

			
			var bootIcon  = new GIcon();
			var startIcon = new GIcon();
			var stopIcon  = new GIcon();
			var startTijd = new Date(2011, 07, 09, 12, 0, 0, 0); //This needs to be the race start time (year, month, day, hours, minutes, seconds, milliseconds)
			var startCenterLat = 47.844321;
			var startCenterLon = 2.366813;
			var startLat = "520521N";
			var startLon = "041350E";			
			var stopLat = "482200N";
			var stopLon = "043000W";

			var start_tt  = 'Start - Scheveningen';
			var start_oms = 'Scheveningen<br /><a href="#" onclick="goto(' + "'http://www.jachtclub.com/'" + ');">Jachtclub Scheveningen</a>';
			var stop_tt   = 'Einde - Brest';
			var stop_oms  = 'Brest';
			
			var nauticalMileUnit = "NM";
			var speedUnit = "Kts";
			
	   	//
			// Start the google maps GMap2 object.
			//
			function load() {	    	
				
				//alert("start = " + startTijd);

				if (!GBrowserIsCompatible()) {
			    	alert('Browser not compatible with google maps');
			    } else {
			    	
			    	//Load all icons used on the map
			    	loadIcons();
					      
			    	//
			    	//Create the Googgle Map Object (GMap2) and set up marker mouseover tooltip div
			    	//
			    	map = new GMap2(document.getElementById("map"));			    		
			      map.addControl(new GLargeMapControl());
			      map.addControl(new GOverviewMapControl ());
			      map.addControl(new GMapTypeControl());
			      map.setCenter(new GLatLng(startCenterLat, startCenterLon), default_zoom,eval("G_SATELLITE_MAP"));
			      //Append dynamic tooltip div
			      tooltip = document.createElement("div");
			      map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
			      tooltip.style.visibility="hidden";
			
						alignDivs();
						loadBoatList();
						loadCatList();
						
						//Add start marker
						var start_marker = new GMarker(new GLatLng(parseFloat(convertLatLonToDecimal(startLat)), parseFloat(convertLatLonToDecimal(startLon))), startIcon);		  
					  start_marker.id = "start";
					  start_marker.tooltip = '<div class="tooltip" style="width: 100px; border: solid; border-width: 1px; padding: 2px; background:url(bg2.png); text-align: center; font-weight: bold;">' +start_tt+ '</div>';
					  GEvent.addListener(start_marker, "click", function() {
							start_marker.openInfoWindowHtml(start_oms);
						});				
					  GEvent.addListener(start_marker,"mouseover", function() {
					    showTooltip(start_marker);
					  });        
					  GEvent.addListener(start_marker,"mouseout", function() {
							tooltip.style.visibility="hidden"
					  });  
		  			map.addOverlay(start_marker);
		  			//Add stop marker
						var stop_marker = new GMarker(new GLatLng(parseFloat(convertLatLonToDecimal(stopLat)), parseFloat(convertLatLonToDecimal(stopLon))), stopIcon);		  
					  stop_marker.id = "stop";
					  stop_marker.tooltip = '<div class="tooltip" style="width: 100px; border: solid; border-width: 1px; padding: 2px; background:url(bg2.png); text-align: center; font-weight: bold;">' +stop_tt+ '</div>';
					  GEvent.addListener(stop_marker, "click", function() {
							stop_marker.openInfoWindowHtml(stop_oms);
						});				
					  GEvent.addListener(stop_marker,"mouseover", function() {
					    showTooltip(stop_marker);
					  });        
					  GEvent.addListener(stop_marker,"mouseout", function() {
							tooltip.style.visibility="hidden"
					  });  
		  			map.addOverlay(stop_marker);
			    }
			}
			
			// Positionering van alle divs
			// - De google maps div wordt even groot als het zichtbare deel van de browser gemaakt.
			// - De 2 menu divs worden naast elkaar in de rechter bovenhoek gepositioneerd.
			function alignDivs() {
				var x,y;
				if (self.innerHeight) // all except Explorer
				{
					x = self.innerWidth;
					y = self.innerHeight;
				}
				else if (document.documentElement && document.documentElement.clientHeight)
					// Explorer 6 Strict Mode
				{
					x = document.documentElement.clientWidth;
					y = document.documentElement.clientHeight;
				}
				else if (document.body) // other Explorers
				{
					x = document.body.clientWidth;
					y = document.body.clientHeight;
				}
				
				//alert(map.getMapTypes()[0].getTileSize());
		
				
				document.getElementById("map").style.left				= "0px";
				//document.getElementById("map").style.width			= (Math.floor(x/256)*256)	+ "px";
				document.getElementById("map").style.width			= x	+ "px";
				document.getElementById("map").style.top				= "0px";
				//document.getElementById("map").style.height			= (Math.floor(y/256)*256)	+ "px";
				document.getElementById("map").style.height			= y	+ "px";
				
				document.getElementById("menu_cat").style.left	= (x - 200 - 20) + "px";
				document.getElementById("menu_cat").style.top		= "30px";
				document.getElementById("menu_boot").style.left	= (x - 200 - 120 - 35) + "px";
				document.getElementById("menu_boot").style.top	= "30px";
				
				document.getElementById("zrr_logo").style.top		= (y-43-50-35) + "px";
				document.getElementById("zrr_logo").style.left		= "2px";
				
				document.getElementById("yc_logo").style.top		= (y-43-30) + "px";
				document.getElementById("yc_logo").style.left		= "1px";
			}
			
		// Load boat list
		function loadBoatList() {
		
   			try {
					var request = GXmlHttp.create();
					
			    request.open("GET", "getdata.php?action=listboot&random="+new Date(), true);
			    request.onreadystatechange = getCallbackFunction(request, processBoatList);
			    request.send(null);
			  } catch(E) {
			  	alert(E);
			  }
		}		
	
		//Parse the boat list
		function processBoatList(xmlDoc) {
			if(xmlDoc != null) {
				var html = '<form action="" method="post"	>' +
										'<table border="0">' +
											'<tr>' +
												'<td>' +
				    							'<select name="boten" size="10" multiple="multiple" class="select_boot">';

				var boten = xmlDoc.documentElement.getElementsByTagName("boot");    
				
				for (var i = 0; i < boten.length; i++) {	
					var id			= boten[i].getElementsByTagName("id")[0].firstChild.nodeValue;
					var nummer	= boten[i].getElementsByTagName("nummer")[0].firstChild.nodeValue;
					var naam		= boten[i].getElementsByTagName("naam")[0].firstChild.nodeValue;
					
					html += '<option value="' + id + '">' + naam + '</option>';
				}
				
				html += '</select>' +
									'</td>' +
										'</tr>' +
									'<tr>' +
										'<td colspan="2" align="center">' +
											'<input type="button" value="toon" onclick="toonBoten();"></input>    ' +
										'</td>' +
									'</tr>' +
								'</table>' +
								'</form>';

			document.getElementById("menu_boot").innerHTML = html;
				
			}
		}
		
		
		// Load category list
		function loadCatList() {
			try {
					var request = GXmlHttp.create();
			    request.open("GET", "getdata.php?action=listcat&random="+new Date(), true);
			    request.onreadystatechange = getCallbackFunction(request, processCatList);
			    request.send(null);
			  } catch(E) {
			  	alert(E);
			  }
		}
		
		//Parse the category list
		function processCatList(xmlDoc) {
			if(xmlDoc != null) {
				var html = '<form action="" method="post"	>' +
										'<table border="0">' +
											'<tr>' +
												'<td valign="top" width="85" rowspan="2">' +
												'Categorie:<br>';

				var categories = xmlDoc.documentElement.getElementsByTagName("cat");    
				
				for (var i = 0; i < categories.length; i++) {	
					var id			= categories[i].firstChild.nodeValue;	
					if( i == 0)				
						html += '<input type="radio" name="category" value="' + id + '" checked>' + id + '</input><br />';
					else
						html += '<input type="radio" name="category" value="' + id + '">' + id + '</input><br />';
				}

				html +=		'</td><td width="80">' +	
										'Van:<br>' +			
										'<select name="category_date_from" size="4" class="cat_select">';
				
				for(var i = 0; i < data.length; i++) {
						html += '<option value="' + data[i] + '">' + data[i] + '</option>';
				}											
									
				html += '</select>' +
									'</td>' +
										'</tr>' +
										'<tr>' +
									
									'<td width="80">' +				
										'Tot:<br>' +
										'<select name="category_date_to" size="4" class="cat_select">';
				
				for(var i = 0; i < data.length; i++) {
						html += '<option value="' + data[i] + '">' + data[i] + '</option>';
				}											
									
				html += '</select>' +
									'</td>' +
									
									'</tr>' +							
									'<tr>' +
										'<td colspan="2" align="center" colspan=2">' +
											'<input type="button" value="toon" onclick="toonCategorie();"></input>    ' +
										'</td>' +
									'</tr>' +									
								'</table>' +
								'</form>';
		
			//alert(html);
			document.getElementById("menu_cat").innerHTML = html;
				
			}
		}
		
		
		
		
		
		
		
		
		
	
		//
		// display the positions. Check if they are available, if not load them.
		//
		function displayPositionsCategorieen(categorie, from_date, to_date) {
				var URL = "getdata.php?action=categorie&random=" + new Date() + "&query_categorie=" + categorie + "&query_fromdate=" + from_date + "&query_todate=" + to_date;
				loadPositions(URL);
		}	
	
		function displayPositionsBoten(boot_ids) {
	
			//create url parameter addition
			var param = "query_boot=";
			for(var i = 0; i < boot_ids.length; i++) {
				param += boot_ids[i] + ",";
			}
			param = param.substring(0, param.length-1);
			
			//create the url with the parameter addition
			var URL = "getdata.php?action=locatie&random=" + new Date() + "&" + param;
			loadPositions(URL);
		}
		  
		//
		// Load the postions.
		//
		function loadPositions(URL) {
		    var request = GXmlHttp.create();
		    request.open("GET", URL, true);
		    request.onreadystatechange = getCallbackFunction(request, processPositionData);
		    request.send(null);
		}
	
		//
		// Process the received xml.
		//
		function processPositionData(xmlDoc){	     
			if(xmlDoc != null) {
				
				initializeMarkerArray();
		  	data = xmlDoc.documentElement.getElementsByTagName("boot");    
		  	
		  	var index = 0;
		  	var route_index = 0;
		  	for (var i = 0; i < data.length; i++) {	
		  		
		  		var id				= data[i].getElementsByTagName("id")[0].firstChild.nodeValue;
		  		var naam  		= data[i].getElementsByTagName("naam")[0].firstChild.nodeValue;
		  		var cat   		= data[i].getElementsByTagName("cat")[0].firstChild.nodeValue;
		  		var positions = data[i].getElementsByTagName("position");
		  		var kleur  	  = data[i].getElementsByTagName("kleurcode")[0].firstChild.nodeValue;
		  		
		  		for(var n = 0; n < positions.length; n++) {
		  			var lat   	= parseFloat(convertLatLonToDecimal(positions[n].getElementsByTagName("lat")[0].firstChild.nodeValue));
		        var lng   	= parseFloat(convertLatLonToDecimal(positions[n].getElementsByTagName("lon")[0].firstChild.nodeValue));
		        var tijd   	= positions[n].getElementsByTagName("tijd")[0].firstChild.nodeValue;
		        var datum  	= positions[n].getElementsByTagName("datum")[0].firstChild.nodeValue;
		        
						
						//Calculate the distance to the previous point (start position if this is the first entry)
						//Calculate the time difference from the previous point
						var lat1, lng1;
						var previousTijd, currentTijd;
						var speed = 0;
						//if(index == 0) {
						if(n == 0) {
							lat1 = parseFloat(convertLatLonToDecimal(startLat));
							lng1 = parseFloat(convertLatLonToDecimal(startLon));
							previousTijd = startTijd;
						} else {
							lat1 = parseFloat(convertLatLonToDecimal(positions[n-1].getElementsByTagName("lat")[0].firstChild.nodeValue));
		        	lng1 = parseFloat(convertLatLonToDecimal(positions[n-1].getElementsByTagName("lon")[0].firstChild.nodeValue));
		        	var tijd1   	= positions[n-1].getElementsByTagName("tijd")[0].firstChild.nodeValue;
		        	var datum1  	= positions[n-1].getElementsByTagName("datum")[0].firstChild.nodeValue;
		        	previousTijd = getTijd(datum1, tijd1);
						}
						var distance =  Math.round(getLatLonDistance(lat1, lng1, lat, lng)*100) / 100;
						var dTijd = getTijd(datum, tijd).getTime() - previousTijd.getTime(); //delta T in milliseconds
						var tijdArray = getTijdComponenten(dTijd);
						var speed = Math.round(distance/(dTijd/1000/60/60) * 100) / 100;

						//Create the remark for this position
		        var opm = "<u>" + datum + " " + tijd + "</u>" +  
		        					"<br><table><tr><td width=\"100\">Afstand:</td><td>~" 	+ distance + nauticalMileUnit + "</td></tr>" +
		        					"<tr><td width=\"100\">Verstreken tijd:</td><td>" 			+ getTijdStringReadable(tijdArray) 		+ "</td></tr>" +
		        					"<tr><td width=\"100\">Snelheid:</td><td>~" 						+ speed + speedUnit 					+ "</td></tr></table>";
		        if(positions[n].getElementsByTagName("opmerking")[0].childNodes.length > 0)
		        	opm += "<p><b>Opmerking:</b><br>" + positions[n].getElementsByTagName("opmerking")[0].firstChild.nodeValue;
		        else
		        	opm += "<p><b>Opmerking:</b><br>Geen opmerking beschikbaar";
	
		        createSiteMarker(new GLatLng(lat,lng),naam, opm, n, index);		        	
		        index++;
		  		}
		  		
		  		//If we have a position for a boat, we need to connect all positions with a line, starting with the start location.
		  		var route = new Array();
		  		if(positions.length > 0) {		  			
		  			route[0] = new GLatLng(parseFloat(convertLatLonToDecimal(startLat)), parseFloat(convertLatLonToDecimal(startLon)));

		  			for(var n = 0; n < positions.length; n++) {	  				
		  				var lat   	= parseFloat(convertLatLonToDecimal(positions[n].getElementsByTagName("lat")[0].firstChild.nodeValue));
		        	var lng   	= parseFloat(convertLatLonToDecimal(positions[n].getElementsByTagName("lon")[0].firstChild.nodeValue));
		        	
		  				route[n+1] = new GLatLng(lat,lng);
		  			}
		  			route_lines[route_index] = new GPolyline(route, "#" + kleur, 3);
		  			route_index++;
		  		}
		
		  	}        	
		  	
		  	displayPositionMarkers();            	
		  } 
		}
	
		//
		// Remove all markers and create a new marker array.
		//
		function initializeMarkerArray() {		
			removePositionMarkers();	
			removeRouteLines();	
			position_markers = new Array();
			route_lines = new Array();
		}
	
		//
		// Remove all existing markers from the map.
		//
		function removePositionMarkers() {
			if(position_markers != null && position_markers.length > 0) {
				for(var i = 0; i < position_markers.length; i++) {
					map.removeOverlay(position_markers[i]);
				}
			}
		}
	
		//
		// Remove all existing route lines from the map.
		//
		function removeRouteLines() {
			if(route_lines != null && route_lines.length > 0) {
				for(var i = 0; i < route_lines.length; i++) {
					map.removeOverlay(route_lines[i]);
				}
			}
		}
	
		//
		// Display the positions on the map.
		//
		function displayPositionMarkers() {
			map.getInfoWindow().hide();
			
			if(position_markers != null && position_markers.length > 0) {
				for(var i = 0; i < position_markers.length; i++) {
					map.addOverlay(position_markers[i]);
				}
			}
			
			if(route_lines != null && route_lines.length > 0) {
				for(var i = 0; i < route_lines.length; i++) {
					map.addOverlay(route_lines[i]);
				}
			}
		}
	
		//
		// Create a GMap marker
		//
		function createSiteMarker(point, name, oms, id, index) {
			var x = point.x;
		  var y = point.y;
		  var pos_marker = new GMarker(point, bootIcon);
		  
		  pos_marker.id = id;
		  pos_marker.tooltip = '<div class="tooltip" style="width: 100px; border: solid; border-width: 1px; padding: 2px; background:url(bg2.png); text-align: center; font-weight: bold;">'+name+'</div>';
		  
		  //Add listeners to the marker
		  GEvent.addListener(pos_marker, "click", function() {
				pos_marker.openInfoWindowHtml(oms);
			});				
		  GEvent.addListener(pos_marker,"mouseover", function() {
		    showTooltip(pos_marker);
		  });        
		  GEvent.addListener(pos_marker,"mouseout", function() {
				tooltip.style.visibility="hidden"
		  });  
		  
		  
		  position_markers[index] = pos_marker;
		}
	
	
		//
		// Show a tooltip.
		//
		function showTooltip(marker) {
		  	tooltip.innerHTML = marker.tooltip;
				var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
				var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
				var anchor=marker.getIcon().iconAnchor;
				var width=marker.getIcon().iconSize.width;
				var height=tooltip.clientHeight;	
				var xmod = (100 - width) / 2;
				var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x - xmod, offset.y - point.y + anchor.y + 10)); 
				pos.apply(tooltip);
				tooltip.style.visibility="visible";
		  }
	  
	  
	  //
	  // Load all icons
	  //
	  function loadIcons() {
	  	bootIcon.image = "http://yachtcontrol.nl/zrr/boot.png";
			bootIcon.shadow = "http://yachtcontrol.nl/zrr/boot.png";
			bootIcon.iconSize = new GSize(48, 48);
			bootIcon.shadowSize = new GSize(48, 48);
			bootIcon.iconAnchor = new GPoint(24, 24);
			bootIcon.infoWindowAnchor = new GPoint(40, 10);
			
			startIcon.image = "http://yachtcontrol.nl/zrr/start.png";
			startIcon.shadow = "http://yachtcontrol.nl/zrr/start.png";
			startIcon.iconSize = new GSize(48, 48);
			startIcon.shadowSize = new GSize(48, 48);
			startIcon.iconAnchor = new GPoint(24, 24);
			startIcon.infoWindowAnchor = new GPoint(40, 10);
			
			stopIcon.image = "http://yachtcontrol.nl/zrr/stop.png";
			stopIcon.shadow = "http://yachtcontrol.nl/zrr/stop.png";
			stopIcon.iconSize = new GSize(48, 48);
			stopIcon.shadowSize = new GSize(48, 48);
			stopIcon.iconAnchor = new GPoint(24, 24);
			stopIcon.infoWindowAnchor = new GPoint(40, 10);
	  }
	  
	  function toonBoten() {
	  	var boten = document.forms[0].boten;
	  	var ids = new Array();
	  	
	  	var index = 0;
	  	for(var i = 0; i < boten.length; i++) {
	  		if(boten[i].selected == true) {
	  			ids[index] = boten[i].value;
	  			index++;
	  		}
	  	}
	  	
	 		displayPositionsBoten(ids);
	  }
	  
	  function toonCategorie() {
	  	var cat       = getCheckedValue(document.forms[1].category);
	  	var date_from = document.forms[1].category_date_from.value;
	  	var date_to   = document.forms[1].category_date_to.value;
	  
	  	if(cat == undefined || cat == "")
	  		alert("Categorie is verplicht. Selecteer een categorie en probeer het opnieuw.");
	  	else if(date_from == undefined || date_from == "")
	  		alert("Van datum is verplicht. Selecteer een van datum en probeer het opnieuw.");
	  	else if(date_to == undefined || date_to == "")
	  		alert("Tot datum is verplicht. Selecteer een tot datum en probeer het opnieuw.");
			else	  	
				date_from = date_from.replace("-", "");
				date_from = date_from.replace("-", "");
				date_to = date_to.replace("-", "");
				date_to = date_to.replace("-", "");
				
				if(!checkData(date_from, date_to)) //date_from > date_to)
					alert("De van datum moet eerder zijn dan de tot datum. Selecteer nieuwe data en probeer het opnieuw." + date_from);
				else	
	  			displayPositionsCategorieen(cat, date_from, date_to);
	  }
	  
	  
	  //
	  // Convert a DMS (degrees/minutes/seconds) latlon location to a decimal latlon location
	  // decimal = degrees + minutes/60 + seconds/3600	 
	  //
	  // return a decimal geographical coordinate
	  //
	  function convertLatLonToDecimal(lon) {
	  	if(lon.length == 7) {
		  	var deg = parseFloat(lon.substring(0,2));
		  	var min = parseFloat(lon.substring(2,4));
		  	var sec = parseFloat(lon.substring(4,6));
		  	var hem = lon.substring(6,7);
		  	
		  	var declatlon = deg + min/60 + sec/3600;
		  	if(hem == "S" || hem == "s" || hem == "W" || hem == "w")
		  		declatlon = declatlon * -1;

		  	return declatlon;
	  	} else {
	  		alert("Cannot convert latlon to decimal (" + lon + ")");
	  		return 0;
	  	}
	  }
	  
	  //
	  // Calculate the distance between 2 geographical coordinates (latitude/longitude)
	  // Uses a spherical earth model, 1" = 1nm
	  //
	  // returns the distance in nautical miles.
	  //
	  function getLatLonDistance(lat1, lon1, lat2, lon2) {
			  var theta = lon1 - lon2;
			  var dist;
			  
			  //theta = lon1 - lon2;
			  dist = Math.sin(degToRad(lat1)) * Math.sin(degToRad(lat2)) + Math.cos(degToRad(lat1)) * Math.cos(degToRad(lat2)) * Math.cos(degToRad(theta));
			  dist = Math.acos(dist);
			  dist = radTodeg(dist);
			  distance = dist * 60 * 1.1515; 		//distance in 	miles
			  //distance = distance * 1.609344 	//distance in kilometers			   
			   distance = distance * 0.8684; 		//distance in nautical miles

				return distance;
	  }
	  
	  //
	  // Convert an angle in degrees to radians
	  //
	  // returns the angle in radians.
	  //
	  function degToRad(deg) {
	  	return deg * Math.PI / 180;
	  }	  

		//
		// Convert an angle in radians to degrees
		//
		// returns the angle in degrees
		//
		function radTodeg(rad) {
			return rad * 180 / Math.PI;
		}
	  
	  //
	  // Open a url in a new window
	  // window size = 800x600
	  //
	  function goto(theUrl) {
	  	window.open(theUrl,'new','width=800,height=600,left=0,top=0,screenX=0,screenY=0,scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes');
	  }	  
	  
	  //
	  // Make a javascript date object from a string date and string time.
	  //	date = "yyyy-mm-dd", time = "hh:mm"
	  //
	  // return a javascript date object
	  //
	  function getTijd(datum, tijd) {
	  	var jaar 	= datum.substring(6, 10);
    	var maand = datum.substring(3,5);
    	var dag 	= datum.substring(0,2);
    	var uur		= tijd.substring(0,2);
    	var min		= tijd.substring(3,5);
    	return new Date(jaar, maand, dag, uur, min, 0, 0);
	  }
	  
	  //
	  // Haal de dagen, uren, minuten en seconden uit een tijd als Date() object.
	  //
	  // return een array met dagen, uren, minuten en seconden.
	  //
	  function getTijdComponentenFromDate(tijd) {
	  	return getTijdComponenten.getTime();
	  }
	  
	  //
	  // Haal de dagen, uren, minuten en seconden uit een tijd in milliseconden.
	  //
	  // return een array met dagen, uren, minuten en seconden.
	  //
	  function getTijdComponenten(tijd) {
	  	var SECOND = 1000; 				
			var MINUTE = SECOND * 60;
			var HOUR 	 = MINUTE * 60;
			var DAY 	 = HOUR * 24;
			var WEEK 	 = DAY * 7; 

			var result = new Array();
			//var milliseconds = tijd.getTime();
			result[0] =	Math.floor(tijd / DAY);
			tijd -= result[0]*DAY;
			result[1] = Math.floor(tijd / HOUR);
			tijd -= result[1] * HOUR;
			result[2] = Math.floor(tijd / MINUTE);
			tijd -= result[2] * MINUTE;
			result[3] = Math.floor(tijd / SECOND);
			
		 	return result;
	  }
	  
	  function getTijdString(tijd) {
	  	var dag = tijd[0];
	  	var uur = tijd[1];
	  	var min = tijd[2];
	  	
	  	var result = "";
	  	if(dag < 10)
	  		result += "0" + dag;
	  	else
	  		result += dag;
	  	
	  	result += ":";
	  	
	  	if(uur < 10) 
	  		result += "0" + uur;
	  	else
	  		result += uur;
	  		
	  	result += ":";
	  	
	  	if(min < 10) 
	  		result += "0" + min;
	  	else
	  		result += min;
	  		
	  	return result;
	  }
	  
	  function getTijdStringReadable(tijd) {
	  	var dag = tijd[0];
	  	var uur = tijd[1];
	  	var min = tijd[2];
	  	
	  	var result = "";
	  	if(dag == 1)
	  		result += dag + " dag";
	  	else
	  		result += dag + " dagen";
	  	
	  	result += ", ";
	  	
	  	if(uur == 1) 
	  		result += uur + " uur";
	  	else
	  		result += uur + " uren";
	  		
	  	result += ", ";
	  	
	  	if(min == 1) 
	  		result += min + " minuut";
	  	else
	  		result += min + " minuten";
	  		
	  	return result;
	  }
	  
	  
	  
	  //
	  // Controleer een radio button of radio button groep en return de geselecteerde waarde.
	  //
	  // returns the value of the selected radio button or an empty string ("") if no selected radio button is found.
	  //
	  function getCheckedValue(radioObj) {
			if(!radioObj)
				return "";
			
			var radioLength = radioObj.length;
			if(radioLength == undefined) {
				if(radioObj.checked)
					return radioObj.value;
				else
					return "";
			}
				
			for(var i = 0; i < radioLength; i++) {
				if(radioObj[i].checked) {
					return radioObj[i].value;
				}
			}
			return "";
		}
		
		function checkData(date1, date2) {
			var dd1 = date1.substring(0,2);
			var mm1 = date1.substring(2,4);
			var yy1 = date1.substring(4,6);
			
			var dd2 = date2.substring(0,2);
			var mm2 = date2.substring(2,4);
			var yy2 = date2.substring(4,6);
			
			if(yy1 > yy2)
				return false;
			else if(yy1 == yy2 && mm1 > mm2)
				return false;
			else if(yy1 == yy2 && mm1 == mm2 && dd1 > dd2)
				return false;
			else
				return true;
		}
	  
	  
	  
	  
	  
	  
	  
	  

	

