﻿(function($) {
    function init() {
        $("#btnSearch").bind("click", function(e) {
            e.preventDefault();
            if ($("#txtSearch").val() != searchLabel) {
                startSearch();
            }
        });

        $("#txtSearch").bind("focus", function() {
            if (this.value === searchLabel) {
                this.value = "";
            }
        }).bind("blur", function() {
            if (this.value.length === 0) {
                this.value = searchLabel;
            }
        });

        $("#txtSearch").bind("keypress", function(e) {
            if (e.keyCode === 13) {
                e.preventDefault();
                startSearch();
            }
        });
    }
    function startSearch() {
        var textSearch = document.getElementById('txtSearch');
        var hrefString = '/' + searchUrl + '?exp=' + escape(textSearch.value);

        document.location.href = document.location.protocol + "//" + document.location.host + hrefString;
    }

    $(document).ready(function() {
        init();
    });
})(jQuery);
