function WrapSearchHolder() {
    var defaulttext = "Search";
    var searchholders = $(".searchholder");
    var i = 0;
    for (i = 0; i < searchholders.length; i++) {
        var theholder = searchholders.eq(i);
        var theinput = theholder.find("input");
       // var thebutton = theholder.find("a");
        theinput.val(defaulttext);
        theinput.attr("defaultvalue", defaulttext)
        //thebutton.bind("click", { input: theinput }, function(event) {
          //  var theinput = event.data.input;
          //  theinput.trigger("search");

       // });
        theinput.bind("search", { input: theinput }, function(event) {
            var theinput = event.data.input;
            var value = theinput.val();
            if (value.toLowerCase() != theinput.attr("defaultvalue").toLowerCase()) {
                var url = "/SearchResults.aspx?pageno=1&searchkey=" + escape(value);
                window.location.href=url
            }
        })
        theinput.bind("focus", { input: theinput }, function(event) {
		
            var theinput = event.data.input;
            var value = theinput.val();
            if (value.toLowerCase() == theinput.attr("defaultvalue").toLowerCase()) {
                theinput.val("");
                theinput.addClass("highlight")
            }
        })
        theinput.bind("blur", { input: theinput }, function(event) {
            var theinput = event.data.input;
            var value = theinput.val();
            if (value.length == 0) {
                theinput.val(theinput.attr("defaultvalue"));
                theinput.removeClass("highlight")
            }
        })
        theinput.bind("keypress", { input: theinput }, function(event) {
            var keypressed = event.keyCode;
            var theinput = event.data.input;
            if (keypressed == '13') {
                
                theinput.trigger("search");
		return false;
            }
            if (keypressed == '27') {
                theinput.val("");
                theinput.trigger("blur");
            }
		
        })
    }
}
$(document).ready(function() {
    WrapSearchHolder();
})
