// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// SRC="MAG_formmail.js"
// Application: maggiesattic.us
//
// Copyright 2007-2010, brymar.net - All rights reserved.
// Copyright 2007-2010  Maggie's Attic of Florida. All rights reserved.
//
//
theC = "#0000aa"
iniC = "#888888"
iniFld = new Array()
iniFld[0] = "To:  (select one)"
iniFld[1] = "Enter your name here"
iniFld[2] = "Enter your e-mail here"
iniFld[3] = "Enter the subject here"
iniFld[4] = "Enter your message here"
//
focusFld = new Array()
focusFld[0] = 0   // send to
focusFld[1] = 0   // from name
focusFld[2] = 0   // from email
focusFld[3] = 0   // subject
focusFld[4] = 0   // message
flds = "sto/frm/eml/sbj/msg/"
//
function iniV(){document.getElementById('frm').value = iniFld[1];
                document.getElementById('eml').value = iniFld[2];
                document.getElementById('sbj').value = iniFld[3];
                document.getElementById('msg').value = iniFld[4];
                document.getElementById('sto').options[0].text = iniFld[0];
                document.getElementById('sto').options[0].selected = 1
                 }
// function for "reset" button
function iniVr(){document.getElementById('frm').value = iniFld[1]; focusFld[1] = 0;
                 document.getElementById('frm').style.color = iniC;
                 document.getElementById('eml').value = iniFld[2]; focusFld[2] = 0;
                 document.getElementById('eml').style.color = iniC;
                 document.getElementById('sbj').value = iniFld[3]; focusFld[3] = 0;
                 document.getElementById('sbj').style.color = iniC;
                 document.getElementById('msg').value = iniFld[4]; focusFld[4] = 0;
                 document.getElementById('msg').style.color = iniC;
                 document.getElementById('sto').options[0].selected = 1; focusFld[0] = 0;
                 document.getElementById('sto').style.color = iniC;
                 }
//
function norC(elmID){document.getElementById(elmID).style.color = theC;
                     fldNo = flds.indexOf(elmID);
                     if(fldNo > 0){fldNo = fldNo/4};
                     if(focusFld[fldNo] == 1){return};
                     focusFld[fldNo] = 1;
                     document.getElementById(elmID).value = "";}
function selC(elmID){document.getElementById(elmID).style.color = theC;
                     fldNo = flds.indexOf(elmID);
                     if(fldNo > 0){fldNo = fldNo/4};
                     focusFld[fldNo] = 1; }
//
//
function snapItSto(fld){fld.focus(); fld.options[0].selected = 1}
function snapIt(fld){fld.focus(); fld.select()}
//
function dsplyErr(errN){if(!errN){return}; alert(errMsg[errN])}
errMsg = new Array()
errMsg[0] = "Unknown error, please start over."
errMsg[1] = "Please provide your name."
errMsg[2] = "Please enter a subject for this message."
errMsg[3] = "The 'Message' field is required."
errMsg[4] = "Please select who this message is for."
errMsg[5] = "E-mail address field is required."
errMsg[6] = "E-mail address appears incorrect, please re-enter."
//
// global variables
goodPh = " 0123456789-().:xet"
CRLF = "\r\n"
// >>>>  Begin form validation for web e-mail form  <<<<
function valiEform(Eform){errCode=0;
                   if(!Eform.from.value || focusFld[1] == 0){
                   dsplyErr(1); snapIt(Eform.from); return false};
                   if(!Eform.subject.value || focusFld[2] == 0){
                   dsplyErr(2); snapIt(Eform.subject); return false};
                   if(!Eform.message.value || focusFld[2] == 0){
                   dsplyErr(3); snapIt(Eform.message); return false};
                   val_Email(Eform.email.value);
                   if(errCode){dsplyErr(errCode); snapIt(Eform.email); return false};
                   if(Eform.to.selectedIndex == 0 || focusFld[0] == 0){
                   dsplyErr(4); snapItSto(share.to); return false};
                   // validation finished, complete the form
                   Eform.recipient.value = actualEM[Eform.to.selectedIndex];
                   Eform.to.options[Eform.to.selectedIndex].value =
                                    Eform.to.options[Eform.to.selectedIndex].text;
                   Eform.subject.value = "Maggies Feedback - ".concat(Eform.subject.value);
                   }
//
function val_Email(ckaddr){badStuff = " /:,;"; i=0; errCode=0;
                   if(!ckaddr || focusFld[6] == 0){errCode=5; return false};
                   while(i < badStuff.length){badChar = badStuff.charAt(i); i++;
                   if(ckaddr.indexOf(badChar) > -1){errCode = 6; return }};
                   at = ckaddr.indexOf("@", 1); if(at <= 0){errCode = 6; return };
                   dot = ckaddr.indexOf(".", at); if(dot < 0){errCode = 6; return };
                   ln = ckaddr.length; if(dot == ln - 2){errCode = 6;  return };
                   return}
//
// --------------------------------------------------------------------------------
//
actualEM = new Array(6)
actualEM[0] = "basicinfo@maggiesattic.us"
actualEM[1] = "basicinfo@maggiesattic.us"
actualEM[2] = "basicinfo@maggiesattic.us"
actualEM[3] = "basicinfo@maggiesattic.us"
actualEM[4] = "basicinfo@maggiesattic.us"
actualEM[5] = "basicinfo@maggiesattic.us"
actualEM[6] = "basicinfo@ymail.com"
actualEM[7] = "basicinfo@brymar.net"
pluged = 0
theN = /basicinfo/
actName = new Array(6)
actName[0] = "webmaster"
actName[1] = "info"
actName[2] = "stephanie"
actName[3] = "terry"
actName[4] = "cellarmaster"
actName[5] = "clubs"
actName[6] = "abbottben"
actName[7] = "webmaster"
//
function showEM(Foption){if(!pluged){pluged = 1; z = 0;
                  while(z < actualEM.length){actualEM[z] =
                  actName[z].concat(actualEM[z].slice(actualEM[z].indexOf("@"))); z++}};
                  if(!Foption.value){return true};
                  Foption.options[Foption.value].text = actualEM[Foption.value];
                  return true;}
// --------------------------------------------------------------------------------------
//
//
//
//
