// namespace functions (YAHOO recommendation)
if (typeof(INVENTIVE) == 'undefined') { INVENTIVE = {}; }

// Limit the scope of variables so this will play nice with other JS code
// YAHOO recommendation
(function (){
    INVENTIVE.addToCartOnSubmit = function(form) {
        if(typeof(form.item_number) != 'undefined') {
            if (form.item_number.value.length == 0) {
                // TODO: a more elegant popup
                alert('Please select an option');
                return false;
            }
        }
        return true;
    };
    INVENTIVE.selectVariantOnChange = function(select_el) {
        var option_el = select_el.options[select_el.selectedIndex];
        var final_price = option_el.getAttribute('final_price');
        select_el.form.amount.value = final_price;
    };
})();

// Suckerfish for main menu
sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

