﻿jQuery.fn.infoBox = function(callback, enterpressed, statictext) {
    callback = typeof callback == "function" ? callback : function() { };
    enterpressed = typeof enterpressed == "function" ? enterpressed : function() { };
    $(this).val(statictext);
    this.focus(
        function() {
            if ($(this).val() == statictext) {
                $(this).val('');
                $(this).addClass('searchInfoBoxActive');
            }
        }
    );
    this.keypress(
		function(e) {
		    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
		    // allow enter/return key (only when in an input box)
		    if (key == 13 && this.nodeName.toLowerCase() == "input") {
		        enterpressed();
		        return false;
		    }
		    else if (key == 13) {
		        return false;
		    }
		    return true;
		}
	)
	.blur(
		function() {
		    var val = jQuery(this).val();
		    if ($(this).val() == '') {
		        $(this).val(statictext);
		        $(this).removeClass('searchInfoBoxActive');
		        $(this).removeClass('inputError');
		    }
		}
	);
    return this;
}
