jQuery.popup = function(){
	var y = null;
	var offsetX = -15;
	var popupTimer = null;
	$("#portfolio li a").hover(function(e){
		clearTimeout(popupTimer);
		popupTimer = null;
		$("#popup").remove();
		var l = $(this).children("img").attr("longdesc");
		this.t = this.title;
		this.title = "";
		this.r = this.rel;
		this.rel = "";
		var c = (this.t != "") ? this.t : "";
		var d = (this.r != "") ? this.r : "";
		y = $(window).width() / 2;
		if(y > e.pageX) {
			var offsetY = 15;
		} else {
			var offsetY = -357;
		};
		$("body").append("<div id='popup'><strong>"+ c +"</strong><span>"+ l +"</span>Click to visit this site in a new tab<br /><br /><img src='"+ d +"' /></div>");
		$("#popup").css("top",(e.pageY - offsetX) + "px").css("left",(e.pageX + offsetY) + "px").fadeIn();
    },
	function(){
		this.title = this.t;
		this.rel = this.r;
		popupTimer = setTimeout(function() {
			$("#popup").hide();
			popupTimer = null;
			t = null;
		}, 10);
    });	
	$("#portfolio li a").mousemove(function(e){
		y = $(window).width() / 2;
		if(y > e.pageX) {
			var offsetY = 15;
		} else {
			var offsetY = -357;
		};
		$("#popup").css("top",(e.pageY - offsetX) + "px").css("left",(e.pageX + offsetY) + "px");
	});		
};