// jQuery PopUp 1.1

$.fn.extend({
	popup: function(settings) {
		var defaults = {
			x: "center",
			y: "middle",
			width: 600,
			height: 600,
		}
		
		options = $.extend(defaults, settings);
		
		return this.each(function() {
			$this = $(this);
			$url = $this.attr("href");
			$xPos = options.x;
			$yPos = options.y;
			$width = options.width;
			$height = options.height;
			
			if(typeof($xPos)!="number") {
				if($xPos=="left") $xPos=0;
				else if($xPos=="center") $xPos=($(window).width()-options.width)/2;
				else if($xPos=="right") $xPos=($(window).width()-options.width);
			}
			if(typeof($yPos)!="number") {
				if($yPos=="top") $yPos=0;
				else if($yPos=="middle") $yPos=($(window).height()-options.height)/2;
				else if($yPos=="bottom") $yPos=($(window).height()-options.height);
			}
			
			$this.click(function(e){
				window.open(this.href, "Pop-Up", [
					"width="+$width,
					"height="+$height,
					"top="+$yPos,
					"left="+$xPos
				]);
				return false;
			});
		});
	}
});
