if ((top.XmlWrapperInit == "undefined") || (top.XmlWrapperInit != true))
{
	/**
	 *
	 * XmlWrapper CLASS definition.
	 *
	 * Implements XML Wrapper/Unwrapper for the Event Service functionality using Javascript Objects.
	 *
	 */

	function XmlWrapper()
	{
	   this.xmlHeaderTag = '';
	   this.PxRecognitionTag = '<payload><![CDATA[';
	   this.payloadStartTag = '<payload>';
	   this.payloadEndTag = '</payload>';
	   this.CDATAStartTag = '<![CDATA[';
	   this.CDATAEndTag = ']]>';
	}

	XmlWrapper.prototype.wrapXml=function (istr)
	{
	   var xmlStr = istr;

	   if (!this.isXml(istr)){
	      xmlStr = new String(this.xmlHeaderTag);
	      xmlStr += this.payloadStartTag + this.CDATAStartTag + istr + this.CDATAEndTag + this.payloadEndTag;
	   }  
	   return xmlStr;
	}

	XmlWrapper.prototype.unWrapXml=function (istr)
	{
	   var plainStr = istr;
	   var plainTextStartLoc, plainTextEndLoc;

	   if (this.isPxXml(istr)){
	       plainTextStartLoc = istr.indexOf(this.CDATAStartTag) + this.CDATAStartTag.length;
	       plainTextEndLoc = istr.lastIndexOf(this.CDATAEndTag);
	       plainStr = istr.substring(plainTextStartLoc, plainTextEndLoc)
	   }   
	   return plainStr;
	}

	XmlWrapper.prototype.forceUnWrapXml=function(istr)
	{
	   if (typeof istr != 'string') {
		return istr;
	   }

	   var plainStr = istr;
	   var plainTextStartLoc, plainTextEndLoc;

	   // assume XML
	   indexOfStart = istr.indexOf(this.payloadStartTag);
	   if (indexOfStart < 0) 	 
		   return istr; 
	   plainTextStartLoc = indexOfStart + this.payloadStartTag.length;
	   plainTextEndLoc = istr.lastIndexOf(this.payloadEndTag);
	   plainStr = istr.substring(plainTextStartLoc, plainTextEndLoc)
	   return plainStr;
	}

	XmlWrapper.prototype.isXml=function (istr)
	{
	  return true;
	  // REVISIT
	}

	XmlWrapper.prototype.isPxXml=function (istr)
	{
	  var isPxXml = false;

	  istr = new String(istr);
	  if (istr.indexOf(this.PxRecognitionTag) < 0){
	      return isPxXml;
	  }
	  isPxXml = true;         
	  return isPxXml;
	}
	
	//////////////////////////////////////

	top.XmlWrapperInit = true;
}
	