function displayHideFields() {
  document.getElementById('titel').innerHTML = 'Titel:';
  if (document.mainform.soort.value == 'vraag') 
    document.getElementById('titel').innerHTML = 'Vraag:';
  if (document.mainform.soort.value == 'aanbod') 
    document.getElementById('titel').innerHTML = 'Aanbod:';
  if ((document.mainform.soort.value == 'vraag') ||
      (document.mainform.soort.value == 'aanbod')) {
    for ($i=1;$i<=3;$i++) 
      document.getElementById('VA'+$i).style.display = 'block';
  } else {
    for ($i=1;$i<=3;$i++) 
      document.getElementById('VA'+$i).style.display = 'none';
  }  
  if (document.mainform.soort.value == 'agenda') {
    for ($i=1;$i<=4;$i++) 
      document.getElementById('AG'+$i).style.display = 'block';
  } else {
    for ($i=1;$i<=4;$i++) 
      document.getElementById('AG'+$i).style.display = 'none';
  }  
  if ((document.mainform.soort.value == 'vraag') ||
      (document.mainform.soort.value == 'aanbod') ||
      (document.mainform.soort.value == 'agenda')) {
    for ($i=1;$i<=2;$i++) 
      document.getElementById('VG'+$i).style.display = 'block';
  } else {
    for ($i=1;$i<=2;$i++) 
      document.getElementById('VG'+$i).style.display = 'none';
  }    
}

function on(o) {
  o.style.backgroundColor='#33CC00';
}  

function off(o) {
  o.style.backgroundColor='';
}  

function showFoto() {
  fCont = document.getElementById('popUpContent').style;
  photo = document.getElementById('popUpDiv').style; 
  photo.top = 30 + document.body.scrollTop;
  fWidth = (document.getElementById("fotoWidth").value * 1.0);
  fCont.width = fWidth; 
  photo.width = fWidth + 2;
  photo.marginLeft = -1 * ((fWidth / 2) + 1);
  fHeight = (document.getElementById("fotoHeight").value * 1.0);
  photo.height = fHeight + 24;
  fCont.height = fHeight; 
  document.getElementById('titleBar').innerHTML = 'Foto';
  document.getElementById("popUpContent").innerHTML = '<img src="' +
  document.getElementById("fotoURL").value + '">';
  photo.display = 'block';
}

function getOffsetX(objectIn) {
  if (!objectIn) {return(0)}
  currLeft = 0;
  do { currLeft += objectIn.offsetLeft; } while (objectIn = objectIn.offsetParent);
  return(currLeft);
}

function getOffsetY(objectIn) {
  if (!objectIn) { return(0)}
  currTop = 0;
  do { currTop += objectIn.offsetTop; } while (objectIn = objectIn.offsetParent);
  return(currTop);
}

function update(lidNr, fNo) {
  var o = document.getElementById('field_' + lidNr + '_' + fNo);
  var o2 = document.getElementById('mark_' + fNo);
  
  if (o != null) {
    document.subForm.newValue.value = o.innerHTML;
    document.subForm.lidNr.value = lidNr;
    document.subForm.fieldNo.value = fNo;
    document.subForm.newValue.value = o.innerHTML;
    document.getElementById('inputDiv').style.left = getOffsetX(o) - 1; 
    document.getElementById('inputDiv').style.top = getOffsetY(o);
    document.getElementById('inputDiv').style.width = getOffsetX(o2) - getOffsetX(o); 
    document.subForm.newValue.style.width = getOffsetX(o2) - getOffsetX(o); 
    document.getElementById('inputDiv').style.display = 'block';
    document.subForm.newValue.focus();
  } else {  
    o = document.getElementById('sel_' + lidNr + '_' + fNo);
    document.subForm.newValue.value = o.value;
    document.subForm.lidNr.value = lidNr;
    document.subForm.fieldNo.value = fNo;
    document.subForm.submit();
  }
}

function handleKey(evt) {
  if ((evt.which == 27) || (evt.keyCode == 27)) 
    document.getElementById('inputDiv').style.display = 'none';
  return true;
}

function showMap(obj) {
  currRow = obj.parentNode.parentNode;
  naam = currRow.getElementsByTagName('td')[3].innerHTML;
  adres = obj.innerHTML + ' ' +
  currRow.getElementsByTagName('td')[5].innerHTML;
  maps = document.getElementById('popUpDiv').style; 
  maps.display = 'block';
  maps.top = 110 + document.body.scrollTop;
  document.getElementById('titleBar').innerHTML = naam + ', ' + adres;
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("popUpContent"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.enableScrollWheelZoom();
    geocoder = new GClientGeocoder();
    geocoder.getLatLng(adres, function(point) {
      if (!point) {
        alert(adres + " niet gevonden");
      } else {
        map.clearOverlays()
        map.setCenter(point, 15);
        var marker = new GMarker(point, {draggable: false});  
        map.addOverlay(marker);
      }  
    });
  }
}

function updateValue(lidNr, fieldNo, newValue) {
  o = top.document.getElementById('field_' + lidNr + '_' + fieldNo);
  if (o != null)
    top.document.getElementById('field_' + lidNr + '_' + fieldNo).innerHTML = newValue;
}
