$.fn.jobPreview = function(options){

	/* Setup the options for the tooltip that can be
	   accessed from outside the plugin              */
	var defaults = {
		speed: 200,
		delay: 800
	};

	var options = $.extend(defaults, options);

	/* Create a function that builds the tooltip
	   markup. Then, prepend the tooltip to the body */
	getTip = function() {
		var tTip =
		"<div class='job-tip'>" +
			"<div class='content'>"	+
			"</div>" +
		"</div>";
		return tTip;
	}
	$("body").prepend(getTip());

	/* Give each item with the class associated with
	   the plugin the ability to call the tooltip    */
	$(this).each(function(){

		var $this = $(this);
		var tip = $('.job-tip');
		var tipInner = $('.job-tip .content');
		var link = $(this);

		var offset = $this.parent().offset();
		var tLeft = offset.left;
		var tTop = offset.top;
		var tWidth = $this.width();
		var tHeight = $this.height();

		/* Mouse over and out functions*/
		$this.parent('article').hover(function() {
			setTip(tTop, (tLeft+tWidth));
			setTimer(link);
		},
		function() {
			stopTimer();
			tip.fadeOut('fast');
		}
	);		   

	/* Delay the fade-in animation of the tooltip */
	setTimer = function(link) {
		$this.showTipTimer = setInterval(function() { showTip(link); }, defaults.delay);
	}

	stopTimer = function() {
		clearInterval($this.showTipTimer);
	}

	/* Position the tooltip relative to the class
	   associated with the tooltip                */
	setTip = function(top, left){
		var topOffset = tip.height();
		var xTip = (left)+"px";
		var yTip = (top)+"px";
		tip.css({'top' : yTip, 'left' : xTip});
	}

	/* This function stops the timer and creates the
	   fade-in animation                          */
	showTip = function(link){
		stopTimer();
		tipInner.load(link.attr('href')+'?ajax&nocache='+Math.random(), function() {
			tip.animate({"top": "+=30px", "opacity": "toggle"}, defaults.speed);		
		});
	}
});
};
