/**
 * Created so that it creates a nicer loading transition.
 */
(function($) {

	$.fn.pldFormHints = function(method, options) {
		
		var methods = {

			peekABoo: function() {
				var settings = {
					fieldSelector: 'input[type="text"]',
					hint: '',
					resetHint: true
				};
				
				if (options) { 
					$.extend(settings, options);
				}
						
				this.each(function() {   
					var $field;

					$field = $(this);

					if ($field[0].nodeName !== 'INPUT') {
						$field = $field.find(settings.fieldSelector);
					}

					$(this).bind('mouseenter', function() {
						if ($field.val() === '') {
							$field.val(settings.hint);
						}
					}).bind('mouseleave', function() {
						if ($field.val() === settings.hint) {
							$field.val('');
						}
					});

					if (settings.resetHint) {
						$field.bind('click', function() {
							var $this = $(this);

							if ($this.val() === settings.hint) {
								$this.val('');
							}
						});
					}
				});
			}	

		};

		// Method calling logic
		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.pldFormHints');
		}    

	};

})(jQuery);
