﻿$(document).ready(function() {

    //hide all overlays
    //$(".Overlay").hide();

    function AddOver(i) {
        return i.replace(".gif", "_Over.gif").replace(".png", "_Over.png").replace(".jpg", "_Over.jpg");
    }

    // dynamically preload over images
    $(".Rollover").each(
        function() {
            jQuery("<img>").attr("src", AddOver(this.src));
        }
    );

    // setup rollover actions
    $(".Rollover").hover(
    function() {
        if (this.className.search("Rollover") >= 0 && this.src.search("_Over") < 0) {
            this.src = AddOver(this.src);
        }
    },
    function() {
        if (this.className.search("Rollover") >= 0) {
            this.src = this.src.replace("_Over", "");
        }
    });

    // rollover menu
    $(".RolloverMenu").hover(
        function() { $(this).addClass("ItemOver"); },
        function() { $(this).removeClass("ItemOver"); }
     );

    // slide effect on product range
    $("div.ProductContainer").hoverIntent(showOverlay, hideOverlay);
});

function showOverlay() {
    $(this).find(".Overlay").animate({ right: 2, width: 125, opacity: 0.85, paddingRight: 0 }, 300, "swing", void(0));
}

function hideOverlay() {
    $(this).find(".Overlay").animate({ right: -125, width: 125, opacity: 0.85, paddingRight: 0 }, 300, "swing", void(0));
}

