$(function () {
    // Use Enter key to search
    $("#search").keyup(function (event) {
        if (event.keyCode == 13) { $("#search_submit").click(); }
    });

    // Show/Hide content in search box
    $('#search').each(function () {
        $.data(this, 'default', this.value);
    }).focus(function () {
        if ($.data(this, 'default') == this.value) { this.value = ''; }
    }).blur(function () {
        if (this.value == '') { this.value = $.data(this, 'default'); }
    });

    // Current navigation highlight in left column
    var url = window.location.href;
    var path = "/catalog/" + url.substring(url.lastIndexOf("/") + 1, url.lenght); //"/catalog/Gas Springs and Dampers"; //url.split('&')[0];
    path = path.replace(/%20/g, " ");
    var target = '#left ul#prod-list a[href$="' + path + '"]';
    if (path) {
        $(target).siblings('ul').attr('class', 'current')
		.parents('li').attr('class', 'current')
		.parents('ul').attr('class', 'current');
    }

    if (location.pathname == "/") { $('#left ul#prod-list a[href$="' + path + '"]').parents("").attr('class', '') };

    $("#catalogprodlist tr:even, #damprate tr:even, .catalogprodlist tr:even").addClass("even");

    // Defines equal height columns
    $.fn.setAllToMaxHeight = function () {
        return this.height(Math.max.apply(this, $.map(this, function (e) {
            return $(e).height()
        })));
    }

});

// Divs with class 'eq' will equal each other. Window.load is required for this to work in Webkit.
$(window).load(function(){
	$('.eq').setAllToMaxHeight();
});
