// wrap plugin in a closure
(function($) {
	// metadatapopup plugin definition
	$.fn.metadatapopup =
		function(options) {
			// extend default options with those provided
			var opts = $.extend({}, $.fn.metadatapopup.defaults, options);

			return this.each(function() {
				var $this = $(this);

				// build element specific options
				var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;

				// plugin functionality starts here
				$this.bind('click', function(event) {
					var options = '';
					$.each(o, function(property, value) {
						options += property + '=' + value + ',';
					})
					options += 'dummy=dummy';
					window.open(
						$this.attr('href'),
						'PopupWindow',
						options
					);
					return false;
				});
			});
		};

	// metadatapopup plugin default options
	$.fn.metadatapopup.defaults =
		{
			height: 768,
			width: 1024,
			scrollbars: 1
		};
})(jQuery);
