helpstat = false;
stprompt = false;
basic = true;

function thelp(swtch){
	if (swtch == 1){
		basic = false;
		stprompt = false;
		helpstat = true;
	} else if (swtch == 0) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 2) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}

function insertsmilie(smilieface) {
	if (document.form.bericht.createTextRange && document.form.bericht.caretPos) {
		var caretPos = document.form.bericht.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smilieface + ' ' : smilieface;
		document.form.bericht.focus();
	} else {
		document.form.bericht.value+=smilieface;
		document.form.bericht.focus();
	}
}

function AddText(NewCode) {
	document.form.bericht.value+=NewCode
}

function AddText(NewCode) {
	if (document.form.bericht.createTextRange && document.form.bericht.caretPos) {
		var caretPos = document.form.bericht.caretPos;
		caretPos.text = NewCode;
	} else {
		document.form.bericht.value+=NewCode;
	}
	document.form.bericht.focus();
}

function bold() {
	var text = getText();
	AddTxt="[b]" + text + "[/b]";
	AddText(AddTxt);
}

function italicize() {
	var text = getText();
	AddTxt="[i]" + text + "[/i]";
	AddText(AddTxt);
}

function underline() {
	var text = getText();
	AddTxt="[u]" + text + "[/u]";
	AddText(AddTxt);
}

function strike() {
	var text = getText();
	AddTxt="[s]" + text + "[/s]";
	AddText(AddTxt);
}

function left() {
	var text = getText();
	AddTxt="[left]" + text + "[/left]";
	AddText(AddTxt);
}

function center() {
	var text = getText();
	AddTxt="[center]" + text + "[/center]";
	AddText(AddTxt);
}

function right() {
	var text = getText();
	AddTxt="[right]" + text + "[/right]";
	AddText(AddTxt);
}

function hr() {
	var text = getText();
	AddTxt="[hr]" + text;
	AddText(AddTxt);
}

function hyperlink() {
	var hyperlink = getText();
	hyperlink=prompt("Vul hier je hyperlink in.","http://"+hyperlink);
	if(hyperlink) {
		hyperlinktxt=prompt("Tekst voor de hyperlink. Leeg laten als je dit hetzelfde wilt als de hyperlink.","");
		if(hyperlinktxt) {
			AddTxt="[url="+hyperlink+"]"+hyperlinktxt+"[/url]";
			AddText(AddTxt);
		}
		else {
			AddTxt="[url="+hyperlink+"]"+hyperlink+"[/url]";
			AddText(AddTxt);
		}
	}
}

function email() {
	var emailadres = getText();
	emailadres=prompt("Vul hier je emailadres in.",emailadres);
	if(emailadres) {
		emaillink=prompt("Tekst voor de emaillink. Leeg laten als je dit hetzelfde wilt als je emailadres.","");
		if(emaillink) {
			AddTxt="[email="+emailadres+"]"+emaillink+"[/email]";
			AddText(AddTxt);
		}
		else {
			AddTxt="[email="+emailadres+"]"+emailadres+"[/email]";
			AddText(AddTxt);
		}
	}
}

function image() {
	var plaatje = getText();
	plaatje=prompt("URL van je plaatje","http://"+plaatje);
	if(plaatje) {
		AddTxt="[img]"+plaatje+"[/img]";
		AddText(AddTxt);
	}
}

function quote() {
	var text = getText();
	AddTxt=" [quote]" + text + "[/quote]";
	AddText(AddTxt);
}

function list() {
	AddTxt=" [list][*] [/*][/list]";
	AddText(AddTxt);
}

function showfont(font) {
	var text = getText();
	if (size) {
		AddTxt="[font="+font+"]" + text + "[/font]";
		AddText(AddTxt);
		document.form.Font.selectedIndex = 0;
	}
}

function showsize(size) {
	var text = getText();
	if (size) {
		AddTxt="[size="+size+"]" + text + "[/size]";
		AddText(AddTxt);
		document.form.Size.selectedIndex = 0;
	}
}

function showcolor(color) {
	var text = getText();
	if (color) {
		AddTxt="[color="+color+"]" + text + "[/color]";
		AddText(AddTxt);
		document.form.Color.selectedIndex = 0;
	}
}

function resizeTextarea()
{
	if (document.form.SelectSize.value == 1)
	{
		document.form.bericht.cols = 45;
		document.form.bericht.rows = 11;
	}
	if (document.form.SelectSize.value == 2)
	{
		document.form.bericht.cols = 70;
		document.form.bericht.rows = 12;
	}
	if (document.form.SelectSize.value == 3)
	{
		document.form.bericht.cols = 90;
		document.form.bericht.rows = 12;
	}
	if (document.form.SelectSize.value == 4)
	{
		document.form.bericht.cols = 130;
		document.form.bericht.rows = 15;
	}
}

function storeCaret(ftext) {
	if (ftext.createTextRange) {
		ftext.caretPos = document.selection.createRange().duplicate();
	}
}

function getText() {
	if (document.form.bericht.createTextRange && document.form.bericht.caretPos) {
		return document.form.bericht.caretPos.text;
	} else {
		return '';
	}
}

function OpenPreview()
{
	if (document.form.bericht) {
		if (trim(document.form.bericht.value)=="") {
			alert("Nothing to Preview!")
			return false
		}
		popupWin = window.open('pop_preview.asp', 'preview_page', 'scrollbars=yes,width=750,height=450')	
		return true
	}
}

function validate(){
	if (document.form.Subject) {
		if (trim(document.form.Subject.value)=="") {
			alert("You must enter a Subject")
			return false
		}
	}
	if (document.form.bericht) {
		if (trim(document.form.value)=="") {
			alert("You must enter a Message")
			return false
		}
	}
	return true
}

function ltrim(s) {
	return s.replace( /^\s*/, "" );
}
function rtrim(s) {
	return s.replace( /\s*$/, "" );
}
function trim ( s ) {
	return rtrim(ltrim(s));
}
