function fsExec(aName, aArg) {
	document.getElementById('editorWindow').focus();
	document.execCommand(aName, false, aArg);
	document.getElementById('editorWindow').focus();
} 

function fSubmit() {
	document.formen.indhold.value = document.getElementById('editorWindow').innerHTML;
	document.formen.submit();
}

function doBR() {
	document.getElementById('editorWindow').focus();
	var cursor = document.selection.createRange();
	document.getElementById('editorWindow').focus();
	cursor.pasteHTML("<br />");
}

function doIMG(url) {
	document.getElementById('editorWindow').focus();
	var cursor = document.selection.createRange();
	document.getElementById('editorWindow').focus();
	cursor.pasteHTML("<img src=\""+url+"\" border=\"0\" />");
}

function Tjek() {
	update();
}

document.onkeydown = Tjek

document.onload = Tjek

function update() {
	change(document.getElementById('bolden'), "Bold");
	change(document.getElementById('italic'), "italic");
	change(document.getElementById('underline'), "underline");
	change(document.getElementById('strikethrough'), "strikethrough");
	change(document.getElementById('superscript'), "superscript");
	change(document.getElementById('subscript'), "subscript");
	change(document.getElementById('justifyleft'), "justifyleft");
	change(document.getElementById('justifycenter'), "justifycenter");
	change(document.getElementById('justifyright'), "justifyright");
	change(document.getElementById('justifyfull'), "justifyfull");
}

function change(objID, type) {
	if (document.queryCommandValue(type)) {
		Button_active(objID);
	}
	if (!document.queryCommandValue(type)) {
		Button_off(objID);
	}
}

function Button_over(objID) {
	objID.style.border='1px solid #000000';
	objID.style.backgroundColor='#e0e0e0'; 
}

function Button_off(objID) {
	objID.style.border='1px solid #FFFFFF';
	objID.style.backgroundColor='#FFFFFF';
}

function Button_active(objID) {
	objID.style.border='1px solid #000000';
	objID.style.backgroundColor='#d0d0d0'; 
}

function PopWin(url,h,w) { 
	var ww = 480, wh = 340, leftPos = null, topPos = null; 
	IE=(document.all)?true:false; 
	var wh = (IE)?document.body.clientHeight : window.innerHeight; 
	var ww = (IE)?document.body.clientWidth : window.innerWidth; 
	if (top.screen){ 
		if (screen.width){ 
  			leftPos = Math.round((ww-w-10)/2); 
			topPos = Math.round((wh-h-29)/2); 
		} else { 
			leftPos = 50 
			topPos = 50 
		} 
	} 
	popupWin = window.open(url, 'popup', 'scrollbars,height=' + h + ',width=' + w + ',top=' + topPos + ',left=' + leftPos + '') 
} 
