// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

	var map;
	var geocoder;

function create_google_map() {
	// Create a google maps geocoder for finding points by addressdata
	geocoder = new GClientGeocoder();
 
	// Create the google map
	map = new GMap2(document.getElementById("map"));

	// Format the address to make it retrievable from the google maps geocoder
	var loc = ['Vergeer Verhuizingen','Beemsterweg 5','1311 XC', 'Almere'];
	// Find the address and center the map at the found point
	add_address(geocoder, loc);
	
	// Add zoom and map type control to the google map
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
}

function add_address(geocoder, loc) {
		var address = loc[1]+ ', ' + loc[2] + ', ' + loc[3] + ', NL';
	
		geocoder.getLatLng(address,	function(point) {
   	  map.setCenter(new GLatLng(52.36845935363963, 5.175976753234863), 14);
       var marker = new GMarker(point);
       map.addOverlay(marker);
			
			var marker_text = '<b>' + loc[0] + '</b><br>' + loc[1] + '<br>' + loc[2] + ' ' + loc[3] +
				'<br><br><a href="http://maps.google.nl/maps?daddr=' + point.lat() + ',' + point.lng() + "(Vergeer Verhuizingen)" + '" target="_blank">Routebeschrijving</a>';
			
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(marker_text);
			});
			marker.openInfoWindowHtml(marker_text);
  	}
	);
}

	var isNav4 = false;
	var isIE4 = false;
	var isMac = false;
	var isNav6 = false;
	
	var	isIE = (navigator.userAgent.indexOf("MSIE") != -1);
	var	isFirefox = (navigator.userAgent.indexOf("Firefox") != -1);
	var	isSafari = (navigator.userAgent.indexOf("Safari") != -1);
	
	var togglingBeheer = false;
	
	if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
		isNav4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) != 5) ? true : false;
		isNav6 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 5) ? true : false;
		isIE4  = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
		isMac  = (navigator.platform.indexOf("Mac") != -1) ? true : false;
	};

// function showErrors() {
// 	var elements = $$("span.label")
// 	var error_messages = $$("span.error_message")
// 	
// 	for (var i = 0; i < elements.length; i++) {
// 		elements[i].addClassName("exclamation")
// 	}
// 	
// 	for (var i = 0; i < error_messages.length; i++) {
// 		error_messages[i].show()
// 	}
// }