﻿$(document).ready(function() {
    // If MSIE, we want to move the #logo to the bottom of the html
    // to compensate for the stupid z-index problems with positioned
    // elements
    if ($.browser.msie) $("#wrap").append($("#logo"));

    $(".product").pngFix();

    var doTopSearch = function() {
        var keyword = $("#top-nav-search-box").val();
        window.location = "/search.aspx?keyword=" + encodeURIComponent(keyword);
        return false;
    }

    $("#top-nav-search-button").click(doTopSearch);
    $("#top-nav-search-box").keypress(function(e) {
        if (e.keyCode == 13)
            return doTopSearch();
    });


    var doRetailSearch = function() {
        var q = $("#find-retailer-form #q");
        if (q.data("val") == q.val())
            return false;
        
        window.location = "/retailers.aspx?q=" + encodeURIComponent(q.val());
        return false;

    }

    $("#find-retailer-form img").click(doRetailSearch);
    $("#find-retailer-form input").keypress(function(e) {
        if (e.keyCode == 13)
            return doRetailSearch();
    });


});