﻿$(function() {
    // dynamically preload over images
    $(".rollover").each(
        function() {
            var overSrc = "";
            if (this.src.endsWith(".gif"))
                overSrc = this.src.replace(".gif", "_Over.gif");
            if (this.src.endsWith(".jpg"))
                overSrc = this.src.replace(".jpg", "_Over.jpg");
            if (this.src.endsWith(".png"))
                overSrc = this.src.replace(".png", "_Over.png");

            jQuery("<img>").attr("src", overSrc);
        }
    );

    // setup rollover actions
    $(".rollover").hover(
        function() {
            if (this.src.search("_Over") < 0) {
                var overSrc = "";
                if (this.src.endsWith(".gif"))
                    overSrc = this.src.replace(".gif", "_Over.gif");
                if (this.src.endsWith(".jpg"))
                    overSrc = this.src.replace(".jpg", "_Over.jpg");
                if (this.src.endsWith(".png"))
                    overSrc = this.src.replace(".png", "_Over.png");

                this.src = overSrc;
            }
        },
        function() {
            this.src = this.src.replace("_Over", "");
        }
    );

    $(".menu-selected").each(
            function() {
                if (this.src.endsWith(".gif"))
                    this.src = this.src.replace(".gif", "_Over.gif");
                if (this.src.endsWith(".jpg"))
                    this.src = this.src.replace(".jpg", "_Over.jpg");
                if (this.src.endsWith(".png"))
                    this.src = this.src.replace(".png", "_Over.png");
            }
    );

    var bottom = parseInt($(".popup").css("bottom"));

    $(".popup").hover(function() {

        $(this).animate({ bottom: 0 }, 200);
    },
            function() {

                $(this).animate({ bottom: bottom }, 200);

            }
        );

    $(".tabs a").wrapInner("<span></span>");

    $(".products td").append("&nbsp;");
});