
function clearSubmitted() {
    var theform = document.webeasel;
    theform.to.value = 'editPage';
    theform.webeaselDone.value = '';
    theform.followLinkRedirect.value = '';
    theform.pathfrom.value = '';
    theform.edit.value = '';
    theform.toPageID.value = '';
    return true;
}
function ojcwebeasel_submit(event) {
    clearSubmitted();
    var theform = document.webeasel;
    if (!theform)
	return;
    theform.webeaselDone.value = 1;
    alreadySubmitted = true;
    theform.submit();
}
function ojcwebeasel_submit_followLinkOut(href) {
    clearSubmitted();
    var theform = document.webeasel;
    theform.to.value = 'followLinkRedirect';
    theform.followLinkRedirect.value = href;
    alreadySubmitted = true;
    theform.submit();
}
function ojcwebeasel_submit_followLink(pathfrom, edit) {
    clearSubmitted();
    var theform = document.webeasel;
    theform.pathfrom.value = pathfrom;
    theform.edit.value = edit;
    alreadySubmitted = true;
    theform.submit();
}
function ojcwebeasel_submit_toEditSite(pathfrom, edit) {
    clearSubmitted();
    var theform = document.webeasel;
    theform.pathfrom.value = pathfrom;
    theform.edit.value = edit;
    alreadySubmitted = true;
    theform.submit();
}
function ojcwebeasel_submit_followLinkByID(pageID) {
    clearSubmitted();
    var theform = document.webeasel;
    theform.toPageID.value = pageID;
    alreadySubmitted = true;
    theform.submit();
}
function ojcwebeasel_submit_onunload() {
    if (alreadySubmitted) return false;
    clearSubmitted();
    var theform = document.webeasel;
    if (!theform)
	return;
    theform.to.value = 'closedWindow';
    theform.submit();
}
function ojcwebeasel_submit_editentire() {
    clearSubmitted();
    var theform = document.webeasel;
    theform.editAllFields.value = 1;
    alreadySubmitted = true;
    theform.submit();
}
function ojcwebeasel_submit_editform(fieldtoedit, anchorname) {
    clearSubmitted();
    var theform = document.webeasel;
    theform.fieldToEdit.value = fieldtoedit;
    theform.action = theform.action + "#" + anchorname;
    if (fieldtoedit == '') {
        // special case so that Insert buttons work 
        // even if editState was editNone
        if (theform.editState.value == 'editNone') {
            theform.editState.value = 'editOne';
        }
    }
    alreadySubmitted = true;
    theform.submit();
    return true;
}
function ojcwebeasel_cancel_edit(what) {
    clearSubmitted();
    var theform = document.webeasel;
    theform.cancelWhat.value = what;
//    theform.fieldToStore.value = "";
    alreadySubmitted = true;
    theform.submit();
}

function ojcwebeasel_init_richtexts() {
	var tas = document.getElementsByTagName("textarea");
	for (var i = tas.length - 1; i >= 0; --i) {
		if (tas[i].className != "ojcweeb_richtext") {
			continue;
		}
		ojcwebeasel_init_rich_editor(tas[i].id);
	}
}
