function Init() {	//called from <body onLoad="Init();">
	LoadGoogleMaps();
}
function Endit() {
	GUnload();
}

function LoadGoogleMaps() {
	if (GBrowserIsCompatible()) {
		if (document.getElementById('dkmap') != null) {
			var map = new GMap2(document.getElementById('dkmap'));
			var HouseArray = new Array();
			HouseArray[1] = '<div align="center"><a href="index.php?ID=19">Marielyst, Falster</a><br>6 handicapegnede huse<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Marielyst.jpg" alt="" width="210" heigth="157" /></div>';
			HouseArray[2] = '<div align="center"><a href="index.php?ID=20">Alvildasvej, Trend</a><br>4 handicapegnede huse<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Trend.jpg" alt="" width="210" heigth="157" /></div>';
			HouseArray[3] = '<div align="center"><br><a href="index.php?ID=31">Nordby, Sams&oslash;</a><br>1 handicapegnet hus<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Nordby.jpg" alt="" width="210" heigth="157" /></div>';
			HouseArray[4] = '<div align="center"><br><a href="index.php?ID=28">Vig</a><br>3 handicapegnede huse<br><br><img src="http://www.cimbria-ferie.dk/Images/Vig_001.jpg" alt="" width="210" heigth="157" /></div>';
			HouseArray[5] = '<div align="center"><br><a href="index.php?ID=21">S&aelig;lvig, Sams&oslash;</a><br>1 handicapegnet hus<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Samsoe.jpg" alt="" width="210" heigth="157" /></div>';
		} else {
			if (document.getElementById('demap') != null) {
				var map = new GMap2(document.getElementById('demap'));
				var HouseArray = new Array();
				HouseArray[1] = '<div align="center"><a href="index.php?ID=19">Marielyst, Falster</a><br>6 behindertengerechte Ha&uuml;ser<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Marielyst.jpg" alt="" width="210" heigth="157" /></div>';
				HouseArray[2] = '<div align="center"><a href="index.php?ID=20">Alvildasvej, Trend</a><br>4 behindertengerechte Ha&uuml;ser<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Trend.jpg" alt="" width="210" heigth="157" /></div>';
				HouseArray[3] = '<div align="center"><br><a href="index.php?ID=31">Nordby, Sams&oslash;</a><br>1 behindertengerechtes Haus<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Nordby.jpg" alt="" width="210" heigth="157" /></div>';
				HouseArray[4] = '<div align="center"><br><a href="index.php?ID=28">Vig</a><br>3 behindertengerechte Ha&uuml;ser<br><br><img src="http://www.cimbria-ferie.dk/Images/Vig_001.jpg" alt="" width="210" heigth="157" /></div>';
				HouseArray[5] = '<div align="center"><br><a href="index.php?ID=21">S&aelig;lvig, Sams&oslash;</a><br>1 behindertengerechtes Haus<br><br><img src="http://www.cimbria-ferie.dk/Images/Map_Samsoe.jpg" alt="" width="210" heigth="157" /></div>';
			}
		}
		map.enableScrollWheelZoom();
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl());
		map.setCenter(new GLatLng(56.2, 10.5), 7);
//		var point = new GLatLng(56.153934,9.697719);
//		map.addOverlay(createMarker(point, HouseArray[1]));
		var point = new GLatLng(54.698936, 11.953623);
		map.addOverlay(createMarker(point, HouseArray[1]));
		point = new GLatLng(56.852869, 9.228568);
		map.addOverlay(createMarker(point, HouseArray[2]));
		point = new GLatLng(55.966131, 10.550611);
		map.addOverlay(createMarker(point, HouseArray[3]));
    point = new GLatLng(55.864507, 11.543191);
		map.addOverlay(createMarker(point, HouseArray[4]));
    point = new GLatLng(55.861839, 10.556971);
		map.addOverlay(createMarker(point, HouseArray[5]));
	}
}

function createMarker(point, text) {
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() {    marker.openInfoWindowHtml(text);  });
	return marker;
}

function getkey(e) {
	if (window.event)
		 return window.event.keyCode;
	else if (e)
		 return e.which;
	else
		 return null;
}

function checknumber(e) {
	var numbers = '0123456789';
	var key, keychar;
	key = getkey(e);
	if (key == null) return true;

	keychar = String.fromCharCode(key);

	if (numbers.indexOf(keychar) != -1)
		return true;

	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
	   return true;

	return false;
}

function formatCurrency(num, decimals) {
	if(isNaN(num))
		num = "0";
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
	if (decimals == 0)
		return (num);
	else
		return (num + '.' + cents);
}

function openCentered(url, name, width, height, options) {
	var x = (screen.width - width) / 2;
	var y = (screen.height - height) / 2;
	win = window.open(url, name, "width="+width+",height="+height+",top="+y+",left="+x+","+options);
	win.focus();
}
