/**
 * @name Visited
 * @desc Mimick :visited by creating and destroying an iframe
 * @date February 2009
 * @author Trevor Morris - www.trovster.com
 * @version 0.1 by Trevor Morris
 */
if(typeof jQuery != 'undefined') {
	(function($) {		
		var $body;
		$body = $('body');
		
		$.fn.extend({
			visited: function(options) {
				return this.each(function() {
					var s, o, $$;
					
					$$ = $(this);
					s = $.extend({}, $.fn.visited.defaults, options);
					o = $.metadata ? $.extend({}, s, $$.metadata()) : s;

					$$.bind('click.visited', $.fn.visited.click);
				});
			}
		});
		
		// Click event
		$.fn.visited.click = function(e){
			var $target, $iframe, href;
			$target = $(e.target);
			if($target.is('a')) {
				href = $target.attr('href');
				$iframe = $('<iframe/>').hide().attr('src', href);
				$iframe.appendTo($body);
				$('<img />').one('load',function(){
					$(this).remove();
					$iframe.remove();
				}).attr({src: href});
			}
		};
	})(jQuery);
}