var _g_eceDefCookieName = "_eceCartv2_" + "3628";
var _g_eceDefCookieMax = 5; 
var _g_eceDefCookieSizeMax = 4000; 
var _g_eceDefExpDate = new Date();
_g_eceDefExpDate.setTime(new Date().getTime() + (2 * 24 * 60 * 60 * 1000));
function changeText(theform){
var num = theform["a1-2"].selectedIndex
switch(num)
{
case 0:
  document.getElementById('fragDesc').innerHTML = '';
  break
case 1:
  document.getElementById('fragDesc').innerHTML = 'Our Creamy Version of a Crackling Fireplace';
  break
case 2:
  document.getElementById('fragDesc').innerHTML = 'Fresh Uncut Roses';
  break
case 3:
  document.getElementById('fragDesc').innerHTML = 'Juicy Blackberries brewed with Calming Sage';
  break
case 4:
  document.getElementById('fragDesc').innerHTML = 'Clean and Fresh';
  break
case 5:
  document.getElementById('fragDesc').innerHTML = 'Fresh Ground Cinnamon';
  break
case 6:
  document.getElementById('fragDesc').innerHTML = 'Real Coconuts and Creamy Vanilla';
  break
case 7:
  document.getElementById('fragDesc').innerHTML = 'Sweet and Tart';
  break
case 8:
  document.getElementById('fragDesc').innerHTML = 'Fresh Cucumbers drenched with Sweet Melon';
  break
case 9:
  document.getElementById('fragDesc').innerHTML = 'Pomegranate, Citrus, and Ocean Mist';
  break
case 10:
  document.getElementById('fragDesc').innerHTML = 'Citrusy Pink Grapefruit - Truly Refreshing';
  break
case 11:
  document.getElementById('fragDesc').innerHTML = 'Cool Water &amp; Summer Flowers';
  break
case 12:
  document.getElementById('fragDesc').innerHTML = 'Soft Jasmine Flowers with Creamy Vanilla';
  break
case 13:
  document.getElementById('fragDesc').innerHTML = 'Soothing Lavender';
  break
case 14:
  document.getElementById('fragDesc').innerHTML = 'World Famous!  Crisp Tart Apples with a dash of Ground Cinnamon.';
  break
case 15:
  document.getElementById('fragDesc').innerHTML = 'Ocean &amp; Sea Berries';
  break
case 16:
  document.getElementById('fragDesc').innerHTML = 'Lemongrass &amp; Sage';
  break
case 17:
  document.getElementById('fragDesc').innerHTML = 'Pure Earthy Patchouli with notes of Clove';
  break
case 18:
  document.getElementById('fragDesc').innerHTML = 'Absolute Peppermint';
  break
case 19:
  document.getElementById('fragDesc').innerHTML = 'Sweet Pears with Soft Spices';
  break
case 20:
  document.getElementById('fragDesc').innerHTML = 'An Intoxicating Blend of Island Flowers';
  break
case 21:
  document.getElementById('fragDesc').innerHTML = 'Creamy Vanilla with a dash of Spice and a hint of Cinnamon';
  break
case 22:
  document.getElementById('fragDesc').innerHTML = '';
  break
case 23:
  document.getElementById('fragDesc').innerHTML = 'Cloves and Orange';
  break
case 24:
  document.getElementById('fragDesc').innerHTML = 'A Blend of Holiday Favorites';
  break
case 25:
  document.getElementById('fragDesc').innerHTML = 'A Real Pine Tree blended with the Aromatic Woods of Nature';
  break
}
}
function _eceGetSubDomain()
{
    if (document.getElementById && location && location.hostname)
    {
        var _eceUseDomain = location.hostname.toLowerCase();
        var _eceUseDomainArray = _eceUseDomain.split(".");

        if (_eceUseDomainArray.length >= 2)
        {
            if (_eceUseDomainArray[_eceUseDomainArray.length - 1].length > 2)
            {
                if (isNaN(_eceUseDomainArray[_eceUseDomainArray.length - 1]))
                {
                    return ("; domain=." + _eceUseDomainArray[_eceUseDomainArray.length - 2] + "." + _eceUseDomainArray[_eceUseDomainArray.length - 1]);
                }
            }
        }
    }
    
    return "";
}

function _eceGetCookie (cookieName)
{
    var retStr = "";
    if (document.cookie)
    {
        if (!cookieName)
            cookieName = _g_eceDefCookieName;
            
        var cookieArray = document.cookie.split(";")
        var nCount = 0;

        for (var n = 0; n < cookieArray.length; n++)
        {
            while(cookieArray[n].charAt(0) == ' '){cookieArray[n] = cookieArray[n].substring(1)}
            if (cookieArray[n].indexOf(cookieName) == 0)
            {
                retStr += cookieArray[n].substring(cookieName.length+1 + (nCount > 0 ? 1 : 0));
                nCount++;
            }
        }
    }

    return retStr;
}


function _eceWriteCookie (cookieValue, cookieName)
{

    if (cookieValue.length > (_g_eceDefCookieMax * _g_eceDefCookieSizeMax))
    {
        alert("Maximum cart size exceeded.");
        return "";
    }

    if (!cookieName)
            cookieName = _g_eceDefCookieName;
            
    _eceResetCart(cookieName);
            
    for (var n = 0; n < _g_eceDefCookieMax; n++)
    {
         if ( cookieValue.length > _g_eceDefCookieSizeMax)
         {
            var setCookie = cookieName + (n > 0 ? n : "") + "=" + cookieValue.substring(0, _g_eceDefCookieSizeMax);
            document.cookie = setCookie + "; expires=" + _g_eceDefExpDate.toGMTString() + "; path=/" + _eceGetSubDomain();
            cookieValue = cookieValue.substring(_g_eceDefCookieSizeMax);
         }
         else
         {
            var setCookie = cookieName + (n > 0 ? n : "") + "=" + cookieValue;
            document.cookie = setCookie + "; expires=" + _g_eceDefExpDate.toGMTString() + "; path=/" + _eceGetSubDomain();
            break;
         }
    }

    return "";
}

function _eceResetCart(cookieName)
{
    if (!cookieName)
            cookieName = _g_eceDefCookieName;
            
    var cookieArray = document.cookie.split(";")
    
    for (var n = 0; n < cookieArray.length; n++)
    {
        while(cookieArray[n].charAt(0) == ' '){cookieArray[n] = cookieArray[n].substring(1)}
        
        for (var x = 0; x < _g_eceDefCookieMax; x++)
        {
            var useCookiename = cookieName + (x > 0 ? x : "") + "=";
            if (cookieArray[n].indexOf(useCookiename) == 0)
                document.cookie = useCookiename + "" + "; expires=-1; path=/" + _eceGetSubDomain();
        }
    }
}




var _g_eceDefCartButton = "https://services.mercantec.com/images/sample_add.jpg";
var _g_eceMerchantID = "3628";
var _g_eceCartButton = "/IMG/buy.png";
var _g_ecePostAddLink = "?added";
var _g_eceDefQtyText = "Quantity:";
var _g_eceImgAltText = 'alt="' + "Add To Cart" + '"';
var _g_eceQtyText = "Quantity:";

if (!_g_eceQtyText)
    _g_eceQtyText = _g_eceDefQtyText;
    
if (_g_eceCartButton)
    _g_eceImgAltText = "";
else
    _g_eceCartButton = _g_eceDefCartButton;
    
function _eceAttributeOptionsStructure(ID, name, priceUnit, price, displayOrder, selected)
{
    this.ID = ID;
    this.name = name;
    this.priceUnit = priceUnit;
    this.price = price;
    this.displayOrder = displayOrder;
    this.selected = selected;
}

function _eceAttributeStructure(name, type, displayOrder, options)
{
    this.name = name;
    this.type = type;
    this.displayOrder = displayOrder;
    this.options = options
}

function _eceProductStructure(ID, name, description, price, shipping, attributesString, attributes)
{
    this.ID = ID;
    this.name = name;
    this.description = description;
    this.price = price;
    this.shipping = shipping;
    this.attributesString = attributesString;
    this.attributes = attributes;
}

function _eceAttributeInputStructure(ID, input)
{
    this.ID = ID;
    this.input = input;
}

var _g_eceProductArray = new Array();

_g_eceProductArray[0] = new _eceProductStructure("56535", "Fragrance Oils", "2oz. Fragrance Oils", "$16.00", "$1.50", '<table cellpadding="2" cellspaing="2"><tr><td align="right" valign="middle">Size:&nbsp;</td><td align="left" valign="top" nowrap="true"><input type="radio" value="84536" checked="checked" name="a1-1">2 oz. ($16)<br><input type="radio" value="84537" name="a1-1">4 oz. ($25)<br></td></tr><tr><td align="right" valign="middle">Fragrance:&nbsp;</td><td align="left" valign="top" nowrap="true"><select name="a1-2" onmouseup="changeText(this.form)"><option value="holiday">Choose a Fragrance</option><option value="73832" disabled>Alpine Ash</option><option value="73833" disabled>Belle Amour Rose</option><option value="73834" >Blackberry Sage</option><option value="73835" >Breeze</option><option value="73836" >Cinnamon</option><option value="73837" disabled>Coconut Vanilla</option><option value="73838" >Cranberry</option><option value="73839" disabled>Cucumber Melon</option><option value="73840" >Fire Island</option><option value="73841" >Grapefruit</option><option value="73842" >Hampton Beach</option><option value="73843" >Jasmine Vanilla</option><option value="73844" >Lavender</option><option value="73845" >Long Island\'s Best Apple Cinnamon</option><option value="73846" >Montauk Mist</option><option value="73847" >Oyster Bay</option><option value="73848" >Patchouli Clove</option><option value="73849" >Peppermint</option><option value="73850" >Spiced Pear</option><option value="73851" >Tropical</option><option value="73852" >Vanilla Chai</option><option value="holiday" >---Special Holiday Scents---</option><option value="81966" >Noel</option><option value="81967" >Bryant Park</option><option value="81968" >Alpine Woods</option></select></td></tr></table>', new Array (new _eceAttributeStructure("Fragrance", "1", "2", new Array (new _eceAttributeOptionsStructure("73832", "Alpine Ash", "$", "0.0000", "1", "False"), new _eceAttributeOptionsStructure("73833", "Belle Amour Rose", "$", "0.0000", "2", "False"), new _eceAttributeOptionsStructure("73834", "Blackberry Sage", "$", "0.0000", "3", "False"), new _eceAttributeOptionsStructure("73835", "Breeze", "$", "0.0000", "4", "False"), new _eceAttributeOptionsStructure("73836", "Cinnamon", "$", "0.0000", "5", "False"), new _eceAttributeOptionsStructure("73837", "Coconut Vanilla", "$", "0.0000", "6", "False"), new _eceAttributeOptionsStructure("73838", "Cranberry", "$", "0.0000", "7", "False"), new _eceAttributeOptionsStructure("73839", "Cucumber Melon", "$", "0.0000", "8", "False"), new _eceAttributeOptionsStructure("73840", "Fire Island", "$", "0.0000", "9", "False"), new _eceAttributeOptionsStructure("73841", "Grapefruit", "$", "0.0000", "10", "False"), new _eceAttributeOptionsStructure("73842", "Hampton Beach", "$", "0.0000", "11", "False"), new _eceAttributeOptionsStructure("73843", "Jasmine Vanilla", "$", "0.0000", "12", "False"), new _eceAttributeOptionsStructure("73844", "Lavender", "$", "0.0000", "13", "False"), new _eceAttributeOptionsStructure("73845", "Long Island's Best Apple Cinnamon", "$", "0.0000", "14", "False"), new _eceAttributeOptionsStructure("73846", "Montauk Mist", "$", "0.0000", "15", "False"), new _eceAttributeOptionsStructure("73847", "Oyster Bay", "$", "0.0000", "16", "False"), new _eceAttributeOptionsStructure("73848", "Patchouli Clove", "$", "0.0000", "17", "False"), new _eceAttributeOptionsStructure("73849", "Peppermint", "$", "0.0000", "18", "False"), new _eceAttributeOptionsStructure("73850", "Spiced Pear", "$", "0.0000", "19", "False"), new _eceAttributeOptionsStructure("73851", "Tropical", "$", "0.0000", "20", "False"), new _eceAttributeOptionsStructure("73852", "Vanilla Chai", "$", "0.0000", "21", "False"), new _eceAttributeOptionsStructure("81966", "Noel", "$", "0.0000", "22", "False"), new _eceAttributeOptionsStructure("81967", "Bryant Park", "$", "0.0000", "23", "False"), new _eceAttributeOptionsStructure("81968", "Alpine Woods", "$", "0.0000", "24", "False"))), new _eceAttributeStructure("Size", "1", "1", new Array (new _eceAttributeOptionsStructure("84536", "2 oz.", "$", "0.0000", "1", "False"), new _eceAttributeOptionsStructure("84537", "4 oz.", "$", "9.0000", "2", "False")))));function _eceAddToCart(itemID, itemQty, linkThrough, _ecePostAddLink, formObj, attCounter)
{
    _ecePostAddLink = unescape(_ecePostAddLink);
 
    if (itemQty.length == 0)
    {
        alert("Quantity cannot be empty.");
        return false;
    }
    else if (isNaN(itemQty))
    {
        alert("Quantity must be numeric.");
        return false;
    }
    else if (parseInt(itemQty) < 1)
    {
        alert("Quantity must be greater than 0.");
        return false;
    }
        
    var currentName = _eceGetCookie();
    var newProdArray = new Array()
    var bFound = false;
    var attribArray = new Array();
    
    if (formObj && attCounter)
    {
        for (n = 0; n < formObj.elements.length; n++)
        {
            var baseName = "a" + attCounter + "-";
            if (formObj.elements[n].name.indexOf(baseName) == 0)
            {

                switch(formObj.elements[n].type)
                {
                case "select-one":
                case "select-multiple":
                    for (var x = 0; x < formObj.elements[n].options.length; x++)
                    {
                        if (formObj.elements[n].options[x].selected)
                            attribArray[attribArray.length] = formObj.elements[n].options[x].value;
                    }
                    
                    break;
                case "radio":
                case "checkbox":
                    if (formObj.elements[n].checked)
                        attribArray[attribArray.length] = formObj.elements[n].value;
                    break;
                    
                case "text":
                case "textarea":
                    if (formObj.elements[n].value.replace(/\s/g, "").length > 0)
                    {
                        var name = formObj.elements[n].name.split("-");
                        if (name.length == 3)
                            attribArray[attribArray.length] = name[2] + "=" + escape(formObj.elements[n].value);
                    }
                    break;
                }
            }
        }
        
    }
    
    if(currentName.length > 0)
    {
        var prodArray = currentName.split(",")
        for (var n = 0; n < prodArray.length; n++)
        {
            var inputsMatch = true;
            var localFound = false;
            var item = prodArray[n].split(":")
            if (item.length == 2)
                item[2] = "";
            if (item.length == 3)
            {
                if (item[0] == itemID && item[2] == attribArray.join("&"))
                {
                    var newQty = parseInt(item[1]) + parseInt(itemQty)
                    newProdArray[newProdArray.length] = item[0] + ":" + newQty + ":" + item[2];
                    bFound = true;
                }
                else if (item[0] != 'm')
                    newProdArray[newProdArray.length] = item[0] + ":" + item[1] + ":" + item[2];
            }
        }
    }
    
    if (!bFound)
    {
        newProdArray[newProdArray.length] = itemID + ":" + itemQty + ":" + attribArray.join("&");
    }
    
    var cookie = newProdArray.join(",");
    _eceWriteCookie (cookie);
    
    //    if (document.getElementById && !_ecePostAddLink)
    //        linkThrough = false;
            
    var postAddLink = (_ecePostAddLink ? _ecePostAddLink : location.href);
        
    if (linkThrough)
        location.href = postAddLink;
    else
    {
        if (typeof(this._eceDisplayMiniCart) != 'undefined')
        {
            if (typeof(this._eceDisplayMiniCart) == 'function')
                _eceDisplayMiniCart(true);
        }
    }
}


function _eceWriteProduct(useQty, useProductInfo)
{
    var _ecePostAddLink = escape(_g_ecePostAddLink);
    
    for (var n = 0; n < _g_eceProductArray.length; n++)
    {
        document.writeln('<form method="post" name="_eceAddToCartForm' + _g_eceProductArray[n].ID + '" action="'+location.href+'" onsubmit="_eceAddToCart('+_g_eceProductArray[n].ID+', this.quantity.value, true, \''+_ecePostAddLink+'\', this, ' + (n+1) + ');return(false)">');
        document.writeln('<table cellpadding="3" cellspacing="3">');
        
        if (useProductInfo)
        {
 
            document.writeln('<tr><td align="right">' + 
                            _g_eceProductArray[n].name +
                            '</td></tr><tr><td align="right">' +
                            _g_eceProductArray[n].price +
                            '</td></tr>');
                         
 


        }
        
        document.writeln('<tr><td align="right">' +
                            _g_eceProductArray[n].attributesString +
                            '</td></tr>');
        
        if (useQty)
        {
            document.write('<tr><td align="right">');

            document.write('<b>'+_g_eceQtyText+' </b><input type="text" name="quantity" value="1" maxlength="4" size="4" />' +
                                '</td></tr><tr><td align="right"><input type="image" src="'+_g_eceCartButton+'" border="0"  '+_g_eceImgAltText+'/>');
 
   
            document.write('</td></tr>');         
        }
        else              
        {
            document.write('<tr><td align="right"><input type="image" src="'+_g_eceCartButton+'" border="0"  '+_g_eceImgAltText+'/>' + 
                            '<input type="hidden" name="quantity" value="1" /></td></tr>');
                          
        }
    
        document.writeln('</table>');
        
        document.writeln('</form>');
    }
}


_eceWriteProduct(true, false);