
	var popup = new function () {

		//--------------------------------------------------
		// Do not allow older browsers to run this script

			if (!document.getElementById || !document.getElementsByTagName) {
				return;
			}

		//--------------------------------------------------
		// Initialisation function used to define the global
		// variables used in this script

			this.init = function () {

				//--------------------------------------------------
				// Regular expression to test the class names

					var popupRegExp = new RegExp('\\bpopup((\\d+)x(\\d+))?\\b');

				//--------------------------------------------------
				// Loop through all links, and search for any which
				// use the 'popup' class, then add an 'onClick' event.

					var links = document.getElementsByTagName('a');

					for (var k = (links.length - 1); k >= 0; k--) {

						var popupInfo = popupRegExp.exec(links[k].className);

						if (popupInfo) {

							links[k].onclick = popup.launch;

							if (popupInfo[2] && popupInfo[3]) {
								links[k].jsPopupName = popupInfo[0];
								links[k].jsPopupWidth = popupInfo[2];
								links[k].jsPopupHeight = popupInfo[3];
							}

							if (links[k].title === '') {
								links[k].title = 'Opens in a new window';
							}

							cssjs('add', links[k], 'jsPopupActive');

						}

					}

			}

		//--------------------------------------------------
		// Function called when the link is used

			this.launch = function () {

				//--------------------------------------------------
				// Try to open the window

					if (this.jsPopupName && this.jsPopupWidth && this.jsPopupHeight) {
						var oWin = window.open(this.href, this.jsPopupName, 'width=' + this.jsPopupWidth + ', height=' + this.jsPopupHeight + ', directories=no, menubar=no, resizable=yes, scrollbars=yes, status=yes, toolbar=no');
					} else {
						var oWin = window.open(this.href);
					}

				//--------------------------------------------------
				// Create a reference for the pop-up to access the
				// opener window - the try is done for Opera 8, which
				// believes this assignment is a security issue.

					try {
						oWin.opener = self;
					} catch (e) {
					}

				//--------------------------------------------------
				// If the pop-up was successfully created, then return
				// false (don't use normal href link), otherwise
				// return true (so the browser links as normal).

					if (oWin == null || typeof(oWin) == 'undefined') {
						return true;
					} else {
						oWin.focus();
						return false;
					}

			}

		//--------------------------------------------------
		// When the page has loaded, run the init function

			addLoadEvent (function() {
				popup.init();
			});

	}

