﻿//define namespace objects only if not already defined
if ("undefined" == typeof Kpw) {Kpw = {};}
if ("undefined" == typeof Kpw.Vendor) {Kpw.Vendor = {};}

$().ready(function(){
	Kpw.Vendor.Directory.init();
});

if ("undefined" == typeof Kpw.Vendor.Directory) {
    Kpw.Vendor.Directory = {
        bindEvents: function() {
            $("div.VendorDirectory div.category div.highlight").fadeTo("fast", .001);
            $("div.VendorDirectory div.category img").mouseover(function() {
                var image = $(this);
                var matte = image.parents("div.matteBorder");
                var matteOffset = matte.offset();
                var highlight = image.prev();
                if (highlight.attr("data-kpw-highlight") != "true") {
                    highlight
                        .attr("data-kpw-highlight", "true")
                        .css("width", matte.outerWidth(true))
                        .css("height", matte.outerHeight(true))
                        .css("left", matteOffset.left)
                        .fadeTo("fast", 0.4, function() {
                            $(this).fadeTo("def", 0.01, function() {
                                highlight
                                    .css("width", "0px")
                                    .css("height", "0px");
                                setTimeout(function() {
                                    highlight.removeAttr("data-kpw-highlight");
                                }, 1);
                            });
                        });
                }
            });

        },
        Category: {
            click: function(href){
                window.location = href;
            }
        },
        init: function() {
            //bind events
            Kpw.Vendor.Directory.bindEvents();
        }
    }
}
