$(function() {
    $('a[href^="#"]').click(function() {
        var the_id = $(this).attr("href");

        if (the_id != "#") {
            $('html, body').animate({
                scrollTop: $(the_id).offset().top
            }, 'slow');
            return false;
        }
    });

    $(window).scroll(function() {
        if ($(this).scrollTop() > 100) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    });

    $('.scrollup').click(function() {
        $("html, body").animate({scrollTop: 0}, 600);
        return false;
    });

    $(".productVariations img").each(function(key, value) {
        var $parent = $(value).closest(".product");
        $(value).click(function() {
            var $this = $(this);

            $parent.find(".productName").text($this.attr("data-name"));
            $parent.find(".productImage").attr("src", $this.attr("data-image"));
            $parent.find(".productUri").attr("href", $this.attr("data-uri"));
        });
    });
});