function loadData(object, action, id) 
{
	Sys.AJAX.SendRequest(displayData, object, action, id);
}

function displayData(oResponse) 
{
	$(oResponse.target).innerHTML = oResponse.content;
}

function opacity(id, opacStart, opacEnd, millisec) 
{ 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) 
{ 
    var object = $(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    //object.filter = "alpha(opacity=" + opacity + ")"; 
}


//-------------------------------------------------------------------------------------

Object.extend = function(destination, source) 
{
  for (property in source) 
  {
    destination[property] = source[property];
  }
  return destination;
}

function oSys() {}
Object.extend(oSys.prototype, {
	AJAX: new oAJAX(),
	Popup: new oPopup,
	UserAgent: new oUserAgent
});

//-------------------------------------------------------------------------------------

function oAJAX() {}
Object.extend(oAJAX.prototype, {
	Version: '1.0',
	XMLHTTP_ActiveX: '',
	Method: 'GET',
	URL: '/AjaxRequest.ashx',
	Data: oXMLLoadDoc(),
	Async: true,
	DoSend: true,
	AddRequest: function(oRequest) {
		AdoptNode(this.Data.documentElement, oRequest);
	},
	SendRequest: function(process, object, action, id) {
		var self = this;
		
	    if (window.XMLHttpRequest) { // Not IE
			self.XMLHTTP = new XMLHttpRequest();
	    } 
		else if (window.ActiveXObject) { // IE!
	        if (this.XMLHTTP_ActiveX) {
	            self.XMLHTTP = new ActiveXObject(this.XMLHTTP_ActiveX);
	        } 
			else {
		    	var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
	
	            for (var i = 0; i < versions.length ; i++) {
	                try {
	                    self.XMLHTTP = new ActiveXObject(versions[i]);
	                    if (oXMLHTTP) {
	                        this.XMLHTTP_ActiveX = versions[i];
	                        break;
	                    }
	                }
	                catch (objException) {} ;
	            }
	        }
	    }
		
		// if no callback process is specified, then assing a default which executes the code returned by the server
	    if (typeof process == 'undefined' || process == null) process = executeReturn;
	    self.process = process;
	
	    // create an anonymous function to log state changes
	    self.XMLHTTP.onreadystatechange = function( ) {
		    if (self.XMLHTTP.readyState == 4) {
		        if (self.XMLHTTP.status == 200) {
					//debugWindow(self.XMLHTTP.responseText);
					oResponse = new oAJAXResponse(self.XMLHTTP, self.process);
				}	
				else {
					debugWindow(self.XMLHTTP.responseText);
				}
		    }
	    }
	
	    // if no method specified, then default to POST
	    if (!this.Method) this.Method = "POST";
	    this.Method = this.Method.toUpperCase();
	
	    if (typeof this.Async == 'undefined' || this.Async == null) this.Async = true;
	
	    self.XMLHTTP.open(this.Method, this.URL +"?class="+object+"&method="+action+"&params="+id, this.Async);
	
	    if (this.Method == "POST") {
	        self.XMLHTTP.setRequestHeader("Connection", "close");
	        self.XMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	        self.XMLHTTP.setRequestHeader("Method", "POST " + this.URL + "HTTP/1.1");
	    }
		
	    // if dosend is true or undefined, send the request
	    // only fails is dosend is false
	    // you'd do this to set special request headers
	    if ( this.DoSend == true || typeof this.DoSend == 'undefined' ) {
		    //if ( !data ) data = ""; 
		    self.XMLHTTP.send("request=" + sGetXMLValue(this.Data));
	    }
		
		this.Data = oXMLLoadDoc()
	    return self.XMLHTTP;
	}
});

function oAJAXResponse(oXMLHTTP, process) 
{
    if (oXMLHTTP.responseText) {
		//alert(oXMLHTTP.responseText);
		var oXMLDoc = oXMLLoadDoc(oXMLHTTP.responseText);
		var oXMLNodes = oXMLDoc.documentElement.selectNodes("response"); 
		for (nIndex=0; nIndex < oXMLNodes.length; nIndex++) 
		{
		    for (i=0; i < oXMLNodes[nIndex].childNodes.length; i++) 
		    {
	            this[oXMLNodes[nIndex].childNodes[i].nodeName] = sGetXMLValue(oXMLNodes[nIndex].childNodes[i].childNodes[0]);
			}
			process(this);
		}
	}
}

function oXMLLoadDoc(sXML) {
	if (isUndefined(sXML)) sXML = "<xml/>";
	if (window.ActiveXObject) {
		var oXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
		oXMLDoc.async = "false";
		oXMLDoc.loadXML(sXML);
	}
	else {
		var oParser = new DOMParser();
		var oXMLDoc = oParser.parseFromString(sXML, "text/xml");
	}
	return oXMLDoc;
}

function oXMLAddNode(oXMLParentNode, sName, sValue) {
	var oXMLNode = oXMLParentNode.ownerDocument.createElement(sName);
	if ((sValue != "" && !isUndefined(sValue)) || sValue == 0){
		var oXMLText = oXMLParentNode.ownerDocument.createCDATASection(sValue);
		oXMLNode.appendChild(oXMLText);
	}
	oXMLParentNode.appendChild(oXMLNode);
	return oXMLNode;
}

function oXMLNodeValue(oXMLNode, sName) {
	return oXMLNode.selectSingleNode(sName).childNodes[0].nodeValue;
}

function sGetXMLValue(oXMLNode) {
    try
    {
	    if (isUndefined(oXMLNode.xml))
		    return (new XMLSerializer()).serializeToString(oXMLNode);
	    else
		    return oXMLNode.xml;
	}
	catch(er)
	{
	    return oXMLNode.nodeValue;
	}
}

function AdoptNode(oXMLParent, oXMLChild)
{
	if (Sys.UserAgent.browser() != "Safari") {
		oXMLParent.appendChild(oXMLChild);
	}
	else {
		var oXMLNode = oXMLParent.ownerDocument.adoptNode(oXMLChild);
		oXMLParent.appendChild(oXMLNode);
	}	
}

function executeReturn(oXMLHTTP) {
	//document.write('AJAXRequest is complete: ' + oXMLHTTP.readyState + "/" + oXMLHTTP.status + "/" + oXMLHTTP.statusText);
    if (oXMLHTTP.responseText) {
	    alert(oXMLHTTP.responseText);
	    eval(oXMLHTTP.responseText);
    }
}

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
	    element = document.getElementById(element);

    if (arguments.length == 1)
    	return element;

    elements.push(element);
  }

  return elements;
}

function $f(sForm, sField) {
  return document.forms[sForm].elements[sField];
}


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if (node == null) node = document;
	if (tag == null) tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
	  	if (pattern.test(els[i].className) ) {
	    	classElements[j] = els[i];
	    	j++;
	  	}
	}
	return classElements;
}

function XMLFormValues(oXMLNode, sForm) {
    form = $(sForm);
    var field = "";
    var value = "";

    for (var i = 0; i < form.elements.length; i++) {
        var field = form.elements[i];

        if (!field.disabled) {
            if (field.type == 'select-one') {
                if (field.selectedIndex > -1) {
                    value = field.options[field.selectedIndex].value;
                }
            } else if (field.type == 'textarea') {
				if (!(typeof FCKeditorAPI == 'undefined')) {
					oFCK = FCKeditorAPI.GetInstance(field.id);
					if (!isUndefined(oFCK)) field.value = FCKeditorAPI.GetInstance(field.id).GetXHTML();
				}
                value = field.value;
            } else {
                value = field.value;
            }
			oXMLAddNode(oXMLNode, field.id, value.encode());
        }
    }
}

function getFormValues(sForm) {
    form = $(sForm);
    var field = "";
    var value = "";
    var valueString = "";

    for (var i = 0; i < form.elements.length; i++) {
        var field = form.elements[i];

        if (!field.disabled) {
            if (field.type == 'select-one') {
                if (field.selectedIndex > -1) {
                    value = field.options[field.selectedIndex].value;
                }
            } else if (field.type == 'textarea') {
				if (!(typeof FCKeditorAPI == 'undefined')) {
					oFCK = FCKeditorAPI.GetInstance(field.id);
					if (!isUndefined(oFCK)) field.value = FCKeditorAPI.GetInstance(field.id).GetXHTML();
				}
                value = field.value;
            } else {
                value = field.value;
            }
            valueString += ((i) ? ',' : '') + field.id.encode() + '=' + value.encode();
        }
    }

    return valueString
}

Object.extend(String.prototype, {
	encode: function() {
	    if (encodeURIComponent) {
	        return encodeURIComponent(this);
	    }
	    if (escape) {
	        return escape(this);
	    }
	},
	decode: function() {
	    this.replace(/\+/g, ' ');
	    if (decodeURIComponent) {
	        return decodeURIComponent(this);
	    }
	    if (unescape) {
	        return unescape(this);
	    }
	    return this;
	}
});

function isUndefined(vValue) {
    return typeof vValue == 'undefined';
}

function isNull(vValue) {
   	return typeof vValue == 'object' && !vValue;
}

function showItem(oItem) {
	oItem.style.position = "static";
	oItem.style.visibility = "visible";
}

function hideItem(oItem) {
	oItem.style.position = "absolute";
	oItem.style.visibility = "hidden";
}
var nCount =0;
function debugWindow(sText) {
   oElement = document.createElement("div");
   oElement.id = "debug" + nCount++;
   oElement.style.border = "1px red solid";
   oElement.style.backgroundColor = "white";
   oElement.style.color = "black";
   oElement.style.position = "absolute";
   oElement.style.left = "200px";
   oElement.style.top = "200px";
   oElement.style.width = "600px";
   oElement.style.padding = "10px";
   oElement.style.textAlign = "left";
   oElement.innerHTML = "<h3 style='color:red'>debug data</h3>";
   oElement.innerHTML += sText.replace(/</g,"&lt;"); 
   oElement.innerHTML += "<br><br><br><div onclick='document.body.removeChild($(" + oElement.id + "));' style='color:red; cursor:pointer;'>close</div>";
   document.body.appendChild(oElement);
}

function oPopup () {}
Object.extend(oPopup.prototype, {
	hWndIndex: 1,
	zIndex: 100,
	currentDragWindow: '', 
	mouseDown: false,
	dragOffsetX: 0,
	dragOffsetY: 0,
	windows: new Array(),
	window: function(sKey) {
		return this.windows[this.windowindex(sKey)];
	},
	windowindex: function(sKey) {
		for (nIndex=0;nIndex < this.windows.length;nIndex++) {
			if (this.windows[nIndex].key==sKey) return nIndex;
		}
	},
	open: function(sHTML) {
		popup = this;
		
		var oWindow = new Object;
		popup.windows.push(oWindow);
		
		oWindow.hWnd = popup.hWndIndex++;
		oWindow.key = "popup" + oWindow.hWnd;
		oWindow.title = 'loading...';
		oWindow.status = 'loading...';
		oWindow.x = 150 + 25 * oWindow.hWnd;
		oWindow.y = 50 + 25 * oWindow.hWnd;
		
		oWindow.element = document.createElement("div");
		oWindow.element.id = oWindow.key;
		oWindow.element.name = oWindow.key;
		oWindow.element.className = 'popup';
		
		oWindow.element.style.left = oWindow.x;
		oWindow.element.style.top = oWindow.y;
		oWindow.element.style.width = 500;
		oWindow.element.style.zIndex = popup.zIndex++;
		
		oWindow.element.titlebar = document.createElement("div");
		oWindow.element.titlebar.className = 'titlebar';
		oWindow.element.titlebar.innerHTML = popup.titlebar(oWindow.key, oWindow.title);
		oWindow.element.appendChild(oWindow.element.titlebar );
		
		oWindow.element.contentpanel = document.createElement("div");
		oWindow.element.contentpanel.className = 'content';
		oWindow.element.contentpanel.innerHTML = sHTML;
		oWindow.element.appendChild(oWindow.element.contentpanel );
		
		oWindow.element.statusbar = document.createElement("div");
		oWindow.element.statusbar.className = 'statusbar';
		oWindow.element.statusbar.innerHTML = popup.statusbar(oWindow.key, oWindow.status);
		oWindow.element.appendChild(oWindow.element.statusbar );		
		
		document.body.onmousedown = function(event) {popup.onMouseDown(event);}
		document.body.onmousemove = function(event) {popup.onMouseMove(event);}
		document.body.onmouseup = function(event) {popup.onMouseUp(event);}	
		
		oWindow.element.onclick = function(event) {popup.onClick(event, oWindow.key);}
		oWindow.element.ondblclick = function(event) {popup.onDblClick(event, oWindow.key);}
		oWindow.element.onmousedown = function(event) {popup.onMouseDownWindow(event, oWindow.key);}
		
		oWindow.element.onmouseover = function(event) {popup.onMouseOver(event, oWindow.key);}
		oWindow.element.onmouseout = function(event) {popup.onMouseOut(event, oWindow.key);}	
		
		oWindow.element.titlebar.onmouseover = function(event) {popup.onMouseOverTitle(event, oWindow.key);}
		oWindow.element.titlebar.onmouseout = function(event) {popup.onMouseOutTitle(event, oWindow.key);}

		this.updateWindows(oWindow.key);
		
		document.body.appendChild(oWindow.element);
		
		$('display').innerText = popup.windows.length;
		return oWindow.key;
	},
	close: function(sKey) {
		document.body.removeChild(this.window(sKey).element);
		this.windows.splice(this.windowindex(sKey),1);
		this.currentDragWindow = "";
		this.updateWindows(this.getTopWindow());
		$('display').innerText = this.windows.length;
	},
	updateWindows: function(sKey) {
		for (nIndex=0;nIndex < this.windows.length;nIndex++) {
			if (this.windows[nIndex].key==sKey) 
				this.windows[nIndex].element.titlebar.className = 'titlebar';
			else
				this.windows[nIndex].element.titlebar.className = 'titlebarinactive';
			
		}
	},
	getTopWindow: function() {
		sKey = '';
		nZIndex = -1;
		for (nIndex=0;nIndex < this.windows.length;nIndex++) {
			if (this.windows[nIndex].element.style.zIndex > nZIndex) {
				nZIndex = this.windows[nIndex].element.style.zIndex;
				sKey = this.windows[nIndex].key;
			}
		}
		return sKey;
	},
	titlebar: function(sKey, sTitle) {
		popup = this;
		return "<div class='icon'><img src='/images/file.gif' alt='minimize' width='16' height='16' border='0'></div>"
			 + "<div class='buttons'>"
			 + "<a onClick='popup.close(\""+sKey+"\");' style='cursor:pointer;'><img src='/images/btnMinimize.gif' alt='minimize' width='16' height='14' border='0'></a>"
			 + "<a onClick='popup.close(\""+sKey+"\");' style='cursor:pointer;'><img src='/images/btnMaximize.gif' alt='Maximize' width='16' height='14' border='0'></a>"
			 + "<a onClick='popup.close(\""+sKey+"\");' style='cursor:pointer;'><img src='/images/btnClose.gif' alt='close' width='16' height='14' border='0'></a>"
			 + "</div>"
			 + sTitle;
	},
	statusbar: function(sKey, sStatus) {
		popup = this;
		return "<div id='resize' class='resize'>"
			 + "<a onClick='popup.close(\""+sKey+"\");' style='cursor:nw-resize;'>"
			 + "<img src='/images/btnDragCorner.gif' alt='drag to resize' width='16' height='16' border='0'>"
			 + "</a>"
			 + "</div>"
			 + sStatus;
	},
	setTitle: function(sKey, sTitle) {
		if (!isUndefined(this.window(sKey))) this.window(sKey).element.titlebar.innerHTML = this.titlebar(sKey, sTitle);
	},
	setContent: function(sKey, sHTML) {
		if (!isUndefined(this.window(sKey))) this.window(sKey).element.contentpanel.innerHTML = sHTML;
	},
	setStatus: function(sKey, sStatus) {
		if (!isUndefined(this.window(sKey))) this.window(sKey).element.statusbar.innerHTML = this.statusbar(sKey, sStatus);
	},
	setCursor: function(sKey, sCursor) {
		if (!isUndefined(this.window(sKey))) this.window(sKey).element.style.cursor = sCursor;
	},
	onClick: function(event, sKey) {
		this.setStatus(sKey, 'onClick');
	},
	onDblClick: function(event, sKey) {
		this.setStatus(sKey, 'onDblClick');
	},
	onMouseOver: function(event, sKey) {
		this.setStatus(sKey, 'onMouseOver');
	},
	onMouseOut: function(event, sKey) {
		if (!this.mouseDown) {
			this.mouseDown = false;
			this.currentDragWindow = "";
			this.setCursor(sKey, 'default');
			this.setStatus(sKey, 'onMouseOut');
		}
	},
	onMouseOverTitle: function(event, sKey) {
		if (this.currentDragWindow == "") this.currentDragWindow = sKey;
		this.setStatus(sKey, 'onMouseOver');
	},
	onMouseOutTitle: function(event, sKey) {
		if (!this.mouseDown) {
			this.currentDragWindow = "";
			this.setStatus(sKey, 'onMouseOut');
		}
	},
	onMouseDownWindow: function(event, sKey) {
		this.window(sKey).element.style.zIndex = this.zIndex++;
		this.updateWindows(sKey);
		this.setStatus(sKey, 'onMouseDown');
	},
	onMouseDown: function(event) {
		if (this.currentDragWindow) {
			this.mouseDown = true;	
			var IE = document.all?true:false;
			if (IE) {
				this.dragOffsetX = window.event.x - parseInt(this.window(this.currentDragWindow).element.style.left);
				this.dragOffsetY = window.event.y - parseInt(this.window(this.currentDragWindow).element.style.top);
			}
			else {
				this.dragOffsetX = event.pageX - parseInt(this.window(this.currentDragWindow).element.style.left);
				this.dragOffsetY = event.pageY - parseInt(this.window(this.currentDragWindow).element.style.top);
			}
			this.window(this.currentDragWindow).element.style.zIndex = this.zIndex++;
			this.setStatus(this.currentDragWindow, 'onMouseDown');
		}
	},
	onMouseMove: function(event) {
		if (this.currentDragWindow) {
			if (this.mouseDown) {
				var IE = document.all?true:false;
				this.setCursor(this.currentDragWindow, 'move');
				if (IE) {
					if (window.event.x > 0) this.window(this.currentDragWindow).element.style.left = window.event.x - this.dragOffsetX;
		   			if (window.event.y > 0) this.window(this.currentDragWindow).element.style.top = window.event.y - this.dragOffsetY;
				}
				else {
					if (event.pageX > 0) this.window(this.currentDragWindow).element.style.left = event.pageX - this.dragOffsetX;
		   			if (event.pageY > 0) this.window(this.currentDragWindow).element.style.top = event.pageY - this.dragOffsetY;
				}
			}
			this.setStatus(sKey, 'onMouseMove');
		}
	},
	onMouseUp: function(event) {
		if (this.currentDragWindow) {
			this.setCursor(this.currentDragWindow, 'default');
			this.setStatus(this.currentDragWindow, 'onMouseUp');
			this.mouseDown = false;
		}
	}
});


/*-------------------------------------------------------------------------------------------*/
//	oUserAgent: browser detection object
/*-------------------------------------------------------------------------------------------*/
function oUserAgent() {}
Object.extend(oUserAgent.prototype, {
	browser: function() {
		return this.searchString(this.dataBrowser) || "An unknown browser";
	},
	version: function() {
		return this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
	},
	OS: function() {
		return this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
});



function rgb2Hex(rgbColour) {
	if (rgbColour.substring(0,3) == "rgb") {
		
	    var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")"));
	    var rgbArray = rgbValues.split(", ");
	
	    var red   = parseInt(rgbArray[0]);
	    var green = parseInt(rgbArray[1]);
	    var blue  = parseInt(rgbArray[2]);
	    var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);
		return hexColour;
	}
	else {
    	return rgbColour;
	}
}

// Converts a number to hexadecimal format
function IntToHex(strNum) {
	base = strNum / 16;
	rem = strNum % 16;
	base = base - (rem / 16);
	baseS = MakeHex(base);
	remS = MakeHex(rem);
	return baseS + '' + remS;
}

// gets the hex bits of a number
function MakeHex(x) {
	if((x >= 0) && (x <= 9)) {
		return x;
	}
	else {
		switch(x) {
			case 10: return "A";
		  	case 11: return "B";
		  	case 12: return "C";
		  	case 13: return "D";
		  	case 14: return "E";
		  	case 15: return "F";
		}
	}
}


if( document.implementation.hasFeature("XPath", "3.0") ){
	if ( typeof XMLDocument == "undefined" ) { XMLDocument = Document; }
	XMLDocument.prototype.selectNodes = function(cXPathString, xNode) {
    if ( !xNode ) {xNode = this;} 
		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for ( var i = 0; i < aItems.snapshotLength; i++) {aResult[i] =  aItems.snapshotItem(i); }
		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode){
		if ( !xNode ) { xNode = this; } 
		var xItems = this.selectNodes(cXPathString, xNode);
		if ( xItems.length > 0 ) {return xItems[0];	}
		else {return null;}
	}
	Element.prototype.selectNodes = function(cXPathString){
		if (this.ownerDocument.selectNodes) {return this.ownerDocument.selectNodes(cXPathString, this);}
		else {throw "For XML Elements Only";}
	}
	Element.prototype.selectSingleNode = function(cXPathString){	
		if (this.ownerDocument.selectSingleNode) {return this.ownerDocument.selectSingleNode(cXPathString, this);	}
		else {throw "For XML Elements Only";}
	}
	Element.prototype.text = function() {return this.childNodes[0].nodeValue};
}



Sys = new oSys();
