//--------------------------------------------------
// When the page has finnished
// loading, then add relevant JS
// for 'popup' links

	addLoadEvent (function() {
		if (document.getElementsByTagName) {

			//--------------------------------------------------
			// Declaire required variables

				var oWin;

			//--------------------------------------------------
			// Return a reference to all links
			// on the page

				var links = document.getElementsByTagName('a');
				var linksLength = links.length;

			//--------------------------------------------------
			// Loop through all links, and search
			// for any which use the 'popup' class,
			// then add an 'onClick' function.

				for (var i=0; i<linksLength; i++) {
					if (cssjs('check', links[i], 'mapLink')) {
						links[i].onclick = function () {

							//--------------------------------------------------
							// Try to open the window

								oWin = window.open (this.href, 'domMap', 'width=762, height=537, directories=no, menubar=no, resizable=yes, scrollbars=no, status=no, toolbar=no');

							//--------------------------------------------------
							// Create a reference for the popup
							// to access the opener window.

								oWin.opener = self;

							//--------------------------------------------------
							// If the popup was sucessfully
							// created, then return false (dont
							// 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;
								}

						}
					}
				}

		}
	});

