d = document;
function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function Focus() {
	d.frmAddMessage.message.focus();
}

function Select() {
	return d.selection.createRange();
}

function Target(t) {
	if(t) return d.getElementById(t);
	else return d.frmAddMessage.message;
}

function format_sel(v) {
	if (d.selection == null ) {
		Target().value += "[" + v + "][/" + v + "]";
		return;
	}
	str = Select().text;
	Focus();
	sel = Select();
	sel.text = "[" + v + "]" + str + "[/" + v + "]";
	return;
}

function insert_link() {
	if (d.selection == null ) {
		my_link = prompt("Voer de URL in:","http://");
		str = prompt("Omschrijving:", "");
		Target().value += "[URL=" + my_link + "]" + str + "[/URL]";
		return;
	}
	str = Select().text;
	Focus();
	my_link = prompt("Voer de URL in:","http://");
	if (my_link != null) {
		sel = Select();
		if (str == '') {
			str = prompt("Omschrijving:", "");
		}
		if (str == '') {
			str = my_link;
		}
		sel.text = "[URL=" + my_link + "]" + str + "[/URL]";
	}
}

function insert_img() {
	if (d.selection == null ) {
		my_link = prompt("Voer de URL in:","http://");
		Target().value += "[IMG]" + my_link + "[/IMG]";
		return;
	}
	Focus();
	my_link = prompt("Voer de URL in:","http://");
	if (my_link != null) {
		sel = Select();
		sel.text = "[IMG]" + my_link + "[/IMG]";
	}
}
function resetImage() {
	document.frmAddMessage.Plaatje.value = 'NONE';
	document.getElementById('huidige').innerHTML = 'GEEN';
}
function OpenPreviewWindow(targetPage, formName){
	now = new Date  
   	MM_openBrWindow('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')
   	formName.action = targetPage + "?ID=" + now.getTime();	
	formName.target = "preview";
	formName.submit();
}
