﻿
// assumes search textbox has id 'txtSearch' and
// go button is 'btnSearch'
// requires jquery
var searchhelpers = function () {
    var $btnSearch = null;
    var $txtSearch = null;

    function doSearch() {
        window.location = "Search.aspx?S=" + encodeURIComponent($txtSearch.val());
    }
    return {
        init: function () {
            $btnSearch = $('#btnSearch');
            $txtSearch = $('#txtSearch');

            $btnSearch.click(function () {
                doSearch();
                return false;
            });

            $txtSearch.keypress(function (evt) {
                var code = evt.keyCode ? evt.keyCode : e.which;

                if (code == 13) {
                    evt.preventDefault();   // needed to prevent ie from firing refresh
                    doSearch();
                }

            });

        }
    }
} ();


