﻿
var SearchHelper = function() {
    var search = function() {
        var text = $('#searchText')[0].value;
        if (text == '') {
            alert(Resources.Search.Invalid);
            return false;
        }
        else {
            var frm = document.getElementById("frmSearch");
            frm.submit();
        }
    }

    return {

        Setup: function() {
            $.ajaxSetup({ cache: false });

            $("#searchImg").click(search);

            //
            $("#searchText").click(function() {

                var pos = $(this).position();
                var y = pos.top + $(this).height() + 10 + "px";
                var x = pos.left + 3 + "px";

                $("#searchOptions").css("position", "absolute");
                $("#searchOptions").css("top", y);
                $("#searchOptions").css("left", x);

                $("#searchText").val('');
                $("#searchOptions").show("slow");
            });

            $("#searchText").blur(function() {
                if ($("#searchText").val() == '') {
                    $("#searchText").val('Search');
                }
                $("#searchOptions").hide("slow");
            })
        }
    };

} ();