All pastes #772274 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-13 18:10 UTC
rendered paste body
var MainScopePlus = this;

var STATUS_UNKNOWN = 0;
var STATUS_OFFLINE = 1;
var STATUS_APPEAROFFLINE = 2;
var STATUS_ONLINE = 3;
var STATUS_BUSY = 4;
var STATUS_BRB = 5;
var STATUS_IDLE = 6;
var STATUS_AWAY = 7;
var STATUS_ONPHONE = 8;
var STATUS_OUTLUNCH = 9;


var EVENTICON_ONLINE = 0;
var EVENTICON_OFFLINE = 1;
var EVENTICON_AWAY = 2;
var EVENTICON_BUSY = 3;
var EVENTICON_BLOCKED = 4;
var EVENTICON_PLUS = 5;
var EVENTICON_NAMECHANGE = 6;
var EVENTICON_PSMCHANGE = 7;
var EVENTICON_MEDIACHANGE = 8;
var EVENTICON_EMAIL = 9;
var EVENTICON_MUSICCHANGE = 10;


var MESSAGEKIND_UNKNOWN = 0;
var MESSAGEKIND_SAYS = 1;
var MESSAGEKIND_WINKS = 2;
var MESSAGEKIND_VOICECLIPS = 3;
var MESSAGEKIND_SEARCHING = 4;
var MESSAGEKIND_FIND = 5;
var MESSAGEKIND_SAYSOFFLINE = 6;


var CREATEWNDOPT_NORMAL = 0;
var CREATEWNDOPT_INVISIBLE = 1;
var CREATEWNDOPT_DONTACTIVATE = 2;

var WNDEXITCODE_OK = 1;
var WNDEXITCODE_CANCEL = 2;
var WNDEXITCODE_ABORT = 3;
var WNDEXITCODE_RETRY = 4;
var WNDEXITCODE_IGNORE = 5;
var WNDEXITCODE_YES = 6;
var WNDEXITCODE_NO = 7;




var Class = {
	'create' : function(){return function(){this.__construct.apply(this,arguments)}},
	'extend' : function(array1,array2){ for(var x in array2){array1[x] = array2[x]; } return array1;},
	'mergeArray' : function(array1,array2){for(var i=0;i < array2.length;i++){array1[array1.length] = array2[i];}return array1;}
	}

function $A(ar){
		var newvar = [];

		for(var i=0;i<ar.length;i++){
			newvar[newvar.length] = ar[i];
			}
			
		return newvar;
}
	
//orginal typeof doesnt return information about Arrays , Regexp , Date or any Object.	
function TypeOf2(thing){

	
	if(thing){
		if(thing.constructor){
			switch(thing.constructor){
				case Array : return 'Array';
				case RegExp : return 'RegExp';
				case Date : return 'Date';
			}
		
		}
	}
		return typeof(thing);
}    


Class.extend(Array.prototype , {
	'foreach' : function(func){if(this.length !=0){for(var i=0;i<this.length;i++){if(func(this[i],i))break;}}else{for(var x in this){if(func(this[x]))break;}}},

	
	'diff' : function (ar2){

	this.foreach(function(item,num){

		for(var i=0;i<ar2.length;i++){
			try{
				if(item == ar2[i]){
				ar2[i] = false;
				}
			}
			catch(e){
				if(item === ar2[i]){
				ar2[i] = false;
				}
			}
		}		
	}.bind(this));
	var diffs = Array();
	ar2.foreach(function(item,num){

			if(item){
				diffs[diffs.length] = item;
			}
			
	}.bind(this));
	return diffs;
}

})



Class.extend(String.prototype, {
	'preg_quote' : function () {
    //makes the string safe to use in regular expression search
    str = this.replace(/([\[\]\|\)\(\*\?\+\.])/g, '\\$1');
    return str;
	},
  	"trim" : function(){
		var s = this.replace(/^([ ]+)/,'');
		s = s.replace(/([ ]+)$/,'');
		return s;
	},
	"toBBCode" : function(){
		return this.replace(/(\<([BISU])\>(.*?)\<\/\2\>)/ig,"[$2]$3[/$2]");
	},
	
	"replaceAll" : function(search,replace){
		var s = this;
		if(TypeOf2(search) =='Array' && TypeOf2(replace)=='Array'){
			for(var i=0;i<search.length;i++){
				s = s.replace(new RegExp(search[i].preg_quote(),'g'),replace[i]);
			}
		
		}
		return s;
	},
	
	//function by Mitch (Chestah)
	"entityReplace" : function(){
		var words = ['&quot;', '&amp;', '&lt;', '&gt;', '&#39;', '&OElig;', '&oelig;', '&Scaron;', '&scaron;', '&Yuml;', '&circ;', '&tilde;', '&ndash;', '&mdash;', '&lsquo;', '&rsquo;', '&sbquo;', '&ldquo;', '&rdquo;', '&bdquo;', '&dagger;', '&Dagger;', '&permil;', '&lsaquo;', '&rsaquo;', '&euro;' ];
		var replace = ['\"', '&', '<', '>', '\'', 'Œ', 'œ', 'Š', 'š', 'Ÿ', 'ˆ', '˜', '–', '—', '‘', '’', '‚', '“', '”', '„', '†', '‡', '‰', '‹', '›', '€' ];
		
		return this.replaceAll(words,replace);
	}
	


}
);


// renamed base64Decode function from http://www.hw-group.com/support/tea/index_en.html#BASE64
function atob(str){
	var result = "";
	var i = 0;
	var x = 0;
	var y = 0;
	var z = 0;
	var count = -1;
	for (i=0; i < str.length; i++) {
		c = str.charAt(i);
		if ('A' <= c && c <= 'Z') x = str.charCodeAt(i) - 65; // 65 = 'A'
		else if ('a' <= c && c <= 'z') x = str.charCodeAt(i) - 97 + 26; // 97 = 'a'
		else if ('0' <= c && c <= '9') x = str.charCodeAt(i) - 48 + 52; // 48 = '0'
		else if (c == '+') x = 62;
		else if (c == '/') x = 63;
		else continue;
		count++;
		switch (count % 4) {
			case 0:
				y = x;
				continue;
			case 1:
				z = (y << 2) | (x >> 4);
				y = x & 0x0F;
				break;
			case 2:
				z = (y << 4) | (x >> 2);
				y = x & 0x03;
				break;
			case 3:
				z = (y << 6) | x;
				y = 0;
				break;
		}
		result = result + String.fromCharCode(z);
	}
	return result.toString();
}


Function.prototype.bind = function(){

  var __method = this;
  var object = arguments[0];
  return function() {return __method.apply(object, arguments);}
}


/*
var BoundArray = Array(); 
Function.prototype.bind = function(){
	BoundArray[BoundArray.length] = [this, arguments[0]];
	var num = BoundArray.length -1;
	return new Function('','BoundArray['+num+'][0].apply(BoundArray['+num+'][1],$A(arguments));');
}
*/

//AJAX class
var Ajax = Class.create();



Ajax.prototype = {

	"options" : {
				'method' : 'GET',
				'data':'',
				"timeout" : 0,
				'onComplete':function(){} ,
				'onError' : function(){},
				'onTimeout' : function(){},
				'contentType' : false
				},


	"__construct" : function(url,options){
		this.options = Class.extend(this.options , options);
		

		
		var onComplete = this.options.onComplete;
		var onError = this.options.onError;
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

		xmlhttp.open(this.options.method, url, true);
		
		if(this.options.method=='POST' && !this.options.contentType){
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		}
		
		if(this.options.contentType){
			xmlhttp.setRequestHeader('Content-Type', this.options.contentType);
		}
		
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4) {
				if(xmlhttp.status == 200){
				onComplete(xmlhttp.responseText,xmlhttp);
			}else{
				//Debug.Trace(xmlhttp.status);
				onError(xmlhttp);
			}
		}
				
	};
		
		
		//if(this.options.timeout > 0)this.startTimer();
		//Debug.Trace(this.options.data);
		xmlhttp.send(this.options.data);	
		
	},
	
	

	
	"startTimer" : function(){
		this.timer = new Timer(this.options.onTimeout,this.options.timeout);
	},
	
	"stopTimer" : function(){
		if(this.timer)
			this.timer.cancel();
	}


}





//FILE class
var File = Class.create();

File.prototype = {
	
	'options' : {},

	"__construct" : function(){
		this.object =  new ActiveXObject("Scripting.FileSystemObject");	
	
	},

	'getContents' : function(file){
		var fO = this.getFileHandle(file);
		var text = fO.ReadAll();
		fO.close();
		return text;
	},
	
	'normalizePath' : function(path){
		return path.replace(/\\/g,'\\\\');
	},
	
	'fileExists' : function(file){
		if(this.object.FileExists(this.normalizePath(file))){
			return true;
		}else{
			return false;
		}
	
	},
	
	'putContents' : function(file,data){
		var fileO =  this.getFileHandle(file,2);
		fileO.Write(data);
		fileO.close();
	},
	
	'appendData' : function(file,data){
		var fO = this.getFileHandle(file,8);
		fO.Write(data);
		fO.close();
	},


	'unlink' : function(file){
		var fO = this.getFileHandle(file);
		fO.Delete(); 
		fO.close();
	},
	
	'move' : function(file,to){
		var fO = this.getFileHandle(file);
		fO.Move(this.normalizePath(to));
		fO.close();
	},
	
	'copy' : function(file,to){
		var fO = this.getFileHandle(file);
		fO.Copy(this.normalizePath(to));
		fO.close();
	},
	
	"folderExists" : function(folder){
		return this.object.FolderExists(this.normalizePath(folder));
	},
	
	"createFolder" : function(folder){
		if(!this.folderExists(folder)){
			return this.object.CreateFolder(this.normalizePath(folder));
		}else{
			return false;
		}
	},

	'getFileHandle' : function(file,type){
		var type = (typeof(type)=='undefined') ? 1 : type;
		if(this.fileExists(file)){
			return this.object.OpenTextFile(this.normalizePath(file), type, 0);
		}else{
			return this.object.CreateTextFile(this.normalizePath(file), true);
		}
	}

	

}




//TIMER
var Timer = Class.create();
var RegisteredTimers = Array('') ;
Timer.prototype = {
	"options" : {},
	
	"__construct" : function(func,time,id){
		this.options.func = func;
		this.options.time = time;
		this.register(id);

		
	},
	
	"register" : function(id){
		
		if(!id){

			id = RegisteredTimers.length;
			//RegisteredTimers.foreach(function(value,num){if(value==this.options.func){id=num;return true;};return false;}.bind(this))
			
			
			
		}
		
		this.id = id;
		RegisteredTimers[id] = this.options.func;
		MsgPlus.AddTimer(id,this.options.time);
	},
	
	"cancel" : function(){
		MsgPlus.CancelTimer(this.id);
	}

}

Timer.interval = Class.create();

Timer.interval.prototype = {
	"__construct" : function(func,time){
		this.func = func;
		this.time = time;
		this.id = RegisteredTimers.length;
		this.register();

	},
	
	"register" : function(){
		this.timer = new Timer(this.reapplytimer.bind(this),this.time,this.id);
	},
	
	"cancel" : function(){
		MsgPlus.CancelTimer(this.id);
	},
	
	"reapplytimer" : function(){
		this.func();
		this.timer ='';
		this.register();	

		
	}



}




function OnEvent_Timer(sTimerId){
	if(RegisteredTimers[sTimerId]){
		
		
		RegisteredTimers[sTimerId]();

	//clean our RegisteredTimers array...
	//RegisteredTimers.splice(sTimerId,1);


	}

}

//these wrappers are to keep shawnz happy :P
function setTimeout(func,time){
	return new Timer(func,time);
}

function setInterval(func,time){
	return new Timer.interval(func,time);
}

function clearTimeout(timer){
	if(timer.cancel)timer.cancel();
}

function clearInterval(timer){
	if(timer.cancel)timer.cancel();
}



// EVENT LISTENER


var EventListenerEvents = {
	'OnEvent_Initialize' : Array(),
	'OnEvent_Uninitialize' : Array(),
	'OnEvent_Signin' : Array(),
	'OnEvent_Signout' : Array(),
	'OnEvent_MyStatusChange' : Array(),
	'OnEvent_MyNameChange' : Array(),
	'OnEvent_MyPsmChange' : Array(),
	'OnEvent_MyMediaChange' : Array(),
	'OnEvent_ContactSignin' : Array(),
	'OnEvent_ContactStatusChange' : Array(),
	'OnEvent_ContactNameChange' : Array(),
	'OnEvent_ContactPsmChange' : Array(),
	'OnEvent_ContactMediaChange' : Array(),
	'OnEvent_ContactBlocked' : Array(),
	'OnEvent_ContactUnblocked' : Array(),
	'OnEvent_MessengerLocked' : Array(),
	'OnEvent_MessengerUnlocked' : Array(),
	'OnEvent_ChatWndCreated' : Array(),
	'OnEvent_ContactListWndCreated' : Array(),
	'OnEvent_ContactListWndDestroyed' : Array(),
	'OnEvent_ChatWndSendMessage' : Array(),
	'OnEvent_ChatWndReceiveMessage' : Array(),
	'OnEvent_ChatWndCreated' : Array(),
	'OnEvent_ChatWndDestroyed' : Array(),
	'OnEvent_ChatWndContactAdded' : Array(),
	'OnEvent_ChatWndContactRemoved' : Array()
}


AddEventListener = Class.create();




AddEventListener.prototype = {
	'event' : '',
	'__construct' : function(type,func){
		//plus event
		if(EventListenerEvents['OnEvent_'+type]){
			
			this.event = 'OnEvent_'+type;
			
			if(EventListenerEvents[this.event].length==0){
				this.createEventFunc();
			}

		EventListenerEvents[this.event][EventListenerEvents[this.event].length] = func;
		
		}else{
			//non plus event
			this.event = type;
			
			if(!EventListenerEvents[this.event])EventListenerEvents[this.event] = Array();
			EventListenerEvents[this.event][EventListenerEvents[this.event].length] = func;

		}
		
	
	}, 
	
	"createEventFunc" : function(){
		//create the function
	//	Debug.Trace('plus function' + this.event +' hooked');
		
		
		var bindedEvent = this.binded.bind(this);
		MainScopePlus[this.event] = bindedEvent;
		
	},

	'binded' : function(){
		var x = new CallEventListener(this.event,true);
		
		return x.call.apply(this,arguments);
	}

}

CallEventListener = Class.create();

CallEventListener.prototype = {
	
	
	'__construct' : function(event,wait){

		this.event = event;

		var args = $A(arguments);
		
		args.shift();
		args.shift();
		if(!wait)return this.call.apply(this,args);	
	},
	
	"call" : function(){
	//	Debug.Trace(this.event);
	//	Debug.Trace(EventListenerEvents[this.event].length);
		if(EventListenerEvents[this.event]){
			var args = $A(arguments);

			for(var i=0;i<EventListenerEvents[this.event].length;i++){
				 EventListenerEvents[this.event][i].apply(this,args);
				
			}
			
		}
	}
	

}





//Command

var Command = Class.create();


Command.prototype = {

	"commands" : {},
	"__construct" : function(){

		var x = this.bound.bind(this);
		this.event = new AddEventListener('ChatWndSendMessage',x);
	},
	
	"add" : function(name,func){
		this.commands[name] = func;
	},

	
	"bound" : function(chatWnd,message){

		for(x in this.commands){

				var regexp = new RegExp('^'+ x.preg_quote()+'( .+|)$','i');

				var m = message.match(regexp);
				if(m){
					var params = m[1].substr(1);
					chatWnd.editText = this.commands[x].apply(this,arguments);
					break;
				}
		
		}
	
	}
	

}


var RemoteCommand = Class.create();


RemoteCommand.prototype = {

	"commands" : {},
	"__construct" : function(){

		var x = this.bound.bind(this);
		this.event = new AddEventListener('ChatWndReceiveMessage',x);
	},
	
	"add" : function(name,func){
		this.commands[name] = func;
	},
	
	
	"bound" : function(chatWnd,sOrgin,message,kind){

		for(x in this.commands){

				var regexp = new RegExp('^'+ x.preg_quote()+'( .+|)$','i');
				
				var m = message.match(regexp);
				
				if(m){
					var params = m[1].substr(1);
					this.commands[x].apply(this,arguments);
					break;
				}
		
		}
	
	}
	

}

var PrefStore = Class.create();

PrefStore.prototype = {
	"__construct" : function(filename){
		this.file = new File();
		this.filename = MsgPlus.ScriptFilesPath + '/' + filename + '.xml';
		this.xml = new ActiveXObject("Microsoft.XMLDOM");
		this.xml.async=false;
		
		if(!this.file.fileExists(this.filename)){
			this.createFile();
		}else{
			this.loadXML();
		}
		
	},
	
	"createFile" : function(){
		var topNode = this.xml.createElement('prefs');
		this.xml.appendChild(topNode);
		this.save();	
	},
	
	"loadXML" : function(){
		this.xml.loadXML(this.file.getContents(this.filename));
	},
	
	"save" : function(){
		this.xml.save(this.filename);
	},
	
	"set" : function(path,data){
		//path = String(path).toLowerCase( );
		path = path.split('/');
		


		var lastNode = this.xml.getElementsByTagName('prefs')[0];

		for(var i=0;i<path.length;i++){
			
			var node = lastNode.selectNodes('pref[@name="'+path[i]+'"]');
			if(node.length != 0){
				lastNode = node[0];
			}else{
				var node = this.xml.createElement('pref');
				node.setAttribute('name',path[i]);
				lastNode.appendChild(node);
				lastNode = node;
			}
			
		}
		var text = this.xml.createTextNode(data);
		var textNodeF = this.getFirstTextNode(lastNode);
		if(textNodeF){
			lastNode.replaceChild(text,textNodeF);
		}else{
			lastNode.appendChild(text);
		}
		
	
	},
	
	"get" : function(path){
		
		
		var xpath = 'prefs/' + this.pathToXpath(path);
		
	
		var element = this.xml.selectNodes(xpath);
		
		if(element.length != 0){
			var text = this.getFirstTextNode(element[0]);
			if(text){
				return text.text;
			}
		
		}
		return -1;

	},
	
	"getAsArray" : function(path){
		var xpath = 'prefs/' + this.pathToXpath(path) + '/*';
		
		var returns = {};
		
		var elements =  this.xml.selectNodes(xpath);
		
		if(elements.length==0){
			Debug.Trace('fat zero');
			return returns;
		}
		
		var array = Array();
		for(var i=0;i<elements.length;i++){
			if(elements[i].nodeType == 1)
				array = this.getAsArrayAddNode(elements[i],array);
		}
		return array;
	},
	
	"getAsArrayAddNode" : function(node,array){
	
		if(node.childNodes.length==1){
			array[node.getAttribute("name")] = this.getFirstTextNode(node).text;
		}else if(node.childNodes.length==0){
			array[node.getAttribute("name")] = '';
		}else{
			//more than one child...
			array[node.getAttribute("name")] = {};
			
			for(var i=0;i<node.childNodes.length;i++){
				if(node.childNodes[i].nodeType == 1)
					array[node.getAttribute("name")] = this.getAsArrayAddNode(node.childNodes[i],array[node.getAttribute("name")]);
			}
			
			
			
		}
	
		return array;
	},
	
	"pathToXpath" : function(path){
		var parts = path.split('/');
		var xpath = '';
		for(var i=0;i<parts.length;i++){
			xpath += "pref[@name='"+parts[i]+"']/";
		}
		
		return xpath.substring(0,xpath.length-1);
	},
	
	"getFirstTextNode" : function(element){
		if(element.hasChildNodes){
			for(var i=0;i<element.childNodes.length;i++){
				if(element.childNodes[i].nodeType == 3){
					return element.childNodes[i];
				}
			}
		}

		return false;
	}




}




var SoapRequest = Class.create();


SoapRequest.prototype = {

	"__construct" : function(url){
		this.url = url;
		this.xmlP =  new ActiveXObject("Microsoft.XMLDOM");
		this.xmlP.async=false;

		//create the basic SOAP packet.

		this.doc = this.xmlP.createElement("SOAP-ENV:Envelope");
		this.doc.setAttribute("xmlns:SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/");
		this.doc.setAttribute("xmlns:xsi","http://www.w3.org/1999/XMLSchema-instance");
		this.doc.setAttribute("xmlns:xsd","http://www.w3.org/1999/XMLSchema");
		
		this.xmlP.appendChild(this.doc);
		this.body = this.xmlP.createElement("SOAP-ENV:Body");
		this.doc.appendChild(this.body);
		
		
	
	},
	
	"call" : function(name,parameters,ns,onComplete){
		this.onComplete = onComplete;

		var reqBody = this.xmlP.createElement("ns1:" + name);
		reqBody.setAttribute('xmlns:ns1',ns);
		reqBody.setAttribute('SOAP-ENV:encodingStyle','http://schemas.xmlsoap.org/soap/encoding/');
		
		for(name in parameters){
			reqBody.appendChild(this.createNodeAndSetType(name,parameters[name]));
		}
		
		this.body.appendChild(reqBody);
	
		
		var d =  this.doc.xml; 
		
		new Ajax(this.url,{'method':'POST','data':d,'onComplete':this.parseCallback.bind(this),"onError":function(x){Debug.Trace('error'+x.status)},"contentType":"text/xml"});
		
	},
	
	"createNodeAndSetType" : function(name,value){
	
		var type = TypeOf2(value);

		if(type != "Array"){
			var node = this.xmlP.createElement(name);
			node.appendChild(this.xmlP.createTextNode(value));
			switch(TypeOf2(value)){
				case "string" : node.setAttribute('xsi:type','xsd:string');break;
				case "number" : node.setAttribute('xsi:type','xsd:int');break;
				case "boolean" : node.setAttribute('xsi:type','xsd:boolean');break;
			}
		
	
		} else{
			//do array stuff...
		}
	
	
		return node;
	},
	
	"parseCallback" : function(data){
		if(data == '') return;
		this.xmlP.loadXML(data);
		
		var bodyNode = this.xmlP.getElementsByTagName('SOAP-ENV:Body')[0];
		bodyNode = bodyNode.childNodes[0];
		
		if(bodyNode.childNodes[0].childNodes.length > 1){
			bodyNode = bodyNode.childNodes[0];
		}


		this.returnArray = Array();
		if(bodyNode.hasChildNodes){

			for(var i=0;i<bodyNode.childNodes.length;i++){
				if(bodyNode.childNodes[i].nodeType == 1){
					//Debug.Trace("LOOP->"+bodyNode.childNodes[i].tagName + '->'+bodyNode.childNodes[i].childNodes.length);
					this.returnArray = this.parseNode(bodyNode.childNodes[i],this.returnArray);
				}
			
			}
		
			
		
		}
		
		if(this.returnArray['return']){
			this.returnArray = this.returnArray['return'];
		}


		this.onComplete(this.returnArray);
		
	},
	
	"parseNode" : function(node,array,inArray){
		

		if(node.getAttribute('xsi:type').match('Array')){
			//Debug.trace('IsArray');
			array[node.tagName] = new Array();
			for(var i=0;i<node.childNodes.length;i++){
				array[node.tagName][i] = Array();
				if(node.childNodes[i].nodeType == 1){
			//		Debug.Trace("SUBLOOP->"+node.childNodes[i].tagName + '->'+node.childNodes[i].childNodes.length);
					array[node.tagName][i] = this.parseNode(node.childNodes[i],array[node.tagName][i]);
				}
			
			}
		
		
		}else{
			
			if(node.childNodes.length > 1){
			

			
			for(var i=0;i<node.childNodes.length;i++){
				if(node.childNodes[i].nodeType == 1){
				//	Debug.Trace("SUBSUBLOOP->"+node.childNodes[i].tagName + '->'+node.childNodes[i].childNodes.length);
					
					if(node.childNodes[i].childNodes.length == 1){
						var d = node.childNodes[i].childNodes[0].text;
						array[node.childNodes[i].tagName] = d;
					
					}else if(node.childNodes[i].childNodes.length ==0){
						array[node.childNodes[i].tagName] = '';
					}else{
					//	Debug.Trace('->->lower->->' + node.childNodes[i].childNodes.length);
						array[node.childNodes[i].tagName] = Array();
						for(var x=0;x<node.childNodes[i].childNodes.length;x++){
					//		Debug.Trace("->->->"+node.childNodes[i].childNodes[x].tagName)
							array[node.childNodes[i].tagName] = this.parseNode(node.childNodes[i].childNodes[x],array[node.childNodes[i].tagName]);
						}
					}
					
				}
			
			}
						
			
			}else{
			
			if(node.childNodes.length <= 1){
					
					if(node.getAttribute('xsi:type').match('base64')){
						var text = atob(node.text);
					}else{
						var text = node.text;
					}
					if(!inArray){
						
						array[node.tagName] = text;
					}else{
						array[array.length] = text
					}
				}else{
				//	Debug.Trace('lower in l');
				}
		
			}
		}



		return array;
	}
	



}



// example to search google with the above class.
/*
var parameters = {
            "key"         : "",
            "q"           : "porn",
            "start"       : 0,
            "maxResults"  : 3,
            "filter"      : false,
            "restrict"    : "",
            "safeSearch"  : false,
            "lr"          : "lang_en", 
            "ie"          : "",
            "oe"          : ""
 };


var testSoap = function(xxx){
	Debug.Trace('x');
}

var soapClient = new SoapRequest("http://api.google.com/search/beta2");
soapClient.call("doGoogleSearch",parameters,"urn:GoogleSearch", testSoap);
*/