function lag(lagnavn) // IE4+
{
    if (document.all[lagnavn].style.display == 'none') {
        document.all[lagnavn].style.display = 'block';
    }
    else {
        document.all[lagnavn].style.display = 'none';
    }
}


function popup(url,name,wwidth,wheight,wscrollbars) {
	window.open(url,name,'width='+wwidth+',height='+wheight+',scrollbars='+wscrollbars+',toolbar=0,status=no,resizable=1');
}

function surroundText(text1,text2){
	tval = document.forms[0].url.value;
	aval = document.forms[0].url.value;
	nval = document.forms[0].naam.value;
	window.opener.document.cform.content.value += text1 + aval + ">" + nval + text2;
	window.opener.document.cform.content.focus();
	window.close();
}

function surroundText2(text1){
	if (document.forms[0].content.createTextRange && document.forms[0].content.caretPos) {      
		var caretPos = document.forms[0].content.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text1 + caretPos.text + ' ' : text1 + caretPos.text;
	}
	else document.forms[0].content.value += text1 + text2;
	document.forms[0].content.focus(caretPos)
}

function replaceText(text)
{
	if (document.forms[0].content.createTextRange && document.forms[0].content.caretPos) {      
		var caretPos = document.forms[0].content.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else document.forms[0].content.value += text;
	document.forms[0].content.focus(caretPos)
}

function storeCaret(text) {
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
}

function sv() {
	nval = "";
	for (i=0;i<document.forms[0].copy2.length;i++) {
		myval = document.forms[0].copy2[i].value;
		nval = nval+myval+',';
	}
	document.forms[0].myfield.value = nval;
}

function sv2() {
	nval2 = "";
	for (i=0;i<document.forms[0].lcopy2.length;i++) {
		myval2 = document.forms[0].lcopy2[i].value;
		nval2 = nval2+myval2+',';
	}
	document.forms[0].myfield2.value = nval2;
}

function myreplace(input) {
	theSelection = document.selection.createRange().text;
	if (input=="") {

	}
	else {
		if (theSelection!="") {
			document.selection.createRange().text = "<"+input+">" + theSelection + "</"+input+">";
		}
		else {
			alert('Selecteer eerst de tekst.');	
		}
	}
}

function addtxt(input) {
	theSelection2 = document.selection.createRange().text;
	if (theSelection2!="") {
		var val_url = prompt('Vul het adres in:', 'http://');
		var val_txt = prompt('Vul de te linken tekst in:', theSelection2);
		document.selection.createRange().text = "<link="+val_url+">" + val_txt + "</link>";
	}
	else {
		var val_url = prompt('Vul het adres in:', 'http://');
		var val_txt = prompt('Vul de te linken tekst in:', '');
		if (val_url=="http://" || val_url=="" || val_txt=="") {
			alert('Vul een internet adres, en een linktekst in.');
		}
		else {
			document.forms[0].content.value += "<link="+val_url+">" + val_txt + "</link>";
		}
	}
}

