/* Copyright (c) 2008 Brian Beck (exogen@gmail.com)
 * MIT (http://www.opensource.org/licenses/mit-license.php) licensed.
 *
 * Version: 1.0
 * Modified by Christopher Najewicz for FMI's Glyph 12/5/2008
 * Requires:
 *   jQuery 1.2+
 *   Dimensions (http://plugins.jquery.com/project/dimensions)
 */

(function($) {
    $.extend({
        ahover: {
            version: 1.0,
            defaults: {
                className: 'ahover'
            },
            effects: {
                'width': {width: 0},
                'height': {height: 0},
                'both': {width: 0, height: 0}
            }
        }
    });
    
    $.fn.extend({
        ahover: function(options) {
            var options = $.extend({}, $.ahover.defaults, options);
        //  var parent = this.offsetParent();
            var parent = this.parent();
            return this.bind('mouseenter',
                function(e) {
					$('div.'+options.className).remove();
					
                    var outer = $(this);
					var outerSize = {
                        width: outer.outerWidth()-4,
                        height: outer.outerHeight()-4
                    };

					var innerSize = {
						width: outerSize.width-4,
						height: outerSize.height-4
					};
					
                    var highlight = $('<div><div class="inner">&nbsp;</div></div>')
                            .addClass(options.className)
							.css(outerSize)
                            .appendTo(parent)
							.bind('mouseleave',
								function() {
									$('div.' + options.className).remove();
								})
							.click(
								function(e){
									outer.trigger({type:'click',pageX:e.pageX,pageY:e.pageY});
								}
							);
					
					highlight.show().find('.inner').css(innerSize);
				
				});
				
        }
    });
})(jQuery);