jQuery.fn.feedback = function(options) {  
    idt = new Date();
	
    defaults = {  
     width: 300,
	 top: 200,
	 btHeight:81,
	 btWidth:47,
	 btImage: 'images/btOpinie.gif',
	 id: idt.getTime(),
	 padding:20
    };  
    options = jQuery.extend(defaults, options);  
       
	  return this.each(function() { // alert(options.btImage);
       obj = jQuery(this); 
	   slideLength = parseInt(options.width)+parseInt(options.padding)*2+2;
	   obj.css({
			   'width': options.width,
			   'right':'-'+(slideLength)+'px',
			   'position':'absolute',
			   'top':options.top,
			   'padding':options.padding,
			   'display':'block',
			   'opacity':0.9,
			   'overflow':'visible'
			   });
       
	  obj.prepend('<div class="feedbackWrap"><a href="#" class="handle" id="'+options.id+'"></a></div><div class="stan" rel="close"></div>');
	  wrap = obj.children('.feedbackWrap');
	  handle = wrap.children('#'+options.id);
	  wrap.css ({
				   'margin':0,
				   'padding':0,
				   'top':0,
				   'position':'relative',
				   'display':'block',
				   'overflow':'visible',
				   'zIndex':'300'
				  });
	  handle.css ({
									 'position':'absolute',
									 'margin':0,
                    				 'padding':0,
									 'top':'-'+options.padding-1+'px',
									 'width':options.btWidth,
									 'height':options.btHeight,
									 'left':'-'+options.btWidth-options.padding+'px',
									 'display':'block',
									 'background':'url('+options.btImage+') no-repeat top left transparent',
									 'overflow':'visible',
									 'zIndex':'300'
									 }); 
											
	 handle.hover( function() {
							jQuery(this).css ({'backgroundPosition':'-47px 0' });
				   },
				   function() {
							jQuery(this).css ({'backgroundPosition':'0 0' });	
				   });
	
	handle.click( function() {
						   
						   if(jQuery(this).parent().parent().children('.stan').attr('rel')=='close')
						   {
							   jQuery('.feedbackWrap').each( function() {
																	  jQuery(this).parent().animate(  {
										                                        'right':'-'+slideLength+'px'	
									                                         	 },150);
																	  jQuery(this).parent().children('.stan').attr('rel','close')
																	  });
							   
							   jQuery(this).parent().parent().animate(  {
										 'right':'-1px'	
										 },300);
							   jQuery(this).parent().parent().children('.stan').attr('rel','open');
							   jQuery(this).blur();
							   return false;
							   
						   }
						   else
						   {
							   
							   
							   jQuery(this).parent().parent().animate(  {
										 'right':'-'+slideLength+'px'	
										 },300);
							   jQuery(this).parent().parent().children('.stan').attr('rel','close');
							   jQuery(this).blur();
							   return false;
						   }
						   
						   });
	
    }); 
};  
