
jQuery.fn.clickSelect = function(initialValue){
    return this.each(
        function(){
            var def;

            if (initialValue) {
                def = initialValue;
    
                if (jQuery(this).val() == '' || jQuery(this).val() == initialValue) {
                    jQuery(this).val(initialValue);
                }
            }
            else {
                def = jQuery(this).val();
            }

            var textSelector = function() {
                var raw    = this;
                var jquery = jQuery(this);
    
                if (jquery.val() == def) {
                    setTimeout(
                        function() {
                            raw.select();
                        },
                        10
                    );
                }
            }

            jQuery(this).focus(textSelector);
        }
    );
};