// GLOBAL VARIABLES

	var d = document;
	
// DOM FUNCTIONS

	var getElement = function(e)
	{
		return d.getElementById(e);
	}
	
// POPUP WINDOW FUNCTION

	var Popup = {
		open: function(domain, w, h, toggle)
		{
			//toggle = 0 = false > turn off scrollbar
			//toggle = 1 = true > turn on scrollbar
			
			this.options = {
			url: domain,
			width: w,
			height: h,
			left: screen.width / 2 - (w / 2),
			top: screen.height / 2 - (h / 2),
			scrollbars: toggle
			}
			
			window.open(this.options.url, '', 'location=yes, resizable=yes, width=' + this.options.width + ',height=' + this.options.height + ',scrollbars=' + this.options.scrollbars + ',left=' + this.options.left + ',top=' + this.options.top);
		}
	}	
	

// OPEN LINKS IN POPUP WINDOW (THIS REQUIRES THE ABOVE SCRIPT)

	function fnOpenWindow()
	{
		/* this function loops through all anchor elements and makes them open new windows dependant on whether that have a specific attribute */
		
		// first store all anchor elements in an array
			var a = d.getElementsByTagName('a');
		
		// loop through the array checking for the rel 'external'
			for(var i=0; i<a.length; i++)
			{
				if(a[i].getAttribute('rel') == 'external')
				{
					// specify the dimensions of the new window
						var width = screen.availWidth;
						var height = screen.availHeight;
						
					// add the event handlers for the anchor element	
						a[i].onclick = function() { Popup.open(this.href, width, height, 1); return false; };
				}
			}
	}

// ADD EVENT FUNCTION

	function fnAddEvent(obj, evType, fn, useCapture)
	{
		
		if (obj.addEventListener)
		// Gecko browsers (Mozilla / Firefox)
		{
			obj.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (obj.attachEvent)
		// Internet Explorer 5+
		{
			var r = obj.attachEvent('on' + evType, fn);
			return r;
		}
		else
		{
			// This sets the event handler for NS4 & IE5/Mac.
			elm['on' + evType] = fn;
		}
	
	}

// EVENT TRIGGERS

	fnAddEvent(window, 'load', fnOpenWindow);
	fnAddEvent(window, 'load', fnStripeTable);
	
// TRIGGERED FUNCTIONS

	function fnStripeTable()
	{
		/*
			This function adds striped row colours to the properties table
		*/
		
		if(getElement('properties') == null || getElement('properties') == 'undefined')
		{
			return false;
		}
		else
		{
			var storeTABLE = getElement('properties');
			var storeTR = storeTABLE.getElementsByTagName('TR');
			var state = 'even';
			
			for(i=1; i<storeTR.length; i++)
			{
				if(state == 'odd')
				{
					storeTR[i].style.backgroundColor = "#eeeeee";
					state = 'even';
				}
				else if(state == 'even')
				{
					storeTR[i].style.backgroundColor = "#FFFFFF";
					state = 'odd';
				}
			}
		}
	}