
function ReplaceMenus()
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    document.getElementById('leftmenu').style.left = "-1000px";
    document.getElementById('leftmenu').style.left = "auto";
    document.getElementById('rightmenu').style.left = "-1000px";
    document.getElementById('rightmenu').style.left = "auto";
  }
}

function ShowElement(id)
{
  document.getElementById(id).style.display = "block";
}

function HideElement(id)
{
  document.getElementById(id).style.display = "none";
}

function ToggleShowElement(id)
{
  if (document.getElementById(id).style.display == "none")
    document.getElementById(id).style.display = "block";
  else
    document.getElementById(id).style.display = "none";
}

function Goto(url)
{
  window.location = url;
}

function AddBookmark(title, url)
{
  if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
  else
  if (document.all)
    window.external.AddFavorite(url, title);
  else if ((window.opera) && (window.print))
    return true;
}

//-------------------------------------------------------

var enhmemoid = "";

function EnhMemoSetText(id, text)
{
	var Memo = document.getElementById(id);
	if (Memo == null) Memo = opener.document.getElementById(id);
  var crossPos = text.indexOf("¤");
  var firstCode = text.substr(0, crossPos);
  var lastCode = text.substr(crossPos + 1, text.length);

	if (window.getSelection)
	{
    var selStart = Memo.selectionStart;
	  var selEnd = Memo.selectionEnd;

	  text = firstCode + Memo.value.substr(selStart, selEnd - selStart) + lastCode;
		Memo.value = Memo.value.substr(0, selStart) + text + Memo.value.substr(selEnd, Memo.value.length);
		var newStart = selStart == selEnd ? selStart + text.length : selStart;
		var newEnd = selStart + text.length;
		Memo.setSelectionRange(newStart, newStart);
	}
	else if (document.selection)
	{
   	var range = document.selection.createRange();
		if (range.parentElement().name == id)
		{
			if (firstCode != "")
				range.text = firstCode + range.text + lastCode;
			else
				range.text = lastCode;
		}
		range.scrollIntoView();
  	Memo.focus();
	}
}

function EnhMemoSelectionToBold(id)
{
	EnhMemoSetText(id, "[b]¤[/b]");
}

function EnhMemoSelectionToUnderline(id)
{
	EnhMemoSetText(id, "[u]¤[/u]");
}

function EnhMemoSelectionToItalic(id)
{
	EnhMemoSetText(id, "[i]¤[/i]");
}

function EnhMemoInsertImage(id)
{
  var url = prompt("Webadres", "http://");
  if ((url == undefined) || (url == "") || (url == "http://")) return;
  EnhMemoSetText(id, "[img]" + url + "[/img]");
}

function EnhMemoInsertEmail(id)
{
  var email = prompt("Email", "");
  if ((email == undefined) || (email == "")) return;
  var name = prompt("Naam (optioneel)", "");
  if (name == undefined) return;

  if (name == "")
	  EnhMemoSetText(id, "[email]" + email + "[/email]");
  else
	  EnhMemoSetText(id, "[email=" + email + "]" + name + "[/email]");
}

function EnhMemoInsertLink(id)
{
  var url = prompt("Webadres", "http://");
  if ((url == undefined) || (url == "") || (url == "http://")) return;
  var desc = prompt("Omschrijving (optioneel)", "");
  if (desc == undefined) return;

  if (desc == "")
	  EnhMemoSetText(id, "[url]" + url + "[/url]");
  else
	  EnhMemoSetText(id, "[url=" + url + "]" + desc + "[/url]");
}

function EnhMemoEmoticons(id)
{
  var url = "?action=emoticons";
  var moda = window.open(url, "moda","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=230, height=210");
  moda.opener = self;
  enhmemoid = id;
  moda.focus();
}

function EnhMemoEmoticonClick(emoticon)
{
  opener.EnhMemoSetText(opener.enhmemoid, " " + emoticon + " ");
}

function EnhMemoPreview(id)
{
	var Memo = document.getElementById(id);
  var moda = window.open("", "moda", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=420, height=420");

  moda.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
  moda.document.write("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>");
  moda.document.write("<body><form id='previewform' action='?' method='get'>\n");
  moda.document.write("<input type='hidden' id='action' name='action' value='preview' />\n");
  moda.document.write("<textarea style='display: none' id='previewtext' name='previewtext'></textarea>\n");
  moda.document.write("</form></body></html>\n");

  moda.document.getElementById("previewtext").value = Memo.value;
  moda.document.getElementById("previewform").submit();
  moda.focus();
}

function EnhMemoHelp(id)
{
  var url = "?action=help";
  var moda = window.open(url, "moda","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=420, height=420");
  moda.focus();
}

//-------------------------------------------------------

function CheckCheckBoxes(formid, checked)
{
  form = document.getElementById(formid);
  var i = 0;
  while (form.elements[i])
  {
    if (form.elements[i].type == "checkbox")
      form.elements[i].checked = checked;
    i++;
  }
}
