/**
 * Autoclear for Avatec Ogłoszenia v1.0
 * Author: Grzegorz Miśkiewicz
 * Copyright (c) 2010 Avatec.pl. Wszystkie prawa zastrzeżone
 **/
 
(function( $ ){

    $.fn.autoClearInput = function( options ) {  
    
        return this.each(function(index) {        
            if ( options ) { 
                $.extend( settings, options );
            } 
            
    /**
      * Find if elements have entered value, if they have, disable background, and 
      * change color set in rel attribute
      **/
			var color = $(this).attr("rel");
            
			$(this).css('background-color' , 'transparent');
            
            if(this.value == '')
            {
                $(this).css('background-color' , 'none');
            } else {
                $(this).css('background-color' , color);
            }
      
      /**
        * Check if clicked on element, and what image he have
        **/
        
            $(this).focus(function() {
                if(!this.value) {
                	var last = $(this).css('background-color');
                	if((last=="transparent") || (last=="rgba(0, 0, 0, 0)")) {
                		$(this).css('background-color' , color);
                	}
                }
            });
            
            $(this).blur(function() {
                if(!this.value) {
                	var last = $(this).css('background-color');
                    if(last != color) {
                        $(this).css('background-color' , 'rgba(0, 0, 0, 0)'); 
                    } else {
                    	$(this).css('background-color' , 'transparent'); 
                    }
                } 
            });

    });

  };
})( jQuery );
