/*--------------------------------------------------------------------
Googlemaps Javascript Sheet

Version: 20110207
Copyright: 2011, dicode® VOF - understanding internet
W: www.dicode.nl
E: info@dicode.nl
T: 0570-750680
--------------------------------------------------------------------*/
/* load script */
window.onload = loadScript;

function loadScript() {
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://maps.google.com/maps/api/js?v=3.2&sensor=false&callback=initialize";
	document.body.appendChild(script);
}

function initialize() {
	
	/* map options */
	var myOptions = {
		zoom: mapZoom,
		center: new google.maps.LatLng(mapLat,mapLng),
		disableDefaultUI: true,
		navigationControl: true,
		navigationControlOptions: {
			style: google.maps.NavigationControlStyle.SMALL
		},
		mapTypeControl: true,
		mapTypeControlOptions: {
			style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
		},
		scaleControl: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	map = new google.maps.Map(document.getElementById( mapDiv ), myOptions);
	
	/* home button */
	var homeControlDiv = document.createElement('DIV');
	var homeControl = new HomeControl(homeControlDiv, map);
	
	homeControlDiv.index = 1;
	map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
	
	setupLocation();
	
	return;
	
}

function setupLocation() {
	
	var icon = new google.maps.MarkerImage('http://chart.apis.google.com/chart?chst=d_map_pin_letter_withshadow&chld='+val+'|'+colorBg+'|'+colorTxt,
		new google.maps.Size(40, 37),
		new google.maps.Point(0, 0),
		new google.maps.Point(11, 36)
	);
	
	var marker = new google.maps.Marker( {
		position: new google.maps.LatLng(locationLat,locationLng),
		icon: icon,
		title: strTitle,
	});
	
	marker.setMap(map);
	
	return;
	
}

function HomeControl(controlDiv, map) {
	controlDiv.style.padding = '5px';
	
	var controlUI = document.createElement('DIV');
	controlUI.style.backgroundColor = 'white';
	controlUI.style.borderStyle = 'solid';
	controlUI.style.borderWidth = '2px';
	controlUI.style.cursor = 'pointer';
	controlUI.style.textAlign = 'center';
	controlUI.title = 'Standaard overzicht';
	controlDiv.appendChild(controlUI);
	
	var controlText = document.createElement('DIV');
	controlText.style.fontFamily = 'Arial,sans-serif';
	controlText.style.fontSize = '12px';
	controlText.style.paddingLeft = '4px';
	controlText.style.paddingRight = '4px';
	controlText.innerHTML = 'Home';
	controlUI.appendChild(controlText);
	
	google.maps.event.addDomListener(controlUI, 'click', function() {
		map.setZoom(mapZoom);
		map.setCenter(new google.maps.LatLng(mapLat,mapLng))
	});
}
