$.fn.tip = function(options) {

	var cfg = $.extend({},{
		attr: 'tip',
		container: "#tip"
	},options);
	
	$('<div id="'+cfg.container.slice(1)+'"></div>').appendTo("body");
	container=$(cfg.container);
	container.css({
		position: "absolute",
		display: "inline"
	}).hide();
		
	var getData = function(obj){
		container.html($(obj).attr(cfg.attr));
	};
		
	var position = function (e){
		$(container).css({
			top: e.pageY,
			left: e.pageX
		});
	};
		
	$(this).bind("mouseover", function(e){
		getData(this);
		container.fadeIn("normal");
		position(e);
		on=true;
	});
	
	
	$(this).bind("mousemove", function(e){
		if(on)position(e);
	});
		
	$(this).bind("mouseout", function(){
		container.hide();
	});
	
	$(this).click(function(){
		container.hide("fast");
		on=false;
	});
};

    $.fn.filestyle = function(options) {
        var settings = {
            width : 250
        };
                
        if(options) {
            $.extend(settings, options);
        };
                        
        return this.each(function() {
            
            var self = this;
            var wrapper = $("<div>")
                            .css({
                                "width": settings.imagewidth + "px",
                                "height": settings.imageheight + "px",
                                "background": "url(" + settings.image + ") 0 0 no-repeat",
                                "background-position": "right",
                                "display": "inline",
                                "position": "absolute",
                                "overflow": "hidden"
                            });
                            
            var filename = $('<input readonly="readonly" class="file">')
                             .addClass($(self).attr("class"))
                             .css({
                                 "display": "inline",
                                 "width": settings.width + "px"
                             });

            $(self).before(filename);
            $(self).wrap(wrapper);

            $(self).css({
                        "position": "relative",
                        "height": settings.imageheight + "px",
                        "width": settings.width + "px",
                        "display": "inline",
                        "cursor": "pointer",
                        "opacity": "0.0"
                    });

            if ($.browser.mozilla) {
                if (/Win/.test(navigator.platform)) {
                    $(self).css("margin-left", "-142px");                    
                } else {
                    $(self).css("margin-left", "-168px");                    
                };
            } else {
                $(self).css("margin-left", settings.imagewidth - settings.width + "px");                
            };

            $(self).bind("change", function() {
                filename.val($(self).val());
            });
      
        });
        

    };

