﻿//when key is pressed in the textbox
$(document).ready(function() {

    var searchBox = $('#searchbox > :text');

    searchBox.focus(function(e) {
        if ($(this).val().length == 0 || $(this).val() == $(this).attr('defaultValue'))
            $(this).val('');
    });

    searchBox.blur(function(e) {
        if ($(this).val().length == 0)
            $(this).val($(this).attr('defaultValue'));
    });

    searchBox.keypress(function(e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            e.preventDefault();
            __doPostBack(searchBox.next().attr('name'), '');
        }
    });

    $(':text,:password').not('#' + searchBox.attr('id')).keypress(function(e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            e.preventDefault();
            var button = $('.btn').eq(0);
            if (button) {
                button.click();
             //   __doPostBack(button.attr('name'), '');
            }
        }
    });
});
