function UpdateControls() {
  if (document.filterform.filterselection.value == '') {
    document.filterform.setfilter.disabled = true;
  }
  else {
    document.filterform.setfilter.disabled = false;
  }
}

function clearFilterCookies() {
  var dc = document.cookie;
  var d = new Date();
  var cookies = dc.split('; ');
  var c = 0;
  while (cookies[c] != null) {
    if (cookies[c].indexOf('lysningfilter') == 0) {
      document.cookie = cookies[c]+'; expires='+d.toGMTString()+';'+';';
    }
    c++;
  }
}

function visLysning(id) {
  var iwidth = 535;
  var iheight = 680;
  var iposx = (screen.width / 2) - (iwidth / 2);
  var iposy = (screen.height / 2) - (iheight / 2);
	newWindow = window.open('lysning.php?id='+id,'lysningWindow','width='+iwidth+',height='+iheight+',scrollbars=1,left='+iposx+',top='+iposy+'');
  newWindow.focus();
}

function SetCaption( id, caption ) {
  vVar = document.getElementById(id);
  if (vVar != null) {
    while (vVar.childNodes[0] != null) vVar.removeChild(vVar.childNodes[0]);
    tText = document.createTextNode(caption);
    vVar.appendChild(tText);
  }
}

function SetCaptions( type ) {
  if (type == 'Fremlysning') {
    SetCaption('titlebar','Fremlysning');
    SetCaption('sted','Fundet i/ved');
    SetCaption('siden','Set siden');
    document.title = 'Fremlysning';
    autofilterbtn = document.getElementById('autofilter');
    if (autofilterbtn != null) {
      autofilterbtn.value = 'Efterlysninger';
    }
  }
  else {
    SetCaption('titlebar','Efterlysning');
    SetCaption('sted','Forsvundet i/ved');
    SetCaption('siden','Væk siden');
    document.title = 'Efterlysning';
    autofilterbtn = document.getElementById('autofilter');
    if (autofilterbtn != null) {
      autofilterbtn.value = 'Fremlysninger';
    }
  }
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}

function formOK() {
	if (document.editor.navn.value.length == 0)
	{
		alert('Du skal oplyse dit navn');
		return false;
	}
	if (document.editor.adresse.value.length == 0)
	{
		alert('Du skal oplyse din adresse');
		return false;
	}
	if (document.editor.postnr.value.length == 0)
	{
		alert('Du skal oplyse dit postnummer');
		return false;
	}
	if (document.editor.telefon.value.length == 0)
	{
		alert('Du skal oplyse dit telefonnummer');
		return false;
	}
	return true;
}
