var Popup = Class.create();
Popup.prototype = {
	initialize: function () {
		var popupLinks = $A(document.getElementsByTagName('a'));
		popupLinks.each(function(popupLink){
			if(popupLink.getAttribute('rel')){
				var relAttribute = String(popupLink.getAttribute('rel'));
				
				if(popupLink.getAttribute('href')&&(relAttribute.match('popup'))){
					popupLink.onclick=function(){
						var dims=this.getAttribute('rel').match(/.*\[([0-9]+)-([0-9]+)\].*/);
						window.open(this.getAttribute('href'),'popup','width='+dims[1]+',height='+dims[2]+',resizable,scrollbars');
						return false;
					}
				}
				else if(popupLink.getAttribute('href')&&(relAttribute.match('external'))){
					popupLink.onclick=function(){
						window.open(this.getAttribute('href'));
						return false;
					}
				}
			}
		});
	}
}

Event.observe(window, 'load', function(){
	new Popup();
}, false);
