// FUNCTION: OPEN/CLOSE DIV
function contact_openCloseDiv() {
    var si=document["form1"]["reason"].selectedIndex;
    var newCode1="";
    var newCode2="";
    document.getElementById("lengthLimit").innerHTML="";
    if (document["form1"]["reason"].options[si].value=="general comment/inquiry") {
        newCode1="<i><b>subject:</b></i><br /><input type=\"text\" name=\"subject\" value=\"\" size=\"38\" /><br /><br />";
    }
    if (document["form1"]["reason"].options[si].value=="submitting a Letter to the Editor") {
        newCode1="<i><b>in reference to:</b></i><br /><input type=\"text\" name=\"subject\" value=\"\" size=\"38\" /><br /><br />";
        newCode2="<i><b>name & location:</b></i><br /><input type=\"text\" name=\"isFrom\" value=\"\" size=\"38\" /><br /><i style=\"color:#707070; line-height:13px; font-size:12px;\">Please include your first and last name<br />and your home city and state.</i><br /><br />";
        document.getElementById("lengthLimit").innerHTML="<i>Limit your letter to 200 words, and please<br />keep the forum friendly.</i>";
    }
    if (document["form1"]["reason"].options[si].value=="contributing a Mission Life story") {
        newCode2="<i><b>name & location:</b></i><br /><input type=\"text\" name=\"isFrom\" value=\"\" size=\"38\" /><br /><i style=\"color:#707070; line-height:13px; font-size:12px;\">Please include your first and last name<br />and your home city and state.</i><br /><br />";
    }
    if (document["form1"]["reason"].options[si].value=="answering Mormon Speak poll question") {
        newCode1="<i><b>which question?</b></i><br /><input type=\"text\" name=\"subject\" value=\"\" size=\"38\" /><br /><br />";
        newCode2="<i><b>name & location:</b></i><br /><input type=\"text\" name=\"isFrom\" value=\"\" size=\"38\" /><br /><i style=\"color:#707070; line-height:13px; font-size:12px;\">Please include your first and last name<br />and your home city and state.</i><br /><br />";
    }
    if (document["form1"]["reason"].options[si].value=="sharing an opinion for Book Reviews") {
        newCode1="<i><b>name of book:</b></i><br /><input type=\"text\" name=\"subject\" value=\"\" size=\"38\" /><br /><br />";
        newCode2="<i><b>name & location:</b></i><br /><input type=\"text\" name=\"isFrom\" value=\"\" size=\"38\" /><br /><i style=\"color:#707070; line-height:13px; font-size:12px;\">Please include your first and last name<br />and your home city and state.</i><br /><br />";
    }
    if (document["form1"]["reason"].options[si].value=="new question for Mormon QandA") {
        newCode2="<i><b>name & location:</b></i><br /><input type=\"text\" name=\"isFrom\" value=\"\" size=\"38\" /><br /><i style=\"color:#707070; line-height:13px; font-size:12px;\">Please include your first and last name<br />and your home city and state.</i><br /><br />";
    }
    if (document["form1"]["reason"].options[si].value=="idea for an interesting story") {
    }
    if (newCode1.length<1) newCode1="<input type=\"hidden\" name=\"subject\" value=\"\" />";
    if (newCode2.length<1) newCode2="<input type=\"hidden\" name=\"isFrom\" value=\"\" />";
    document.getElementById("optSubject").innerHTML=""+newCode1+"";
    document.getElementById("optFrom").innerHTML=""+newCode2+"";
}
// FUNCTION: CHECK FORM
function contact_checkForm() {
    var si=document["form1"]["reason"].selectedIndex;
    if (si<1) document["form1"]["reason"].options[1].selected=true;
    document["form1"].submit();
}
// FUNCTION: CHECK NUMBER OF WORDS
var wordLimit=200;
var tmpMSG1;
function contact_checkWordLen() {
    tmpMSG1=document["form1"]["message"].value;
}
function contact_checkWordLen2() {
    var tmpMSG2=document["form1"]["message"].value;
    if (tmpMSG2.length>tmpMSG1.length) {
        var allWords = tmpMSG1.split(/[\s]+/);
        if (allWords.length > wordLimit) {
            tmpMSG1="";
            for (var i=0; i<wordLimit; i++) {
                tmpMSG1+=allWords[i]+" ";
            }
            document["form1"]["message"].value=tmpMSG1;
            document.getElementById("msgStatus").innerHTML = "<i><b>text:</b> <span style=\"color:#CC0000;\">(please limit messages to "+wordLimit+" words)</span></i>";
        } else {
            document.getElementById("msgStatus").innerHTML = "<i><b>text:</b></i>";
        }
    } else {
        tmpMSG1=tmpMSG2;
    }
    return true;
}
