document.observe('dom:loaded', function() {

	$$('a[rel=popup]').each(function(el) {
		Event.observe(el, 'click', function(e) {
			Event.stop(e);
			var el = Event.findElement(e, 'a'),
				options = {
					width: 900,
					height: 600,
					features: 'resizable,scrollbars'
				};
				
			if (el.readAttribute('popup-style')) {
				var parts = {};
				el.readAttribute('popup-style').split(";").each(function(val) {
					if (!val.length) { return; }
					var pair = val.split(":", 2);
					if (!pair[0].length || !pair[1].length) { return; }
					parts[pair[0]] = pair[1]; 
				});
				Object.extend(options, parts);
			}
			var href = el.href;
			if (!href.include('nopopup=')) {
				href += (href.include('?') ? '&' : '?') + 'nopopup=0';
			}
			
			return popup(href, options)
		});
	});
	
	// init highslide
	initHighslide();

}, false);
