﻿
// = = = = = = = = = = = = = = = = = = = = = = = = = = =
// XMLHELPER OBJECT
// = = = = = = = = = = = = = = = = = = = = = = = = = = =

var tXMLHelper = Class.create(); //IE sucks big time
tXMLHelper.prototype = {
			
	initialize: function( pXMLDocument ){
		this.xmldocument = pXMLDocument;
	},
	
	getFirstValue: function ( pTag ) {
		if (pTag.has('.')) 
		{
			var pTags = pTag.split('.');
			return(this.xmldocument.getElementsByTagName(pTags[0])[0].getAttribute(pTags[1]));
		}
		if ((this.xmldocument.getElementsByTagName(pTag)[0].firstChild) == null) return ''; //tag IS empty!
		return(this.xmldocument.getElementsByTagName(pTag)[0].firstChild.nodeValue);
	},
	
	getAll: function ( pTag ) { 
		//return(this.xmldocument.getElementsByTagName(pTag)[0].getElementsByTagName('*'));
	},
	
	nodeExists: function ( pTag ) {
		if (this.xmldocument.getElementsByTagName(pTag)[0] == undefined) return false
				else return true;
	},
	
	nodeToString: function ( pTag ) {
		var xmlNode = this.xmldocument.getElementsByTagName(pTag)[0];
		var text = '';
		if (xmlNode.text) text = xmlNode.text
				else text = xmlNode.textContent;
		if (text == undefined) text = '';
		return text; //#WARNING: modified after revision #69
	}
}


var tJsCallback = Class.create();
tJsCallback.prototype = {
	
	initialize: function(pFunc, pThisObj, pParams) {
	
		this.func = pFunc;
		if(pThisObj == undefined)
			pThisObj = null;
		if(pParams == undefined)
			pParams = new Array();
		this.thisObj = pThisObj;
		this.params = pParams;
	},
	
	invoke: function() {
		
		if(this.thisObj)
			this.func.apply(this.thisObj, this.params);
		else
			this.func.apply(null, this.params);
	}
}

