(function($){

	var settings = {
	  type : 'tester'
	}
	
	var methods = {
		init : function( options ) {
			return this.each(function(){
				var $this 		= $(this);
				var $opts 		= $this.data('opts');
				if(!$opts){
					$opts = $.extend(settings, (options ? options : {} ));
					$(this).data('opts', $opts);
					
        			$(window).bind('resize.resizetooltips', function(){ $this.tooltip('reposition') });
					
					$this.css({border : '#000 solid 1px', width:'100px', cursor:'pointer'});
					
					$(this).bind('click',function(){
						$(this).tooltip('update',$(this).html() + ' x ')
					});
				}
	 		});
	 	},
		
		destroy : function(){
			return this.each(function(){
				var $this = $(this);
				var $opts = $this.data('opts');
				if($opts){
					$(window).unbind('.resizetooltips');
					$this.removeData('opts');
					$this.css({border : '#F00 solid 1px'});
				}
			})	
		},
		
		reposition : function(){
			return this.each(function(){
				var $this = $(this);
				var $opts = $this.data('opts');
				if($opts){
					$this.css('width',($this.width()+10)+'px');
				}
			})	
		},
		
		update : function(content){
			return this.each(function(){
				var $this = $(this);
				var $opts = $this.data('opts');
				if($opts){
					$this.html(content)
				}
			})	
		}
	};


	$.fn.tooltip = 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.tooltip' );
		}
	};
})(jQuery);
  
