helpon = false  // ...true or false
document.write('<B>HTML mode:    </B><br>')
modeindex = 0   // ...0=simple, 1=sample, 2=prompt
document.write('</td></tr><tr><td><table align="center"><tr><td><input type="radio" name="radiomode"  value="freecards" checked onClick = " modeindex = 0 "> Simple')
document.write('</td><td><input type="radio" name="radiomode"  value="freecards" onClick = " modeindex = 1"> Sample')
document.write('</td><td><input type="radio" name="radiomode"  value="freecards" onClick = " modeindex = 2"> Prompt')
document.write('</td></tr><tr><td><input type="button" value="Bold" onClick="HjButton(this.form,jBold)">')
document.write('</td><td><input type="button" value="Anchor" onClick="HjButton(this.form,jAnchor)">')
document.write('</td><td><input type="button" value="PREformated" onClick="HjButton(this.form,jPre)">')
document.write('</td><td><input type="button" value="H1 (Header)" onClick="HjButton(this.form,jH1)">')
document.write('</td><td><input type="button" value="Italics" onClick="HjButton(this.form,jItalics)">')
document.write('</td></tr><tr><td><input type="button" value="BReak" onClick="HjButton(this.form,jBreak)">')
document.write('</td><td><input type="button" value="Paragraph" onClick="HjButton(this.form,jPara)">')
document.write('</td><td><input type="button" value="Horizontal Rule" onClick="HjButton(this.form,jRule)">')
document.write('</td><td><input type="button" value="H2 (Header)" onClick="HjButton(this.form,jH2)">')
document.write('</td><td><input type="button" value="Center" onClick="HjButton(this.form,jCenter)"></td></tr></table>')
function HTMLtag (buttonname, insertmode, inserttext, tagstart, tagmiddle, tagend, sampletext, sampletext2, helptext) {
        // ...this fuction defines the object HTMLtag
        this.buttonname = buttonname
        this.insertmode = insertmode    
                // ...1=none 2=standard input 3=lists (UL and OL) 4=DL list 5=anchor
        this.inserttext = inserttext    // ...prompt when asking for insert text
        this.tagstart   = tagstart
        this.tagmiddle  = tagmiddle
        this.tagend     = tagend
        this.sampletext = sampletext    // ...sample text placed between tags in TextArea 
        this.sampletext2= sampletext2
        this.helptext   = helptext
}
jBold = new HTMLtag ( "B", "2", "Enter the text to be BOLD", " <B>", "", "</B>",
        "This will be bold", "" ,
        "The text placed between the <B> and the </B> will be BOLD" )
jItalics = new HTMLtag ( "I", "2", "Enter the text to be ITALICIZED", " <I>", "", "</I>",
        "This will be in italics", "" ,
        "The text placed between the <I> and the </I> will be ITALICIZED" )
jPre = new HTMLtag ( "PRE", "2", "Enter the text to be PREformatted", " <PRE>", "", "</PRE>",
        "This will be PREformatted", "" ,
        "The text placed between the <PRE> and the </PRE> will be PREformatted" )
jPara = new HTMLtag ( "P", "2", "Enter the text for a PARAGRAPH", " <P>", "", "</P>",
        "Start of a PARAGRAPH that continues until the start of next PARAGRAPH.", "" ,
        "The text placed after the <P> will be a separate PARAGRAPH until the next <P>" )
jBreak = new HTMLtag ( "BR", "1", "", " <BR>", "", "",
        "", "" ,
        "This tag forces a line break, start of the next line." )
jRule = new HTMLtag ( "HR", "1", "", " <HR>", "", "",
        "", "" ,
        "This tag puts a (horizontal rule) line on the page." )
jH1 = new HTMLtag ( "H1", "2", "Enter the text for the HEADLINE", " <H1>", "", "</H1>",
        "This will be a top level HEADLINE", "" ,
        "The text placed between the <H1> and the </H1> will be the HEADLINE." )
jH2 = new HTMLtag ( "H2", "2", "Enter the text for the HEADLINE", " <H2>", "", "</H2>",
        "This will be a next to top level HEADLINE", "" ,
        "The text placed between the <H2> and the </H2> will be the HEADLINE." )
jCenter = new HTMLtag ( "Center", "2", "Enter the text to be CENTERED", " <CENTER>", "", "</CENTER>",
        "This will be a CENTERED", "" ,
        "The text placed between the <CENTER> and the </CENTER> will be the CENTERED." )
jAnchor = new HTMLtag ("Anchor", 5, "Enter the URL (e.g., http://www.yahoo.com)", ' <A HREF="', '"> ', '</A>',
        "http://mtvwebdesign.hypermart.net/freecards/", "freEcards (description here)", 
        "Enter the URL (e.g., http://mtvwebdesign.hypermart.net/freecards/index.html) followed by the description." )
jAnchor.inserttext2 = "Enter description (e.g., freEcards)"
function HjButton (form,selection) {    // ...all HTML button call this routine
        if (helpon) {
                if (confirm(selection.helptext)){
                        addHTML (form,selection)
                }
        }else{
                addHTML (form,selection)
        }
}
function addHTML (form,selection) {
        // ...add text to value ot TextArea
        cancel = false
        addText=selection.tagstart
        if (modeindex==2) {     // ...insert mode
                if (selection.insertmode != 1 ) {       // ...if none, skip it all
                        addText += addHTMLinsert (selection, addText, form)
                        if (addText == selection.tagstart) {
                                cancel = true
                        }
                }
        }
        if (modeindex==1) {     // ...sample mode
                addText = addText + selection.sampletext + selection.tagmiddle + selection.sampletext2
        }
        if (modeindex==0) {     // ...simple mode
                addText += selection.tagmiddle
        }
        addText += selection.tagend
        if (cancel == false) {  // ...put text into TextArea unless canceled
                form.text.value += addText
        }
}
function addHTMLinsert (selection, addText, form) {
        // ...insert mode
        // ...addText alread as .tagstart, cancel=false
        // ...insertmodes 1=none, 2=insert, 3=lists (UL and OL), 4=DL list, 5=anchor
        if (selection.insertmode ==2) {         // ...simple insert (eg.<B>...</B>
                i = ""
                i = prompt (selection.inserttext, "")
                if ((i != null) && (i != "")) {                 // ...if input add
                        addText = i 
                }else{
                        addText = ""
                }
        }
        if (selection.insertmode == 5) {        // ...Anchor
                addText = ""
                i = ""
                i = prompt (selection.inserttext, "")
                // ... used for debugging form.text.value += "-->" + i + "<--"
                if ((i != null) && (i != "")) {
                        j = ""
                        j=prompt (selection.inserttext2, "")
                        if ((j != null) && (j != "")) {
                                addText=i + selection.tagmiddle + j
                        }
                }
        }
        return addText
}
