var mccann = {

	popups: {
		init: function () {
			var popupRegExp = new RegExp('\\bpopup\\d+x\\d+\\b');
			var links = document.getElementsByTagName('a');
			for (var i = (links.length - 1); i >= 0; i--) {
				if ( popupRegExp.test(links[i].className) || YAHOO.util.Dom.hasClass(links[i], 'popup') ) {
					links[i].onclick = mccann.popups.launch;
					links[i].title = 'Opens in a new window';
				}
			}
		},

		launch: function () {
			var popupRegExp = new RegExp('\\bpopup(\\d+)x(\\d+)\\b');
			var popupDimentions = popupRegExp.exec(this.className);

			if (popupDimentions && popupDimentions.length == 3) {
				var width = popupDimentions[1];
				var height = popupDimentions[2];
			} else {
				var width = 0;
				var height = 0;
			}

			if (width == 0 || height == 0) {
				var oWin = window.open (this.href);
			} else {
				var oWin = window.open (this.href, this.className.replace( ' ', '_' ), 'width=' + width + ', height=' + height + ', directories=no, menubar=no, resizable=yes, scrollbars=yes, status=yes, toolbar=no');
			}

			try {
				oWin.opener = self;
			} catch (e) {
			}
			if (oWin == null || typeof(oWin) == 'undefined') {
				return true;
			} else {
				oWin.focus();
				return false;
			}
		}
	}
}



window.onload = function ()
{
	mccann.popups.init();
}
