
	var SessionUrl;
	var SessionHost;
	var SessionID = "";
	var xmlHttp;

//******************************************************************************************
// The ParseSetListXML function parses the Set List XML that holds Informations about
// the availiable Sets and stores then in an handy to use SetList Array.
//******************************************************************************************
	function MyObjSetList()
	{
		this.SetID					= 0;
		this.Alias				= 0;
		this.Name				= '';
		this.Height				= 0;
		this.Width				= '';
		this.ThumbNail			= '';
	};

	function ParseSetListXML(SetListXML)
	{
		var LastDataByte	= 0;
		var n = 0;
		var CurSetList = new Array();
		var FindStr = new Array('Set ID', 'Alias', 'Name', 'Height', 'Width', 'ThumbNail');
		
		while (SetListXML.indexOf('Set ID') != -1)
		{
			n++;
			CurSetList[n] = new MyObjSetList();
			for(i=0; i<FindStr.length; i++)
			{
				SetListXML = SetListXML.slice(SetListXML.indexOf(FindStr[i])+FindStr[i].length+2,SetListXML.length);
				LastDataByte = SetListXML.indexOf('"');
				if (SetListXML.slice(0,LastDataByte) != "")
				{
					CurSetList[n][FindStr[i].replace(/ /g, "")]	= SetListXML.slice(0,LastDataByte).replace(/amp;/g,'');
				}
				else
				{
					CurSetList[n][FindStr[i].replace(/ /g, "")]	= '';
				}
			}
		}	
		return CurSetList;
	}
	
//******************************************************************************************
// The ParseDocStatusXML function parses the Sastus XML that holds the JobStatus
// Informations and stores then in an handy to use DocStatus Object.
//******************************************************************************************
	function MyObjDocStatus()
	{
		this.State					= 0;
		this.PageCount				= 0;
		this.LastProgressMsg		= '';
		this.LastProgressPercent	= 0;
		this.LastErrorMsg			= '';
		this.PDFUrl					= '';
		this.Key					= 0;
		this.Updated				= '';
		this.Created				= '';
		this.LastErrorXMLUrl		= '';
		this.Pages					= new Array();
		this.PUrl					= new Array();
		
	};
	
	function ParseDocStatusXML(DocStatusXML)
	{
		var LastDataByte	= 0;
		var CurDocStatus = new MyObjDocStatus();
		var FindStr = new Array('State', 'PageCount', 'LastProgressMsg', 'LastProgressPercent', 'LastErrorMsg', 'PDFUrl', 'Key', 'Updated', 'Created', 'LastErrorXMLUrl');

		for(i=0; i<FindStr.length; i++)
		{
			DocStatusXML = DocStatusXML.slice(DocStatusXML.indexOf(FindStr[i])+FindStr[i].length+2,DocStatusXML.length);
			LastDataByte = DocStatusXML.indexOf('"');
			if (DocStatusXML.slice(0,LastDataByte) != "")
			{
				CurDocStatus[FindStr[i]]	= DocStatusXML.slice(0,LastDataByte);
			}
			else
			{
				CurDocStatus[FindStr[i]]	= '';
			}
		}
		
		i = 0;
		while (DocStatusXML.indexOf('Jpeg') >= 0)
		{
			i++;
			DocStatusXML = DocStatusXML.slice(DocStatusXML.indexOf('Jpeg')+11,DocStatusXML.length);
			LastDataByte = DocStatusXML.indexOf('"');
			if (DocStatusXML.slice(0,LastDataByte) != "")
			{
				CurDocStatus.Pages[i]	= DocStatusXML.slice(0,LastDataByte);
			}
			else
			{
				CurDocStatus.Pages[i]	= 0;
			}

			DocStatusXML = DocStatusXML.slice(DocStatusXML.indexOf('Url=')+5,DocStatusXML.length);
			LastDataByte = DocStatusXML.indexOf('"');
			if (DocStatusXML.slice(0,LastDataByte) != "")
			{
				CurDocStatus.PUrl[i] = DocStatusXML.slice(0,LastDataByte);
			}
			else
			{
				CurDocStatus.PUrl[i] = '';
			}
		}	
		return CurDocStatus;
	}
	
//******************************************************************************************
// The FillAliasArray function converts the DocList String or an ImageList XML into an array.
//******************************************************************************************
	function FillAliasArray(StrBuff)
	{
		var i=0;
		var Position=0;
		var AArray		= new Array();
		
		if (StrBuff.slice(0,8)=='&lt;?xml')  // This is a DocumentListXML
		{
			while(StrBuff != "")
			{
				Position = StrBuff.indexOf('Alias');
				if (Position == -1)
				{
					StrBuff = "";
				}
				else
				{
					StrBuff = StrBuff.slice(Position+7,StrBuff.length);
					
					AArray[i] = StrBuff.slice(0,StrBuff.indexOf('"'));
					StrBuff = StrBuff.slice(Position+1,StrBuff.length);
					i++
				}				
			}

		}
		else // We assume this is an ImageList since its not a DocumentListXML
		{
			while(StrBuff != "")
			{
				Position = StrBuff.indexOf(',');
				if (Position == -1)
				{
					AArray[i] = StrBuff;
					StrBuff = "";
				}
				else
				{
					AArray[i] = StrBuff.slice(0,Position);
					StrBuff = StrBuff.slice(Position+1,StrBuff.length);
					i++
				}
			}
		}
		return AArray;
	}
	
//*************************************************************************************
/*			DirectSmile Online Functions 					*/
//*************************************************************************************
	
	var SessionUrl;
	var SessionHost;
	var xmlHttp;
	var SessionRunAsync;
	
	function SetConstants(location)
	{
	  SessionUrl = 'http://'+location+'/dsmo/lb.asmx';
	  SessionHost = location+'/dsmo';
	  SessionRunAsync = false;
	}

//****************************************************************************************************
//****************************************************************************************************
//*	 DSMOHelper.js                 	(c) 2008 DirectSmile         *
//*															*
//* The following Functions simply build coresponding soap Envelopes and posting them                *
//* to the WebService. Then according to Sync or Async mode, they return eather the                  *
//* result of the call or an empty string.                                                           *
//* In case of Async mode, one can retreave the Result by entering code into the                     *
//* corresponding EventHandling Functions.                                                           *
//*                                                                                                  *
//* Calling Function: 'GetAuthenticationCodeResult')	Event:	onAuthCodeArrived(ResultValue);      *
//* Calling Function: 'GetAvailableSetListAuthResult')	Event:	onSetListArrived(ResultValue);       *
//* Calling Function: 'GetAvailableDocListAuthResult')	Event:	onDocListArrived(ResultValue);       *
//* Calling Function: 'GetImageUrlAuthResult')		Event:	onImageUrlArrived(ResultValue);      *
//* Calling Function: 'StartDocResult')			Event:	onStartDocArrived(ResultValue);      *
//* Calling Function: 'GetDocStatusResult') 		Event:	onGetDocStatusArrived(ResultValue);  *
//*                                                                                                  *
//****************************************************************************************************
//****************************************************************************************************

	
//*************************************************************************************
/*		 Functions handeling AUTHENTICATIONS			*/
//*************************************************************************************

    function Authenticate(UserName, PWD)
    {  
      var FunctionCall = "Authenticate"; 
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<UserName>' + UserName + '</UserName>'
        + '<Password>' + PWD + '</Password>'
        + '<Language></Language>'
		+ '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
	}   

    function GetAuthenticationCode(UserName, PWD)
    {  
      var FunctionCall = "GetAuthenticationCode";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<Username>' + UserName + '</Username>'
        + '<Password>' + PWD + '</Password>'
		+ '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

//*************************************************************************************
/*		 Functions handeling SETS			*/
//*************************************************************************************

    function GetAvailableSetList(SessionID)
    {  
      var FunctionCall = "GetAvailableSetList";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},
 
          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

    function GetAvailableSetListXML(SessionID)
    {  
      var FunctionCall = "GetAvailableSetListXML";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetAvailableSetListAuth(AuthenticationCode)
    {  
      var FunctionCall = "GetAvailableSetListAuth";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<AuthenticationCode>' + AuthenticationCode + '</AuthenticationCode>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

    function GetAvailableSetListXMLAuth(AuthenticationCode)
    {  
      var FunctionCall = "GetAvailableSetListXMLAuth";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<AuthenticationCode>' + AuthenticationCode + '</AuthenticationCode>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetImageUrl(SessionID, SetAlias, TextToRender, PixelWidth, Filename, Quality, Key, WaterMarkType)
    {  
      var FunctionCall = "GetImageUrl";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '<SetAlias>' + SetAlias + '</SetAlias>'
        + '<TextToRender>' + TextToRender + '</TextToRender>'
        + '<PixelWidth>' + PixelWidth + '</PixelWidth>'
        + '<Filename>' + Filename + '</Filename>'
        + '<Quality>' + Quality + '</Quality>'
        + '<Key>' + Key + '</Key>'
        + '<WaterMarkType>' + WaterMarkType + '</WaterMarkType>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetImageUrlAuth(AuthenticationCode, SetAlias, TextToRender, PixelWidth, Filename, Quality, WaterMarkType)
    {  
	  var FunctionCall = "GetImageUrlAuth";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<AuthenticationCode>' + AuthenticationCode + '</AuthenticationCode>'
        + '<SetAlias>' + SetAlias + '</SetAlias>'
        + '<TextToRender>' + TextToRender + '</TextToRender>'
        + '<PixelWidth>' + PixelWidth + '</PixelWidth>'
        + '<Filename>' + Filename + '</Filename>'
        + '<Quality>' + Quality + '</Quality>'
        + '<WaterMarkType>' + WaterMarkType + '</WaterMarkType>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   
	
/*****************************************************/
/*		 Functions handeling DOCUMENTS			*/
/*****************************************************/

	function GetAvailableDocList(SessionID)
    {  
      var FunctionCall = "GetAvailableDocList";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetAvailableDocListAuth(AuthenticationCode)
    {  
      var FunctionCall = "GetAvailableDocListAuth";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<AuthenticationCode>' + AuthenticationCode + '</AuthenticationCode>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetDocDataInterfaceURL(SessionID, DocumentAlias)
    {  
      var FunctionCall = "GetDocDataInterfaceURL";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '<DocumentAlias>' + DocumentAlias + '</DocumentAlias>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetDocAttributes(SessionID, DocumentAlias)
    {  

      var FunctionCall = "GetDocAttributes";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SID>' + SessionID + '</SID>'
        + '<DocumentAlias>' + DocumentAlias + '</DocumentAlias>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);

	  if (SessionRunAsync == false)
	  {

		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function StartDoc(SessionID, DocumentAlias, MsgComXML)
    {  
      var FunctionCall = "StartDoc";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<Sid>' + SessionID + '</Sid>'
        + '<DocumentAlias>' + DocumentAlias + '</DocumentAlias>'
        + '<MsgComXML><![CDATA[' + MsgComXML + ']]></MsgComXML>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function GetDocStatus(SessionID, Key)
    {  
      var FunctionCall = "GetDocStatus";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '<Key>' + Key + '</Key>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function DeleteDocOrderByDocID(SessionID, Key)
    {  
      var FunctionCall = "DeleteDocOrderByDocID";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '<Key>' + Key + '</Key>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

	function DeleteAllByAcccountID(SessionID)
    {  
      var FunctionCall = "DeleteAllByAcccountID";
	  var MyEnvelope = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        + ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
        + '<soap:Body><'+FunctionCall+' xmlns="http://www.directsmile.de/GenService/LB">'
        + '<SessionID>' + SessionID + '</SessionID>'
        + '</'+FunctionCall+'></soap:Body>'
        + '</soap:Envelope>';

      var headers = [
          {name:"SOAPAction", value:'"http://www.directsmile.de/GenService/LB/'+FunctionCall+'"'},

          {name:"Content-Type", value:'text/xml; charset=utf-8'}
      ]
      ajaxCall('POST', SessionUrl, headers, MyEnvelope, OnSoapResponse, SessionRunAsync);
	  if (SessionRunAsync == false)
	  {
		return GetResult(FunctionCall+"Result");
	  }
	  else
	  {
		return "";
	  }
    }   

//*************************************************************************************
/*				 Ajax Support Functions 				*/
//*************************************************************************************
	
    function ajaxCall(method, url, headers, Envelope, callback, RunAsync) 
    {
        
        if (xmlHttp = newXMLHTTPRequest()) 
        {
            xmlHttp.open(method, url, RunAsync);

            for( var i = 0; i<headers.length; i++)
            {
                try 
                {
                    xmlHttp.setRequestHeader(headers[i].name, headers[i].value);
                }
                catch (ex)
                {
                    alert(ex);
                }
            }
            xmlHttp.onreadystatechange = callback;
            xmlHttp.send(Envelope);
        }
        else
        {
            alert("AJAX not supported");
        }
    }

	function GetResult(ResultLookup)
	{
		try {
            if (xmlHttp.readyState == 4) 
			{
                if (xmlHttp.status == 200) 
				{

					return parseResult(ResultLookup);
                } else 
				{
                    alert('ERROR xmlHttp.status='+xmlHttp.status+':'+xmlHttp.statusText+' --> '+xmlHttp.responseText);
                }
            }
        }
        catch( e ) 
		{
            alert('Caught Exception: ' + e.description);
        }
	}

    function parseResult(wich) 
    {
        var Result;
		var strPos;
		
		Result = xmlHttp.responseText;

		strPos = Result.search(wich);
		if (strPos == -1) 
		{
		  return "";
		}  
		Result = Result.slice(strPos+wich.length+1);
		if (Result.search('</'+wich+'>') != -1)
		{
			Result = Result.slice(0,Result.search('</'+wich+'>'));
		}
		else
		{
			Result = "";
		}
		return Result;
	}

	function OnSoapResponse() 
    {
       // 0 - uninitialized
       // 1 - loading
       // 2 - loaded
       // 3 - interactice
       // 4 - complete

		var ResultFrom = "";
		var ResultValue = "";

		switch (xmlHttp.readyState)
		{
			case 0:
				//alert("uninitialized");
				break;
			case 1:
				//alert("loading");
				break;
			case 2:
				//alert("loaded");
				break;
			case 3:
				//alert("interactive");
				break;
			case 4:
				ResultFrom = xmlHttp.responseText.slice(xmlHttp.responseText.search('www.directsmile.de/GenService/LB')+35,xmlHttp.responseText.length);
				ResultFrom = ResultFrom.slice(0,ResultFrom.search('>'));
				
				ResultValue = parseResult(ResultFrom);
				break;
			default:
				alert("unhandled return code from xmlHttp ->" + xmlHttp.readyState);
				break;
		}
    }

    function newXMLHTTPRequest()
    {
        // Mozilla, Opera, Safari and Internet Explorer 7
        if (typeof XMLHttpRequest != 'undefined') 
        {
            xmlHttp = new XMLHttpRequest();
        }
        if (!xmlHttp) 
        {
        // Internet Explorer 6 and older
            try 
            {
                xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
            } 
    
            catch(e) 
            {
                try 
                {
                    xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e) 
                {
                    xmlHttp  = null;
                }
            }
        }
        return xmlHttp;
    }

	function wait(msecs)
	{
		var start = new Date().getTime();
		var cur = start
		while(cur - start < msecs)
		{
			cur = new Date().getTime();
		}
	}