/* copyright 2000-2006 Trezorix BV */

// t.b.v. markeren van een stranding op de kaart

var dialogArgs;

function createDialogArgs() {
  dialogArgs = new Object();
	dialogArgs = {
   'mark_x':document.getElementById("mark_x"),
   'mark_y':document.getElementById("mark_y"),
   'mark_long':document.getElementById("mark_long"),
   'mark_lat':document.getElementById("mark_lat"),
   'coord':document.getElementById("coord"),
   'coordx':document.getElementById("vondst-xcoordinaat"),
   'coordy':document.getElementById("vondst-ycoordinaat")
  };
}

function clickCoordMap() {
  createDialogArgs();
	showPopUp(this.getAttribute("href") + "&mark_x=" + document.getElementById("mark_x").value + "&mark_y=" + document.getElementById("mark_y").value + "&plaats=" + document.getElementById("vondst-plaats").value, "Coordinaten", "left=100,top=20,height=760,width=550,scrollbars=no,resizable=yes");
	return false;
}

function wisCoordinaten() {
	document.getElementById("mark_x").value = "";
  document.getElementById("mark_y").value = "";
  document.getElementById("mark_long").value = "";
  document.getElementById("mark_lat").value = "";
	if (document.getElementById("vondst-xcoordinaat")) {
		document.getElementById("vondst-xcoordinaat").value = "";
	}
	if (document.getElementById("vondst-ycoordinaat")) {
		document.getElementById("vondst-ycoordinaat").value = "";
	}
  /*
  if (document.getElementById("coord").textContent) {
		document.getElementById("coord").textContent = "...";
	}
	else {
		document.getElementById("coord").innerHTML = "...";
	}
	*/
}

// bij het verversen van de pagina wordt de DOM gegenereerde tekst verwijderd. deze functie copieert de long lat 
// coordinaten uit de hidden input boxen (die niet worden gewist) naar het element dat de coordinaten als tekst bevat
function setCoordText() {
	if (document.getElementById("mark_rdx") != null) {
		if (document.getElementById("mark_rdx").value != '') {
			if (document.getElementById("vondst-xcoordinaat")) {
				document.getElementById("vondst-xcoordinaat").value = "" + FormatFloat(document.getElementById("mark_rdx").value, 3);
			}
			if (document.getElementById("vondst-ycoordinaat")) {
				document.getElementById("vondst-ycoordinaat").value = "" + FormatFloat(document.getElementById("mark_rdy").value, 3);
			}
			/*
			if (document.getElementById("coord").textContent) {
				document.getElementById("coord").textContent = "(" + twodec(document.getElementById("mark_long").value) + ", " + twodec(document.getElementById("mark_lat").value) + ")";
			}
			else {
				document.getElementById("coord").innerHTML = "(" + twodec(document.getElementById("mark_long").value) + ", " + twodec(document.getElementById("mark_lat").value) + ")";
			}
			*/
		}
	}
}

addEvent(window, 'load', setCoordText);

