// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// SRC="MAG_global_js.js"
// Application: maggiesattic.us
//
// Copyright 2007, brymar.net - All rights reserved.
// Copyright 2007  Maggie's Attic of Florida. All rights reserved.
//
avWdth = screen.availWidth; if(!avWdth){avWdth = 800}
//
function GoLink(webPage){window.open(webPage)}
function goWMF(){window.open("http://brymar.net/WMSTR/WMF_feedbk.htm", "", "status")}
function goWM(){window.open("http://brymar.net/WM_email.htm", "", "status")}
function LinkClsGo(webPage){window.open(webPage); window.close();}
function pgPrint(){window.print()}
function pgClose(){window.close()}
function pgPrintCls(){window.print(); window.close()}
function GoStore(){window.open("http://shop.maggiesattic.us")}
//  https://ssl207.chi.us.siteprotect.com/maggiesattic.us/merchantmanager/admin/login.php
function splash(splashit){document.getElementById(splashit).style.display = "inline";
                          SplashIntrv = setInterval("closeSplash('splashPOP')", 7200)}
function closeSplash(splashit){document.getElementById(splashit).style.display = 'none'}
// - - - -    GoStore(){parent.location = "shop")}
//
//
function bigPic(pageImg){dsplyImg = pageImg; findbigD(dsplyImg); bigDesc = findB; window.open("MA_bigPic_01.htm", "theBigPic", "height=500, width=500, titlebar=1, screenX=200, screenY=100")}
bigD = new Array()      // images must be 400x400
bigD[0] = "columbiawinery/<B>Riesling</B> ~ Columbia Winery"
bigD[1] = "tunnel/<B>Tunnel of Elms</B> ~ Napa Valley, CA"
bigD[2] = "pop/<B>Pommery &quot;POP&quot;</B> ~ Champagne, France"
bigD[3] = "pumpkinhead/<B>Pumpkin Head Beer</B> ~ Shipyard Brewing, MN"
bigD[4] = "lambic/<B>Lindemans</B> ~ Lambic Beers, Belgium<BR><SPAN CLASS='text08'>Your choice: Raspberry, Cheery, Green Apple,<BR>Peach and Cassis</SPAN>"
bigD[5] = "opus/<B>OPUS ONE</B> ~ Napa Valley, CA <SPAN CLASS='text08'> * Highly allocated * (limited</SPAN>)<BR>Wine Spectator Rating - 90pts."
bigD[6] = "rosen/<B>Zinfandel Vintner's Cuvee XXX</B><BR>Rosenblum Cellars, CA "
bigD[7] = "salmon/<B>Salmon Creek</B> ~ Sanoma, CA<BR><SPAN CLASS='text08'>Your Choice: Cab, Merlot, Chard, Pinot Grigio, White Zin</SPAN>"
bigD[8] = "syrahtica/<B>Syrahtica X-Winery</B> ~ Napa Valley, CA"
bigD[9] = "veuve/<B>Veuve Clicquot &quot;Yellow Jacket&quot;</B><BR>Champagne, France"
bigD[10] = "bellini/<B>Bellini Wine Cocktail</B><BR><SPAN CLASS='text08'>(A blend of rare Italian white peaches) - 750ml</SPAN>"
bigD[11] = "chateau/<B>Chateau De Beaucastel</B><BR>Chateauneuf-Du-Pape 2004 (limited)        <BR>Wine Spectator Rating 96 points "
bigD[12] = "desiree/<B>D&eacute;sir&eacute;e&nbsp;&nbsp; &quot;Chocolate Port&quot;</B>   <BR>Rosenblum Cellars, CA&nbsp;&nbsp;&nbsp;( 375ml bottle )"
bigD[13] = "domaine/<B>Domaine Des Chanssaud </B><BR>Chateauneuf-Du-Pape 2000 (limited) "
bigD[14] = ""
function findbigD(imgName){findB = ""; y = 0; z = bigD.length;
                           a = imgName.indexOf("_")+1; b = imgName.indexOf("_", a);
                           serB = imgName.slice(a, b);
                           while(z > y){yn = bigD[y].indexOf(serB);
                                        if(yn < 0){y=y+1} else {break}};
                           locB = bigD[y].indexOf("/"); findB = bigD[y].substr(locB + 1)}
//
// - - - -   imgsARE,  1-home page unless; 2-celler; 3-events
imgsARE = 1
logoIMG = new Array(5)      // images must be 230x152
logoIMG[0] = ""
logoIMG[1] = "MAGimg/mag_logo_attic_003-gif.gif"
logoIMG[2] = "MAGimg/mag_logo_cellar_003-gif.gif"
logoIMG[3] = "MAGimg/mag_logo_attic_003-gif.gif"
logoIMG[4] = "MAGimg/mag_logo_clubs_006.gif"
//
function iView_Load(webURL, sideURL, which){
                    iChoice.location = webURL; iSide.location = sideURL;
                    document.magLogo.src = logoIMG[which];}
function iView_Chng(webURL){parent.iChoice.location = webURL;}
function dsplyLOCs(){d=rLoc.length; while(d > 1){document.write(rLoc[d-1]); d--}}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//
popOK = 0; isIE = 0; isNS = 0; isOP = 0;
if(navigator.appName == "Microsoft Internet Explorer"){isIE = 1; if(navigator.appVersion.charAt(0) >= 4){popOK = 1}};
if(navigator.appName == "Netscape"){isNS = 1; if(navigator.appVersion.charAt(0) >= 5){popOK = 1}};
if(navigator.appName == "Opera"){isOP = 1; if(navigator.appVersion.charAt(0) >= 9){popOK = 1}};
//
function menuV(menuElem){if(popOK){document.getElementById(menuElem).style.display = "inline"}}
function menuH(menuElem){if(popOK){document.getElementById(menuElem).style.display = "none"}}
//
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//
dowList = new Array(7)
dowList[0] = "Sunday"
dowList[1] = "Monday"
dowList[2] = "Tuesday"
dowList[3] = "Wednesday"
dowList[4] = "Thursday"
dowList[5] = "Friday"
dowList[6] = "Saturday"
//
function dateNow(){dateNow = new Date();
                   daNow = dateNow.getDate().toString().concat("-");
                   moNow = (dateNow.getMonth() + 1).toString().concat("-");
                   yrNow = dateNow.getYear().toString(); if(dateNow.getYear() < 200){yrNow = (dateNow.getYear() + 1900).toString()};
                   dowNow = dowList[dateNow.getDay()].concat("&nbsp;&nbsp;");
                   dowmdyNow = (dowNow.concat(moNow.concat(daNow))).concat(yrNow)}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//
em_prt1 = "hut@maggiesatticessyt";
em_prt2 = ".us";
em_prt3 = ".com";
em_prt4 = "amslziwshtu";
em_prt5 = "sufntszuwbk";
function isTo(){whoTo1 = ""; i = 1; whoTo2 = ""; k = 1;
            while(i < em_prt4.length - 1){whoTo1 = whoTo1.concat(em_prt4.substr(i,1)); i=i+2;};
            while(k < em_prt5.length - 1){whoTo2 = whoTo2.concat(em_prt5.substr(k,1)); k=k+2;};
            //
            whoTo1 = whoTo1.concat(em_prt1.substr(3, 13)).concat(em_prt2);
            whoTo2 = whoTo2.concat(em_prt1.substr(3, 13)).concat(em_prt2)}
//
// ----------------------------------------------------------------------------------------
//
dd = "maggiesattic"
tt = "us"
ss = ""
nnList = new Array(6)
nnList[0] = "webmaster"
nnList[1] = "stephanie"
nnList[2] = "terry"
nnList[3] = "jerome"
nnList[4] = "cellarmaster"
nnList[5] = "clubs"
//
function sendTo(thisObj, nn, subj){ss = "";  realThing = thisObj.href;
                             if(subj){ss = "?subject=" + subj};
                             thisObj.href = "mailto:" +nnList[nn] + "@" + dd + "." + tt + ss;
                             return true}
// ----------------------------------------------------------------------------------------
//
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"
pluged = 0
theN = /basicinfo/
actName = new Array(6)
actName[0] = "webmaster"
actName[1] = "stephanie"
actName[2] = "terry"
actName[3] = "cellarmaster"
actName[4] = "clubs"
actName[5] = "webmaster"
//
function snapForm(Fname,Fld){fldTo = eval("document." + Fname + "." + Fld); fldTo.focus()}
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 enter recipe title."
errMsg[2] = "Please enter enter your ingredients."
errMsg[3] = "Please enter your directions."
errMsg[4] = "Name field is required."
errMsg[5] = "E-mail address field is required."
errMsg[6] = "E-mail address appears incorrect, please re-enter."
errMsg[7] = "Please enter a phone number."
errMsg[8] = "Please enter a valid phone number."
//
errMsg[9] = "First name field required."
errMsg[10] = "Last name field required."
//
errMsg[11] = "Please provide your name."
errMsg[12] = "Please enter a subject for this message."
errMsg[13] = "The 'Message' field is required."
errMsg[14] = "Please select who this message is for."
//
//
// global variables
goodPh = " 0123456789-().:xet"
whoto = "isharebook"
CRLF = "\r\n"
//addEM = ""
//addNM = ""
//addFLG = 0
//
// >>>>>>>> Begin validation of recipe form <<<<<<<<<<<
function valishare(share){errCode=0;
                  if(!share.recipetitle.value){dsplyErr(1); snapIt(share.recipetitle); return false};
                  if(!share.ingredients.value){dsplyErr(2); snapIt(share.ingredients); return false};
                  if(!share.directions.value){dsplyErr(3); snapIt(share.directions); return false};
                  if(!share.name.value){dsplyErr(4); snapIt(share.name); return false};
                  val_Email(share.email.value);
                  if(errCode){dsplyErr(errCode); snapIt(share.email); return false};
                  val_Phone(share.phone.value);
                  if(errCode){dsplyErr(errCode); snapIt(share.phone); return false};
                  // form validated, finish form.
                  if(!share.mlist.checked){share.addto.value = ""};
                  share.ingredients.value = CRLF.concat(share.ingredients.value);
                  share.directions.value = CRLF.concat(share.directions.value);
                  if(share.notes.value){share.notes.value = CRLF.concat(share.notes.value)};
                  if(share.city.value = "Enter City"){share.city.value = ""};
                  share.recipient.value = whoto.substr(1).concat("@maggiesattic.us");
                  if(share.mlist.checked){opener.addEM = share.email.value;
                                          opener.addNM = share.name.value;
                                          opener.addFLG = 1 };
                  return true}
//
function val_Email(ckaddr){badStuff = " /:,;"; i=0; errCode=0;
                   if(!ckaddr){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}
function val_Xmail(ckaddr){badStuff = " /:,;"; i=0; errCode=0;
                   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}
//
function val_Phone(ckPh){errCode=0; k=0; j=0; nn=0; ex=0;
                   if(!ckPh){errCode=7; return};
                   if(ckPh.length < 7){errCode=8; return};
                   while(k < ckPh.length){if(goodPh.indexOf(ckPh.charAt(k), 0) < 0)
                   {errCode = 8; break}; k++}; // set flag & break if non-allowable chars found
                   return}
function clearCity(wipe){wipe.value = ""; return true}
// ------------------------------------------------------------------------------------------
// >>>>  Begin form validation for mail list  <<<<
function valiList(mList){errCode=0; emStrng = "";
                    if(!mList.fname.value){dsplyErr(9); snapIt(mList.fname); return false};
                    if(!mList.lname.value){dsplyErr(10); snapIt(mList.lname); return false};
                    val_Email(mList.email.value);
                    if(errCode){dsplyErr(errCode); snapIt(mList.email); return false};
                    if(mList.omail.value){val_Xmail(mList.omail.value);
                    if(errCode){dsplyErr(errCode); snapIt(mList.omail); return false}};
                    // validation finished, complete the form
                    isTo();
                    if(mList.remove.checked){mList.recipient.value = whoTo2; mList.subject.value = "Please Remove From Maggie's Mailing List"} else {mList.recipient.value = whoTo1};
                    emStrng = emStrng.concat(mList.fname.value + ",").concat(mList.lname.value + ",").concat(mList.email.value); mList.emSave.value = emStrng;
                    return true}
// ------------------------------------------------------------------------------------------
// >>>>  Begin form validation for web e-mail form  <<<<
function valiEform(Eform){errCode=0;
                       if(!Eform.from.value){dsplyErr(11); snapIt(Eform.from); return false};
                       val_Email(Eform.email.value);
                       if(errCode){dsplyErr(errCode); snapIt(Eform.email); return false};
                       if(!Eform.subject.value){dsplyErr(12); snapIt(Eform.subject); return false};
                       if(!Eform.message.value){dsplyErr(13); snapIt(Eform.message); return false};
                       if(Eform.to.options[Eform.to.selectedIndex].value == "0"){dsplyErr(14);                        Eform.to.focus(); Eform.to.options[0].selected; 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 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;}
// --------------------------------------------------------------------------------------
// Copyright 2008, Bryan Ault / BryMar.net, All rights reserved !
//
stSite = "From Maggie's Attic:"   // set to name of the site
stHide = "z5@9f"
stLevel = new Array()
stLevel[0] = "xxx"
stLevel[1] = "com"
stLevel[2] = "us"
stLevel[3] = "org"
stLevel[4] = "biz"
stLevel[5] = "net"
stWho = new Array()
stWho[0] = "rofnicisabz"
stWho[1] = "5ofnik"
stWho[2] = "qnoopsycuass"
stWho[3] = "ggnivilyhtlaeh47"
stWho[4] = "1yllohybsemohp"
stWho[5] = "zyriqni9"
stWho[6] = "yttocstz"
stWho[7] = ""
stDN = new Array()
stDN[0] = "??????????"
stDN[1] = "bethsirishcorner"
stDN[2] = "saucyspoon"
stDN[3] = "aol"
stDN[4] = "beachrentalsofdaytona"
stDN[5] = "embarqmail"
stDN[6] = "tscottwalker"
stDN[7] = ""
function stIsto(Ann)
               {stAt = stHide.substr(2, 1);
                ln = stWho[Ann].length - 1; k = ln;
                stWhois = ""; wkWho = stWho[Ann].substr(1, ln-1);
                while(k > -1){stWhois = stWhois.concat(wkWho.substr(k, 1)); k=k-1;};
                }
function AnySendTo(thisObj, stL, stW, stD)
               {ss = "";  realThing = thisObj.href;
                ss = "?subject=" + stSite;
                stIsto(stW);
                thisObj.href = "mailto:" + stWhois + stAt + stDN[stD] + "." + stLevel[stL] + ss;
                return true}
// ----------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
//addem('MAG_mlist2')
//function addem(Fn){if(!opener.addFLG){return};
//                   isTo(); Fobj = eval("document." + Fn);
//                   Fobj.fname.value = opener.addNM.substr(0, opener.addNM.indexOf(" "));
//                   if(opener.addNM.indexOf(" ") < 0){Fobj.lname.value = ""} else {
//                   Fobj.lname.value = opener.addNM.substr(opener.addNM.indexOf(" ")+1)};
//                   Fobj.email.value = opener.addEM;
//                   Fobj.recipient.value = whoTo1;
//                   Fobj.subject.value = "Add To Maggie's Mailing List From Recipe Form";
 //                  Fobj.emSave.value = Fobj.fname.value+","+Fobj.lname.value+","+opener.addEM;
//                  Fobj.submit();
//                   }
// -------------------------------------------------------------------------------------------
//