/**
 * gInput - jQuery plugin
 * @version: 1.0 (2011/02/07)
 * @requires jQuery v1.4 or later 
 * @author Dawid Szwed
 * Examples and documentation at: N/A yet
 
 * No license or any other circumstences, do what you want
**/
(function( $ ){
	var settings = {
		      default_text: "Tu wpisz swój mail"
	};
	var methods = {
		     init : function( options ) {
				$.extend( settings, options );
				 
				return this.each(function(index){
					$this = $(this);
					$this.focus(methods.removeText);
					$this.blur(methods.insertText);
					$this.trigger('blur');
				});
		     },
		     removeText : function(e)
		     {
		    	 var target = $(e.currentTarget);
		    	 
		    	 if(target.attr('value') == settings.default_text)
		    		 target.attr('value','');		    	
		     },
		     insertText : function(e)
		     {
		    	 var target = $(e.currentTarget);
		    	
		    	 if(target.attr('value') == "")
		    	 {
					target.attr('value',settings.default_text);
		    	 }    	
		     }
		  };
	
	$.fn.ginput = 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.ginput' );
	    }   
  };
})( jQuery );

