(function($)
{
    var opts;

    var methods = {

        init : function(options)
        {
            opts = $.extend({},$.fn.nplaceholders.defaults,options);

            return this.each(function()
            {
                var defaultText = $(this).val();
                var defaultColour = $(this).css('color');

                $(this).focus(function()
                {
                    if($.trim($(this).val()) == defaultText)
                    {
                        $(this).val("");
                        $(this).css({'color':defaultColour});
                    }

                }).blur(function()
                {
                    if($.trim($(this).val()) == "")
                    {
                        $(this).val(defaultText);
                        $(this).css({'color':opts.inactiveColour});
                    }
                });
                
                $(this).css({'color':opts.inactiveColour});
            });
        }
    };

    $.fn.nplaceholders = function(method)
    {
        if (methods[method])
        {
            return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
        }
        else if (typeof method === 'object' || !method)
        {
            return methods.init.apply(this, arguments);
        }
        else
        {
            $.error('Method ' + method + ' does not exist on jQuery.nplaceholders');
        }
    };

    $.fn.nplaceholders.defaults = {
		inactiveColour : '#cccccc'
    };

})(jQuery);

$(function()
{
	$('.nplaceholder').nplaceholders();
});
