defmode = "advmode";		// default mode (normalmode, advmode, helpmode)

if (defmode == "advmode") {
        helpmode = false;
        normalmode = false;
        advmode = true;
} else if (defmode == "helpmode") {
        helpmode = true;
        normalmode = false;
        advmode = false;
} else {
        helpmode = false;
        normalmode = true;
        advmode = false;
}
function chmode(swtch){
        if (swtch == 1){
                advmode = false;
                normalmode = false;
                helpmode = true;
               
        } else if (swtch == 0) {
                helpmode = false;
                normalmode = false;
                advmode = true;
                
        } else if (swtch == 2) {
                helpmode = false;
                advmode = false;
                normalmode = true;
             
        }
}

function AddText(NewCode) {
        if(document.all){
        	insertAtCaret(document.input.content, NewCode);
        	setfocus();
        } else{
        	document.input.content.value += NewCode;
        	setfocus();
        }
}

function storeCaret (textEl){
        if(textEl.createTextRange){
                textEl.caretPos = document.selection.createRange().duplicate();
        }
}

function insertAtCaret (textEl, text){
        if (textEl.createTextRange && textEl.caretPos){
                var caretPos = textEl.caretPos;
                caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
        } else if(textEl) {
                textEl.value += text;
        } else {
        	textEl.value = text;
        }
}




function setfocus() {
        document.input.content.focus();
}
