function addProof(chk)
{
    var html = '';
    var divProof = document.getElementById("divProof");
    if (chk.checked)
    {
        html = "<br>Please enter your <b>fax number</b>: <input type=text name=vwattr299_Fax><input type=hidden name=vwitem299 value='engraving-proof'>";
    }
    else
    {
        html = "";
    }
    divProof.innerHTML = html;
}

function getQty()
{
    if (theForm['vwquantity'])
    {
        if (!isNaN(theForm['vwquantity'].value) && theForm['vwquantity'].value > 0)
            return(parseInt(theForm['vwquantity'].value));
    }
    if (theForm['vwquantity0'])
    {
        if (!isNaN(theForm['vwquantity0'].value) && theForm['vwquantity0'].value > 0)
            return(parseInt(theForm['vwquantity0'].value));
    }
    return(1);
}

function showPrevPreview()
{
    var qty = getQty();

    if (currentPreview == 1)
        currentPreview = qty;
    else
        currentPreview --;
    
    showPreview(currentPreview,qty);
}

function showNextPreview()
{
    var qty = getQty();

    if (currentPreview == qty)
        currentPreview = 1;
    else
        currentPreview ++;
    
    showPreview(currentPreview,qty);
}

function showAddToCart(where)
{
    var elm = document.getElementById(where);
    if (elm)
    {
        elm.innerHTML = "<p><span class=add2cartborder><input type=submit class='add2cartbutton' value='Add to Cart'></span>";
    }
}

function formattingOnOff(elem)
{
    for (var i = 0; i < theForm.elements.length; i++)
    {
        if (theForm.elements[i].className == 'formatting')
        {
            if (elem.checked)
            {
                theForm.elements[i].disabled = true;
            }
            else
            {
                theForm.elements[i].disabled = false;
            }
        }
    }
}

function showPreview(item, qty)
{
    for (var i = 1; i <= qty; i++)
    {
        var pr = document.getElementById("preview" + i);
        if (pr)
        {
            if (i == item)
            {
                pr.style.display = "block";
            }
            else
            {
                pr.style.display = "none";
            }
        }
    }
    
    document.getElementById("counter").innerHTML = "(Item # " + item + ")";
}

function preview()
{
    var spchk = document.getElementById("spellchkbtn");
    if (spchk)
        spchk.style.display = "inline";
        
    var qty = getQty();
    
    var pDiv = document.getElementById("preview");
    if (pDiv)
    {
        pDiv.style.width = "300px";
        pDiv.style.fontSize = "20px";
        // pDiv.style.fontWeight = "bold"
        pDiv.style.padding ="5px";
        
        var logofile = "";
        if (pcolor)
        {
            //pDiv.style.backgroundColor = "gold";
            //pDiv.style.color = "black";
            logofile = "http://site.strictlygifts.com/engraving/goldlogo.gif";
        }
        else
        {
            //pDiv.style.backgroundColor = "black";
            //pDiv.style.color = "gold";
            logofile = "http://site.strictlygifts.com/engraving/blacklogo.gif";
        }
        var pHTML = "";
        
        var logoplacement = null;
        if (theForm[vwattr + "Logo Placement"])
        {
            if (!theForm[vwattr + "Logo Placement"].length)
            {
                logoplacement = theForm[vwattr + "Logo Placement"].value;
            }
            else
            {
                if (theForm[vwattr + "Logo Placement"][0].checked)
                {
                    logoplacement = "Centered Top";
                }
                else if (theForm[vwattr + "Logo Placement"][1].checked)
                {
                    logoplacement = "Centered Bottom";
                }
                else if (theForm[vwattr + "Logo Placement"][2].checked)
                {
                    logoplacement = "Centered on Item";
                } else
                    logoplacement = "Centered Top";
            }
        }
        
        for (var item = 1; item <= qty; item++)
        {
            pHTML += "<div id=preview" + item + ">";
            if (rlogo && logoplacement == "Centered Top")
            {
                pHTML += "<div style='text-align: center; margin-bottom: 5px; ";
                pHTML += "'>";
                pHTML += "<img border=0 src=" + logofile + ">";
                pHTML += "</div>";
            }
            /*
            if (theForm[vwattr + "Personalization for each item"])
            {
                if (theForm[vwattr + "Personalization for each item"].length)
                {
                    for (var tmpi = 0; tmpi <= theForm[vwattr + "Personalization for each item"].length; tmpi++)
                    {
                        if (theForm[vwattr + "Personalization for each item"][tmpi].checked)
                        {
                            lines = tmpi;
                            break;
                        }
                    }
                }
                else
                {
                    lines = parseInt(theForm[vwattr + "Personalization for each item"].value);
                }
            } 
            */
            if (lines)
            {
                // check if vertical centering was requested
                var vertCenter = false;
                var firstRow = 1;
                var lastRow = lines;
                if (theForm[vwattr + "CenterVertically"])
                {
                    if (theForm[vwattr + "CenterVertically"].type == 'hidden')
                        vertCenter = (theForm[vwattr + "CenterVertically"].value == 'Yes' ? true : false );
                    else
                    {
                        vertCenter = theForm[vwattr + "CenterVertically"][0].checked;
                        //vertCenter = theForm[vwattr + "CenterVertically"].value == 'Yes';
                    }
                }
                if (vertCenter)
                {
                    // figure out the first and last rows
                    var firstRow = 1;
                    var LastRow = lines;
                    for (firstRow = 1; firstRow <= lines; firstRow++)
                    {
                        if (theForm[vwattr + "Item " + item + " Line " + firstRow] && theForm[vwattr + "Item " + item + " Line " + firstRow].value != '')
                        {
                            break;
                        }
                    }
                    for (lastRow = lines; lastRow >= 1; lastRow--)
                    {
                        if (theForm[vwattr + "Item " + item + " Line " + lastRow] && theForm[vwattr + "Item " + item + " Line " + lastRow].value != '')
                        {
                            break;
                        }
                    }
                    if (firstRow < 1 || firstRow > lines)
                        firstRow = 1
                    if (lastRow > lines || lastRow < 1)
                        lastRow = lines;
                }
                var nSpaces = (lines - (lastRow - firstRow)) / 2;
                if (vertCenter)
                {
                    for (var i = 1; i <= nSpaces; i++)
                        pHTML += "<div>&nbsp;</div>";
                }
                for (var i = firstRow; i <= lastRow; i++)
                {
                    if (theForm[vwattr + "Item " + item + " Line " + i] || true)
                    {
                        pHTML += "<div style='";
                        if (theForm[vwattr + "Item " + item + " Line " + i + " Align"])
                        {
                            if (!theForm[vwattr + "Item " + item + " Line " + i + " Align"].length)
                            {
                                pHTML += "text-align: " + theForm[vwattr + "Item " + item + " Line " + i + " Align"].value + "; ";
                            }
                            else
                            {
                                if (theForm[vwattr + "Item " + item + " Line " + i + " Align"][0].checked)
                                {
                                    pHTML += "text-align: left; ";
                                }
                                else if (theForm[vwattr + "Item " + item + " Line " + i + " Align"][1].checked)
                                {
                                    pHTML += "text-align: center; ";
                                }
                                else if (theForm[vwattr + "Item " + item + " Line " + i + " Align"][2].checked)
                                {
                                    pHTML += "text-align: right; ";
                                }
                                else
                                    pHTML += "text-align: center; ";
                            }
                            
                            if (theForm[vwattr + "Item " + item + " Line " + i + " Font"])
                            {
                                if (theForm[vwattr + "Item " + item + " Line " + i + " Font"].type.toLowerCase() == 'hidden')
                                {
                                    var txtFont = theForm[vwattr + "Item " + item + " Line " + i + " Font"].value + "; ";
                                }
                                else
                                {
                                    var txtFont = theForm[vwattr + "Item " + item + " Line " + i + " Font"].options[theForm[vwattr + "Item " + item + " Line " + i + " Font"].selectedIndex].value;
                                    if (txtFont == '')
                                        txtFont = theForm[vwattr + "Item " + item + " Line " + i + " Font"].options[theForm[vwattr + "Item " + item + " Line " + i + " Font"].selectedIndex].text;
                                }
                                pHTML += " font-family: " + txtFont + "; ";
                            }
                            
                            if (theForm[vwattr + "Item " + item + " Line " + i + " Font Size"])
                            {
                                switch (theForm[vwattr + "Item " + item + " Line " + i + " Font Size"].value)
                                {
                                    case "XS":
                                        pHTML += " font-size: 14px; ";
                                        break;
                                        
                                    case "S":
                                        pHTML += " font-size: 16px; ";
                                        break;

                                    case "M":
                                        pHTML += " font-size: 18px; ";
                                        break;

                                    case "L":
                                        pHTML += " font-size: 22px; ";
                                        break;

                                    case "XL":
                                        pHTML += " font-size: 24px; ";
                                        break;
                                        
                                    default:
                                        pHTML += " font-size: 18px; ";
                                        break;
                                }
                            }
                            
                            if (theForm[vwattr + "Item " + item + " Line " + i + " Bold"])
                            {
                                if ( theForm[vwattr + "Item " + item + " Line " + i + " Bold"].checked ||  (theForm[vwattr + "Item " + item + " Line " + i + " Bold"].value == 'Yes' && theForm[vwattr + "Item " + item + " Line " + i + " Bold"].type.toLowerCase() == 'hidden') )
                                    pHTML += " font-weight: 900; "
                            }
                            if (theForm[vwattr + "Item " + item + " Line " + i + " Italics"])
                            {
                                if ( theForm[vwattr + "Item " + item + " Line " + i + " Italics"].checked ||  (theForm[vwattr + "Item " + item + " Line " + i + " Italics"].value == 'Yes' && theForm[vwattr + "Item " + item + " Line " + i + " Italics"].type.toLowerCase() == 'hidden') )
                                    pHTML += " font-style: italic; "
                            }
                        }
                        else
                            pHTML += "text-align: center; ";
                        if (lines == 3 && !format)
                        {
                            pHTML += " font-family: times new roman,times,serif; ";
                            if (i == 1 || i == 3)
                                pHTML += " font-size: 18px;"
                            else
                                pHTML += " font-size: 22px;"
                        }
                        var lineVal;
                        if (theForm[vwattr + "Item " + item + " Line " + i])
                            lineVal = theForm[vwattr + "Item " + item + " Line " + i].value;
                        else
                            lineVal = "&nbsp;";
                        if (lineVal == "")
                            lineVal = "&nbsp;"
                        pHTML +="'>" + lineVal + "</div>";
                    }
                }
                if (vertCenter)
                {
                    for (var i = 1; i <= nSpaces; i++)
                        pHTML += "<div>&nbsp;</div>";
                }
            }
            if (rlogo && logoplacement == "Centered Bottom")
            {
                pHTML += "<div style='text-align: center; margin-top: 5px; ";
                pHTML += "'>";
                pHTML += "<img border=0 src=" + logofile + ">";
                pHTML += "</div>";
            }
            pHTML += "</div>";
        }
        
        window.currentPreview = 1;
        var controls = "";
        if (qty > 1)
        {
            controls += "Preview Item: <a href='javascript:showPrevPreview()'>Previous</a> | <a href='javascript:showNextPreview()'>Next</a> <span style='font-size: 12px' id=counter>(Item # 1)</span>";
            /*
            for (var item = 1; item <= qty; item++)
            {
                controls += "<a href='javascript:showPreview(" + item + "," + qty + ")'>" + item + "</a>";
                if (item < qty)
                {
                    controls += " | ";
                }
            }
            */
        }
        pHTML = controls + pHTML;
        
        if (format)
        {
            pHTML += "<br><span style='font-size: 12px'>Please Note: Not all fonts (ex. Script) will display correctly on all browsers, but they will be engraved properly.</span>";
        }
        
        pDiv.innerHTML = pHTML;
        for (var item = 1; item <= qty; item++)
        {
            var pv = document.getElementById("preview" + item);
            if (pv)
            {
                if (pcolor)
                {
                    pv.style.backgroundColor = "#C8A370";
                    pv.style.color = "black";
                }
                else
                {
                    pv.style.backgroundColor = "black";
                    pv.style.color = "#C8A370";
                }
                pv.style.padding = "5px";
                if (item == 1)
                {
                    pv.style.display = "block";
                }
                else
                {
                    pv.style.display = "none";
                }
            }
        }
        if (document.getElementById("previewbottom"))
            document.getElementById("previewbottom").innerHTML = "<p><span class=add2cartborder><input type=submit class='add2cartbutton' value='Add to Cart'></span>";
    }
    location.href = "#previewPersButton";
}

function CopyDown(srcIdx)
{
    var src;
    var target;
    
    src = theForm[vwattr + "Item 1 Line " + srcIdx];
    if (src)
    {
        for (var idx = 2; idx <= vwquantity; idx++)
        {
            target = theForm[vwattr + "Item " + idx + " Line " + srcIdx];
            if (target)
            {
                target.value = src.value;
            }
        }
    }    

    src = theForm[vwattr + "Item 1 Line " + srcIdx + " Bold"];
    if (src)
    {
        for (var idx = 2; idx <= vwquantity; idx++)
        {
            target = theForm[vwattr + "Item " + idx + " Line " + srcIdx + " Bold"];
            if (target)
            {
                target.checked = src.checked;
            }
        }
    }    

    src = theForm[vwattr + "Item 1 Line " + srcIdx + " Italics"];
    if (src)
    {
        for (var idx = 2; idx <= vwquantity; idx++)
        {
            target = theForm[vwattr + "Item " + idx + " Line " + srcIdx + " Italics"];
            if (target)
            {
                target.checked = src.checked;
            }
        }
    }    
    
    src = theForm[vwattr + "Item 1 Line " + srcIdx + " Align"];
    if (src)
    {
        for (var idx = 2; idx <= vwquantity; idx++)
        {
            target = theForm[vwattr + "Item " + idx + " Line " + srcIdx + " Align"];
            if (target)
            {
                for (var j = 0; j < src.length; j++)
                {
                    target[j].checked = src[j].checked;
                }
            }
        }
    }    

    src = theForm[vwattr + "Item 1 Line " + srcIdx + " Font"];
    if (src)
    {
        for (var idx = 2; idx <= vwquantity; idx++)
        {
            target = theForm[vwattr + "Item " + idx + " Line " + srcIdx + " Font"];
            if (target)
            {
                target.selectedIndex = src.selectedIndex;
            }
        }
    }    

    src = theForm[vwattr + "Item 1 Line " + srcIdx + " Font Size"];
    if (src)
    {
        for (var idx = 2; idx <= vwquantity; idx++)
        {
            target = theForm[vwattr + "Item " + idx + " Line " + srcIdx + " Font Size"];
            if (target)
            {
                target.selectedIndex = src.selectedIndex;
            }
        }
    }    
}

function ShowSection(section)
{
/*
    if (lastSection != section)
    {
        lastSection = section;
        flipflop = !flipflop;
    }
*/    
    var HTMLstuff = "";
    
    switch (section)
    {
        case 'anyother':
            HTMLstuff = "<br><b>Would you like to add text to each item now?</b> <input type=radio name='" + vwattr + "Other Personalization' value='Yes' onclick=ShowSection('otherpers')>Yes <input type=radio name='" + vwattr + "Other Personalization' value='No' onclick=\"showAddToCart('otherpers')\">No<br><br>    ";
            HTMLstuff += "<div id=otherpers></div>";
            break;
            
        case 'logopers':
            HTMLstuff += "<br>Once your order is placed, you will be able to upload your artwork through a link on the checkout confirmation page.<br><br>";
            HTMLstuff += "<br><b>Where would you like the logo placed?</b><br>";
            HTMLstuff += "<input onclick=ShowSection('anyother') type=radio name='" + vwattr + "Logo Placement' value='Centered Top'>Centered Top<br>";
            HTMLstuff += "<input onclick=ShowSection('anyother') type=radio name='" + vwattr + "Logo Placement' value='Centered Bottom'>Centered Bottom</br>";
            HTMLstuff += "<input onclick=ShowSection('anyother') type=radio name='" + vwattr + "Logo Placement' value='Other (please email)'>Other (please email)</br>";
            HTMLstuff += "<div id=anyother></div>";
            break;
            
        case 'otherpers':
            if (personalizationCharge)
            {
                HTMLstuff += "<b>Please specify personalization for each item:</b><br>";
                for (var pi = 0; pi < personalizationCharge.length; pi++)
                {
                    // options include the number of lines.
                    var nLines = pi;
                    var numbers = new Array('one','two','three','four','five','six','seven','eight','nine','ten');
                    for (var ni = 0; ni < numbers.length; ni++)
                    {
                        var re = new RegExp(numbers[ni],'gi');
                        if (re.test(personalizationCharge[pi]))
                        {
                            nLines = ni + 1;
                            break;
                        }
                    }
                    HTMLstuff += "<input type=radio name='" + vwattr + "Personalization for each item' value='" + personalizationCharge[pi] + "' onclick='window.lines=" + nLines + ";lines.value=" + nLines + ";ShowSection(\"perslines\")'> " + personalizationCharge[pi] + "<br>";
                }
            }
            else
            {
                HTMLstuff = "<b>How would you like to give us your personalization?</b><br>";
                HTMLstuff += "<input type=radio name='" + vwattr + "Personalization Provided' value='Enter Here' onclick='ShowSection(\"perslines\")'>Enter Here (preferred to reduce errors)<br>";
                HTMLstuff += "<input type=radio onclick='showAddToCart(\"perslines\")' name='" + vwattr + "Personalization Provided' value='Send via Email'>Send via E-mail or upload after your order is placed through a link on the checkout confirmation page.<br>"
            }
            //HTMLstuff += "<input type=radio onclick='showAddToCart(\"perslines\")' name='" + vwattr + "Personalization Provided' value='Send via Fax'>Send via Fax<br>"
            if (rlogo)
                HTMLstuff += "<input type=radio onclick='showAddToCart(\"perslines\")' name='" + vwattr + "Personalization Provided' value='Only logo'>No personalization besides logo<br>"
            HTMLstuff += "<div id=perslines></div>";
            break;

        case 'perslines':
            if (lines && format)
            {
                var formattingChargeStr;
                if (formattingCharge > 0)
                    formattingChargeStr = "(+$" + formattingCharge + ")";
                else
                    formattingChargeStr = "";
                    
                HTMLstuff += "<br>Click here <input onclick='ShowSection(\"perslinesCont\")' type=radio name='" + 
                              vwattr + 
                              "Formatting By' value='Customer'> to try your own formatting or here " +
                              "<input onclick='ShowSection(\"perslinesCont\")' type=radio name='" + 
                              vwattr + "Formatting By' value='TrophyCentral " + formattingChargeStr + "'> to have TrophyCentral format for you " + formattingChargeStr +
                              ". <a href='javascript:void(0)' onclick='$(\"#tcFormattingHelp\").modal( { onShow: function(d) { if($.browser.msie) $(\"#modalOverlay\").css(\"top\" , (document.documentElement.scrollTop || document.body.scrollTop) + \"px\" ) } } )' style='font-size: 11px'>Need Help?</a>";
                              
                HTMLstuff += "<div id=perslinesCont></div>";
                break;
            }
            HTMLstuff += "<div id=perslinesCont></div>";
            // we do want to spill into the next block if we are here.
            
        case 'perslinesCont':
            if (lines)
            {
                HTMLstuff = "<br>";
                HTMLstuff += "<b>Please enter engraving and formatting below.</b> ";
                //if (format)
                //    HTMLstuff += "If you prefer us to do the formatting for you, please check this box <input onclick='formattingOnOff(this)' type=checkbox name='" + vwattr + "Customize it for me' value=x><br><br>";
                if (lines == 3 && !format)
                {
                    HTMLstuff += "<table border=0><tr valign=top><td>";
                }
                for (var idx = 1; idx <= vwquantity; idx ++)
                {
                    if (vwquantity > 1)
                        HTMLstuff += "<div class=persItemHead>Item " + idx + "</div>";
                    HTMLstuff += "<table border=0 cellpadding=0 cellspacing=2>";
                    for (var i = 1; i <= lines; i++)
                    {
                        HTMLstuff += "<tr valign=top>";
                        HTMLstuff += "<td style='border-bottom: 1px solid silver'>Line " + i + ". <input type=text size=" + CHAR + " maxlength=" + CHAR + " name='" + vwattr + "Item " + idx + " Line " + i + "' id=" + vwattr + "Item_" + idx + "_Line_" + i + "></td>";
                        spellCheckFields[spellCheckFields.length] = vwattr + "Item_" + idx + "_Line_" + i;
                        if (format && $(theForm[vwattr + "Formatting By"])[0].checked )
                        {
                            HTMLstuff += "<td style='border-bottom: 1px solid silver'>";
                            HTMLstuff += "<input class=formatting type=radio name='" + vwattr + "Item " + idx + " Line " + i + " Align' value=Left><span class=formatting>Left</span> ";
                            HTMLstuff += "<input class=formatting type=radio name='" + vwattr + "Item " + idx + " Line " + i + " Align' value=Center checked><span class=formatting>Center</span> ";
                            HTMLstuff += "<input class=formatting type=radio name='" + vwattr + "Item " + idx + " Line " + i + " Align' value=Right><span class=formatting>Right</span>&nbsp;&nbsp; ";
                            if (Font)
                            {
                                HTMLstuff += "<br>";
                                var fonts = Font.split(",");
                                HTMLstuff += "<span class=formatting>Font:</span>&nbsp;<select class=formatting name='" + vwattr + "Item " + idx + " Line " + i + " Font'>";
                                for (var f = 0; f < fonts.length; f++)
                                {
                                    HTMLstuff += "<option>" + fonts[f] + "</option>";
                                }
                                HTMLstuff += "</select> ";
                            }
                            HTMLstuff += "<span class=formatting>Font Size:</span>&nbsp;";
                            HTMLstuff += "<select class=formatting name='" + vwattr + "Item " + idx + " Line " + i + " Font Size'>";
                            HTMLstuff += "<option value=XS>Extra Small</option>";
                            HTMLstuff += "<option value=S>Small</option>";
                            HTMLstuff += "<option value=M selected>Medium</option>";
                            HTMLstuff += "<option value=L>Large</option>";
                            HTMLstuff += "<option value=XL>Extra Large</option>";
                            HTMLstuff += "</select>";
                            HTMLstuff += "<br><input class=formatting type=checkbox name='" +vwattr + "Item " + idx + " Line " + i + " Bold' value='Yes'> <span class=formatting>Bold</span> &nbsp;&nbsp; <input class=formatting type=checkbox name='" +vwattr + "Item " + idx + " Line " + i + " Italics' value='Yes'> <span class=formatting>Italics</span>";
                            HTMLstuff += "</td>";
                        }
                        if (vwquantity > 1 && idx == 1)
                        {
                            HTMLstuff += "<td valign=bottom>";
                            HTMLstuff += "<input type=button value='Copy Settings & Text' onclick='CopyDown(" + i + ")'>";
                            HTMLstuff += "</td>";
                        }
                        HTMLstuff += "</tr>";
                    }
                    HTMLstuff += "</table>";
                    if (vwquantity > 1)
                        HTMLstuff += "<hr>";
                }
                if (lines == 3 && !format)
                {
                    HTMLstuff += "</td><td align=center>Example of Personalized Tags. Middle line will be larger as shown (if you prefer all lines be the same size, please let us know in the special instructions section on the checkout page).<br>";
                    HTMLstuff += "<img src=/lib/sportsawards/3-line-sample1.gif><br><br><img src=/lib/sportsawards/3-line-sample2.gif>";
                    
                    HTMLstuff += "</td></tr></table>";
                }
                if (format && lines > 1)
                {
                    HTMLstuff += "Would you like to center the text from top to bottom? Yes <input type=radio name='" + vwattr + "CenterVertically' value=Yes checked> No <input type=radio name='" + vwattr + "CenterVertically' value=No>";
                }
            }
            HTMLstuff += "<br><table width=100%><tr valign=top>";
            HTMLstuff += "<td><div style='background-color: white'><span class=add2cartborder><input type= button class=add2cartbutton onclick='preview()' value='Preview Personalization' id=previewPersButton></span><br><br><div id=preview></div><div id=previewbottom></div></td>";
            if (spellCheckFields.length > 0)
            {
                HTMLstuff += "<td align=right><div style='background-color: white; display: none;' id=spellchkbtn><span class=add2cartborder><input type= button class=add2cartbutton onclick='spellCheck()' value='Spell Check' id='spellCheckBtn'></span><br><div id=spellCheck></div><br><small style='color: red'>(Please be patient<br>as it could take up to 1 minute to load the spell checker<br>the first time it is used.)</small></td>";
            }
            HTMLstuff += "</tr></table>";
            
            if (lines >=4 || format)
            {
                HTMLstuff += "<input type=checkbox onclick='addProof(this)'> " + engravingProofText + "<br><div id=divProof></div><br>"
            }
            
            HTMLstuff += "<input type=checkbox name='" + vwattr + "Approved'> Please check this box to indicate that you have reviewed and approve all spelling for your engraving.</div>";
            break;            
    }
    
    var el = document.getElementById(section);
    if (el)
    {
        el.style.backgroundColor = (flipflop ? 'white' : '#d3e9fe');
        el.innerHTML = HTMLstuff;
    }
}

function spellCheck()
{
    var spellCheckHTML = "";
    textAreas = new Array();
    for (var s = 0; s < spellCheckFields.length; s++)
    {
        textAreas[textAreas.length] = document.getElementById(spellCheckFields[s]);
    }

    spellCheckHTML = '  \
        <applet codebase="/lib/sportsawards/" code="net.xde.SpellChecker.SpellCheck.class" archive="xdespellchecker.jar,usenglish.jar,system.jar" height="1" name="spellcheck" width="1" alt="Applet not Supported">  \
          <param name="name" value="spellcheck">    \
          <param name="scriptable" value="true">    \
          <param name="mayscript" value="true">     \
          <param name="logoURL" value="xde.gif">    \
          <param name="img.width" value="100">      \
          <param name="img.height" value="79">No JDK 1.1 support for APPLET!!   \
        </applet>                                   \
        ';

    document.getElementById("spellCheckBtn").value = "Please wait..";
    if (document.getElementById("spellCheck").innerHTML == "")
        document.getElementById("spellCheck").innerHTML = spellCheckHTML;
    document.getElementById("spellCheckBtn").value = "Spell Check";

    SpellCheckFieldsLocal();
}

function HideSection(section)
{
//    flipflop = !flipflop;
    document.getElementById(section).innerHTML = "";
}

var spellCheckFields = new Array();
var textAreas = new Array();
var flipflop = true;
var lastSection = "";
var format = false;
var pcolor = false;
var CHAR = false;
var lines = false;
var rlogo = false;
var Font = false;
var vwattr = "";
var vwquantity = 1;
var personalizationCharge = null;

var theForm;

function initParams(frm)
{
    if (frm['vwquantity'])
    {
        if (isNaN(frm['vwquantity'].value))
            vwquantity = 1;
        else
            vwquantity = parseInt(frm['vwquantity'].value);
    }
    else if (frm['vwquantity0'])
    {
        if (isNaN(frm['vwquantity0'].value))
            vwquantity = 1;
        else
            vwquantity = parseInt(frm['vwquantity0'].value);
    }

    if (frm['multiple-add'])
        vwattr = "vwattr0_";
        
    if (frm['format'])
        if (frm['format'].value=='true')
            format = true;
        else
            format = false;
    else
        format = false;
   
    if (frm['pcolor'])
        if (frm['pcolor'].value=='true')
            pcolor = true;
        else
            pcolor = false;
    else
        pcolor = false;
    
    if (frm['CHAR'])
        CHAR = parseInt(frm['CHAR'].value);
    
    if (frm['Font'])
        Font = frm['Font'].value;

    if (frm['lines'])
        lines = parseInt(frm['lines'].value);

    if (frm['rlogo'])
        rlogo = parseFloat(frm['rlogo'].value);
        
    if (frm['personalization-charge'])
    {
        personalizationCharge = frm['personalization-charge'].value.split("|");
    }
}

function Engrave(frm)
{
    theForm = frm;
    
    // update the form's target
    frm.action = "http://site.strictlygifts.com/engraving/engraving.php";
    var engraveHTML = "";

    initParams(frm);
    
    engraveHTML += "<br><b style='background-color: yellow'>To load a previous engraving</b>, <a href=#top onclick='engravingLoad()'>click here</a>. Otherwise...<br>";
    engraveHTML += "<br>If you have multiple items, please be sure to enter the quantity first (above personalization button) and then re-press the Personalization Button.  This will make formatting multiple items, even if they are not all the same, easier.<br>"
    
    if (rlogo)
    {
        engraveHTML += "<br><b>Please select logo option</b><br>";
        engraveHTML += "<input onclick=\"document.getElementById('logopers').innerHTML='<br><div id=otherpers></div>';ShowSection('otherpers')\" type=radio name='" + vwattr + "Logo Engraving Option' value='No'>No logo or artwork required, only standard text needed<br>";
        engraveHTML += "<input onclick=ShowSection('logopers') type=radio name='" + vwattr + "Logo Engraving Option' value='Vector, one-time setup $" + rlogo + "'>Add logo or artwork - already in vector format (eps or ai file), one-time setup $" + rlogo + "<br>";
        engraveHTML += "<input onclick=ShowSection('logopers') type=radio name='" + vwattr + "Logo Engraving Option' value='Not Vector, one-time setup $" + (rlogo+15) + "'>Add logo or artwork, not in vector format (.jpg, gif or bmp file), one-time setup $" + (rlogo + 15) + "<br>";
        //engraveHTML += "<input type=hidden name=" + vwattr + "'Include Logo' value='Yes (+$" + rlogo + ")'>";
        engraveHTML += "<input onclick=\"showAddToCart('logopers')\" type=radio name='" + vwattr + "Logo Engraving Option' value='No, blank item'>No logo or text needed (blank item)<br>";
        engraveHTML += "<div id=logopers></div>";
    }
    else
    {
        engraveHTML += "<br><b>Would you like to add text to each item now?</b> <input type=radio name='" + vwattr + "Other Personalization' value='Yes' onclick=ShowSection('otherpers')>Yes <input type=radio name='" + vwattr + "Other Personalization' value='No' onclick=showAddToCart('otherpers')>No<br><br>    ";
        engraveHTML += "<div id=otherpers></div>";
    }
    
    document.getElementById("engraving").innerHTML = engraveHTML;
    location.href = "#engraveButton";
}

document.write("<div id=engraving></div>");