// SRC="ggc_formval-js.js"
// Application: gainesvillegardenclub.org
//
// Copyright September 2006, brymar.net - All rights reserved.
//
//
actualEM = new Array(6)
actualEM[0] = "webmaster@ggcfl.org"
actualEM[1] = "president@ggcfl.org"
actualEM[2] = "vice-president@ggcfl.org"
actualEM[3] = "secretary@ggcfl.org"
actualEM[4] = "treasurer@ggcfl.org"
actualEM[5] = "rentals@ggcfl.org"
//
function snapTo(snapNum){document.GGCmail[snapNum].focus()}
function snapSel(selNum){document.GGCmail[selNum].select()}
function dsplyErr(errNum){if(errMsg == ""){return}; alert(msgList[errNum])}
//
msgList = new Array(8)
msgList[0] = "unknown error."
msgList[1] = "Please provide your name."
msgList[2] = "Please enter a subject for this message."
msgList[3] = "Your e-mail entry appears invalid, please re-enter."
msgList[4] = "Your e-mail entry is required."
msgList[5] = "The 'Message' field is required."
msgList[6] = "Please indicate who this message is for."
msgList[7] = "Please provide the area code with your phone number."
//
// >>>>  Begin form validation  <<<<
function GGCvalform(){errMsg = "";
                       if(!document.GGCmail.from.value){errMsg = 1; dsplyErr(errMsg); snapTo(1); snapSel(1); return false}; 
                       if(!document.GGCmail.email.value){errMsg = 4; dsplyErr(errMsg); snapTo(2); snapSel(2); return false};
                       if(!document.GGCmail.subject.value){errMsg = 2; dsplyErr(errMsg); snapTo(4); snapSel(4); return false};
                       if(!document.GGCmail.message.value){errMsg = 5; dsplyErr(errMsg); snapTo(5); snapSel(5); return false};
                       if(document.GGCmail.to.options[document.GGCmail.to.selectedIndex].value == "0000"){errMsg = 6; dsplyErr(errMsg); snapTo(0); return false};
//
                       valiMail(); if(valiMail()){dsplyErr(errMsg); snapTo(2); snapSel(2); return false};
                       valiPhon(); if(valiPhon()){dsplyErr(errMsg); snapTo(3); snapSel(3); return false};
//
                       document.GGCmail.recipient.value = actualEM[document.GGCmail.to.selectedIndex];
                       document.GGCmail.to.options[document.GGCmail.to.selectedIndex].value = document.GGCmail.to.options[document.GGCmail.to.selectedIndex].text;
                       document.GGCmail.subject.value = "GGCFLsite - ".concat(document.GGCmail.subject.value);
                   }
//  >>>> End form validation  <<<<
//  >>>> called form validation routines  <<<<
//

function valiMail(){badStuff = " /:,;"; eAddr = document.GGCmail.email.value;
                    for(i=0; i<badStuff.length; i++){badChar = badStuff.charAt(i); if(eAddr.indexOf(badChar) > -1){errMsg = 3; return true}};  // bad character found
                    atLoc = eAddr.indexOf("@", 1); if(atLoc == -1){errMsg = 3; return true};
                    dotLoc = eAddr.indexOf(".", atLoc); if(dotLoc == -1){errMsg = 3; return true}; if(dotLoc+3 > eAddr.length){errMsg = 3; return true};
                    return false}
function valiPhon(){if(!document.GGCmail.phone.value){return false};
                    if(document.GGCmail.phone.value.length < 10 || document.GGCmail.phone.value.length > 14){errMsg = 7; return true}; return false}

//
//
