var Locations = new Array()
var LocDesc = new Array()
var LocIcon = new Array()
var LocPage = new Array()
var curLocation = 1
var MarkerType1 = new GIcon(false, "custom/design/maplogovka.png")
	MarkerType1.iconAnchor = new GPoint(17, 15)
	MarkerType1.iconSize = new GSize(30, 16);
	MarkerType1.shadowSize = new GSize(40, 16);
	MarkerType1.shadow = "custom/design/maplogovka_s.png"
var MarkerType2 = new GIcon(false, "custom/design/maplogovka_r.png")
	MarkerType2.iconAnchor = new GPoint(17, 15)
	MarkerType2.iconSize = new GSize(30, 16);
	MarkerType2.shadowSize = new GSize(40, 16);
	MarkerType2.shadow = "custom/design/maplogovka_s.png"


//Aggersund - ?
Locations[0] = new GLatLng(57.002475, 9.289016)
LocDesc[0] = "Aggersund"
LocIcon[0] = 1
LocPage[0] = "default.aspx?m=2&i=43"

//Alstrup
Locations[1] = new GLatLng(56.699973, 9.261609)
LocDesc[1] = "Alstrup"
LocIcon[1] = 1
LocPage[1] = "default.aspx?m=2&i=44"

//Blære
Locations[2] = new GLatLng(56.865367, 9.512427)
LocDesc[2] = "Blære"
LocIcon[2] = 1
LocPage[2] = "default.aspx?m=2&i=45"

//Borregaard, vesthimmerland
Locations[3] = new GLatLng(56.8496145, 9.237895)
LocDesc[3] = "Borregaard"
LocIcon[3] = 1
LocPage[3] = "default.aspx?m=2&i=46"

//Brøndum, vesthimmerland - ?
Locations[4] = new GLatLng(56.964027, 9.354101)
LocDesc[4] = "Brøndum"
LocIcon[4] = 1
LocPage[4] = "default.aspx?m=2&i=47"

//Ertebølle, vesthimmerland
Locations[5] = new GLatLng(56.810901, 9.177323)
LocDesc[5] = "Ertebølle"
LocIcon[5] = 1
LocPage[5] = "default.aspx?m=2&i=48"

//Fandrup, vesthimmerland - ?
Locations[6] = new GLatLng(56.764112, 9.298709)
LocDesc[6] = "Fandrup"
LocIcon[6] = 1
LocPage[6] = "default.aspx?m=2&i=49"

//Farsø, vesthimmerland
Locations[7] = new GLatLng(56.774680, 9.339720)
LocDesc[7] = "Farsø"
LocIcon[7] = 1
LocPage[7] = "default.aspx?m=2&i=50"

//Fjelsø, vesthimmerland
Locations[8] = new GLatLng(56.666442, 9.433749)
LocDesc[8] = "Fjelsø"
LocIcon[8] = 1
LocPage[8] = "default.aspx?m=2&i=51"

//Flejsborg, vesthimmerland
Locations[9] = new GLatLng(56.860849, 9.338797)
LocDesc[9] = "Flejsborg"
LocIcon[9] = 1
LocPage[9] = "default.aspx?m=2&i=52"

//Fredbjerg, vesthimmerland - ?
Locations[10] = new GLatLng(56.807396, 9.295132)
LocDesc[10] = "Fredbjerg"
LocIcon[10] = 1
LocPage[10] = "default.aspx?m=2&i=53"

//Gatten, vesthimmerland
Locations[11] = new GLatLng(56.880467, 9.399376)
LocDesc[11] = "Gatten"
LocIcon[11] = 1
LocPage[11] = "default.aspx?m=2&i=54"

//Gedsted, vesthimmerland
Locations[12] = new GLatLng(56.690168, 9.335096)
LocDesc[12] = "Gedsted"
LocIcon[12] = 1
LocPage[12] = "default.aspx?m=2&i=55"

//Gislum, vesthimmerland
Locations[13] = new GLatLng(56.766440, 9.518312)
LocDesc[13] = "Gislum"
LocIcon[13] = 1
LocPage[13] = "default.aspx?m=2&i=56"

//Gl. Ullits, vesthimmerland
Locations[14] = new GLatLng(56.713330, 9.307503)
LocDesc[14] = "Gl. Ullits"
LocIcon[14] = 1
LocPage[14] = "default.aspx?m=2&i=57"

//Gundersted, vesthimmerland
Locations[15] = new GLatLng(56.903693, 9.480753)
LocDesc[15] = "Gundersted"
LocIcon[15] = 1
LocPage[15] = "default.aspx?m=2&i=58"

//Haubro, vesthimmerland
Locations[16] = new GLatLng(56.800670, 9.418271)
LocDesc[16] = "Haubro"
LocIcon[16] = 1
LocPage[16] = "default.aspx?m=2&i=59"

//Hemdrup, vesthimmerland - ?
Locations[17] = new GLatLng(56.959153, 9.386368)
LocDesc[17] = "Hemdrup"
LocIcon[17] = 1
LocPage[17] = "default.aspx?m=2&i=60"

//Hornum, vesthimmerland
Locations[18] = new GLatLng(56.840907, 9.425862)
LocDesc[18] = "Hornum"
LocIcon[18] = 1
LocPage[18] = "default.aspx?m=2&i=61"

//Hvalpsund, vesthimmerland - ?
Locations[19] = new GLatLng(56.70109, 9.197337)
LocDesc[19] = "Hvalpsund"
LocIcon[19] = 1
LocPage[19] = "default.aspx?m=2&i=62"

//Hyllebjerg, vesthimmerland - ?
Locations[20] = new GLatLng(56.834610, 9.294600)
LocDesc[20] = "Hyllebjerg"
LocIcon[20] = 1
LocPage[20] = "default.aspx?m=2&i=63"

//Klotrup, vesthimmerland - ?
Locations[21] = new GLatLng(56.684281, 9.424757)
LocDesc[21] = "Klotrup"
LocIcon[21] = 1
LocPage[21] = "default.aspx?m=2&i=64"

//Kornum, vesthimmerland
Locations[22] = new GLatLng(56.956548, 9.322329)
LocDesc[22] = "Kornum"
LocIcon[22] = 1
LocPage[22] = "default.aspx?m=2&i=65"

//Louns, vesthimmerland
Locations[23] = new GLatLng(56.686838, 9.223677)
LocDesc[23] = "Louns"
LocIcon[23] = 1
LocPage[23] = "default.aspx?m=2&i=66"

//Løgstør, vesthimmerland
Locations[24] = new GLatLng(56.967581, 9.257093)
LocDesc[24] = "Løgstør"
LocIcon[24] = 1
LocPage[24] = "default.aspx?m=2&i=67"

//Nyrup, vesthimmerland - ?
Locations[25] = new GLatLng(56.770427, 9.504810)
LocDesc[25] = "Nyrup"
LocIcon[25] = 1
LocPage[25] = "default.aspx?m=2&i=68"

//Næsborg, vesthimmerland
Locations[26] = new GLatLng(56.979114, 9.340514)
LocDesc[26] = "Næsborg"
LocIcon[26] = 1
LocPage[26] = "default.aspx?m=2&i=69"

//Overlade, vesthimmerland
Locations[27] = new GLatLng(56.859687, 9.262060)
LocDesc[27] = "Overlade"
LocIcon[27] = 1
LocPage[27] = "default.aspx?m=2&i=70"

//Padkær, vesthimmerland - ?
Locations[28] = new GLatLng(56.853592, 9.292363)
LocDesc[28] = "Padkær"
LocIcon[28] = 1
LocPage[28] = "default.aspx?m=2&i=71"

//Ranum, vesthimmerland
Locations[29] = new GLatLng(56.895114, 9.227207)
LocDesc[29] = "Ranum"
LocIcon[29] = 1
LocPage[29] = "default.aspx?m=2&i=72"

//Ravnstrup, vesthimmerland
Locations[30] = new GLatLng(56.946478, 9.259699)
LocDesc[30] = "Ravnstrup"
LocIcon[30] = 1
LocPage[30] = "default.aspx?m=2&i=73"

//Risgårde, vesthimmerland - ?
Locations[31] = new GLatLng(56.768139, 9.209075)
LocDesc[31] = "Risgårde"
LocIcon[31] = 1
LocPage[31] = "default.aspx?m=2&i=74"

//Rønbjerg, vesthimmerland - ?
Locations[32] = new GLatLng(56.892155, 9.171599)
LocDesc[32] = "Rønbjerg"
LocIcon[32] = 1
LocPage[32] = "default.aspx?m=2&i=75"

//Simested, vesthimmerland
Locations[33] = new GLatLng(56.696760, 9.552580)
LocDesc[33] = "Simested"
LocIcon[33] = 1
LocPage[33] = "default.aspx?m=2&i=76"

//Skarp Salling, vesthimmerland
Locations[34] = new GLatLng(56.950036, 9.360342)
LocDesc[34] = "Skarp Salling"
LocIcon[34] = 1
LocPage[34] = "default.aspx?m=2&i=77"

//Skivum, vesthimmerland
Locations[35] = new GLatLng(56.866117, 9.589568)
LocDesc[35] = "Skivum"
LocIcon[35] = 1
LocPage[35] = "default.aspx?m=2&i=78"

//Strandby, vesthimmerland
Locations[36] = new GLatLng(56.793014, 9.214199)
LocDesc[36] = "Strandby"
LocIcon[36] = 1
LocPage[36] = "default.aspx?m=2&i=79"

//Svingelbjerg, vesthimmerland
Locations[37] = new GLatLng(56.741032, 9.348388)
LocDesc[37] = "Svingelbjerg"
LocIcon[37] = 1
LocPage[37] = "default.aspx?m=2&i=80"

//Testrup, vesthimmerland
Locations[38] = new GLatLng(56.721826, 9.50026)
LocDesc[38] = "Testrup"
LocIcon[38] = 1
LocPage[38] = "default.aspx?m=2&i=81"

//Tolstrup, vesthimmerland
Locations[39] = new GLatLng(56.982010, 9.321940)
LocDesc[39] = "Tolstrup"
LocIcon[39] = 1
LocPage[39] = "default.aspx?m=2&i=82"

//Uhrehøj Plantage – Skovens Dag, vesthimmerland - ?
Locations[40] = new GLatLng(56.801389, 9.268889)
LocDesc[40] = "Uhrehøj Plantage – Skovens Dag"
LocIcon[40] = 1
LocPage[40] = "default.aspx?m=2&i=83"

//Ullits, vesthimmerland
Locations[41] = new GLatLng(56.726220, 9.287063)
LocDesc[41] = "Ullits"
LocIcon[41] = 1
LocPage[41] = "default.aspx?m=2&i=84"

//Vegger, vesthimmerland
Locations[42] = new GLatLng(56.886212, 9.570830)
LocDesc[42] = "Vegger"
LocIcon[42] = 1
LocPage[42] = "default.aspx?m=2&i=85"

//Vester Hornum, vesthimmerland
Locations[43] = new GLatLng(56.836053, 9.360255)
LocDesc[43] = "Vester Hornum"
LocIcon[43] = 1
LocPage[43] = "default.aspx?m=2&i=86"

//Vesterbølle, vesthimmerland
Locations[44] = new GLatLng(56.711914, 9.364960)
LocDesc[44] = "Vesterbølle"
LocIcon[44] = 1
LocPage[44] = "default.aspx?m=2&i=87"

//Vilsted, vesthimmerland
Locations[45] = new GLatLng(56.903747, 9.286754)
LocDesc[45] = "Vilsted"
LocIcon[45] = 1
LocPage[45] = "default.aspx?m=2&i=88"

//Vindblæs, vesthimmerland
Locations[46] = new GLatLng(56.927918, 9.349998)
LocDesc[46] = "Vindblæs"
LocIcon[46] = 1
LocPage[46] = "default.aspx?m=2&i=89"

//Vognsild, vesthimmerland
Locations[47] = new GLatLng(56.754887, 9.422278)
LocDesc[47] = "Vognsild"
LocIcon[47] = 1
LocPage[47] = "default.aspx?m=2&i=90"

//Østerbølle, vesthimmerland
Locations[48] = new GLatLng(56.705307, 9.453247)
LocDesc[48] = "Østerbølle"
LocIcon[48] = 1
LocPage[48] = "default.aspx?m=2&i=91"

//Østrup, vesthimmerland
Locations[49] = new GLatLng(56.747877, 9.473056)
LocDesc[49] = "Østrup"
LocIcon[49] = 1
LocPage[49] = "default.aspx?m=2&i=92"

//Aalestrup, vesthimmerland
Locations[50] = new GLatLng(56.692990, 9.500111)
LocDesc[50] = "Aalestrup"
LocIcon[50] = 1
LocPage[50] = "default.aspx?m=2&i=93"

//Aars, vesthimmerland
Locations[51] = new GLatLng(56.804487, 9.513460)
LocDesc[51] = "Aars"
LocIcon[51] = 1
LocPage[51] = "default.aspx?m=2&i=94"

var curPage = location.href.indexOf("&i=")
if (curPage > 0) {
	var intPage = parseInt(location.href.substring(curPage + 3, curPage + 5), 10)
	if (intPage > -1) {
		LocIcon[intPage-43] = 2
	}
}

var myGoogleMap
function loadMap() {
	if (GBrowserIsCompatible()) {
		myGoogleMap = new GMap2(document.getElementById("MapsDiv"));
		myGoogleMap.addControl(new GLargeMapControl());
		myGoogleMap.addControl(new GMapTypeControl());
		myGoogleMap.addMapType(G_PHYSICAL_MAP);
		myGoogleMap.removeMapType(G_SATELLITE_MAP);
		myGoogleMap.enableScrollWheelZoom();
		myGoogleMap.setCenter(new GLatLng(56.832, 9.35), 10);
		myGoogleMap.setMapType(G_PHYSICAL_MAP); //(G_SATELLITE_MAP);
		setLocations()
		document.body.onmousemove = function(event) { captureMousePos(event) }
	}
}

function setLocations() {
	for (var intI = 0; intI < Locations.length; intI++) {
		myGoogleMap.addOverlay(createMarker(Locations[intI], intI))
	}
}

function createMarker(point, index) {
	var marker
	if (LocIcon[index] == 1)
		marker = new GMarker(point, MarkerType1)
	else if (LocIcon[index] == 2)
		marker = new GMarker(point, MarkerType2)

  GEvent.addListener(marker, "click", function() {
    mapGotoPage(index);
  });
  /*GEvent.addListener(marker, "dblclick", function() {
  	panmapWithZoom(index);
  });*/
  GEvent.addListener(marker, "mouseover", function() {
		mapDisplayTitle(index);
  });
  GEvent.addListener(marker, "mouseout", function() {
	  mapHideTitle(index);
  });
  return marker;
}

var MousePosX = 0
var MousePosY = 0
function captureMousePos(e) {
	if (!mi) {
		MousePosX = e.pageX
		MousePosY = e.pageY
	} else {
		MousePosX = event.clientX
		MousePosY = event.clientY
	}
}

function mapGotoPage(index) {
	if (LocPage[index]) {
		location.href = LocPage[index]
	}
}

function panmapWithZoom(index) {
	if (index > -1) {
		myGoogleMap.setZoom(15)
		myGoogleMap.panTo(Locations[index])
	}
}

function mapDisplayTitle(index) {
	if (LocDesc[index] && document.getElementById("MapsTitle")) {
		//document.getElementById("MapsTitle").innerHTML = LocDesc[index]
		document.getElementById("MapsTitle").innerHTML = "<b>" + LocDesc[index] + "</b><br><br>Klik på ikon for at se datoer og indsamlet materiale."

		document.getElementById("MapsTitle").style.left = MousePosX + 20
		if (mi)
			document.getElementById("MapsTitle").style.top = MousePosY + document.body.scrollTop + 1
		else
			document.getElementById("MapsTitle").style.top = MousePosY
		document.getElementById("MapsTitle").style.visibility = "visible"
	}
}

function mapHideTitle(index) {
	if (document.getElementById("MapsTitle")) {
		document.getElementById("MapsTitle").style.visibility = "hidden"
	}
}

