function copyOf(b) {
    var a = new Object();
    for (v in b) {
        a[v] = b[v]
    }
    return a
}
if (!Array.indexOf) {
    Array.prototype.indexOf = function (b) {
        for (var a = 0; a < this.length; a++) {
            if (this[a] == b) {
                return a
            }
        }
        return -1
    }
}
function asMoney(a, b) {
    if (currencyFormat && !b) {
        b = copyOf(currencyFormat)
    }
    if (!b || !b.currency) {
        b = {
            cpos: true,
            currency: "$",
            precision: 2,
            decimals: ".",
            thousands: ","
        }
    }
    a = formatNumber(a, b);
    if (b.cpos) {
        return b.currency + a
    }
    return a + b.currency
}
function asPercent(a, b) {
    if (currencyFormat && !b) {
        b = copyOf(currencyFormat)
    }
    if (!b) {
        b = {
            decimals: ".",
            thousands: ","
        }
    }
    b.precision = 1;
    return formatNumber(a, b) + "%"
}
function formatNumber(b, e) {
    if (!e) {
        e = {
            precision: 2,
            decimals: ".",
            thousands: ","
        }
    }
    b = asNumber(b);
    var f = b.toFixed(e.precision).toString().split(".");
    var b = "";
    if (e.indian) {
        var c = f[0].slice(0, -3);
        b = f[0].slice(-3, f[0].length) + ((b.length > 0) ? e.thousands + b : b);
        for (var a = 0; a < (c.length / 2); a++) {
            b = c.slice(-2 * (a + 1), c.length + (-2 * a)) + ((b.length > 0) ? e.thousands + b : b)
        }
    } else {
        for (var a = 0; a < (f[0].length / 3); a++) {
            b = f[0].slice(-3 * (a + 1), f[0].length + (-3 * a)) + ((b.length > 0) ? e.thousands + b : b)
        }
    }
    if (e.precision > 0) {
        b += e.decimals + f[1]
    }
    return b
}
var asNumber = function (a) {
    if (!a) {
        a = 0
    }
    a = a.toString().replace(new RegExp(/\,/g), ".");
    a = a.toString().replace(new RegExp(/[^0-9\.\,]/g), "");
    a = a.toString().replace(new RegExp(/\.(?=$|.*\..+$)/g), "");
    if (isNaN(new Number(a))) {
        a = a.replace(new RegExp(/\./g), "").replace(new RegExp(/\,/), ".")
    }
    return new Number(a)
};
var CallbackRegistry = function () {
    this.callbacks = new Array();
    this.register = function (a, b) {
        this.callbacks[a] = b
    };
    this.call = function (d, c, b, a) {
        this.callbacks[d](c, b, a)
    };
    this.get = function (a) {
        return this.callbacks[a]
    }
};

function addEvent(d, b, a) {
    if (d.addEventListener) {
        d.addEventListener(b, a, false)
    } else {
        if (d.attachEvent) {
            var c = b + a;
            d["e" + c] = a;
            d[c] = function () {
                d["e" + c](window.event)
            };
            d.attachEvent("on" + b, d[c])
        } else {
            d["on" + b] = a
        }
    }
}
function removeEvent(d, b, a) {
    if (d.removeEventListener) {
        d.removeEventListener(b, a, false)
    } else {
        if (d.detachEvent) {
            var c = b + a;
            d.detachEvent("on" + b, d[c]);
            d["e" + c] = null;
            d[c] = null
        } else {
            d["on" + b] = null
        }
    }
}
function formatFields() {
    (function (b) {
        var a = b("input");
        a.each(function (c, d) {
            var d = b(d);
            if (d.hasClass("currency")) {
                d.change(function () {
                    b(d).val(asMoney(b(d).val()))
                }).change()
            }
        })
    })(jQuery)
}
if (!Number.prototype.roundFixed) {
    Number.prototype.roundFixed = function (a) {
        var b = Math.pow(10, a || 0);
        return String(Math.round(this * b) / b)
    }
}
var ProductOptionsMenus;
(function (a) {
    ProductOptionsMenus = function (k, f, o, p) {
        var n = this;
        var g = 0;
        var j = false;
        var l = false;
        var m = new Array();
        var e = a(k);
        if (!p) {
            p = 0
        }
        e.each(function (r, i) {
            l = i;
            m[r] = a(i).children();
            if (a.browser.msie) {
                b(i)
            }
            if (r > 0) {
                j = e[r - 1]
            }
            if (e.length == 1) {
                q()
            } else {
                if (j) {
                    a(j).change(function () {
                        if (e.index(l) == e.length - 1) {
                            q()
                        }
                        if (this.selectedIndex == 0 && this.options[0].value == "") {
                            a(i).attr("disabled", true)
                        } else {
                            a(i).removeAttr("disabled")
                        }
                    }).change()
                }
            }
            g++
        });

        function q() {
            var r = new Array();
            e.not(l).each(function () {
                if (a(this).val() != "") {
                    r.push(a(this).val())
                }
            });
            var i = a(l).val();
            a(l).empty();
            m[e.index(l)].each(function (u, t) {
                a(t).appendTo(a(l))
            });
            a(l).val(i);
            var s = new Array();
            a(l).children("option").each(function () {
                if (a(this).val() != "") {
                    var z = r.slice();
                    z.push(a(this).val());
                    var y = o[c(z)];
                    if (!y) {
                        y = o[d(z)]
                    }
                    if (y) {
                        var A = asNumber(formatNumber(y.onsale ? y.promoprice : y.price));
                        var u = asNumber(formatNumber(A * p));
                        var x = asMoney(A + u);
                        var t = a(this).attr("text");
					
                        var w = t.lastIndexOf("(");
                        if (w != -1) {
                           t = t.substr(0, w)
                       }
                       a(this).attr("text", t + "  (" + x + ")");
                        if ((y.inventory == "on" && y.stock == 0) || y.type == "N/A") {
                            if (a(this).attr("selected")) {
                                a(this).parent().attr("selectedIndex", 0)
                            }
                            if (f) {
                                a(this).remove()
                            } else {
                                h(this)
                            }
                        } else {
                            a(this).removeAttr("disabled").show()
                        }
                        if (y.type == "N/A" && f) {
                            a(this).remove()
                        }
                    }
                }
            })
        }
        function c(t) {
            for (var s = 0, r = 0; r < t.length; r++) {
                s = s ^ (t[r] * 7001)
            }
            return s
        }
        function d(t) {
            for (var s = 0, r = 0; r < t.length; r++) {
                s = s ^ (t[r] * 101)
            }
            return s
        }
        function h(i) {
            a(i).attr("disabled", true);
            if (!a.browser.msie) {
                return
            }
            a(i).css("color", "#ccc")
        }
        function b(i) {
            a(i).change(function () {
                if (!this.options[this.selectedIndex].disabled) {
                    this.lastSelected = this.selectedIndex;
                    return true
                }
                if (this.lastSelected) {
                    this.selectedIndex = this.lastSelected
                } else {
                    var r = a(this).children("option:not(:disabled)").get(0);
                    this.selectedIndex = r ? r.index : 0
                }
            })
        }
    }
})(jQuery);

function addtocart(a) {
    (function (d) {
        var b = d(a).find("select.options");
        if (b && options_default) {
            var c = true;
            for (menu in b) {
                if (b[menu].selectedIndex == 0 && b[menu][0].value == "") {
                    c = false
                }
            }
            if (!c) {
                if (!options_required) {
                    options_required = "You must select the options for this item before you can add it to your shopping cart."
                }
                alert(options_required);
                return false
            }
        }
        if (d(a).find("input.addtocart").hasClass("ajax")) {
            ShoppCartAjaxRequest(a.action, d(a).serialize())
        } else {
            a.submit()
        }
    })(jQuery);
    return false
}
function cartajax(b, c, a) {
    (function (e) {
        if (!a) {
            a = "json"
        }
        var d = ((a == "json") ? "json" : "string");
        e.ajax({
            type: "POST",
            url: b,
            data: c + "&response=" + a,
            timeout: 10000,
            dataType: d,
            success: function (f) {
                ShoppCartAjaxHandler(f)
            },
            error: function () {}
        })
    })(jQuery)
}
var ShoppCartAjaxRequest = function (b, c, a) {
    cartajax(b, c, a)
};
var ShoppCartAjaxHandler = function (a) {
    (function (c) {
        var d = c("#shopp-cart-ajax");
        d.empty().hide();
        var b = c("<ul></ul>").appendTo(d);
        if (a.Item.thumbnail) {
            c('<li><img src="' + a.Item.thumbnail.uri + '" alt="" width="' + a.Item.thumbnail.width + '"  height="' + a.Item.thumbnail.height + '" /></li>').appendTo(b)
        }
        c("<li></li>").html("<strong>" + a.Item.name + "</strong>").appendTo(b);
        if (a.Item.optionlabel.length > 0) {
            c("<li></li>").html(a.Item.optionlabel).appendTo(b)
        }
        c("<li></li>").html(asMoney(a.Item.unitprice)).appendTo(b);
        if (c("#shopp-sidecart-items").length > 0) {
            c("#shopp-sidecart-items").html(a.Totals.quantity);
            c("#shopp-sidecart-total").html(asMoney(a.Totals.total))
        } else {
            c(".widget_shoppcartwidget p.status").html('<a href="' + a.url + '"><span id="shopp-sidecart-items">' + a.Totals.quantity + '</span> <strong>Items</strong> &mdash; <strong>Total</strong> <span id="shopp-sidecart-total">' + asMoney(a.Totals.total) + "</span></a>")
        }
        d.slideDown()
    })(jQuery)
};

function quickSelects(a) {
    (function (b) {
        if (!a) {
            a = b(".selectall")
        } else {
            a = b(a).find(".selectall")
        }
        b(a).each(function (c) {
            b(this).mouseup(function (d) {
                this.select()
            })
        })
    })(jQuery)
}
function buttonHandlers() {
    (function (a) {
        a("input.addtocart").each(function () {
            var b = a(this).parents("form.product");
            if (!b) {
                return false
            }
            a(b).submit(function (c) {
                c.preventDefault();
                addtocart(this)
            });
            if (a(this).attr("type") == "button") {
                a(this).click(function () {
                    a(b).submit()
                })
            }
        })
    })(jQuery)
}
function catalogViewHandler() {
    (function (c) {
        var d = c("#shopp");
        var a = new Date();
        a.setTime(a.getTime() + (30 * 86400000));
        var b = c(this);
        c(d).find("ul.views li button.list").click(function () {
            c(d).removeClass("grid").addClass("list");
            document.cookie = "shopp_catalog_view=list; expires=" + a + "; path=/"
        });
        c(d).find("ul.views li button.grid").click(function () {
            c(d).removeClass("list").addClass("grid");
            document.cookie = "shopp_catalog_view=grid; expires=" + a + "; path=/"
        })
    })(jQuery)
}
function cartHandlers() {
    (function (a) {
        a("#cart #shipping-country").change(function () {
            this.form.submit()
        })
    })(jQuery)
}
function helpHandler() {
    var a = document.getElementById("wpwrap");
    if (!a) {
        return true
    }(function (c) {
        if (helpurl) {
            var b = c(a).find("a");
            b.each(function (e, f) {
                var d = c(f).attr("href");
                if (d && d.match(new RegExp(/(.*?)=shopp\/help$/))) {
                    d = d.replace(new RegExp(/(.*?)=shopp\/help$/), helpurl);
                    c(f).attr("href", d);
                    c(f).attr("target", "_blank")
                }
            })
        }
    })(jQuery)
}
function shopp_debug() {
    (function (c) {
        var b = c('<div id="debug" class="shopp overlay"></div>').appendTo(document.body);
        var a = c('<div id="debug" class="shopp"></div>').appendTo(document.body);
        c("<h3>Shopp Debug Console</h3>").appendTo(a);
        if (memory_profile) {
            c("<h4></h4>").html("Memory:").appendTo(a);
            c("<p></p>").html(memory_profile).appendTo(a)
        }
        if (wpquerytotal || shoppquerytotal) {
            c("<h4></h4>").html("Queries:").appendTo(a);
            c("<p></p>").html("WP Total: " + wpquerytotal + "<br />Shopp Total: " + shoppquerytotal).appendTo(a)
        }
        a.click(function () {
            b.remove();
            a.remove()
        });
        return true
    })(jQuery)
}
function shopp_gallery(b, a) {
    (function (e) {
        if (!a) {
            a = "click"
        }
        var c = e(b);
        var f = c.find("ul.thumbnails li");
        var d = c.find("ul.previews");
        f.bind(a, function () {
            var h = e("#" + e(this).attr("class").split(" ")[0]);
            if (!h.hasClass("active")) {
                var g = c.find("ul.previews li.active");
                h.addClass("active").hide();
                if (g.length) {
                    g.fadeOut(800, function () {
                        e(g).removeClass("active")
                    })
                }
                h.appendTo(d).fadeIn(500)
            }
        })
    })(jQuery)
}
function htmlentities(a) {
    if (!a) {
        return ""
    }
    a = a.replace(new RegExp(/&#(\d+);/g), function () {
        return String.fromCharCode(RegExp.$1)
    });
    return a
}
function PopupCalendar(q, o, h) {
    var b = this;
    var c = jQuery.noConflict();
    var m = new Array(new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), new Array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
    var i = 639787;
    var l = 11;
    var p = 42;
    var k = 4;
    var d = 6;
    var f = new Array(30, 31, 1, 2, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
    var n = new Date();
    n = new Date(n.getFullYear(), n.getMonth(), n.getDate());
    var j = new Array();
    var e = new Array();
    var r = new Date();
    b.selection = r;
    var a = "month";
    b.scope = a;
    var g = true;
    b.scheduling = g;
    this.render = function (K, G, D) {
        c(q).empty();
        if (!K) {
            K = n.getMonth() + 1
        }
        if (!D) {
            D = n.getFullYear()
        }
        e = this.getDayMap(K, D, 0, true);
        var t = new Array();
        var u = new Array();
        var A = new Array();
        var z = (K - 1 < 1) ? 12 : K - 1;
        var s = (K + 1 > 12) ? 1 : K + 1;
        var L = (z == 12) ? D - 1 : D;
        var J = (s == 1) ? D + 1 : D;
        var H = 0,
            C = 0;
        var B = c('<span class="back">&laquo;</span>').appendTo(q);
        var I = new Date(D, K - 2, n.getDate());
        if (!b.scheduling || (b.scheduling && I >= n.getTime())) {
            B.click(function () {
                b.scope = "month";
                b.selection = new Date(D, K - 2);
                b.render(b.selection.getMonth() + 1, 1, b.selection.getFullYear());
                c(b).change()
            })
        }
        var M = c('<span class="next">&raquo;</span>').appendTo(q);M.click(function () {
            b.scope = "month";
            b.selection = new Date(D, K);
            b.render(b.selection.getMonth() + 1, 1, b.selection.getFullYear());
            c(b).change()
        });
        var N = c("<h3></h3>").appendTo(q);c('<span class="month">' + MONTH_NAMES[K] + "</span>").appendTo(N);c('<span class="year">' + D.toString() + "</span>").appendTo(N);A[C] = c('<div class="week"></week>').appendTo(q);
        for (H = 0; H < WEEK_DAYS.length; H++) {
            var E = WEEK_DAYS[H];
            t[H] = c('<div class="label">' + E.substr(0, 3) + "</span>").appendTo(A[C])
        }
        for (H = 0; H < e.length; H++) {
            var y = e[H].getMonth() + 1;
            var x = e[H].getFullYear();
            var F = new Date(x, y - 1, e[H].getDate());
            if (H % 7 == 0) {
                A[++C] = c('<div class="week"></div>').appendTo(q)
            }
            if (e[H] != -1) {
                j[H] = c('<div title="' + H + '">' + F.getDate() + "</div>").appendTo(A[C]);
                j[H].date = F;
                if (y != K) {
                    j[H].addClass("disabled")
                }
                if (b.scheduling && F.getTime() < n.getTime()) {
                    j[H].addClass("disabled")
                }
                if (F.getTime() == n.getTime()) {
                    j[H].addClass("today")
                }
                j[H].hover(function () {
                    c(this).addClass("hover")
                }, function () {
                    c(this).removeClass("hover")
                });
                j[H].mousedown(function () {
                    c(this).addClass("active")
                });
                j[H].mouseup(function () {
                    c(this).removeClass("active")
                });
                if (!b.scheduling || (b.scheduling && F.getTime() >= n.getTime())) {
                    j[H].click(function () {
                        b.resetCalendar();
                        if (!c(this).hasClass("disabled")) {
                            c(this).addClass("selected")
                        }
                        b.selection = e[c(this).attr("title")];
                        b.scope = "day";
                        if (b.selection.getMonth() + 1 != K) {
                            b.render(b.selection.getMonth() + 1, 1, b.selection.getFullYear());
                            b.autoselect()
                        } else {
                            c(q).hide()
                        }
                        c(b).change()
                    })
                }
            }
        }
    };
    this.autoselect = function () {
        for (var s = 0; s < e.length; s++) {
            if (e[s].getTime() == this.selection.getTime()) {
                j[s].addClass("selected")
            }
        }
    };
    this.resetCalendar = function () {
        for (var s = 0; s < j.length; s++) {
            c(j[s]).removeClass("selected")
        }
    };
    this.getDayMap = function (B, D, u, F) {
        var E = 1;
        var C = 0;
        var H = new Array();
        var z = (B - 1 == 0) ? 12 : B - 1;
        var x = (z == 12) ? D - 1 : D;
        if (B == 9 && D == 1752) {
            return f
        }
        for (var w = 0; w < p; w++) {
            H.push(-1)
        }
        var t = m[(this.is_leapyear(x)) ? 1 : 0][z];
        var y = m[(this.is_leapyear(D)) ? 1 : 0][B];
        var s = this.dayInWeek(1, B, D, u);
        var G = this.dayInWeek(1, B, D, u);
        if (F) {
            while (G--) {
                H[G] = new Date(x, z - 1, t--)
            }
        }
        while (y--) {
            H[s++] = new Date(D, B - 1, E++)
        }
        var A = H.length - s;
        if (F) {
            while (C < A) {
                H[s++] = new Date(D, B, ++C)
            }
        }
        return H
    };
    this.dayInYear = function (t, x, w) {
        var s = (this.is_leapyear(w)) ? 1 : 0;
        for (var u = 1; u < x; u++) {
            t += m[s][u]
        }
        return t
    };
    this.dayInWeek = function (u, x, w, t) {
        var s = (w - 1) * 365 + this.leapYearsSinceBC(w - 1) + this.dayInYear(u, x, w);
        var y = k;
        if (s < i) {
            y = ((s - 1 + d) % 7)
        }
        if (s >= (i + l)) {
            y = (((s - 1 + d) - l) % 7)
        }
        if (y <= t) {
            return y += (7 - t)
        } else {
            return y -= t
        }
    };
    this.is_leapyear = function (s) {
        if (s <= 1752) {
            return !((s) % 4)
        } else {
            return ((!((s) % 4) && ((s) % 100) > 0) || (!((s) % 400)))
        }
    };
    this.centuriesSince1700 = function (s) {
        if (s > 1700) {
            return (Math.floor(s / 100) - 17)
        } else {
            return 0
        }
    };
    this.quadCenturiesSince1700 = function (s) {
        if (s > 1600) {
            return Math.floor((s - 1600) / 400)
        } else {
            return 0
        }
    };
    this.leapYearsSinceBC = function (s) {
        return (Math.floor(s / 4) - this.centuriesSince1700(s) + this.quadCenturiesSince1700(s))
    }
}
jQuery(document).ready(function () {
    formatFields();
    buttonHandlers();
    cartHandlers();
    catalogViewHandler();
    helpHandler();
    quickSelects()
});
var helpurl;
var options_required;
var options_default;
var productOptions = new Array();