	if ( window.documentManager != null ) {
		alert ( "WARNING\r\ndocumentManager included on page more than once" );
	}
	function fnGetIEVersion () {
	    var strApp = navigator.appVersion.toLowerCase();
		var numPos  = strApp.indexOf ( "msie" );
	    if ( numPos != -1 ) {
			var strVersion = strApp.substring ( numPos + 5, strApp.indexOf ( ';', numPos ) )
			var numVersion = parseFloat ( strVersion );
			if ( ! isNaN ( numVersion ) ) {
				if ( numVersion >= 5.0 ) {
					if ( document.childNodes == null ) {
						// Can't be IE5
						numVersion = 4.0;
					}
				}
				return numVersion;
			}
		}
		alert ( "IE BROWSER VERSION UNKNOWN" );
		return 5.0;
	}
	var browserVersion = fnGetIEVersion ();
	if ( browserVersion > 5.0 ) {
		if ( ( ScriptEngineMajorVersion() == 5 ) && ( ScriptEngineMinorVersion() == 5 ) ) {
			Array.prototype.toString = function () {
				return this.join ( "," );
			}
		}
	}

    function getBoundingClientRect( e )
    {
       var result1 = null;
       
       //debugger;
       // getting very stange results
       //if (e.getBoundingClientRect)  
       //{
       //   result1 = e.getBoundingClientRect();  
       //}
       
       // make a work-around
       var element = e;
       var coords = { left: 0, top: 0, width: element.offsetWidth, height:
                        element.offsetHeight, bottom: 0, right: 0 };

        while (element) {
            coords.left += element.offsetLeft;
            coords.top += element.offsetTop;
            element = element.offsetParent;
        }
        
        coords.bottom = coords.top + coords.height;
        coords.right  = coords.left + coords.width;
        //trace("coords", "coords ("+ coords.left + "," + coords.top+ "," coords.width +","+ coords.height +")" );
        //if ( result1 != null) trace("coords", "brect ("+ result1.left + "," + result1.top+ "," result1.width +","+ result1.height +")" );

        return coords;
    }

	/*--------------------------------------------------------------*/
    function xGetElementById(id)
    {
      if (document.getElementById)
      {
        return document.getElementById(id);
      }
      else
      if (document.layers && document.layers[id])
      {
        return document.layers[id];
      }
      else
      if (document.all)
      {
        return document.all[id];
      }
    }
	/*--------------------------------------------------------------*/
    function getKeyCode( e )
    {
        var code;
        if ( e.keyCode )
        {
            code = e.keyCode;
        }
        else
        if ( e.which )
        {
            code = e.which;
        }
        return code;
    }
	/*--------------------------------------------------------------*/
    function fnGetLangCode() {
	  var strApp = navigator.userLanguage.toLowerCase();
		var twoLtrCode = strApp.charAt(0)+strApp.charAt(1);
		switch (twoLtrCode){
		  case "en":threeLtrCode = "ENG";break;
			case "fr":threeLtrCode = "FRE";break;
			case "de":threeLtrCode = "GER";break;
			case "nl":threeLtrCode = "DUT";break;
			default:threeLtrCode = "ENG";
		}
		return(threeLtrCode);
	}
	/*--------------------------------------------------------------*/
	// Get LangCode From URL
	function GetParaFromURL (str)
	{
		var regexS = "[\\?&]"+str+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var tmpURL = window.location.href;
		var getLang = regex.exec( tmpURL );
		
		if (getLang != null)
		{
			//alert(getLang[1]);
			return getLang[1];
		}
		return null;
	}

	
	/*--------------------------------------------------------------*/

    function trim(text)
    {      
       var index = 0;               
       var newText = "";            
       var lastSpacePos = -1;       
       var reached = false;         
       for (index = 0; index < text.length; index++){   
          if (text.charAt(index) != " "){reached = true;}
          if (reached) {newText += text.charAt(index);}
       }   
       reached = false;
       for (index = newText.length; index >= 0; index--){   
          if (!reached){   
             if ((newText.charAt(index) != " ") && (index !=newText.length)){
                lastSpacePos = index + 1;
                reached = true;
             }
          }
       }   
       if (lastSpacePos != -1){newText = newText.substring(0, lastSpacePos);}
       return newText;
    }

	/*--------------------------------------------------------------*/

		function dataStoreObject ()
		{
			this.fields = new Object ();
		}
		
		dataStoreObject.prototype.isDefined = function ( fieldName, propertyName ) {

			var fieldObject = this.fields [ fieldName ];
			
			if ( ( typeof fieldObject ) == "undefined" ) return false;
			
			if ( ( typeof fieldObject [ propertyName ] ) == "undefined" ) return false;

			return true;
		}

		dataStoreObject.prototype.isFieldDefined = function ( fieldName ) {

			var fieldObject = this.fields [ fieldName ];
			
			if ( ( typeof fieldObject ) == "undefined" ) return false;

			return true;
		}

		dataStoreObject.prototype.remove = function ( fieldName, propertyName ) {
		
			var fieldObject = this.fields [ fieldName ];
			
			if ( ( typeof fieldObject ) == "undefined" ) return false;
			
			if ( ( typeof fieldObject [ propertyName ] ) == "undefined" ) return false;
			
			delete fieldObject [ propertyName ];

			for ( var i in fieldObject ) { return true; }
			
			delete this.fields [ fieldName ];

			return true;
		}

		dataStoreObject.prototype.getFieldObject = function ( fieldName ) {

			var result = this.fields [ fieldName ];
			
			if
				( result == null )
			{
				result = new Object;
				this.fields [ fieldName ] = result;
			}

			return result;
		}

		dataStoreObject.prototype.write = function ( fieldName, propertyName, value ) {

			var fieldObject = this.getFieldObject ( fieldName );
			fieldObject [ propertyName ] = value;
		}

		dataStoreObject.prototype.read = function ( fieldName, propertyName ) {

			var fieldObject = this.getFieldObject ( fieldName );
			var result = fieldObject [ propertyName ];

			if
				( result == null )
			{
				// Both must be set to real null...
				
				fieldObject [ propertyName ] = null;
				result = null;
			}

			return result;
		}

		/*-------------------------------------------------------*/
		
		function databaseObject ()
		{
			this.dataStore = new dataStoreObject ();
			this.undoHistory = new Array ();
			this.redoHistory = new Array ();
			this.undoTransaction = null;
			this.redoTransaction = null;
			this.historyIndex = 0;
			this.undoCount = null;
			this.historyIndexTop = 0;
			this.mode = "";
			this.newIdentifier = 0;
		}

		databaseObject.prototype.newFieldName = function () {

			return "_" + this.newIdentifier++;
		}
	
		databaseObject.prototype.read = function ( fieldName, propertyName ) {
		
			return this.dataStore.read ( fieldName, propertyName );
		}

		databaseObject.prototype.write = function ( fieldName, propertyName, value ) {
		
			if
				( this.mode == "" )
			{
				this.dataStore.write ( fieldName, propertyName, value );
				
				return;
			}
		
			if
				( this.mode == "transaction" )
			{
				var oldValue = this.dataStore.read ( fieldName, propertyName );
				
				if
					( value != oldValue )
				{
					var oldState = this.undoTransaction;
				
					if
						( ! oldState.isDefined ( fieldName, propertyName ) )
					{
						oldState.write ( fieldName, propertyName, oldValue );
						this.undoCount++;
					}
					else
					if
						( oldState.read ( fieldName, propertyName ) == value )
					{
						oldState.remove ( fieldName, propertyName );
						this.undoCount--;
					}
				
					this.redoTransaction.write ( fieldName, propertyName, value );
					this.dataStore.write ( fieldName, propertyName, value );
				}
				
				return;
			}
			
			alert ( "Can't write during " + this.mode + " mode" );
		}

		databaseObject.prototype.transactionStarted = function () {

			return ( this.mode == "transaction" );
		}

		databaseObject.prototype.startTransaction = function () {
		
			if
				( this.mode != "" )
			{
				//alert ( "Can't start transaction during " + this.mode + " mode" );
			}
			else
			{
				this.undoTransaction = new dataStoreObject ();
				this.redoTransaction = new dataStoreObject ();

				this.mode = "transaction";
				this.undoCount = 0;
			}
		}
		
		databaseObject.prototype.endTransaction = function () {
		
			if
				( this.mode != "transaction" )
			{
				//alert ( "Can't end transaction during " + this.mode + " mode" );
			}
			else
			{
				if
					( this.undoCount != 0 )
				{
					this.undoHistory [ this.historyIndex ] = this.undoTransaction;
					this.redoHistory [ this.historyIndex ] = this.redoTransaction;
					this.historyIndex++;
					this.historyIndexTop = this.historyIndex;
				}
				
				this.mode = "";

				return ( this.undoCount != 0 );
			}
			return false;
		}
		
		databaseObject.prototype.changed = function () {

			return ( this.undoCount != 0 );
		}
		
		databaseObject.prototype.canUndo = function () {
		
			return ( this.historyIndex > 0 );
		}

		databaseObject.prototype.canRedo = function () {
		
			return ( this.historyIndex < this.historyIndexTop );
		}

		databaseObject.prototype.imposeChanges = function ( fields ) {

			for ( var fieldName in fields ) {

				var field = fields [ fieldName ];

				for ( var propertyName in field ) {

					this.dataStore.write ( fieldName, propertyName, field [ propertyName ] );
				}
			}
		}

		databaseObject.prototype.undo = function ( object, methodName ) {
		
			if
				( this.mode != "" )
			{
				alert ( "Can't undo during " + this.mode + " mode" );
			}
			else
			{
				if
					( this.historyIndex > 0 )
				{
					this.mode = "undo";
					
					this.historyIndex--;

					this.imposeChanges ( this.undoHistory [ this.historyIndex ].fields );

					object [ methodName ] ( this.undoHistory [ this.historyIndex ].fields );
					
					this.mode = "";
				}
			}
		}

		databaseObject.prototype.redo = function ( object, methodName ) {
		
			if
				( this.mode != "" )
			{
				alert ( "Can't redo during " + this.mode + " mode" );
			}
			else
			{
				if
					( this.historyIndex < this.historyIndexTop )
				{
					this.mode = "redo";
					
					this.imposeChanges ( this.redoHistory [ this.historyIndex ].fields );

					object [ methodName ] ( this.redoHistory [ this.historyIndex ].fields );

					this.historyIndex++;

					this.mode = "";
				}
			}
		}

		/*-------------------------------------------------------*/
		
		function handleManagerObject ()
		{
			this.objects = new Object ();
			this.handle = 0;
		}
		
		handleManagerObject.prototype.newHandleForObject = function ( object ) {
			
			var h = this.handle;

			this.handle++;
			this.objects [ h ] = object;
			return h;
		}
		
		handleManagerObject.prototype.getObject = function ( handle ) {
		
			return this.objects [ handle ];
		}
		
		handleManagerObject.prototype.removeHandle = function ( handle ) {
		
			delete this.objects [ handle ];
		}

		handleManagerObject.prototype.getObjects = function () {

			return this.objects;
		}

		/*-------------------------------------------------------*/

		function updateObject ( interface )
		{
			this.fields = new Object ();
			this.interface = interface;
		}
		
		updateObject.prototype.newFieldName = function () {
		
			return this.interface.newFieldName ();
		}

		updateObject.prototype.read = function ( fieldName, propertyName ) {

			return this.interface.read ( fieldName, propertyName );
		}

		updateObject.prototype.write = function ( fieldName, propertyName, value ) {

			var fieldObject = this.fields [ fieldName ];
			
			if
				( fieldObject == null )
			{
				fieldObject = new Object;
				this.fields [ fieldName ] = fieldObject;
			}

			fieldObject [ propertyName ] = value;
		}

		updateObject.prototype.isWriteDefined = function ( fieldName, propertyName ) {

			var fieldObject = this.fields [ fieldName ];
			
			if ( ( typeof fieldObject ) == "undefined" ) return false;
			
			if ( ( typeof fieldObject [ propertyName ] ) == "undefined" ) return false;

			return true;
		}

		updateObject.prototype.peekWrite = function ( fieldName, propertyName ) {

			var fieldObject = this.fields [ fieldName ];
		
			if
				( fieldObject != null )
			{
				return fieldObject [ propertyName ];
			}
			return null;
		}

		/*-------------------------------------------------------*/

		function queueObject ()
		{
			this.content = null;
		}

		queueObject.prototype.isEmpty = function () {

			return this.content == null;
		}

		queueObject.prototype.count = function () {

			if
				( this.content == null )
			{
				return 0;
			}
			else
			{
				return this.next - this.first;
			}
		}

		queueObject.prototype.put = function ( object ) {

			if
				( this.content == null )
			{
				this.content = new Object;
				this.content [ 0 ] = object;
				this.first = 0;
				this.next = 1;
			}
			else
			{
				this.content [ this.next ] = object;
				this.next++;
			}
		}

		queueObject.prototype.get = function () {

			var result = this.content [ this.first ];

			this.first++;
			
			if
				( this.first == this.next )
			{
				this.content = null;
			}

			return result;
		}

		/*-------------------------------------------------------*/


		function interfaceObject ( database )
		{
			this.database = database;

			this.dependencies = new dataStoreObject ();
			this.connections = new Object ();
			
			this.objects = new handleManagerObject ();
			this.readWrite = new Object ();

			this.clientHandle = null;
			this.updating = false;

			this.thingsToDo = new queueObject ();

			this.dependentProcessHandles = new Object ();
			this.dependentObserverHandles = new Object ();
		}
		
		interfaceObject.prototype.addDependencies = function ( handle, fields ) {

			for ( var fieldName in fields ) {

				for ( var propertyName in fields [ fieldName ] ) {

					var handleMap = this.dependencies.read ( fieldName, propertyName );
					
					if
						( handleMap == null )
					{
						handleMap = new Object ();
						this.dependencies.write ( fieldName, propertyName, handleMap );
					}

					if
						( handleMap [ handle ] == null )
					{
						var connections = this.connections [ handle ];
				
						if
							( connections == null )
						{
							connections = new dataStoreObject ();
							this.connections [ handle ] = connections;
						}

						connections.write ( fieldName, propertyName, true );

						handleMap [ handle ] = true;
					}
				}
			}
		}

		interfaceObject.prototype.removeDependencies = function ( handle ) {

			var connections = this.connections [ handle ];

			var empty;
			
			if
				( connections != null )
			{
				for ( var fieldName in connections.fields ) {

					for ( var propertyName in connections.fields [ fieldName ] ) {

						var handleMap = this.dependencies.read ( fieldName, propertyName );
					
						delete handleMap [ handle ];

						empty = true;

						for ( var h in handleMap ) { empty = false; break; }

						if
							( empty )
						{
							// This item has no dependent processes...

							this.dependencies.remove ( fieldName, propertyName );
						}
					}
				}
				
				delete this.connections [ handle ];
			}
		}

		interfaceObject.prototype.detatch = function ( object ) {

			var handle = object.interfaceHandle;

			if
				( handle != null )
			{
				this.removeDependencies ( handle );
			
				delete this.readWrite [ handle ];
				
				this.objects.removeHandle ( handle );
			}

			object.bDetatched = true;
		}

		interfaceObject.prototype.read = function ( fieldName, propertyName ) {
		
			if
				( this.clientHandle == null )
			{
				alert ( "Illegal out of context read to " + fieldName + "." + propertyName );
				
				return null;
			}
			else
			{
				this.clientReads.write ( fieldName, propertyName, true );

				if ( this.clientWrites != null ) {
					if ( this.clientWrites.isDefined ( fieldName, propertyName ) ) {
						//alert ( "CHANGED FIELD READ AFTER WRITE\r\n\r\nFIELD " + fieldName + ":" + propertyName + " WAS '" + this.database.read ( fieldName, propertyName ) + "' IS NOW '" + this.clientWrites.read ( fieldName, propertyName )+ "'" );
						return this.clientWrites.read ( fieldName, propertyName );
					}
				}

				return this.database.read ( fieldName, propertyName );
			}
		}
	
		interfaceObject.prototype.write = function ( fieldName, propertyName, value ) {
		
			if
				( this.clientHandle == null )
			{
				alert ( "Illegal out of context write to " + fieldName + "." + propertyName );
				
				return null;
			}
			else
			{
				if
					( this.readWrite [ this.clientHandle ] )
				{
					if
						( value == this.database.read ( fieldName, propertyName ) )
					{
						this.clientWrites.remove ( fieldName, propertyName );
					}
					else
					{
						this.clientWrites.write ( fieldName, propertyName, value );
					}
				}
				else
				{
					alert ( "Read only process attempted to write to " + fieldName + "." + propertyName );
				}
			}
		}

		interfaceObject.prototype.applyChanges = function ( changes ) {

			for ( var fieldName in changes.fields ) {

				var fieldObject = changes.fields [ fieldName ];

				for ( var propertyName in fieldObject ) {
						
					var value = fieldObject [ propertyName ];

					if
						( this.database.read ( fieldName, propertyName ) != value )
					{
						this.database.write ( fieldName, propertyName, value );

						if
							( this.dependencies.isDefined ( fieldName, propertyName ) )
						{
							var handleMap = this.dependencies.read ( fieldName, propertyName );

							for ( var h in handleMap ) {

								if
									( this.readWrite [ h ] )
								{
									this.dependentProcessHandles [ h ] = true;
								}
								else
								{
									this.dependentObserverHandles [ h ] = true;
								}
							}
						}
					}
				}
			}
		}

		interfaceObject.prototype.notifyChanges = function () {

			var done = true;

			this.updating = true;
			this.quiet = false;

			for ( var i in this.dependentProcessHandles ) { done = false; break; }

			if
				( ! done )
			{
				// Let all the objects make their changes...

				var updates = new dataStoreObject ();
				var change = false;

				for
					( var handle in this.dependentProcessHandles )
				{
					if
						( this.connections [ handle ] != null )
					{
						this.clientHandle = handle;
						this.clientWrites = new dataStoreObject ();
						this.clientReads = new dataStoreObject ();
					
						this.objects.getObject ( handle ).notifyChange ();

						this.clientHandle = null;

						this.removeDependencies ( handle );
						this.addDependencies ( handle, this.clientReads.fields );

						// Merge the changes and check for conflicts...

						for ( var fieldName in this.clientWrites.fields ) {

							var fieldObject = this.clientWrites.fields [ fieldName ];

							for ( var propertyName in fieldObject ) {
									
								var value = fieldObject [ propertyName ];

								if
									( updates.isDefined ( fieldName, propertyName ) )
								{
									if
										( value != updates.read ( fieldName, propertyName ) )
									{
										//alert ( "Update conflict on " + fieldName + "." + propertyName + " value=" + value + " valueRead=" + updates.read ( fieldName, propertyName ));
									}
								}
								else
								{
									updates.write ( fieldName, propertyName, value );
									change = true;
								}
							}
						}
					}
				}

				this.dependentProcessHandles = new Object ();

				if ( change ) this.applyChanges ( updates );

				done = true;

				for ( var i in this.dependentProcessHandles ) { done = false; break; }
			}

			if
				( done )
			{
				for ( var i in this.dependentObserverHandles ) { done = false; break; }

				if
					( ! done )
				{
					for ( var handle in this.dependentObserverHandles ) {

						if
							( this.connections [ handle ] != null )
						{
							this.clientHandle = handle;
							this.clientWrites = null;
							this.clientReads = new dataStoreObject ();

							this.objects.getObject ( handle ).notifyChange ();

							this.clientHandle = null;

							this.removeDependencies ( handle );
							this.addDependencies ( handle, this.clientReads.fields );
						}
					}

					this.dependentObserverHandles = new Object ();

				} else {

					if
						( this.thingsToDo.count () )
					{
						var thingToDo = this.thingsToDo.get ();

						if
							( thingToDo.action == "update" )
						{
							this.applyChanges ( thingToDo.changes );

							this.notifyChanges ();
						}
						else
						if
							( thingToDo.action == "attatch" )
						{
							var object = thingToDo.object;

							if ( ! object.bDetatched ) {

								var handle = object.interfaceHandle;
								var readWrite = thingToDo.readWrite;

								if ( handle == null ) {

									handle = this.objects.newHandleForObject ( object );
									object.interface = this;
									object.interfaceHandle = handle;
								}

								if ( this.connections [ handle ] == null ) {

									this.connections [ handle ] = new dataStoreObject ();
								}

								this.readWrite [ handle ] = readWrite;

								if
									( readWrite )
								{
									this.dependentProcessHandles [ handle ] = true;
								}
								else
								{
									this.dependentObserverHandles [ handle ] = true;
								}
								this.notifyChanges ();
							}
						}
					}
					else
					{
						this.quiet = true;
					}
				}
			}

			this.updating = false;
		}
		
		interfaceObject.prototype.attatch = function ( object, readWrite ) {

			this.thingsToDo.put ( { action:"attatch", object:object, readWrite:readWrite } );
		}

		interfaceObject.prototype.update = function ( changes ) {

			this.thingsToDo.put ( { action:"update", changes:changes } );
		}
		
		interfaceObject.prototype.syncUpdate = function ( changes ) {

			this.fullUpdate ();

			this.update ( changes );

			this.fullUpdate ();
		}

		interfaceObject.prototype.fullUpdate = function () {

			do { this.notifyChanges (); } while ( ! this.quiet );
		}

		interfaceObject.prototype.undo = function () {
		
			this.fullUpdate ();

			this.database.undo ( this, "applyGlobalChange" );
		}
		
		interfaceObject.prototype.redo = function () {
		
			this.fullUpdate ();

			this.database.redo ( this, "applyGlobalChange" );
		}
		
		interfaceObject.prototype.applyGlobalChange = function ( fields ) {

			if
				( this.updating )
			{
				alert ( "ERROR: global change during update" );
			}
			else
			{
				var handles = new Object ();

				for ( var fieldName in fields ) {

					var field = fields [ fieldName ];

					for ( var propertyName in field ) {

						var handleMap = this.dependencies.read ( fieldName, propertyName );
						
						if
							( handleMap != null )
						{
							for ( var h in handleMap ) {
							
								handles [ h ] = true;
							}
						}
					}
				}

				this.updating = true;

				for ( var h in handles ) {
				
					if
						( this.connections [ h ] )
					{
						this.clientHandle = h;
						this.clientWrites = new dataStoreObject ();
						this.clientReads = new dataStoreObject ();

						this.objects.getObject ( h ).notifyChange ();
						
						this.clientHandle = null;

						this.removeDependencies ( h );
						this.addDependencies ( h, this.clientReads.fields );
					}
				}

				this.updating = false;
			}
		}

		interfaceObject.prototype.newFieldName = function () {
		
			return this.database.newFieldName ();
		}

		interfaceObject.prototype.observedFieldNames = function () {

			/* This is an ABBOMINATION and must be removed as soon as possible */

			var result = new Array ();

			for ( var fieldName in this.dependencies.fields ) {

				if
					( this.dependencies.isFieldDefined ( fieldName ) )
				{
					result [ result.length ] = fieldName;
				}
			}

			return result;
		}

		interfaceObject.prototype.fnStartTransaction = function () {
			this.database.startTransaction ();
		}
		interfaceObject.prototype.fnEndTransaction = function () {
			return this.database.endTransaction ();
		}
		interfaceObject.prototype.fnUndo = function () {
			this.undo ();
		}
		interfaceObject.prototype.fnRedo = function () {
			this.redo ();
		}

	/*------------------------------------------------------*/
	/*-------------------------------------------------------*/
	/*-------------------------------------------------------*/
	/*-------------------------------------------------------*/
	/*-------------------------------------------------------*/
	/*-------------------------------------------------------*/
	/*-------------------------------------------------------*/

	var documentManager = new Object ();

    documentManager.getInterface = function() {
        return this.interface;
    }
    
	documentManager.initialise = function () {

		this.ready = false;

		this.childManager = new handleManagerObject ();
		this.parent = this.getParentManager ();

		if
			( this.parent != null )
		{
			this.handleInParent = this.parent.attatchChild ( this );
			
			this.database = this.parent.database;
			this.interface = this.parent.interface;
		}
		else
		{
			this.database = new databaseObject ();
			this.interface = new interfaceObject ( documentManager.database );
		}

		this.attributePrefix = "ALSi";
		
		this.attatchments = new Object ();
		this.newProcesses = new Array ();
		this.startups = [];
        this.onresizes = [];

		this.shutdowns = [];
		this.windows = new Array ();

		this.constructors = new Object ();
		this.types = new Object ();

		this.objects = new Array ();
		this.tasks = new Array ();

		this.globals = new Object ();
		this.translations = new Object ();

		this.setTimer ();

		window.onbeforeunload = this.doUnload;
	}

	documentManager.getTransactionManager = function () {
		var tm = this.transactionManager;
		if ( tm == null ) {
			tm = this.findNamedObject ( "transactionManager" );
		}
		if ( tm == null ) {
			tm = this.interface;
		}
		return tm;
	}

	documentManager.setGlobalProperty = function ( name, object ) {

		this.globals [ name ] = object;
	}

	documentManager.getGlobalProperty = function ( name ) {

		var object = this.globals [ name ];

		if (  object != null ) {

			if ( typeof object == "function" ) {

				return object ();
			}
			else
			{
				return object;
			}
		}

		return ( void 0 );
	}

	documentManager.getGlobalPropertiesRecursive = function ( name ) {

		result = [];
		var value = this.getGlobalProperty ( name );

		if
			( value != null )
		{
			result [ 0 ] = value;
		}

		for ( var h in this.childManager.objects ) {

			result = result.concat ( this.childManager.objects [ h ].getGlobalPropertiesRecursive ( name ) );
		}

		return result;
	}

	documentManager.attatchChild = function ( object ) {

		return this.childManager.newHandleForObject ( object );
	}

	documentManager.topManager = function () {

		if ( this.parent == null ) return this;

		return this.parent.topManager ();
	}

    documentManager.windowSize = function ()
    {
            var myWidth = 0, myHeight = 0;
    
            if( typeof( window.innerWidth ) == 'number' ) {
                //Non-IE
                myWidth = window.innerWidth;
                myHeight = window.innerHeight;
            } 
            else if
                ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
            {
                myWidth = document.documentElement.clientWidth;
                myHeight = document.documentElement.clientHeight;
            }
            else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
            {
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }
        return {  width: myWidth , height: myHeight };
    }

    documentManager.getId = function () {

		if ( this.handleInParent == null ) {
		
			return "";
		}
		else
		{
			var result = this.parent.getId ();
			
			if ( result != "" ) result += ",";
			
			return result + this.handleInParent;
		}
	}

	documentManager.getFromId = function ( id ) {

		if ( this.parent != null ) {
		
			return this.parent.getFromId ( id );
		}
		else
		{
			var result = this;
			var handles = id.split ( "," );

			for ( var i = 0; i < handles.length; i++ ) {

				var result = result.childManager.getObject ( handles [ i ] );

				if ( result == null ) break;
			}

			return result;
		}
	}

	documentManager.childReady = function ( handle ) {

		var object = this.childManager.getObject ( handle );

		for ( var h in this.windows ) {

			var window = this.windows [ h ];

			if
				( window != null )
			{
				if
					( window [ "documentManager" ] == object )
				{
					this.objects [ h ].loaded ( window );
				}
			}
		}
	}

	documentManager.findChild = function ( handle ) {

		var object = this.childManager.getObject ( handle );

		for ( var h in this.windows ) {

			var window = this.windows [ h ];

			if
				( window != null )
			{
				if
					( window [ "documentManager" ] == object )
				{
					return this.objects [ h ];
				}
 			}
		}

		return null;
	}

	documentManager.closeMe = function ( handle ) {

		var object = this.findChild ( handle );

		if ( object != null ) object.close ();

		this.addImperativeTask ( new Function ( "documentManager.resetGlobalFocus();" ) );
	}

	documentManager.move = function ( dx, dy ) {

		if
			( this.parent )
		{
			this.parent.moveMe ( this.handleInParent, dx, dy );
		}
	}

	documentManager.moveMe = function ( handle, dx, dy ) {

		var object = this.findChild ( handle );

		if ( object != null ) object.move ( dx, dy );
	}

	documentManager.size = function ( dx, dy ) {

		if
			( this.parent )
		{
			this.parent.sizeMe ( this.handleInParent, dx, dy );
		}
	}

	documentManager.sizeMe = function ( handle, dx, dy ) {

		var object = this.findChild ( handle );

		if ( object != null ) object.size ( dx, dy );
	}

	documentManager.close = function () {

		if
			( this.parent != null )
		{
			this.parent.closeMe ( this.handleInParent );
		}
	}

	documentManager.getContainer = function () {

		/*
			Returns the *object* (floatingFrameObject) belonging to the outer frame's DM
			which houses this DM's frame- or null if this DM's frame is not a DM
			floating frame.
		*/

		if
			( this.parent != null )
		{
			return this.parent.findChild ( this.handleInParent );
		}

		return null;
	}

	documentManager.getTopContainer = function () {

		/*
			Returns the outer most *object* (floatingFrameObject) in an un-broken chain of
			nested floating frames (as getContainer- but iterates if the container's DM is
			its self contained in an outer floating frame).
			UNTESTED.
		*/

		var result = this.getContainer ();
		var next = result;

		while ( next != null ) {

			next = result.manager.getContainer ();

			if ( next != null ) result = next;
		}

		return result;
	}

	documentManager.nextZIndex = function () {

		if ( this.zIndex == null ) this.zIndex = 10;

		return this.zIndex++;
	}

	documentManager.detatchChild = function ( handle ) {

		this.childManager.removeHandle ( handle );
	}

	documentManager.detatch = function () {

		this.doFunctions ( this.shutdowns );
		this.clearHandlers ();

		if
			( this.parent != null )
		{
			this.parent.detatchChild ( this.handleInParent );

			for ( var h in this.attatchments ) {
				this.interface.detatch ( this.attatchments [ h ] );
			}

			if
				( this.focusObject != null )
			{
				this.setGlobalFocus ( null, null );
			}

			if ( window.disconnectAll !== ( void 0 ) ) {

				disconnectAll ();
			}
		}
	}

	documentManager.doUnload = function () {

		documentManager.detatch ();
	}

	documentManager.doFunctions = function ( list ) {

		for ( var i = 0; i < list.length; i++ ) {

			var transactionFunction = list [ i ];
			var updates = new updateObject ();
			var o = new transactionBaseObject ( updates, this.database );

			o.f = transactionFunction;

			o.f ();

			this.applyChanges ( updates );
		}
	}

	documentManager.start = function ( documentElement ) {

		if ( window.onbeforeunload == this.doUnload ) window.onbeforeunload = null;

		this.hoverObject = null;
		this.selectedObject = null;
		this.focusObject = null;
		
		this.hoverRectangle = null;

		this.documentElement = documentElement.body;
		this.rootObject = this.create ( "container" );

		this.rootObject.start ( this.documentElement );

		this.attatchNewProcesses ();

		with ( documentElement ) {
		
			onclick = this.doClick;
			ondblclick = this.doDoubleClick;
			onmousedown = this.doMouseDown;
			onmousemove = this.doMouseMove;
			onmouseup = this.doMouseUp;
			ondragstart = this.doDragStart;
			onselectstart = this.doSelectStart;

			if
				( document.onkeypress == null )
			{
				onkeypress = this.doKeyPress;
			}

			onkeydown = this.doKeyDown;
			onkeyup = this.doKeyUp;
			onresize = this.doResize;
			onunload = this.doUnload;
		}
		
		if
			( this.parent != null )
		{
			this.parent.childReady ( this.handleInParent );
		}

		this.doFunctions ( this.startups );

		this.ready = true;

		window.onfocus = this.windowGetsFocus;

		if
			( this.rootObject.first == null )
		{
			this.focusStarted = true;
		}
		else
		{
			var bBounceFocus = false;
			var bBodyHasFocus = false;
			var elFocus = document.activeElement;
			if ( elFocus != null ) {
				if ( elFocus.tagName != null ) {
					if ( elFocus.tagName == "BODY" ) {
						bBodyHasFocus = true;
					} else {
						var strHandle = this.getElementHandle ( elFocus );
						if ( strHandle != null ) {
							var object = this.getObject ( strHandle );
							if ( object != null ) {
								if ( object.localFocusElement == elFocus ) {
									bBounceFocus = true;
								}
							}
						}
					}
				}
			}
			if ( bBounceFocus ) {
				window.focus ();
			} else {
				this.focusStarted = true;
				if ( bBodyHasFocus ) {
					document.selection.empty ();
				}
			}
		}

		if ( this.doAfterLoad !== ( void 0 ) ) this.doAfterLoad ();
	}

	documentManager.getVersion = function () { return 1.0 }

	documentManager.getParentManager = function () {

		if
			( parent != self )
		{
			if
				( parent.documentManager != null )
			{
				if
					( parent.documentManager.getVersion != null )
				{
					if
						( parent.documentManager.getVersion () == this.getVersion () )
					{
						return parent.documentManager;
					}
				}
			}
		}
	}
	
	documentManager.registerClass = function ( name, constructor ) {
	
		name = name.toLowerCase ();

		if
			( this.constructors [ name ] != null )
		{
			alert ( "class name " + name + " re-registered." );
		}

		this.constructors [ name ] = constructor;
	}

	documentManager.registerType = function ( name, constructor ) {

		name = name.toLowerCase ();

		if
			( this.types [ name ] != null )
		{
			alert ( "type name " + name + " re-registered." );
		}

		this.types [ name ] = constructor;
	}

	documentManager.getTypeConstructor = function ( name ) {

		return this.types [ name.toLowerCase () ];
	}

	documentManager.manage = function ( object ) {

		var newHandle = this.objects.length;
		this.objects [ newHandle ] = object;
		object.handle = newHandle;
		object.manager = this;

//		alert ( "DM: creating " + newHandle );
	}

	documentManager.create = function ( name ) {
	
		name = name.toLowerCase ();

		var constructor = this.constructors [ name ];
		
		if
			( constructor == null )
		{
			alert ( "class name " + name + " not registered." );
		}
		else
		{
			var object = new constructor ();

			this.manage ( object );

			return object;
		}
		
		return null;
	}

	documentManager.remove = function ( handle ) {

		if
			( this.objects [ handle ] == null )
		{
			alert ( "@@@" );
		}
		else
		{
			var object = this.objects [ handle ];

			// alert ( "DM: removing " + handle );

			if ( object.parent != null ) {

				object.parent.remove ( object );
			}

			if
				( this.focusObject == object )
			{
				this.setGlobalFocus ( this, null );
				object.focus = false;
			}

			if ( this.selectedObject == object ) {
				this.setSelectedObject ( null );
			}

			if ( this.hoverObject == object ) {
				this.hoverObject = null;
				this.updateHover ();
			}
			
			delete this.objects [ handle ];

			if
				( this.windows [ handle ] != null )
			{
				delete this.windows [ handle ];
			}

			if
				( this.attatchments [ handle ] != null )
			{
				this.interface.detatch ( this.attatchments [ handle ] );

				delete this.attatchments [ handle ];
			}
		}
	}
	
	documentManager.removeLater = function ( handle ) {

		this.addTask ( new Function ( "documentManager.remove ( " + handle + " );" ), -2 );
	}

	documentManager.getObject = function ( handle ) {
	
		return this.objects [ handle ];
	}
	
	documentManager.globalUndo = function ( doUndo ) {

		this.getTransactionManager ().fnEndTransaction ();

		if
			( doUndo )
		{
			this.getTransactionManager ().fnUndo ();
		}
		else
		{
			this.getTransactionManager ().fnRedo ();
		}
		
		if
			( this.hoverObject != null )
		{
			this.hoverObject = null;
			this.updateHover ();
		}

		this.getTransactionManager ().fnStartTransaction ();
	}
	
	documentManager.createCallback = function ( object, method, parameter ) {

		return new Function ( "return documentManager.callback ( " + object.handle + ", '" + method + "', '" + parameter + "' )" );
	}

	documentManager.addTask = function ( functionCall, priority ) {

		this.addTaskObject ( { object:functionCall, priority:priority } );
	}

	documentManager.addImperativeTask = function ( functionCall ) {

		this.addTaskObject ( { object:functionCall, imperative:true } );
	}

	documentManager.addTaskObject = function ( taskObject ) {

		if
			( taskObject.priority == null )
		{
			taskObject.priority = 0;
		}
		if
			( taskObject.imperative == null )
		{
			taskObject.imperative = false;
		}

		this.tasks [ this.tasks.length ] = taskObject;
	}

	documentManager.viewUpdated = function () {

		if
			( this.parent != null )
		{
			this.size ();
		}
		else
		{
			documentManager.updateHoverRectangle ();
			documentManager.updateFocusRectangle ();
		}
	}

	documentManager.doTasks = function () {

		if
			( this.tasks.length != 0 )
		{
			var task = null;
			var newTasks = [];
			var tasks = [];
			var pTask = false;
			var maxPriority;

			for ( var i = 0; i < this.tasks.length; i++ ) {

				with ( this.tasks [ i ] ) {

					if
						( ! imperative )
					{
						if ( ! pTask ) {

							pTask = true;
							maxPriority = priority;
						}
						else
						if
							( priority > maxPriority )
						{
							maxPriority = priority;
						}
					}
				}
			}

			for ( var i = 0; i < this.tasks.length; i++ ) {

				var task = this.tasks [ i ];

				if
					( task.imperative )
				{
					tasks [ tasks.length ] = task;
					done = true;
				}
				else
				{
					var done = false;

					if
						( pTask )
					{
						if
							( task.priority == maxPriority )
						{
							pTask = false;
							tasks [ tasks.length ] = task;
							done = true;
						}
					}

					if
						( ! done )
					{
						newTasks [ newTasks.length ] = task;
					}
				}
			}

			this.tasks = newTasks;

			for ( var i = 0; i < tasks.length; i++ ) {

				var task = tasks [ i ];
				var result;

				if
					( task.method == null )
				{
					result = task.object ();
				}
				else
				{
					result = task.object [ task.method ] ( task.parameter );
				}

				if
					( result == "repeat" )
				{
					this.addTaskObject ( task );
				}
			}
		}

		if
			( this.parent == null )
		{
			this.interface.notifyChanges ();
		}

		if
			( this.timeOut != null )
		{
			if
				( ( ( new Date () ).getTime () - this.lastTime ) > this.timeOut )
			{
				this.timeOut = null;

				if
					( this.onTimeOut != null )
				{
					this.onTimeOut ();
				}
			}
		}
	}

	documentManager.setIsLegendEditor = function () {
		this.bIsLegendEditor = true;
	}
	documentManager.getIsLegendEditor = function () {
		return this.bIsLegendEditor == true;
	}
	documentManager.setOnTimeOut = function ( action, seconds ) {
		this.lastTimeOutHandler = action;
		this.doSetOnTimeOut ( action, seconds, false );
	}
	documentManager.setOnActivity = function ( action ) {
		this.lastActivityHandler = action;
		this.doSetOnActivity ( action, false );
	}
	documentManager.clearHandlers = function () {
		this.doSetOnTimeOut ( this.lastTimeOutHandler, 0, true );
		this.doSetOnActivity ( this.lastActivityHandler, true );
	}
	documentManager.doSetOnTimeOut = function ( action, seconds, bRemove ) {
		if ( this.parent != null ) {
			if ( ! this.parent.getIsLegendEditor () ) {
				this.parent.doSetOnTimeOut ( action, seconds, bRemove );
				return;
			}
		}
		if ( bRemove ) {
			if ( this.onTimeOut == action ) {
				this.timeOut = null;
				this.onTimeOut = null;
			}
		} else {
			if
				( ( seconds != null ) && ( action != null ) )
			{
				this.lastTime = new Date ();
				this.timeOut = seconds * 1000;
				this.onTimeOut = action;
			}
			else
			{
				this.timeOut = null;
				this.onTimeOut = null;
			}
		}
	}
	documentManager.doSetOnActivity = function ( action, bRemove ) {
		if ( this.parent != null ) {
			if ( ! this.parent.getIsLegendEditor () ) {
				this.parent.doSetOnActivity ( action, bRemove );
				return;
			}
		}
		if ( bRemove ) {
			if ( action == this.onActivity ) {
				this.onActivity = null;
			}
		} else {
			if
				( action == null )
			{
				this.onActivity = null;
			}
			else
			if
				( this.onActivity == null )
			{
				this.onActivity = action;
			}
		}
	}

	/*
		setNamedItem and removeNamedItem set and unset a 'local' value
		for a given arbitary named item.
		getNamedItemsGlobal returns a LIST of all such item values (with the
		specified name) that are currently set by any DMs across the entire frame
		hierarchy (from the root down).
		See other parts of the DM for internal use of 'named items'
	*/

	documentManager.setNamedItem = function ( name, item ) {

		if ( this.localItems == null ) this.localItems = {};

		this.localItems [ name ] = item;
	}

	documentManager.removeNamedItem = function ( name ) {

		if ( this.localItems != null ) {
		
			delete this.localItems [ name ];
		}
	}

	documentManager.getNamedItemsRecursive = function ( name ) {

		result = [];

		if ( this.localItems != null ) {

			var value = this.localItems [ name ];

			if ( value != null ) result [ result.length ] = value;
		}

		for ( var h in this.childManager.objects ) {

			result = result.concat ( this.childManager.objects [ h ].getNamedItemsRecursive ( name ) );
		}

		return result;
	}

	documentManager.getNamedItemsGlobal = function ( name ) {

		if ( this.parent != null ) {

			return this.parent.getNamedItemsGlobal ( name );
		}

		return this.getNamedItemsRecursive ( name );
	}

	documentManager.setTimer = function () {

		var time = 100;

		if ( this.tasks.length != 0 ) time = 10;

		if ( this.timer != null ) delete this.timer;

		this.timer = window.setTimeout ( "documentManager.doTimer ()", time );
	}
	
	documentManager.doTimer = function () {

		this.doTasks ();
		this.setTimer ();
	}

	documentManager.applyChanges = function ( updates ) {

		this.interface.syncUpdate ( updates );
	}

	documentManager.registerFieldProperties = function ( fieldName, properties ) {

		var update = new updateObject ();

		update.write ( fieldName, "checked", false );
		update.write ( fieldName, "edit", false );
		update.write ( fieldName,"changed", false );

		if
			( properties != null )
		{
			for ( var propertyName in properties ) {
			
				update.write ( fieldName, propertyName, properties [ propertyName ] );
			}
		}

		this.interface.syncUpdate ( update );
	}

	documentManager.makeTypeObjectForElement = function ( element, fieldName ) {

		var parameters = null;
		var objectLiteral = element.getAttribute ( this.attributePrefix + "TypeMap" );

		if
			( ( objectLiteral != null ) && ( objectLiteral != "" ) )
		{
			eval ( "parameters = " + objectLiteral + ";" ); 
		}

		if
			( parameters != null )
		{
			var type = parameters [ "Type" ];

			if
				( type == null )
			{
				type = parameters [ "type" ];
			}
		}
		else
		{
			type = element.getAttribute ( this.attributePrefix + "Type" );
		}

		if
			( type == null )
		{
			type = "default";
		}

		var constructor = this.getTypeConstructor ( type );

		if
			( constructor == null )
		{
			alert ( "Standard type '" + type + "' not known" );
		}
		else
		{
			var validator = new constructor ();

			if ( type != "default" ) {

				var list = this.getFieldsByType ( type );

				list [ list.length ] = fieldName;
			}

			if
				( parameters != null )
			{
				for ( var pName in parameters ) {

					validator.parameters [ pName ] = parameters [ pName ];
				}
			}

			for ( var pName in validator.parameters ) {

				var value = element.getAttribute ( this.attributePrefix + pName );

				if
					( value != null )
				{
					validator.parameters [ pName ] = value;
				}
			}

			return validator;
		}

		return null;
	}

	documentManager.registerFieldType = function ( fieldName, element ) {

		var validator = this.makeTypeObjectForElement ( element, fieldName );

		if
			( validator != null )
		{
			validator.fieldName = fieldName;

			validator.initialise ();

			this.attatch ( validator, true );
		}
	}

	documentManager.getFieldsByType = function ( type ) {

		if ( this.parent ) {

			return this.parent.getFieldsByType ( type );
		}
		else
		{
			var key = type.toString ().toLowerCase ();

			if ( this.typeToField == null ) this.typeToField = {};

			if ( this.typeToField [ key ] == null ) this.typeToField [ key ] = [];

			return this.typeToField [ key ];
		}
	}

	documentManager.getBestFieldOfTypes = function ( types ) {

		var list = [];

		for ( var i = 0; i < types.length; i++ ) {

			var type = types [ i ];

			list = list.concat ( this.getFieldsByType ( type ) );
		}

		if
			( list.length == 0 )
		{
			return null;
		}
		else
		if
			( list.length > 1 )
		{
			var focusObject = this.getGlobalFocus ();

			if ( focusObject != null ) {

				if ( focusObject.fieldName != null ) {

					for ( var i = 0; i < list.length; i++ ) {

						if ( list [ i ] == focusObject.fieldName ) {

							return list [ i ];
						}
					}
				}
			}
		}

		return list [ 0 ];
	}

	documentManager.attatch = function ( object, readWrite ) {

		if
			( object.handle == null )
		{
			this.manage ( object );
		}

		this.interface.attatch ( object, readWrite );

		this.attatchments [ object.handle ] = object;
	}

	documentManager.attatchNewProcesses = function () {

		for ( var i = 0; i < this.newProcesses.length; i++ ) {

			this.attatch ( this.newProcesses [ i ].object, this.newProcesses [ i ].readWrite );
		}

		this.newProcesses = new Array ();
	}

	documentManager.addNewProcessObject = function ( processObject, readWrite ) {

		var i = this.newProcesses.length;

		this.newProcesses [ i ] = { object:processObject, readWrite:readWrite };
	}

	documentManager.addNewProcess = function ( processFunction, readWrite ) {

		var processObject = new processBaseObject ();

		processObject.notifyChange = processFunction;

		this.addNewProcessObject ( processObject, readWrite );
	}

	documentManager.addRule = function ( ruleFunction ) {
	
		this.addNewProcess ( ruleFunction, true );
	}
	
	documentManager.addWatch = function ( watchFunction ) {
	
		this.addNewProcess ( watchFunction, false );
	}

	documentManager.addStartup = function ( f ) {

		this.startups [ this.startups.length ] = f;
	}

    /***
        add's a function to be called when the document is resized.
    ***/

    documentManager.addOnResize = function ( f ) {

        this.onresizes [ this.onresizes.length ] = f;
    }

	documentManager.addShutdown = function ( f ) {

		/*
			Functions to be called when this window is unloaded.
		*/

		this.shutdowns [ this.shutdowns.length ] = f;
	}

	documentManager.apply = function ( transactionFunction ) {

		var updates = new updateObject ();
		var o = new transactionBaseObject ( updates, this.database );

		o.f = transactionFunction;

		o.f ();

		this.applyChanges ( updates );
	}

	documentManager.focusOnFirstEditableControlElement = function () {

		var o = this.rootObject.getFirstEditableControl ();

		if ( o != null ) {

			o.pluginElement.focus();
		}
	}

	documentManager.focusOnAndSelectFirstEditableControlElement = function () {

		var o = this.rootObject.getFirstEditableControl ();

		if ( o != null ) {

			o.pluginElement.focus();

			if ( o.pluginElement.select != null ) {

				o.pluginElement.select();
			}
		}
	}

	documentManager.windowGetsFocus = function () {
	}
	
	documentManager.controlGetsFocus = function ( handle ) {

		if
			( this.ready )
		{
			var object = this.getObject ( handle );

			this.focusStarted = true;

			this.setGlobalFocus ( this, object );
		}
	}
	
	documentManager.controlLoosesFocus = function ( handle ) {

		if
			( this.ready )
		{
			if
				( ! this.focusStarted )
			{
				var object = this.getObject ( handle );

				this.focusStarted = true;

				if
					( object.localFocusElement != null )
				{
					object.localFocusElement.focus ();
				}
			}
		}
	}

	documentManager.callback = function ( handle, method, parameter ) {
	
		var object = this.getObject ( handle );
		
		if
			( object != null )
		{
			var result = object [ method ] ( parameter );
			
			return result;
		}
		
		return false;
	}

	documentManager.activity = function () {
		if ( this.parent != null ) {
			if ( ! this.parent.getIsLegendEditor () ) {
				this.parent.activity ();
				return;
			}
		}

		if
			( this.onActivity != null )
		{
			var a = this.onActivity;

			this.onActivity = null;

			a ();
		}
	}

	documentManager.setGlobalFocus = function ( manager, object ) {

		if
			( this.parent != null )
		{	
			this.parent.setGlobalFocus ( manager, object );
		}
		else
		{ 

			if
				( this.globalFocusManager != manager )
			{
				if
					( this.globalFocusManager != null )
				{
					this.globalFocusManager.setFocus ( null );
				}
			}

			this.globalFocusManager = manager;

			if
				( this.globalFocusManager != null )
			{
				this.globalFocusManager.setFocus ( object );
			}
		}
	}

	documentManager.resetGlobalFocus = function () {

		if
			( this.parent != null )
		{	
			this.parent.resetGlobalFocus ();
		}
		else
		{
			if
				( this.globalFocusManager )
			{
				if
					( this.globalFocusManager.focusObject != null )
				{
					var o = this.globalFocusManager.focusObject;
					var boolFail = false;

					o.setFocus ( false );

					if ( o.callControlFocus ) {
						boolFail = ! o.callControlFocus ();
					}

					if ( boolFail ) {
						this.setGlobalFocus ( null, null );
					} else {
						o.setFocus ( true );
					}
				}
			}
		}
	}

	documentManager.getGlobalFocus = function () {

		if
			( this.parent != null )
		{	
			return this.parent.getGlobalFocus ();
		}
		else
		{
			if
				( this.globalFocusManager )
			{
				return this.globalFocusManager.focusObject;
			}
		}

		return null;
	}

	documentManager.setGlobalFocusUndo = function () {

		if
			( this.parent != null )
		{	
			this.parent.setGlobalFocusUndo ();
		}
		else
		{
			if
				( this.globalFocusManager != null )
			{
				this.globalFocusManager.setFocusUndo ();
				this.globalFocusManager = null;
			}
		}
	}

	documentManager.setFocusUndo = function () {

		if
			( this.focusObject != null )
		{
			if
				( this.focusObject.editable )
			{
				this.database.write ( this.focusObject.fieldName, "edit", false );
			}

			this.focusObject.setFocus ( false );

			if
				( this.focusObject.showFocus )
			{
				this.hideFocus ();
			}

			this.focusObject = null;

			window.focus ();
		}
	}

	documentManager.setFocus = function ( object ) {

		if
			( this.focusObject != object )
		{
			var clearOld = false;

			if
				( this.focusObject != null )
			{
				this.focusObject.setFocus ( false );
				
				if
					( this.focusObject.editable )
				{
					var update = new updateObject ();
					
					update.write ( this.focusObject.fieldName, "edit", false );
					
					if
						(
							( this.database.read ( this.focusObject.fieldName, "value" ) != this.oldFocusValue ) ||
							( this.database.read ( this.focusObject.fieldName, "valid" ) != this.oldFocusValid )
						)
					{
						update.write ( this.focusObject.fieldName, "checked", false );
						update.write ( this.focusObject.fieldName, "changed", true );
					}

					this.interface.syncUpdate ( update );
				}

				clearOld = this.focusObject.showFocus;
			}

			this.getTransactionManager ().fnEndTransaction ();
			this.getTransactionManager ().fnStartTransaction ();

			this.focusObject = object;

			this.oldFocusValue = null;
			this.oldFocusValid = null;

			if
				( this.focusObject != null )
			{
				this.focusObject.setFocus ( true );
				
				if
					( this.focusObject.editable )
				{
					var update = new updateObject ();
					
					update.write ( this.focusObject.fieldName, "edit", true );
			
					this.interface.syncUpdate ( update );

					this.oldFocusValue = this.database.read ( this.focusObject.fieldName, "value" );
					this.oldFocusValid = this.database.read ( this.focusObject.fieldName, "valid" );
				}

				if
					( this.focusObject.showFocus )
				{
					this.updateFocus ();
				}
				else
				if
					( clearOld )
				{
					this.hideFocus ();
				}
			}
			else
			{
				var obError = null;
				if
					( clearOld )
				{
					this.hideFocus ();
				}
				try {
					this.documentElement.document.selection.empty ();
				}
				catch ( obError ) {
				}
			}
		}
	}

	documentManager.scanChildren = function ( element ) {

		var coll = element.children;
			
		if
			( coll != null )
		{
			var l = coll.length;
				
			if
				( l >= 1 )
			{
				for ( var i = 0; i < l; i++ ) {
					
					var e = coll [ i ];
					var handle = e.getAttribute ( "objectHandle" );
						
					if
						( handle != null )
					{
						this.objects [ handle ].element = e;
					}
					
					this.scanChildren ( e )
				}
			}
		}
	}

	documentManager.allBoundObjects = function ( element ) {

		var result = [];

		if ( element.children != null ) {

			for ( var i = 0; i < element.children.length; i++ ) {

				var e = element.children [ i ];
				var handle = e.getAttribute ( "objectHandle" );

				if ( handle != null ) {

					var o = this.objects [ handle ];

					if ( o != null ) {

						result [ result.length ] = o;
					}
				}
				else
				{
					result = result.concat ( this.allBoundObjects ( e ) );
				}
			}
		}

		return result;
	}

	documentManager.bindChildElements = function ( element ) {

		var e = element;

		while ( e != null ) {

			var handle = e.getAttribute ( "objectHandle" );

			if ( handle != null ) {

				var o = this.objects [ handle ];

				if ( o != null ) {

					if ( o.traverseChildren != null ) {

						o.traverseChildren ( element );

						return;
					}
				}
			}

			e = e.parentElement;
		}
	}

	documentManager.removeChildElements = function ( element ) {
		var arrayObs = this.allBoundObjects ( element );
		for ( var numIndex = 0; numIndex < arrayObs.length; numIndex++ ) {
			this.remove ( arrayObs [ numIndex ].handle );
		}
	}

	documentManager.findControls = function ( element ) {
	
		var result = new Array ();

		if
			( element.focus != null )
		{
			if
				( element.value != null )
			{
				result [ 0 ] = element;

				return result;
			}
		}

		var coll = element.children;
			
		if
			( coll != null )
		{
			for ( var i = 0; i < coll.length; i++ ) {
					
				var e = coll [ i ];

				result = result.concat ( this.findControls ( e ) );
			}
		}
		
		return result;
	}
	
	documentManager.findName = function ( element ) {

		var name = element.getAttribute ( this.attributePrefix + "Name" );

		if
			( name == null )
		{
			name = element.getAttribute ( "name" );
		}

		if
			( name != null )
		{
			return name;
		}

		var coll = element.children;
			
		if
			( coll != null )
		{
			for ( var i = 0; i < coll.length; i++ ) {
					
				var e = coll [ i ];

				name = this.findName ( e );

				if
					( name != null )
				{
					return name;
				}
			}
		}
		
		return null;
	}

	documentManager.getElementHandle = function ( element ) {

		while
			( element != null )
		{
			var handle = element.objectHandle;
			
			if
				( handle != null )
			{
				return handle;
			}

			element = element.parentElement;
		}
		
		return null;
	}
	
	documentManager.doClick = function () {

	}

	documentManager.doDoubleClick = function () {
		var object = documentManager.getObject ( documentManager.getElementHandle ( event.srcElement ) );		
		if ( object != null ) {
			if ( object.onDoubleClick != null ) {
					object.onDoubleClick ();			
			}
		}
	}
	
	documentManager.onKeyDown = function () {
	
		var code = event.keyCode;

		if
			( code == 38 )
		{
			// Up arrow
		}
		else
		if
			( code == 40 )
		{
			// Down arrow
		}
		else
		if
			( code == 37 )
		{
			// Left arrow
		}
		else
		if
			( code == 39 )
		{
			// Right arrow
		}
		else
		if
			( code == 9 )
		{
			// Tab key
		}
		
		return false;
	}

	documentManager.doKeyDown = function () {
		
		documentManager.activity ();

		var handled = false;

		var code = event.keyCode;

		documentManager.controlToggle = ( code == 17 );

		if
			( event.ctrlKey )
		{
			if ( code == 221 ) // If Ctrl-] then set controlToggle to enable popup using keyboard scanner
			{
				documentManager.controlToggle = true; 
			}
			else
			if ( code == 222 ) // If Ctrl-| then set commandToggle to enable next key is command using keyboard scanner
			{
				documentManager.commandToggle = true; 
			}
			else
			if
				( ( code == 89 ) || ( code == 90 ) )
			{
				var undo = ( code == 90 );
				if ( documentManager.focusObject != null ) {
					if ( documentManager.focusObject.bRetainFocusOnUndo != true ) {
						documentManager.setGlobalFocusUndo ();
					}
				}
				documentManager.addTask ( new Function ( "documentManager.globalUndo ( " + undo + ");" ) );
				handled = true;
			}
		}

		if
			( ! handled )
		{
			if
				( documentManager.focusObject != null )
			{
				if
					( documentManager.focusObject.onKeyDown != null )
				{
					handled = documentManager.focusObject.onKeyDown ();
				}
			}
		}

		if
			( ! handled )
		{
			if
				( documentManager.selectedObject != null )
			{
				if
					( documentManager.selectedObject.onKeyDown != null )
				{
					handled = documentManager.selectedObject.onKeyDown ();
				}
			}
		}

		if
			( ! handled )
		{
			handled = documentManager.onKeyDown ();

			if
				( ! handled )
			{
				// Sink backspace- the default is to make the browser go-back...

				if
					( code == 8 )
				{
					if ( browserVersion < 5 ) {

						handled = true;

						if
							( documentManager.focusObject != null )
						{
							if
								( documentManager.focusObject.editable || documentManager.focusObject.allowBackSpace )
							{
								handled = false;
							}
						}
					}
					else
					{
						if
							( documentManager.focusObject != null )
						{
							handled = true;

							if
								( documentManager.focusObject.editable || documentManager.focusObject.allowBackSpace )
							{
								handled = false;
							}
						}
					}
				}
			}
		}

		

		if
			( handled )
		{
			//event.keyCode = 0;
			event.cancelBubble = true;
			return false;
		}
		
		return true;
	}

	/*
		If any DM uses setNamedItem to set "keyPressHandler"
		to a function then that function will be called when ever a keyPress event
		occurs in ANY DM (the function is passed a key code and returns a Boolean
		which if true implies that the function handled the keyPress- otherwise
		the keyPress is handled in the default way by the DM in which the event
		occurred). This mechanism allows one or more DMs (a character picker, for
		example) to intercept and optionally handle keyPress events occurring in
		ALL DM controlled frames.
	*/

	documentManager.doKeyPress = function () {

		if
			( this.oldOnKeyPress != null )
		{
			this.oldOnKeyPress ();
		}
		else
		{
			var code = event.keyCode;
			var handlers = documentManager.getNamedItemsGlobal ( "keyPressHandler" );
			var handled = false;

			for ( var i = 0; i < handlers.length; i++ ) {

				handled = handlers [ i ] ( code );

				if ( handled ) break;
			}

			if ( ! handled ) {

				if
					( ( code == 26 ) || ( code == 25 ) )
				{
					// Sink ctrl-y and ctrl-z...

					event.keyCode = 0;
					return;
				}

				if ( documentManager.commandToggle )
				{
					// Sink command character
					if ( code == 28 ) // Ctrl-|
					{
						event.keyCode = 0;
						return;
					}
					// Handle commands
						var w = findChildWindowWithProperty( window, "InterpretBarCode" );
						if ( w != null )
						{
							switch ( code )
							{
								case 65:	// Command A
										w.InterpretBarCode( "AAF" );
									break;
								case 66:	// Command B
										w.InterpretBarCode( "CAN" );
									break;
								case 67:	// Command C
										w.InterpretBarCode( "CON" );
									break;
								case 68:	// Command D
										w.InterpretBarCode( "DEF" );
									break;
								case 69:	// Command E
										w.InterpretBarCode( "DEA" );
									break;
								case 70:
										w.InterpretBarCode( "ENT" );
									break;
								case 71:
										w.InterpretBarCode( "FIN" );
									break;
								case 72:
										w.InterpretBarCode( "ISS" );
									break;
								case 73:
										w.InterpretBarCode( "PEA" );
									break;
								case 74:
										w.InterpretBarCode( "PEB" );
									break;
								case 75:
										w.InterpretBarCode( "PEC" );
									break;
								case 76:
										w.InterpretBarCode( "PED" );
									break;
								case 77:
										w.InterpretBarCode( "PEE" );
									break;
								case 78:
										w.InterpretBarCode( "NET" );
									break;
								case 79:
										w.InterpretBarCode( "PAY" );
									break;
								case 80:
										w.InterpretBarCode( "PYA" );
									break;
								case 81:
										w.InterpretBarCode( "PYI" );
									break;
								case 82:
										w.InterpretBarCode( "REF" );
									break;
								case 83:
										w.InterpretBarCode( "REN" );
									break;
								case 84:
										w.InterpretBarCode( "RET" );
									break;
								case 85:
										w.InterpretBarCode( "SLP" );
									break;
								case 86:
										w.InterpretBarCode( "STO" );
									break;
								case 87:
										w.InterpretBarCode( "VTR" );
									break;
								case 88:
										w.InterpretBarCode( "WAI" );
									break;
								case 89:
										w.InterpretBarCode( "WRO" );
									break;
							}
						}
						else
						{
							alert("Script not found")
						}

					// If the command wasn't handled the command character is thrown away
					event.keyCode = 0;
					documentManager.commandToggle = false;
					return;
				}


				if
					( documentManager.focusObject != null )
				{
					if
						( documentManager.focusObject.onKeyPress != null )
					{
						handled = documentManager.focusObject.onKeyPress ();
					}
				}
				
				if
					( ! handled )
				{
					if
						( code == 13 )
					{
						// Sink enter...

						// handled = true;
					}

					if
						( code == 27 )
					{
						// Sink escape...

						handled = true;
					}
				}
			}

			if
				( handled )
			{
				event.keyCode = 0;
				event.cancelBubble = true;
				return false;
			}
		}
	}
	
	documentManager.doKeyUp = function () {

		var handled = false;
	
		var code = event.keyCode;

		if ( code == 17 ) {

			if ( documentManager.controlToggle ) {

				var m = documentManager;

				while ( m != null ) {

					var f = m.documentElement.document.parentWindow.launchGlobalMenu;

					if ( f != null ) {

						m = null;

						f ();
					}
					else
					{
						m = m.parent;
					}
				}
			}

			documentManager.controlToggle = false;
		}

		if
			( ! handled )
		{
			if
				( documentManager.focusObject != null )
			{
				if
					( documentManager.focusObject.onKeyUp != null )
				{
					handled = documentManager.focusObject.onKeyUp ();
				}
			}
		}
	}

	documentManager.setSelectedObject = function ( object ) {
		if ( this.selectedObject != object ) {
			if ( this.selectedObject != null ) {
				if ( this.selectedObject.hoverOut != null ) {
					if ( this.selectedObject != this.hoverObject ) {
						this.selectedObject.hoverOut ();
					}
				}
			}
			this.selectedObject = object;
			if ( this.selectedObject != null ) {
				if ( this.selectedObject.hoverIn != null ) {
					if ( this.selectedObject != this.hoverObject ) {
						this.selectedObject.hoverIn ();
					}
				}
			}
		}
		this.setHoverObject ( object );
	}

	documentManager.setHoverObject = function ( object ) {
		if ( this.hoverObject != object ) {
			var clearOld = false;
			if ( this.hoverObject != null ) {
				if ( this.hoverObject.hoverOut != null ) {
					if ( this.hoverObject != this.selectedObject ) {
						this.hoverObject.hoverOut ();
					}
				}
				clearOld = this.hoverObject.showHover;
			}
			this.hoverObject = object;
			if ( this.hoverObject != null ) {
				if ( this.hoverObject.hoverIn != null ) {
					if ( this.hoverObject != this.selectedObject ) {
						this.hoverObject.hoverIn ();
					}
				}
				if ( this.hoverObject.showHover ) {
					this.updateHover ();
				} else if ( clearOld ) {
					this.hideHover ();
				}
			} else if ( clearOld ) {
				this.hideHover ();
			}
		}
	}

	documentManager.doHover = function ( element ) {
		var object = this.getObject ( this.getElementHandle ( element ) );
		this.setHoverObject ( object );
		if ( object != null ) {
			if ( object.selectable != null ) {
				if ( object.selectable () ) {
					this.setSelectedObject ( object );
				}
			}
		}
	}

	documentManager.updateHoverRectangle = function () {
		if
			( this.hoverRectangle )
		{
			this.hoverRectangle.fnUpdate ();
		}
	}

	documentManager.hideHover = function () {
		if
			( this.hoverRectangle != null )
		{
			this.hoverRectangle.fnHide ();
		}

		this.updateHoverRectangle ();
	}

	documentManager.updateHover = function () {

		var object = this.hoverObject;
		var show = false;

		if
			( object != null )
		{
			show = object.showHover;
		}

		if
			( show )
		{
			var element = object.outerElement;

			if ( object.showFocusElement != null ) element = object.showFocusElement;

			if
				( this.hoverRectangle == null )
			{
				this.hoverRectangle = new cHighlightRectangle ( "hover" );
				this.hoverRectangle.fnSetThickness ( 2 );
				this.hoverRectangle.fnSetColor ( "bisque" );
			}

			this.hoverRectangle.fnSetElement ( element );
			this.hoverRectangle.fnShow ();
		}
		else
		{
			if
				( this.hoverRectangle != null )
			{
				this.hoverRectangle.fnHide ();
			}
		}

		this.addTaskObject ( { object:this, method:"updateHoverRectangle", priority:1 } );
	}

	documentManager.updateFocusRectangle = function () {

		if
			( this.focusRectangle )
		{
			this.focusRectangle.fnUpdate ();
		}
	}

	documentManager.hideFocus = function () {

		if
			( this.focusRectangle != null )
		{
			this.focusRectangle.fnHide ();
		}
	}

	documentManager.updateFocus = function () {

		var object = this.focusObject;
		var show = false;

		if
			( object != null )
		{
			show = object.showFocus;
		}

		if
			( show )
		{
			var advice = this.focusObject.advice;
			var element = object.outerElement;

			if ( advice == null ) advice = "";

			if
				( advice != "" )
			{
				advice = this.translateAdvice ( advice );
			}

			if ( object.showFocusElement != null ) element = object.showFocusElement;

			if
				( this.focusRectangle == null )
			{
				this.focusRectangle = new cHighlightRectangle ( "focus" );
				this.focusRectangle.fnSetThickness ( 3 );
			}

			this.focusRectangle.fnSetElement ( element );
			this.focusRectangle.fnSetAdvice ( advice );
			this.focusRectangle.fnShow ();

			if ( advice != "" ) {
				this.focusRectangle.fnSetAdvicePosition ( object.getInheritedAttribute ( this.attributePrefix + "AdvicePosition" ) );
			}
		}
		else
		{
			if
				( this.focusRectangle != null )
			{
				this.focusRectangle.fnHide ();
			}
		}
	}

	function cHighlightRectangle ( strName ) {
		this.elOwner = null;
		this.arrayBits = null;
		this.numThickness = 3;
		this.strAdvice = "";
		this.strColor = "darkorange";
		this.strName = strName;
	}
	with ( cHighlightRectangle ) {
		prototype.fnCreateBits = function ( el ) {
			var elParent = el.parentElement;
			if ( this.arrayBits != null ) {
				for ( var i = 0; i < this.arrayBits.length; i++ ) {
					var elBit = this.arrayBits [ i ];
					if ( elBit.parentElement != null ) {
						elBit.style.display = "none";
					}
				}
			}
			this.arrayBits = [];
			var elPrev = el.previousSibling;
			while ( elPrev != null ) {
				if ( elPrev.strRectName != null ) {
					if ( elPrev.strRectName == this.strName ) {
						this.arrayBits [ this.arrayBits.length ] = elPrev;
					}
					elPrev = elPrev.previousSibling;
				} else {
					break;
				}
			}
			if ( this.arrayBits.length != 0 ) {
				this.arrayBits.reverse ();
				this.arrayBits [ 5 ].style.visibility = "hidden";
			} else {
				for ( var i = 0; i < 6 ; i++ ) {
					var elBit = document.createElement ( "div" );
					elParent.insertBefore ( elBit, el );
					elBit.strRectName = this.strName;
					this.arrayBits [ i ] = elBit;
				}
			}
			for ( var i = 0; i < 6 ; i++ ) {
				var elBit = this.arrayBits [ i ];
				elBit.style.position = "absolute";
				elBit.style.display = "none";
				elBit.style.width = 0;
				elBit.style.height = 0;
				if ( i == 4 ) {
					elBit.className = "advice-style";
				} else {
					elBit.style.fontSize = "0pt";
					if ( i == 5 ) {
						elBit.style.visibility = "hidden";
					}
				}
			}
			this.elOwner = el;
			this.bHidden = true;
		}
		prototype.fnPingUpdate = function () {
			this.bWaiting = false;
			if ( this.elWaiting != this.elOwner ) {
				this.bSecond = false;
			}
			this.fnUpdate ();
		}
		prototype.fnUpdate = function () {
			if ( this.elOwner != null ) {
				if ( this.elOwner.parentElement != null ) {
					var elAdvice = this.arrayBits [ 4 ];
					if ( this.strAdvice == "" ) {
						elAdvice.style.display = "none";
					}
					if ( ( ! this.bHidden ) && ( ! this.bWaiting ) ) {
						var elB = this.arrayBits [ 5 ];
						var obRect = this.elOwner.getBoundingClientRect ();
						var numWidth = obRect.right - obRect.left;
						var numHeight = obRect.bottom - obRect.top;
						var numT = this.numThickness;
						if ( ! this.bSecond ) {
							elB.style.left = obRect.left;
							elB.style.top = obRect.top;
						}
						if ( browserVersion < 5.5 ) {
							if ( ! this.bSecond ) {
								this.bSecond = true;
								this.bWaiting = true;
								this.elWaiting = this.elOwner;
								documentManager.addTaskObject ( { object:this, method:"fnPingUpdate", imperative:true } );
								return;
							} else {
								this.bSecond = false;
							}
						}
						var obRectB = elB.getBoundingClientRect ();
						var numOffsetLeft = obRectB.left - obRect.left;
						var numOffsetTop = obRectB.top - obRect.top;
						var numLeft = obRect.left - numOffsetLeft;
						var numTop = obRect.top - numOffsetTop;

						with ( this.arrayBits [ 0 ].style ) {
							top = numTop - numT - 1;
							left = numLeft - numT - 1;
							width = numWidth + ( numT + 1 ) * 2;
							height = numT;
							backgroundColor = this.strColor;
						}
						with ( this.arrayBits [ 1 ].style ) {
							top = numTop - 1;
							left = numLeft - numT - 1;
							width = numT;
							height = numHeight + 2;
							backgroundColor = this.strColor;
						}
						with ( this.arrayBits [ 2 ].style ) {
							top = numTop + numHeight + 1;
							left = numLeft - numT - 1;
							width = numWidth + ( numT + 1 ) * 2;
							height = numT;
							backgroundColor = this.strColor;
						}
						with ( this.arrayBits [ 3 ].style ) {
							top = numTop - 1;
							left = numLeft + numWidth + 1;
							width = numT;
							height = numHeight + 2;
							backgroundColor = this.strColor;
						}
						if ( this.strAdvice != "" ) {
							with ( elAdvice.style ) {
								if ( this.strAdvicePosition == "below" ) {

									left = numLeft - 4;
									top = numTop + numHeight + 5;
								}
								else if ( this.strAdvicePosition == "belowFlushRight" )
								{
									left = numLeft + numWidth - 95;
									top = numTop + numHeight + 5;
									textAlign = "center";
								}
								else
								{
									left = numLeft + numWidth + 10;
									top = numTop - numT
								}
								width = 100;
								height = 20;
								elAdvice.innerText = this.strAdvice;
								this.arrayBits [ 4 ].style.display = "block";
							}
							elAdvice.style.display = "block";
						}
					}
				}
			}
		}
		prototype.fnSetElement = function ( el ) {
			if ( this.elOwner != el ) {
				this.fnCreateBits ( el );
				this.elWaiting = null;
			}
		}
		prototype.fnSetDisplay = function ( strDisplay ) {
			for ( var i = 0; i < 6; i++ ) {
				var el = this.arrayBits [ i ];
				el.style.display = strDisplay;
			}
		}
		prototype.fnHide = function () {
			if ( ! this.bHidden ) {
				this.bHidden = true;
				if ( this.elOwner != null ) {
					this.fnSetDisplay ( "none" );
				}
			}
		}
		prototype.fnShow = function () {
			if ( this.bHidden ) {
				this.bHidden = false;
				if ( this.elOwner != null ) {
					if ( this.elOwner.parentElement != null ) {
						this.fnSetDisplay ( "block" );
						this.fnUpdate ();
					}
				}
			}
		}
		prototype.fnSetAdvice = function ( strAdvice ) {
			if ( strAdvice != this.strAdvice ) {
				this.strAdvice = strAdvice;
				this.fnUpdate ();
			}
		}
		prototype.fnSetAdvicePosition = function ( strPosition ) {
			this.strAdvicePosition = strPosition;
			this.fnUpdate ();
		}
		prototype.fnSetThickness = function ( numThickness ) {
			this.numThickness = numThickness;
			this.fnUpdate ();
		}
		prototype.fnSetColor = function ( strColor ) {
			this.strColor = strColor;
			this.fnUpdate ();
		}
	}

	documentManager.getAbsoluteBodyOffset = function ( element ) {
		var obRects = element.getBoundingClientRect();
		var obBody = document.body;
		var numX = ( obRects.left ) + document.body.scrollLeft;
		var numY = ( obRects.top ) + document.body.scrollTop;
		numX -= element.document.body.clientLeft;
		numY -= element.document.body.clientTop;
		return { x:numX, y:numY };
	}
	
	documentManager.getOffset = function ( reference, element ) {

		var x = 0;
		var y = 0;
		var p = element;

		while
			( ( p != reference.offsetParent ) && ( p != null ) )
		{
			x += p.offsetLeft;
			y += p.offsetTop;

			if
				( p.scrollTop != null )
			{
				y -= p.scrollTop;
			}
			if
				( p.scrollLeft != null )
			{
				x -= p.scrollLeft;
			}

			p = p.offsetParent;
		}
		
		return { x:x, y:y };
	}

	documentManager.scrollIntoView = function ( element ) {

		var parent = element.offsetParent;
		var height = element.offsetHeight;

		var y = 0;

		while ( parent != null ) {

			y += element.offsetTop;

			var top = parent.scrollTop;
			var bottom = top + parent.offsetHeight;
			var done = false;

			if ( height > parent.offsetHeight ) {

				if ( ( ( y + height ) > top ) && ( y < bottom ) ) return;
			}

			if
				( ( y + height ) > bottom )
			{
				var delta = ( ( y + height ) - bottom );

				parent.scrollTop += delta;

				top = parent.scrollTop;
				bottom = top + parent.offsetHeight;

				done = true;
			}

			if
				( y < top )
			{
				parent.scrollTop -= ( top - y );

				done = true;
			}

			if ( done ) return true;

			element = parent;
			parent = element.offsetParent;
		}

		return false;
	}
	
	documentManager.translateAdvice = function ( advice ) {

		if
			( this.parent )
		{
			return this.parent.translateAdvice ( advice );
		}

		var result = this.translations [ advice.toLowerCase () ];

		if
			( ( result != null ) && ( result != "" ) )
		{
			return result;
		}

		return advice;
	}

	documentManager.mapAdviceText = function ( fromString, toString ) {

		if
			( this.parent )
		{
			this.parent.mapAdviceText ( fromString, toString );
		}

		this.translations [ fromString.toLowerCase () ] = toString;
	}

	documentManager.doMouseDown = function () {

		documentManager.obLastMouseDownObject = documentManager.getObject ( documentManager.getElementHandle ( event.srcElement ) );

		documentManager.activity ();

		documentManager.startDrag ();
	}

	documentManager.getInheritedAttribute = function ( element, attribute ) {

		var result = null;

		while
			( element != null )
		{
			result = element [ attribute ];

			if ( result != null ) break;

			if
				( element == document.body )
			{	
				element = null;
			}
			else
			{
				element = element.parentElement;
			}
		}
		
		return result;
	}

	documentManager.startDrag = function () {

		var element = event.srcElement;

		while
			( element != null )
		{
			var object = this.getObject ( this.getElementHandle ( element ) );

			if
				( object == null )
			{
				return;
			}
			else
			{
				if
					( object.doDrag != null )
				{
					this.dragObject = object;
					this.mouseDownX = event.screenX;
					this.mouseDownY = event.screenY;

					if
						( object.startDrag != null )
					{
						object.startDrag ();
					}

					return;
				}

				element = element.parentElement;
			}
		}
	}

	documentManager.doMouseMove = function () {
		if ( ( documentManager.lastMouseX != event.screenX ) || ( documentManager.lastMouseY != event.screenY ) ) {
			documentManager.lastMouseX = event.screenX;
			documentManager.lastMouseY = event.screenY;
			documentManager.activity ();
			documentManager.actionMouseMove ( event );
		}
	}

	documentManager.actionMouseMove = function ( event ) {
		if ( this.lastHoverElement != event.srcElement ) {
			this.lastHoverElement = event.srcElement;
			this.doHover ( event.srcElement );
		}
		this.notifyMouseMove ( event.screenX, event.screenY, event.button );
	}

	documentManager.notifyMouseMove = function ( x, y, buttons ) {

		if
			( this.parent != null )
		{
			this.parent.notifyMouseMove ( x, y, buttons );
		}
		else
		{
			this.performMouseMove ( x, y, buttons );
		}
	}

	documentManager.performMouseMove = function ( x, y, buttons ) {

		if
			( this.dragObject != null )
		{
			if
				( buttons == 1 )
			{
				var dx = x - this.mouseDownX;
				var dy = y - this.mouseDownY;

				this.mouseDownX = x;
				this.mouseDownY = y;

				this.dragObject.doDrag ( dx, dy );
			}
			else
			{
				this.doDragStop ();
			}
		}

		var children = this.childManager.getObjects ();

		for ( var h in children ) {

			children [ h ].performMouseMove ( x, y, buttons );
		}
	}

	documentManager.doMouseUp = function () {

		var obLastMouseDownObject = documentManager.obLastMouseDownObject;
		documentManager.obLastMouseDownObject = null;
		if
			( documentManager.dragObject != null )
		{
			documentManager.doDragStop ();
		}

		{
			var object = documentManager.getObject ( documentManager.getElementHandle ( event.srcElement ) );
			if
				( object != null )
			{
				if ( object == obLastMouseDownObject ) {
					if ( event.srcElement != object.localFocusElement ) {
						if ( object.onClick != null ) {						
//							if ( document.selection.type != "Text" ) {
								object.onClick ();
//							}
						}
					}
				}
			}
		}
	}

	documentManager.doDragStop = function () {

		if
			( this.dragObject != null )
		{
			if
				( this.dragObject.stopDrag != null )
			{
				this.dragObject.stopDrag ();
			}

			this.dragObject = null;
		}

		this.resetGlobalFocus ();
	}

	documentManager.doDragStart = function () {
	}

	documentManager.doSelectStart = function () {
	}

	documentManager.doResize = function () {
		if ( ! documentManager.bDoingResize ) {
			documentManager.bDoingResize = true;
			documentManager.addTaskObject ( { object:documentManager, method:"actionResize", priority:2 } );
		}
	}

	var lastWindowWidth = -1;
	var lastWindowHeight = -1;

	documentManager.actionResize = function () {
		//documentManager.updateHoverRectangle ();
		//documentManager.updateFocusRectangle ();
        
   		var myWidth = 0, myHeight = 0;
		
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} 
		else if
			( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
		if ((myWidth != lastWindowWidth) || (myHeight != lastWindowHeight))
		{
			
			lastWindowHeight = myHeight;
			lastWindowWidth  = myWidth;
				
			//trace("","action Resize");
			documentManager.updateHoverRectangle ();
			documentManager.updateFocusRectangle ();
			//("","do onresizes");
			this.doFunctions ( this.onresizes );
			//trace("","done");
		}
        this.bDoingResize = false;

        
        
		this.bDoingResize = false;
	}

	documentManager.startupWatchdog = function () {
	
		if
			( document.readyState == "complete" )
		{
			documentManager.start ( document );
		}
		else
		{
			return "repeat";
		}
	}

	documentManager.findNamedObject = function ( name ) {

		if ( window.findNamedObject ) {

			return findNamedObject ( name );
		}

		if
			( this.parent != null )
		{
			return this.parent.findNamedObject ( name );
		}

		return null;
	}

	documentManager.fetchEnumResource = function ( enumName ) {

		function mapFromRaw ( object ) {

			if
				( object.charCodeAt == ( void 0 ) )
			{
				var map = {};

				for ( var i = 0; i < object.length; i++ ) {

					map [ object [ i ] [ 0 ] ] = mapFromRaw ( object [ i ] [ 1 ] );
				}

				return map;
			}

			return object;
		}

		var result = [];

		if ( ( this.styleSet == null ) || ( this.appServer == null ) ) {

			alert ( "DOCUMENT MANAGER CAN'T FETCH RESOURCES WITHOUT A FETCHR OBJECT AND A STYLE SET" );
		}
		else
		{
			var r = null;

			this.appServer.ClearCmd();
			this.appServer.CmdPrefix = "APS_RESOURCE?" + this.styleSet;
			this.appServer.CmdSet("Method","Fetch");
			this.appServer.CmdSet("Resources", enumName );
			this.appServer.CmdSet("Style", "ALSi" );
			this.appServer.DoCmd();

			eval ( "r = " + this.appServer.TextResponse );
			var table = r [ enumName ];

			if ( table == null ) {

				alert ( "RESOURCE:" + enumName + " NOT FOUND" );
			}
			else
			{
				for ( var i = 0; i < table.length; i++ ) {

					var value = table [ i ] [ 0 ];
					var map = mapFromRaw ( table [ i ] [ 1 ] );
					var text = map.text;
					
					if ( text == null ) {
					
						text = "";
					}

					result [ result.length ] = { value:value, text:text };
				}
			}
		}

		return result;
	}
	documentManager.setControlToNewValue = function ( el, str ) {
		var bDone = false;
		if ( el.value.length == str.length ) {
			var range = document.selection.createRange ();
			if ( range.text == "" ) {
				if ( el.createTextRange != null ) {
					var rangeEl = el.createTextRange ();
					var numCharIndex = -1;
					if ( rangeEl.inRange ( range ) ) {
						range.setEndPoint ( "StartToStart", rangeEl );
						numCharIndex = range.text.length;
					} else if ( el == range.parentElement () ) {
						range.text = "\u0001";
						numCharIndex = el.value.indexOf ( "\u0001" );
					}
					el.value = str;
					bDone = true;
					if ( numCharIndex >= 0 ) {
						rangeEl = el.createTextRange ();
						rangeEl.moveStart ( "character", numCharIndex );
						rangeEl.collapse ( true );
						rangeEl.select ();
					}
				}
			}
		}
		if ( ! bDone ) {
			el.value = str;
		}
	}
	documentManager.setUseScriptHTTPFetcher = function ( bSet ) {
		this.bUseScriptHTTPFetcher = ( ( bSet == "1" ) || ( bSet == true ) );
	}
	documentManager.getUseScriptHTTPFetcher = function () {
		if ( this.bUseScriptHTTPFetcher ) {
			return true;
		}
		if ( this.parent != null ) {
			return this.parent.getUseScriptHTTPFetcher ();
		}
		return false;
	}
	documentManager.trySetFocus = function ( el ) {
		var bError = false;
		var obError = null;
		try { el.focus (); }
		catch ( obError ) {
			var numCode = obError.number & 0xFFFF;
			bError = true;
			if ( numCode == 2110 ) {
				// Control is invisible...
			} else {
				throw ( obError );
			}
		}
		return ! bError;
	}

	documentManager.initialise ();
	documentManager.addTask ( documentManager.startupWatchdog );

	/*-------------------------------------------------*/
	
		function baseObject ()
		{
			this.manager = null;
			this.handle = null;

			this.parent = null;
			this.previous = null;
			this.next = null;

			this.showHover = false;
			this.showFocus = true;

			this.editable = false;

			this.focus = false;
			this.valid = true;
			this.disabled = false;
			this.advice = null;
		}

		/*

		baseObject.prototype.select = function () {

			if
				( this.localFocusElement )
			{
				this.localFocusElement.focus ()
			}
			else
			{
				this.manager.setGlobalFocus ( this.manager, this );
			}
		}

		*/

		baseObject.prototype.setFocus = function ( focusOn ) {
		
			if
				( this.focus != focusOn )
			{
				this.focus = focusOn;
				
				if
					( focusOn )
				{
					this.focusIn ();
				}
				else
				{
					this.focusOut ();
				}
			}
		}
		
		baseObject.prototype.createCallback = function ( method, parameter ) {

			return this.manager.createCallback ( this, method, parameter );
		}
		
		baseObject.prototype.scanChildElements = function ( element ) {

			var coll = element.children;
				
			if
				( coll != null )
			{
				var l = coll.length;
					
				for ( var i = 0; i < l; i++ ) {
						
					var e = coll [ i ];
					var handle = e.getAttribute ( "objectHandle" );
							
					if
						( handle != null )
					{
						this.renderHandleIntoElement ( handle, e );
					}
					else
					{
						this.scanChildElements ( e )
					}
				}
			}
		}

		baseObject.prototype.renderTemplateIntoElement = function ( template, element ) {
		
			element.innerHTML = template;
			this.scanChildElements ( element );
		}
		
		baseObject.prototype.getInheritedAttribute = function ( attribute ) {

			return this.manager.getInheritedAttribute ( this.outerElement, attribute );
		}
		
		baseObject.prototype.focusOut = function () {}
		baseObject.prototype.focusIn = function () {}
		baseObject.prototype.renderHandleIntoElement = function ( handle, element ) {
		
			element.innerHTML = "<SPAN style=color:red>HANDLE:" + handle + "</SPAN>";
		}

	/*-------------------------------------------------*/

		function containerObject ()
		{
			this.first = null;
			this.last = null;
			this.showFocus = false;
			this.count = 0;
		}
	
		documentManager.registerClass ( "container", containerObject );

		containerObject.prototype = new baseObject ();

		containerObject.prototype.start = function ( element ) {
		
			this.outerElement = element;
			element.objectHandle = this.handle;

			this.localFocusElement = null;
			this.innerElement = this.outerElement;

			this.savedClass = this.outerElement.className;
			this.hoverClass = this.outerElement.getAttribute ( this.manager.attributePrefix + "HoverClass" );

			this.traverseChildren ( this.innerElement );
		}
		
		containerObject.prototype.onClick = function () {
		
//			this.manager.setGlobalFocus ( this.manager, this );
		}

		containerObject.prototype.append = function ( o ) {
	
			o.parent = this;
			
			if
				( this.count == 0 )
			{
				this.first = o;
				this.last = o;

				o.previous = null;
				o.next = null;
			}
			else
			{
				o.previous = this.last;
				o.next = null;
				
				this.last.next = o;
				this.last = o;
			}
			
			this.count++;
		}

		containerObject.prototype.remove = function ( object ) {

			var o = this.first;
			var last = null;

			while ( o != null ) {

				if ( o == object ) {

					if ( last != null ) {

						last.next = o.next;
					}
					else
					{
						this.first = o.next;
					}

					if ( o.next != null ) {

						o.next.previous = last;
					}
					else
					{
						this.last = o.previous;
					}

					this.count--;

					break;
				}

				last = o;
				o = o.next;
			}
		}

		containerObject.prototype.getFirstEditableControl = function () {

			var o = this.first;

			while ( o != null ) {

				if ( o.editableControl ) {

					return o;
				}

				o = o.next;
			}

			return null;
		}

		containerObject.prototype.traverseChildren = function ( element ) {

			if
				( element.children.length != 0 )
			{
				// Make a copy of the child list because the 'live' one could change during processing...

				var coll = new Array ();
				var l = element.children.length;

				for ( var i = 0; i < l; i++ ) {

					coll [ coll.length ] = element.children [ i ];
				}

				for ( var i = 0; i < l; i++ ) {
				
					var e = coll [ i ];
					var objectClass = e.getAttribute ( this.manager.attributePrefix + "Class" );
					
					if
						( objectClass != null )
					{
						var handle = e.getAttribute ( "objectHandle" );

						if ( handle == null ) {

							var o = this.manager.create ( objectClass );
							
							if
								( o != null )
							{
								this.append ( o );
								o.start ( e, objectClass, this );
							}
						}
					}
					else
					{
						this.traverseChildren ( e )
					}
				}
			}
		}

		containerObject.prototype.hoverIn = function () {

			if ( ! this.hover ) {

				this.hover = true;

				if ( this.hoverClass != null ) {

					this.outerElement.className = this.hoverClass;
				}
			}
		}

		containerObject.prototype.hoverOut = function () {

			if ( this.hover ) {

				this.hover = false;

				if ( this.hoverClass != null ) {

					this.outerElement.className = this.savedClass;
				}
			}
		}
		containerObject.prototype.fnMoveSelection = function ( el, numDelta ) {
			var numIndex = el.sourceIndex;
			var arrayAll = document.all;
			while ( true ) {
				numIndex += numDelta;
				el = arrayAll [ numIndex ];
				if ( el == null ) {
					break;
				} else if ( el.objectHandle != null ) {
					var obHandler = this.manager.getObject ( el.objectHandle );
					if ( obHandler != null ) {
						if ( obHandler.hoverIn != null ) {
							if ( obHandler.parent == this.parent ) {
								this.manager.setSelectedObject ( obHandler );
								this.manager.scrollIntoView ( el );
								return true;
							}
						}
					}
				}
			}
			return false;
		}
		containerObject.prototype.fnGetParentHasFocus = function () {
			var obFocus = this.manager.getGlobalFocus ();
			if ( obFocus != null ) {
				var el = this.outerElement;
				while ( true ) {
					if ( el.objectHandle != null ) {
						var obP = this.manager.getObject ( el.objectHandle );
						if ( obP == obFocus ) return true;
					}
					el = el.parentElement;
					if ( el == document.body ) break;
				}
			}
			return false;
		}
		containerObject.prototype.fnAskParentForMore = function ( bUp ) {
			var el = this.outerElement;
			while ( true ) {
				if ( el.objectHandle != null ) {
					var obP = this.manager.getObject ( el.objectHandle );
					if ( obP != null ) {
						if ( obP.fnExternalRequestMore != null ) {
							var fnCallback = this.createCallback ( bUp ? "fnMoveUpOneCallback" : "fnMoveDownOneCallback" );
							return obP.fnExternalRequestMore ( bUp, fnCallback );
						}
					}
				}
				el = el.parentElement;
				if ( el == document.body ) break;
			}
			return false;
		}
		containerObject.prototype.fnMoveUpOneCallback = function () {
			if ( this.manager.selectedObject == this ) {
				this.fnMoveSelection ( this.outerElement, -1 );
			}
		}
		containerObject.prototype.fnMoveDownOneCallback = function () {
			if ( this.manager.selectedObject == this ) {
				this.fnMoveSelection ( this.outerElement, 1 );
			}
		}
		containerObject.prototype.onKeyDown = function () {
			var code = event.keyCode;
			if ( this.fnGetParentHasFocus () ) {
				if
					( code == 38 )
				{
					var bDone = this.fnMoveSelection ( this.outerElement, -1 );
					if ( ! bDone ) {
						bDone = this.fnAskParentForMore ( true );
					}
					return bDone;
				}
				else
				if
					( code == 40 )
				{
					var bDone = this.fnMoveSelection ( this.outerElement, 1 );
					if ( ! bDone ) {
						bDone = this.fnAskParentForMore ( false );
					}
					return bDone;
				}
				else
				if
					( code == 37 )
				{
					// Left arrow
				}
				else
				if
					( code == 39 )
				{
					// Right arrow
					this.tryToSelect ();
					return true;
				}
				else
				if
					( code == 13 )
				{
					// Enter
					this.tryToSelect ();
					return true;
				}
				else
				if
					( code == 9 )
				{
					// Tab key
				}
			}
			return false;
		}
		containerObject.prototype.selectable = function () {
			if ( this.outerElement != document.body ) {
				return true;
			}
			return false;
		}
		containerObject.prototype.fnHierarchySearch = function ( el, fnTest ) {
			if ( fnTest ( el ) ) {
				return el;
			} else if ( el.nodeType == 1 ) {
				for ( var elChild = el.firstChild; elChild != null; elChild = elChild.nextSibling ) {
					var elResult = this.fnHierarchySearch ( elChild, fnTest );
					if ( elResult != null ) return elResult;
				}
			}
			return null;
		}
		containerObject.prototype.tryToSelect = function () {
			var fnTest = function ( el ) {
				if ( el.onclick != null ) return true;
				if ( el.href != null ) return true;
				return false;
			}
			var el = this.fnHierarchySearch ( this.outerElement, fnTest );
			if ( el != null ) {
				el.click ();
			}
		}

	/*-------------------------------------------------*/

		function controlManagerObject ()
		{
			this.active = false;
			this.lastValue = null;
			this.showHover = true;
			this.editable = true;
		}
		
		documentManager.registerClass ( "control", controlManagerObject );
		
		controlManagerObject.prototype = new baseObject ();

		controlManagerObject.prototype.suppressedAdvice = {
			"InComplete" : true,
			"StringTooShort" : true,
			"BadDay" : true,
			"BadMonth" : true,
			"BadYear" : true,
			"InvalidDay" : true,
			"InvalidMonth" : true,
			"InvalidYear" : true
		}
	
		controlManagerObject.prototype.start = function ( element ) {

			this.outerElement = element;
			element.objectHandle = this.handle;

			this.effectElement = null;
			this.localFocusElement = null;
			this.pluginElement = null;

			var controls = this.manager.findControls ( this.outerElement );
			var properties = {};
			
			if
				( controls.length == 1 )
			{
				this.pluginElement = controls [ 0 ];
				this.localFocusElement = this.pluginElement;
				this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
				this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );
				this.savedClassName = this.pluginElement.className;
				this.effectElement = this.pluginElement;

				if
					( this.pluginElement.tagName == "SELECT" )
				{
					var value = this.pluginElement.getAttribute ( this.manager.attributePrefix + "Value" );
					var options = this.pluginElement.options;

					this.textLookup = new Object ();

					// Fixup the value of selects...

					if
						( value != null )
					{
						this.pluginElement.value = value;
					}

					// Setup the map

					for ( var i = 0; i < options.length; i++ ) {

						var option = options [ i ];

						this.textLookup [ option.value ] = option.text;
					}

					properties [ "textLookup" ] = this.textLookup;

					// No effects for selects...

					this.effectElement = null;
				}

				if
					( this.pluginElement.type.toLowerCase () == "checkbox" )
				{
					this.checkbox = true;
					this.checkboxChecked = this.pluginElement.checked;
					this.checkboxIndeterminate = this.pluginElement.indeterminate;

					properties.checkboxChecked = this.checkboxChecked;
					properties.checkboxIndeterminate = this.checkboxIndeterminate;
				}

				var tabIndex = this.getInheritedAttribute ( this.manager.attributePrefix + "TabIndex" );

				if
					( tabIndex != null )
				{
					this.pluginElement.tabIndex = tabIndex;
				}

				this.fieldName = this.manager.findName ( this.outerElement );

				if
					( this.fieldName != null )
				{
					properties.value = this.pluginElement.value;
					this.manager.registerFieldType ( this.fieldName, this.outerElement );
					this.manager.registerFieldProperties ( this.fieldName, properties );
				}

				this.manager.attatch ( this, false );

				this.obTypeAssistDB = this.manager.findNamedObject ( "typeAssistDatabase" );

				if ( this.pluginElement.getAttribute ( this.manager.attributePrefix + "SuppressCommonAdvice" ) == "1" ) {
					this.bSuppressCommonAdvice = true;
				}
				if ( this.pluginElement.getAttribute ( this.manager.attributePrefix + "TabKeyForTextEdit" ) == "1" ) {
					this.bTabKeyForTextEdit = true;
				}
			}
			else
			{
				alert ( "controlManagerObject error: unable to find control" );
				this.outerElement.innerHTML = "???";
			}
		}
		
		controlManagerObject.prototype.notifyChange = function () {

			var disabled = this.interface.read ( this.fieldName, "disabled" );
			var valid = this.interface.read ( this.fieldName, "valid" );

			if
				( disabled != null )
			{
				if
					( this.pluginElement.disabled != disabled )
				{
					this.pluginElement.disabled = disabled;
				}
			}

			this.editableControl = ! disabled;

			if
				( this.checkbox )
			{
				var checked = this.interface.read ( this.fieldName, "checkboxChecked" );
				var indeterminate = this.interface.read ( this.fieldName, "checkboxIndeterminate" );

				if ( this.pluginElement.checked != checked ) this.pluginElement.checked = checked;
				if ( this.pluginElement.indeterminate != indeterminate ) this.pluginElement.indeterminate = indeterminate;

				this.checkboxChecked = checked;
				this.checkboxIndeterminate = indeterminate;
			}
			
			if
				( valid != null )
			{
				var value = this.interface.read ( this.fieldName, "value" );
				var advice = this.interface.read ( this.fieldName, "advice" );

				if ( this.suppressedAdvice [ advice ] ) {
					if ( this.bSuppressCommonAdvice || ( ! this.interface.read ( this.fieldName, "changed" ) ) ) {
							advice = null;
					}
				}

				if
					( value != null )
				{
					if
						( this.pluginElement.value != value )
					{
						this.manager.setControlToNewValue ( this.pluginElement, value );
					}

					if
						( this.pluginElement.tagName == "TEXTAREA" )
					{
						var doResize = this.pluginElement.getAttribute ( this.manager.attributePrefix + "AutoSize" );

						if ( doResize != 0 ) {

							var height = this.pluginElement.scrollHeight;

							if
								( height != this.pluginElement.clientHeight )
							{
								this.pluginElement.style.pixelHeight = height;

								var delta = height - this.pluginElement.clientHeight;

								this.pluginElement.style.pixelHeight += delta;

								this.manager.updateFocusRectangle ();
								this.manager.updateHoverRectangle ();
							}

							this.pluginElement.style.overflow = "hidden";
						}
					}

					if
						( ( this.disabled != disabled ) || ( this.valid != valid ) )
					{
						this.disabled = disabled;
						this.valid = valid;

						if
							( this.effectElement != null )
						{
							if
								( ( ! this.valid ) && ( ! this.disabled ) )
							{
								this.effectElement.className = "plugin-invalid";
							}
							else
							{
								this.effectElement.className = this.savedClassName;
							}
						}
					}

					if
						( this.advice != advice )
					{
						this.advice = advice;

						if
							( this.active )
						{
							this.manager.updateFocus ();
						}

						if ( this.pluginElement.getAttribute ( this.manager.attributePrefix + "DisableToolTip" ) != "1" ) {
							if ( advice == null ) advice = "";
							if ( advice != "" ) advice = this.manager.translateAdvice ( advice );
							this.pluginElement.title = advice;
						}
					}
				}
			}

			this.manager.viewUpdated ();
		}

		controlManagerObject.prototype.focusIn = function () {

			if
				( ! this.active )
			{
				if
					( this.pluginElement != null )
				{
					this.lastValue = this.pluginElement.value;
					this.manager.addImperativeTask ( this.createCallback ( "watchdog" ) );
				}

				this.showFloatingList ();

				this.active = true;
			}
		}
	
		controlManagerObject.prototype.callControlFocus = function () {

			if
				( this.pluginElement != null )
			{
				if ( this.pluginElement.focus != null ) {

					if ( ! this.pluginElement.disabled ) {

						if ( this.pluginElement.tagName == "SELECT" ) {
							this.manager.addTask ( this.createCallback ( "focusMe" ) );
						} else {
							return this.focusMe ();
						}
					}
				}
			}
			return true;
		}

		controlManagerObject.prototype.focusMe = function () {
			return this.manager.trySetFocus ( this.pluginElement );
		}

		controlManagerObject.prototype.focusOut = function () {

			this.hideFloatingList ();
			this.active = false;
		}

		controlManagerObject.prototype.insertText = function ( text ) {

			if ( this.lastSelection != null ) {

				if ( document.activeElement != this.pluginElement ) {

					this.manager.addImperativeTask ( this.createCallback ( "doActualFocus" ) );
				}

				this.lastSelection.text = text;
			}
		}

		controlManagerObject.prototype.doActualFocus = function () {

			this.pluginElement.focus ();
		}

		controlManagerObject.prototype.onClick = function () {
		}

		controlManagerObject.prototype.watchdog = function () {

			if
				( this.active )
			{
				if
					( this.checkbox )
				{
					var checked = this.pluginElement.checked;
					var indeterminate = this.pluginElement.indeterminate;

					if
						( ( checked != this.checkboxChecked ) || ( indeterminate != this.checkboxIndeterminate ) )
					{
						var update = new updateObject ();

						update.write ( this.fieldName, "checkboxChecked", checked );
						update.write ( this.fieldName, "checkboxIndeterminate", indeterminate );

						this.interface.syncUpdate ( update );
					}
				}
				else
				{
					var value = this.pluginElement.value;

					if ( document.activeElement == this.pluginElement ) {
						this.lastSelection = document.selection.createRange ();
					}

					if ( this.obTypeAssistDB != null ) {
						if ( this.lastValue != value ) {
							if ( this.typeHistory != null ) {
								var result = this.obTypeAssistDB.test ( this.typeHistory );
								if ( result != null ) {
									var textRange = document.selection.createRange ();
									textRange.moveStart ( "character", -1 * result.from.length );
									if ( textRange.text == result.from ) {
										textRange.text = result.to;
										this.lastTypeAssist = result;
										value = this.pluginElement.value;
									}
									this.typeHistory = "";
								}
							}
						}
					}

					if
						( this.lastValue != value )
					{
						var update = new updateObject ();

						update.write ( this.fieldName, "value", value );
						update.write ( this.fieldName, "checked", false );

						this.interface.syncUpdate ( update );

						this.lastValue = this.pluginElement.value;

						if ( this.floatingList ) {

							this.setDirection ();
						}
					}
				}

				return "repeat";
			}

			return false;
		}

		controlManagerObject.prototype.showFloatingList = function () {

			if ( this.floatingList != null ) {

				this.floatingList.show ();
			}
			else
			{
				var hintsPath = this.getInheritedAttribute ( this.manager.attributePrefix + "HintsPath" );

				if ( hintsPath != null ) {

					var hints = this.manager.fetchEnumResource ( hintsPath );
					var list = [];

					for ( var i = 0; i < hints.length; i++ ) {

						list [ list.length ] = hints [ i ].text;
					}

					var sort = this.getInheritedAttribute ( this.manager.attributePrefix + "HintsSort" );
					if ( sort == "0" )
					{
						this.silo = { index:0, list:list };
					}
					else
					{
						this.setStrings ( list );
					}

					var view = this.getInheritedAttribute ( this.manager.attributePrefix + "HintsView" );
					if ( view == "full" )
					{
						var container = this.manager.getContainer();
						var rectangle = container.getRectangle();
						var height = hints.length * 30 + 25;
						this.floatingList = this.manager.topManager().create ( "floatingElement" );
						this.floatingList.setRectangle ( rectangle.x, rectangle.y + rectangle.height - this.pluginElement.offsetHeight - this.pluginElement.clientHeight, 600, height );
						this.floatingList.setFontSize  ( null );
					}
					else
					{
						this.floatingList = this.manager.create ( "floatingElement" );
						this.floatingList.setRectangle ( 0, this.pluginElement.clientHeight + 10, 600, 100 );
					}

					this.floatingList.setReferenceObject ( this );
					this.floatingList.setServer ( this );
					this.floatingList.focusOnClick = false;

					this.floatingList.start ();

					this.floatingList.show ();
					this.pluginElement.onkeydown = this.createCallback ( "keyDown" );
				}
			}
		}

		controlManagerObject.prototype.hideFloatingList = function () {

			if
				( this.floatingList )
			{
				this.floatingList.hide ();
//				this.floatingList.close ();
			}
		}

		controlManagerObject.prototype.setStrings = function ( list ) {

			var f = function ( a, b ) {
			
				a = a.toLowerCase ();
				b = b.toLowerCase ();
				
				if ( a < b ) return - 1;
				if ( a > b ) return 1;

				return 0;
			}

			this.silo = { index:0, list:list.sort ( f ) };
		}

		controlManagerObject.prototype.getMoreUp = function ( floatingList ) {
		}

		controlManagerObject.prototype.getMoreDown = function ( floatingList ) {

			with ( this.silo ) {

				if ( index < list.length ) {

					var text = list [ index ];

					if ( text == "" ) {

						index++;

						this.getMoreDown ( floatingList );
					}
					else
					{
						var style = "";
						if ( floatingList.fontSize != null ) style = " style='font-size:" + floatingList.fontSize + "'";
						floatingList.insertItem ( "end", "<NOBR" + style + ">" + text + "</NOBR>", index );

						index++;
					}
				}
			}
		}

		controlManagerObject.prototype.selectionMade = function ( value, context ) {

			if ( value != null ) {

				this.pluginElement.value = this.silo.list [ value ];
				this.direction = null;
				this.pluginElement.focus ();
			}
		}

		controlManagerObject.prototype.listDirection = function () {

			var text = this.floatingList.selectedText ();
			
			if ( text != null ) {
			
				var value = this.pluginElement.value.toLowerCase ();
				text = text.toLowerCase ();

				if ( text < value ) return "down";
				if ( text > value ) return "up";
				return "correct";
			}

			return null;
		}

		controlManagerObject.prototype.setDirection = function () {

			this.direction = this.listDirection ();
			this.moveSelection ();
		}

		controlManagerObject.prototype.selectionChanged = function ( value, context ) {

			if ( this.direction == null ) {

				this.selectionMade ( value, context );
			}
			else
			{
				this.manager.addTask ( this.createCallback ( "moveSelection" ) );
			}
		}

		controlManagerObject.prototype.moveSelection = function () {

			var direction = this.listDirection ();

			if ( this.direction == "correct" ) {

				this.direction = null;
			}
			else
			{
				if ( direction != this.direction ) {

					var text = this.floatingList.selectedText ().toLowerCase ();
					var value = this.pluginElement.value.toLowerCase ();

					if ( value.length < text.length ) {

						if ( text.slice ( 0, value.length ) == value ) {

							this.direction = null;

							return;
						}
					}

					this.direction = "correct";
				}

				if ( direction == "down" ) this.floatingList.moveDown ();
				if ( direction == "up" ) this.floatingList.moveUp ();
			}
		}

		controlManagerObject.prototype.keyDown = function () {
			if ( this.floatingList ) {
				var code = event.keyCode;
				if 
					( code == 13 )
				{
					// Enter...
					this.floatingList.makeSelection ();
					return true;
				}
				else
				if
					( code == 38 )
				{
					// Up arrow
					this.direction = null;
					this.floatingList.moveUp ();
					return true;
				}
				else
				if
					( code == 40 )
				{
					// Down arrow
					this.direction = null;
					this.floatingList.moveDown ();
					return true;
				}
			}
			return false;
		}

		controlManagerObject.prototype.onKeyPress = function () {
			var numCode = event.keyCode;
			if ( this.obTypeAssistDB != null ) {
				var code = event.keyCode;
				if ( this.typeHistory == null ) this.typeHistory = "";
				this.typeHistory = ( String.fromCharCode ( code ) + this.typeHistory ).toString ().slice ( 0, 30 );
			}
			if ( ( numCode == 9 ) && this.bTabKeyForTextEdit ) {
				// Tab
				return true;
			}
			return false;
		}
		controlManagerObject.prototype.onKeyDown = function () {
			var numCode = event.keyCode;
			if ( this.obTypeAssistDB != null ) {
				var lastTypeAssist = this.lastTypeAssist;
				this.lastTypeAssist = null;
				if ( numCode == 8 ) {
					// Backspace
					if ( lastTypeAssist != null ) {
						var textRange = document.selection.createRange ();
						textRange.moveStart ( "character", -1 * lastTypeAssist.to.length );
						if ( textRange.text == lastTypeAssist.to ) {
							textRange.text = lastTypeAssist.from;
						}
						return true;
					}
				}
			}
			if ( ( numCode == 9 ) && this.bTabKeyForTextEdit ) {
				// Tab
				var obRange = document.selection.createRange ();
				if ( obRange.parentElement () == this.pluginElement ) {
					var boolShift = event.shiftKey;
					var obRange = document.selection.createRange ();
					if ( obRange.text != "" ) {
						while ( true ) {
							var text = obRange.text;
							if ( text == "" ) break;
							obRange.moveEnd ( "character", -1 );
							if ( obRange.text != text ) {
								obRange.moveEnd ( "character", 1 );
								break;
							}
						}
						obRange.select ();
						var arrayText = obRange.text.split ( "\n" );
						for ( var numIndex = 0; numIndex < arrayText.length; numIndex++ ) {
							var strLine = arrayText [ numIndex ];
							if ( strLine.match ( /^\s*$/ ) != null ) {
								arrayText [ numIndex ] = "";
							} else {
								if ( ! boolShift ) {
									arrayText [ numIndex ] = "\t" + strLine;
								} else {
									if ( strLine.charAt ( 0 ) == "\t" ) {
										arrayText [ numIndex ] = strLine.slice ( 1 );
									}
								}
							}
						}
						var obStartRange = obRange.duplicate ();
						var obEndRange = obRange.duplicate ();
						obStartRange.collapse ( true );
						obEndRange.collapse ( false );
						obRange.text = arrayText.join ( "\n" );
						obRange.setEndPoint ( "StartToStart", obStartRange );
						obRange.setEndPoint ( "EndToEnd", obEndRange );
						obRange.select ();
						return true;
					} else {
						if ( ! boolShift ) {
							obRange.text = "\t";
							obRange.collapse ( false );
							obRange.select ();
							return true;
						}
					}
				}
			}
			return false;
		}

/*--------------------------------------------------------------*/

		function echoObject ()
		{
			this.propertyName = "value";
		}
		
		documentManager.registerClass ( "echo", echoObject );
		
		echoObject.prototype = new baseObject ();
	
		echoObject.prototype.start = function ( element, objectClass ) {

			this.outerElement = element;
			element.objectHandle = this.handle;

			this.localFocusElement = null;

			var propertyName = this.outerElement.getAttribute ( this.manager.attributePrefix + "PropertyName" );
			var value = this.outerElement.getAttribute ( this.manager.attributePrefix + "Value" );
			var setValue = this.outerElement.getAttribute ( this.manager.attributePrefix + "SetValue" );

			if
				( propertyName != null )
			{
				this.propertyName = propertyName;
			}

			this.fieldName = this.manager.findName ( this.outerElement );

			if
				( this.fieldName != null )
			{
				if
					( setValue == 1 )
				{
					var properties = new Object ();

					if
						( value == null )
					{
						properties.value = this.outerElement.innerText;
					}
					else
					{
						properties.value = value;
						properties.textLookup = new Object ();
						properties.textLookup [ value ] = this.outerElement.innerText;
					}

					this.manager.registerFieldProperties ( this.fieldName, properties );
				}

				this.manager.attatch ( this, false );
			}
		}
		
		echoObject.prototype.notifyChange = function () {

			var property = this.propertyName;

			var value = this.interface.read ( this.fieldName, property );

			if ( value == null ) value = "";

			if
				( property == "value" )
			{
				var lookup = this.interface.read ( this.fieldName, "textLookup" );

				if
					( lookup != null )
				{
					value = lookup [ value ];
				}
			}


			this.outerElement.innerText = value;

			if ( this.outerElement.getAttribute ( this.manager.attributePrefix + "DisableToolTip" ) != "1" ) {
				var advice = this.interface.read ( this.fieldName, "advice" );
				if ( advice == null ) advice = "";
				if ( advice != "" ) advice = this.manager.translateAdvice ( advice );
				this.outerElement.title = advice;
			}

			this.manager.viewUpdated ();
		}

		echoObject.prototype.onClick = function () {
		
		}

/*--------------------------------------------------------------*/

		function formManagerObject ()
		{
			this.showHover = false;
		}
		
		documentManager.registerClass ( "form", formManagerObject );
		
		formManagerObject.prototype = new baseObject ();

		with ( formManagerObject ) {
	
			prototype.start = function ( element, strClass, obContainer ) {
				this.outerElement = element;
				element.objectHandle = this.handle;
				this.localFocusElement = null;
				this.formName = this.manager.findName ( this.outerElement );
				obContainer.traverseChildren ( element ); // Recurse binding to child elements.
				if
					( this.formName == null )
				{
					alert ( "formManagerObject error : managed forms must have a name" );
				} else {
					var update = new updateObject ();
					update.write ( this.formName, "valid", true );
					this.manager.interface.syncUpdate ( update );
					this.manager.attatch ( this, true ); // Read-write (like a validator).
				}
			}

			prototype.getFieldNames = function () {
				var l = this.manager.allBoundObjects ( this.outerElement );
				var result = [];
				for ( var i = 0; i < l.length; i++ ) {
					var o = l [ i ];
					if ( o.fieldName != null ) {
						result [ result.length ] = o.fieldName;
					}
				}
				return result;
			}
			prototype.notifyChange = function () {
				var names = this.getFieldNames ();
				var valid = true;
				for ( var i = 0; i < names.length; i++ ) {
					var fieldName = names [ i ];
					if
						( this.interface.read ( fieldName, "valid" ) == false )
					{
						if
							( this.interface.read ( fieldName, "disabled" ) != true )
						{
							valid = false;
							break;
						}
					}
				}
				this.interface.write ( this.formName, "valid", valid );
			}
		}

/*--------------------------------------------------------------*/

		function submitManagerObject ()
		{
			this.showHover = true;
			this.disabled = false;
		}
		
		documentManager.registerClass ( "submit", submitManagerObject );
		
		submitManagerObject.prototype = new baseObject ();
	
		submitManagerObject.prototype.start = function ( element ) {

			this.outerElement = element;
			element.objectHandle = this.handle;

			this.localFocusElement = null;

			var controls = this.manager.findControls ( this.outerElement );
			
			if
				( controls.length == 1 )
			{
				this.localFocusElement = controls [ 0 ];
				this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
				this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );

				var tabIndex = this.getInheritedAttribute ( this.manager.attributePrefix + "TabIndex" );

				if
					( tabIndex != null )
				{
					this.localFocusElement.tabIndex = tabIndex;
				}
				
				this.manager.attatch ( this, false );
			}
			else
			{
				alert ( "submitManagerObject error: unable to find control" );
				this.OuterElement.innerHTML = "???";
			}
			this.formName = this.outerElement.getAttribute ( this.manager.attributePrefix + "FormName" );
			var e = this.outerElement;
			while ( e != null ) {
				if ( e.tagName == "FORM" ) break;
				e = e.parentElement;
			}
			if ( e != null ) {
				if ( this.formName != null ) {
					alert ( "submitManagerObject error: can't specify a target form name for a submit control INSIDE a form" );
				}
				this.eForm = e;
				this.oldOnSubmit = e.onsubmit;
				e.onsubmit = this.createCallback ( "checkSubmit" );
			}
			// Default DelaySubmit to always true to ensure we catch all pages that have a problem with immediate form submits
			this.bDelaySubmit = true;
			if ( this.outerElement.getAttribute ( this.manager.attributePrefix + "SuppressDelaySubmit" ) == "1" ) {
				this.bDelaySubmit = false;
			}
		}

		submitManagerObject.prototype.getFieldNames = function () {

			var e = this.eForm;
			if ( e == null ) {
				return this.interface.observedFieldNames ();
			}
			else
			{
				var l = this.manager.allBoundObjects ( e );
				var result = [];

				for ( var i = 0; i < l.length; i++ ) {

					var o = l [ i ];

					if ( o.fieldName != null ) {

						result [ result.length ] = o.fieldName;
					}
				}

				return result;
			}
		}

		submitManagerObject.prototype.checkSubmit = function () {

			if ( this.disabled ) {
				return false;
			}
			else
			{
				var bDoIt = true;
				if ( this.oldOnSubmit != null ) {
					bDoIt = this.oldOnSubmit ();
					if ( bDoIt == null ) {
						bDoIt = true;
					} else if ( bDoIt === ( void 0 ) ) {
						bDoIt = true;
					}
					if ( event.returnValue == false ) {
						bDoIt = false;
					}
				}
				if ( this.bDelaySubmit ) {
					if ( bDoIt ) {
						this.manager.addImperativeTask ( this.createCallback ( "submitManagerObject_doSubmit" ) );
					}
					return false;
				} else {
					return bDoIt;
				}
			}
		}

		// Renamed doSubmit to submitManagerObject_doSubmit to avoid a name clash on some ACQ pages
		submitManagerObject.prototype.submitManagerObject_doSubmit = function () {
			if ( this.eForm != null ) {
				this.eForm.submit ();
			}
		}

		submitManagerObject.prototype.notifyChange = function () {

			var disabled = false;

			if ( ( this.eForm == null ) && ( this.formName != null ) ) {
				disabled = this.interface.read ( this.formName, "valid" ) != true;
			} else {
				var names = this.getFieldNames ();
				for ( var i = 0; i < names.length; i++ ) {

					var fieldName = names [ i ];

					if
						( this.interface.read ( fieldName, "valid" ) == false )
					{
						if
							( this.interface.read ( fieldName, "disabled" ) != true )
						{
							disabled = true;
							break;
						}
					}
				}
			}
			
			if
				( disabled != this.disabled )
			{
				this.disabled = disabled;
				this.localFocusElement.disabled = disabled;

				if
					( disabled )
				{
					this.localFocusElement.style.cursor = "";
				}
				else
				{
					this.localFocusElement.style.cursor = "hand";
				}
			}

			this.manager.viewUpdated ();
		}

		submitManagerObject.prototype.onKeyPress = function () {
	
			var code = event.keyCode;

			if
				( code == 13 )
			{
//				return true;
			}
		}

/*--------------------------------------------------------------*/

		function linkManagerObject ()
		{
			this.showHover = true;
		}
		
		documentManager.registerClass ( "link", linkManagerObject );
		
		linkManagerObject.prototype = new baseObject ();
	
		linkManagerObject.prototype.start = function ( element ) {

			this.outerElement = element;
			element.objectHandle = this.handle;

			this.localFocusElement = null;

			if
				( element.focus != null )
			{
				this.localFocusElement = element;
				this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
				this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );
			}
		}

		linkManagerObject.prototype.onKeyPress = function () {
	
			var code = event.keyCode;

			if
				( code == 13 )
			{
				return true;
			}
		}

/*--------------------------------------------------------------*/

		function floatingFrameObject ()
		{
			this.disabled = false;

			this.rectangle = new Object ();

			this.rectangle.x = 0;
			this.rectangle.y = 0;
			this.rectangle.width = 0;
			this.rectangle.height = 0;

			this.frameLoaded = false;
			this.ready = false;
		}

		floatingFrameObject.prototype = new baseObject ();

		documentManager.registerClass ( "floatingFrame", floatingFrameObject );

		floatingFrameObject.store = { id:0, list:[] };

		floatingFrameObject.prototype.createFrame = function () {

			var store = floatingFrameObject.store;
			var id = "floatingFrame" + store.id++;
			var element;
			var html = "<IFRAME src='about:blank' style='display:none; position:absolute; width:0; height:0;filter:progid:DXImageTransform.Microsoft.Shadow(color=#888888, Direction=135, Strength=5)' frameborder=no id=" + id + "></IFRAME>";

			document.body.insertAdjacentHTML ( "beforeEnd", html );

			element = document.all [ id ];

			var newItem = { free:false, element:element, id:id };
			
			store.list [ store.list.length ] = newItem;

			return newItem;
		}

		floatingFrameObject.prototype.disableDropShadow = function () {
			this.frameElement.style.filter = "";
		}

		floatingFrameObject.prototype.allocateFrame = function () {

			var store = floatingFrameObject.store;

			for ( var i = 0; i < store.list.length; i++ ) {

				with ( store.list [ i ] ) {

					if ( free ) {

						free = false;
						return store.list [ i ];
					}
				}
			}

			return this.createFrame ();
		}

		floatingFrameObject.prototype.start = function () {

			var zIndex = this.manager.nextZIndex ();

			this.frameItem = this.allocateFrame ();

			this.outerElement = this.frameItem.element;
			this.frameElement = this.frameItem.element;

			this.localFocusElement = null;

			this.manager.windows [ this.handle ] = frames [ this.frameItem.id ];

			this.outerElement.objectHandle = this.handle;
			this.outerElement.style.zIndex = zIndex;
		}

		floatingFrameObject.prototype.doRectangle = function () {

			if
				( this.outerElement != null )
			{
				this.outerElement.style.pixelLeft = this.rectangle.x;
				this.outerElement.style.pixelTop = this.rectangle.y;
				this.outerElement.style.pixelWidth = this.rectangle.width;
				this.outerElement.style.pixelHeight = this.rectangle.height;
				this.outerElement.style.display = "";
			}
		}

		floatingFrameObject.prototype.setRectangle = function ( x, y, width, height ) {

			this.rectangle.x = x;
			this.rectangle.y = y;
			this.rectangle.width = width;
			this.rectangle.height = height;

			this.doRectangle ();
		}

		floatingFrameObject.prototype.getRectangle = function () {

			with ( this.rectangle )
			{
				return { x:x, y:y, width:width, height:height };
			}
		}

		floatingFrameObject.prototype.move = function ( dx, dy ) {

			this.rectangle.x += dx;
			this.rectangle.y += dy;

			this.doRectangle ();
		}

		floatingFrameObject.prototype.size = function ( dx, dy ) {

			if
				( ( dx == null ) && ( dy == null ) )
			{
				this.adjustSize ();
			}
			else
			{
				this.rectangle.width += dx;
				this.rectangle.height += dy;

				this.doRectangle ();
				this.manager.addTask ( this.createCallback ( "adjustSize" ) );
			}
		}

		floatingFrameObject.prototype.load = function ( url ) {
			
			this.frameLoaded = false;
			this.ready = false;
			this.url = url;
			this.loadRetryCount = 0;
			this.checkLoaded ();
		}

		floatingFrameObject.prototype.checkLoaded = function () {
			if ( ! this.frameLoaded ) {
				if ( ! this.bIsClosed ) {
/*
					if ( this.loadRetryCount == null ) {
						this.loadRetryCount = 0;
					}
*/

					this.loadRetryCount++;


					if ( this.loadRetryCount == 4 ) {
						this.rectangle.height = 500;
						this.rectangle.width = 500;
						this.doRectangle ();
						alert ( "Frame failed to load" );
					} else {
						var timeToWait = this.loadRetryCount * 5000;
						this.frameElement.src = this.url;
						window.setTimeout ( this.createCallback ( "checkLoaded" ), timeToWait );
					}
				}
			}
/*			
			else
			{
				this.loadRetryCount = null;
			}
*/
		}

		floatingFrameObject.prototype.loaded = function ( childWindow ) {

			this.childWindow = childWindow;

			this.doRectangle ();
			this.manager.addTask ( this.createCallback ( "adjustSize" ) );
			this.frameLoaded = true;

			this.manager.resetGlobalFocus ();
		}

		floatingFrameObject.prototype.adjustSize = function () {

			if
				( this.frameLoaded && ( ! this.frameItem.free ) )
			{	
				var width = this.childWindow.document.body.scrollWidth;
				var height = this.childWindow.document.body.scrollHeight;
				var clientHeight = this.childWindow.document.body.clientHeight;

				if ( browserVersion < 5 ) {

					if ( clientHeight > height ) height = clientHeight;
				}
				else
				{
					var delta = Math.abs ( height - clientHeight );

					if ( delta <= 2 ) height = clientHeight;
				}

				this.childWindow.document.body.scrollTop = 0;

				this.rectangle.height = height;

				if ( width > this.rectangle.width ) {

					this.rectangle.width = width;
				}

				this.doRectangle ();

				if
					( ! this.ready )
				{
					this.ready = true;

					if
						( this.onLoad != null )
					{
						this.onLoad ();
					}
				}
			}
		}

		floatingFrameObject.prototype.addOnClose = function ( f ) {

			/*
				Functions to be called when this object is closed.
				These functions will ONLY GET CALLED IF THE OBJECT IS CLOSED,
				they will not get called if the object's frame is
				re-loaded or re-navigated etc...
			*/

			if ( this.shutdowns == null ) this.shutdowns = [];

			this.shutdowns [ this.shutdowns.length ] = f;
		}

		floatingFrameObject.prototype.close = function () {

			if ( ! this.bIsClosed ) {

				var childManager = this.childWindow.documentManager;

				if ( childManager != null ) {

					if ( this.shutdowns != null ) {

						childManager.doFunctions ( this.shutdowns );
					}

					childManager.doFunctions ( childManager.shutdowns );

					childManager.shutdowns = [];
				}

				this.manager.addTask ( this.createCallback ( "killFrame" ) );
				this.manager.removeLater ( this.handle );

				this.bIsClosed = true;
			}
		}

		floatingFrameObject.prototype.getIsClosed = function () {
			if ( ! this.bIsClosed ) {
				return false;
			}
			return true;
		}

		floatingFrameObject.prototype.killFrame = function () {

			this.frameElement.src = "about:blank";
			this.manager.windows [ this.handle ] = null;
			this.frameItem.free = true;
			this.outerElement.style.display = "none";
		}

/*--------------------------------------------------------------*/

		function listItemManagerObject ()
		{
			this.selected = false;
		}
		
		documentManager.registerClass ( "listItem", listItemManagerObject );
		
		listItemManagerObject.prototype = new baseObject ();
	
		listItemManagerObject.prototype.start = function ( element ) {

			this.outerElement = element;
			element.objectHandle = this.handle;

			this.localFocusElement = null;

			this.outerElement.onselectstart = new Function ( "return false;" );
			this.outerElement.ondragstart = new Function ( "return false;" );

			this.savedClassName = this.outerElement.className;
		}

		listItemManagerObject.prototype.onClick = function () {

			this.container.itemClicked ( this.handleInContainer );
		}

		listItemManagerObject.prototype.hoverIn = function () {

			this.container.itemHovered ( this.handleInContainer );
		}

		listItemManagerObject.prototype.setSelection = function ( selected ) {

			if
				( selected != this.selected )
			{
				this.selected = selected;

				if
					( this.selected )
				{
					this.outerElement.className = "list-item-selected";
				}
				else
				{
					this.outerElement.className = "list-item-not-selected";
				}
			}
		}

		listItemManagerObject.prototype.asText = function () {

			return this.outerElement.innerText;
		}

		listItemManagerObject.prototype.close = function () {

			this.outerElement.style.display = "none";
			this.outerElement.innerHTML = "";
			this.manager.removeLater ( this.handle );
		}

/*--------------------------------------------------------------*/

		function floatingElementObject ()
		{
			this.showHover = false;
			this.disabled = false;
			this.active = false;
			this.visible = false;
			this.fontSize = "larger";

			this.rectangle = new Object ();

			this.rectangle.x = 0;
			this.rectangle.y = 0;
			this.rectangle.width = 0;
			this.rectangle.height = 0;
			this.rectangle.maxWidth = 0;
			this.rectangle.maxHeight = 0;

			this.count = 0;
			this.indexToObject = new Object ();
			this.valueToObject = new Object ();

			this.dragMode = "start";
			
			this.referenceObject = null;

			this.autoSelect = true;
			this.selectOnHover = false;
			this.focusOnClick = true;
		}

		floatingElementObject.prototype = new baseObject ();

		floatingElementObject.store = { id:0, list:new Array () };

		documentManager.registerClass ( "floatingElement", floatingElementObject );

		floatingElementObject.prototype.newDiv = function () {

			var store = floatingElementObject.store;
			var id = "floatingElement" + store.id++;
			var element;

			html = "<DIV style='border:1 black solid; display:none; position:absolute; width:0; height:0;' id=" + id + "><DIV style='background-color:silver;'></DIV><DIV style='overflow:hidden; height:0'></DIV></DIV>";

			document.body.insertAdjacentHTML ( "beforeEnd", html );

			element = document.all [ id ];

			store.list [ store.list.length ] = { free:false, element:element, listElement:element.children [ 1 ], headElement:element.children [ 0 ] };

			element.onselectstart = new Function ( "return false;" );
			element.ondragstart = new Function ( "return false;" );

			return store.list [ store.list.length - 1 ];
		}

		floatingElementObject.prototype.allocateDiv = function () {

			var store = floatingElementObject.store;

			for ( var i = 0; i < store.list.length; i++ ) {

				with ( store.list [ i ] ) {

					if ( free ) {

						free = false;
						return store.list [ i ];
					}
				}
			}

			return this.newDiv ();
		}

		floatingElementObject.prototype.freeDiv = function ( outerElement ) {

			var store = floatingElementObject.store;

			for ( var i = 0; i < store.list.length; i++ ) {

				with ( store.list [ i ] ) {

					if ( ! free ) {

						if ( outerElement == element ) {

							free = true;
							listElement.innerHTML = "";
							element.style.display = "none";

							return;
						}
					}
				}
			}
		}

		floatingElementObject.prototype.start = function ( element ) {

			var zIndex = this.manager.nextZIndex ();

			if
				( element == null )
			{
				var newDiv = this.allocateDiv ();

				this.outerElement = newDiv.element;
				this.listElement = newDiv.listElement;

				var eTable = document.createElement ( "table" );
				var eRow = eTable.insertRow ();
				var eLeft = eRow.insertCell ();
				var eRight = eRow.insertCell ();
				var eInput = document.createElement ( "input" );
				var eButton = document.createElement ( "button" );
				var eImage = document.createElement ( "img" );

				eButton.appendChild ( eImage );

				eLeft.appendChild ( eInput );
				eRight.appendChild ( eButton );

				eTable.cellPadding = 0;
				eTable.cellSpacing = 3;
				eTable.style.width = "100%";

				eInput.style.border = "none";
				eInput.style.fontFamily = "arial";
				eInput.style.fontSize = "80%";

				eRight.align = "right";
				eRight.vAlign = "top";
				eRight.style.paddingRight = "3px";

				eImage.src = "/script/sde/bitmaps/close.gif";
				eImage.width = 16;
				eImage.height = 16;

				eButton.style.border = "none";
				eButton.style.width = "16px";
				eButton.style.height = "16px";

				newDiv.headElement.innerHTML = "";
				newDiv.headElement.appendChild ( eTable );

				this.inputElement = eInput;

				this.allowBackSpace = true;
				this.inputElement.onkeyup = this.createCallback ( "newInput" );

				eButton.onclick = this.createCallback ( "doCancel" );
			}
			else
			{
				this.outerElement = element;
				this.listElement = this.outerElement;
				this.fixedPosition = true;
			}

			this.outerElement.style.zIndex = zIndex;

			this.localFocusElement = null;
			this.outerElement.objectHandle = this.handle;

			this.outerElement.onselectstart = new Function ( "return false;" );
			this.outerElement.ondragstart = new Function ( "return false;" );
		}

		floatingElementObject.prototype.show = function () {

			if ( ! this.visible ) {

				this.visible = true;
				this.doRectangle ();
				this.manager.addTask ( this.createCallback ( "dynamicSize" ), 3 );
			}
		}

		floatingElementObject.prototype.hide = function () {

			if ( this.visible ) {

				this.visible = false;
				this.outerElement.style.display = "none";
			}
		}

		floatingElementObject.prototype.dynamicSize = function () {

			if
				( this.visible )
			{
				var height = this.listElement.scrollHeight + this.listElement.offsetTop;
				var width = this.outerElement.scrollWidth + 2;
				var more = false;

				if
					( height > this.rectangle.maxHeight )
				{
					height = this.rectangle.maxHeight;
				}
				else
				{
					more = true;
				}

				if
					( width > this.rectangle.maxWidth )
				{
					width = this.rectangle.maxWidth;
				}

				if ( width < 10 ) width = 10;
				if ( height < 10 ) height = 10;

				if
					( width != this.rectangle.width || height != this.rectangle.height )
				{
					if
						( this.active )
					{
						this.manager.hideFocus ();
					}

					this.rectangle.width = width;
					this.rectangle.height = height;

					this.doRectangle ();

					this.manager.scrollIntoView ( this.outerElement );

					if
						( this.active )
					{
						if ( this.inputElement != null ) {

							this.inputElement.focus ();
						}
						else
						{
							this.outerElement.focus ();
						}
					}

					if
						( more )
					{
						var count = this.count;

						if
							( this.server != null )
						{
							this.server.getMoreDown ( this );
						}

						if
							( count != this.count )
						{
							if
								( this.selectedIndex == null )
							{
								if
									( this.count != 0 )
								{
									if
										( this.autoSelect )
									{
										this.select ( this.lowIndex, true );
									}
								}
							}

							this.manager.addTask ( this.createCallback ( "dynamicSize" ), 3 );

							return;
						}
					}

					this.manager.updateFocus ();
				}
			}
		}

		floatingElementObject.prototype.setFontSize = function ( size ) {

			this.fontSize = size;

			if
				( this.visible )
			{
				this.doRectangle;
			}
		}

		floatingElementObject.prototype.setReferenceObject = function ( object ) {
		
			this.referenceObject = object;

			if
				( this.visible )
			{
				this.doRectangle;
			}
		}

		floatingElementObject.prototype.setRectangle = function ( x, y, width, height ) {

			this.rectangle.x = x;
			this.rectangle.y = y;
			this.rectangle.maxWidth = width;
			this.rectangle.maxHeight = height;
		}

		floatingElementObject.prototype.doRectangle = function () {

			if
				( this.outerElement != null )
			{
				if
					( this.fixedPosition )
				{
					var offset = this.manager.getAbsoluteBodyOffset ( this.outerElement );

					this.rectangle.x = offset.x;
					this.rectangle.y = offset.y;
				}

				var x = this.rectangle.x;
				var y = this.rectangle.y;
				
				if
					( this.referenceObject != null )
				{
					var element = this.referenceObject.outerElement;

					if ( element == null ) {

						if ( this.referenceObject.getFocusElement != null ) {
					
							 element = this.referenceObject.getFocusElement ();
						}
					}

					if
						( element != null )
					{
						var offset = this.manager.getOffset ( this.outerElement, element );
						x += offset.x;
						y += offset.y;
					}
				}
				
				this.outerElement.style.pixelLeft = x;
				this.outerElement.style.pixelTop = y;
				this.outerElement.style.pixelWidth = this.rectangle.width;
				this.outerElement.style.pixelHeight = this.rectangle.height;
				this.outerElement.style.display = "";

				if ( this.inputElement != null ) {

					var w = this.rectangle.width - 40;
					if ( w < 100 ) w = 100;

					this.inputElement.style.pixelWidth = w;
				}

				if ( this.outerElement != this.listElement ) {

					this.listElement.style.pixelHeight = this.rectangle.height - this.listElement.offsetTop;
				}
			}
		}

		floatingElementObject.prototype.move = function ( dx, dy ) {

			if
				( ! this.fixedPosition )
			{
				this.rectangle.x += dx;
				this.rectangle.y += dy;

				this.doRectangle ();
			}
		}

		floatingElementObject.prototype.size = function ( dx, dy ) {

			this.rectangle.width += dx;
			this.rectangle.height += dy;

			this.doRectangle ();
		}

		floatingElementObject.prototype.remove = function ( position, number ) {

			if
				( this.count > 0 )
			{
				if
					( position == "start" )
				{
					startIndex = this.lowIndex;
					endIndex = startIndex + number - 1;
				}
				else
				{
					startIndex = ( this.highIndex - number ) + 1;
					endIndex = this.highIndex;
				}

				if ( startIndex < this.lowIndex ) startIndex = this.lowIndex;
				if ( endIndex > this.highIndex ) endIndex = this.highIndex;

				for ( var i = startIndex; i <= endIndex; i++ ) {

					var object = this.indexToObject [ i ];

					if
						( i == this.selectedIndex )
					{
						this.selectedIndex = null;
					}

					if
						( object != null )
					{
						var value = object.valueInContainer;

						if
							( this.valueToObject [ value ] == object )
						{
							delete this.valueToObject [ value ];
						}

						delete this.indexToObject [ i ];

						object.close ();
					}

					this.count--;
				}

				if
					( position == "start" )
				{
					this.lowIndex = endIndex + 1;
				}
				else
				{
					this.highIndex = startIndex - 1;
				}

				if
					( this.visible )
				{
					this.manager.addTask ( this.createCallback ( "dynamicSize" ) );
				}
			}
		}

		floatingElementObject.prototype.startDrag = function () {

			this.dragMode = "start";
			this.dx = 0;
			this.dy = 0;
		}

		floatingElementObject.prototype.stopDrag = function () {

			this.dragMode = "start";
//			this.outerElement.style.filter = "";
			if
				( this.active )
			{
				this.manager.updateFocus ();
			}
		}

		floatingElementObject.prototype.doDrag = function ( dx, dy ) {

			if
				( this.dragMode == "start" )
			{
				this.dx += dx;
				this.dy += dy;

				if
					( ( Math.abs ( this.dx ) > 5 ) || ( Math.abs ( this.dy ) > 5 ) )
				{
					if
						( Math.abs ( this.dx ) > 5 )
					{
						this.dragMode = "move";
						dx = this.dx;
						dy = this.dy;
					}
					else
					{
						this.dragMode = "scroll";
					}

					////////// Force move mode for now...

					this.dragMode = "move";

					if
						( this.active )
					{
						this.manager.hideFocus ();
					}
				}
			}

			if
				( this.dragMode != "start" )
			{
				if
					( Math.abs ( dx ) > Math.abs ( dy ) )
				{
					this.dragMode = "move";
				}

				if
					( this.dragMode == "move" )
				{
//					this.outerElement.style.filter = "alpha(opacity=" + "50" + ")";

					this.move ( dx, dy );
				}
				else
				{
					var amount = Math.pow ( Math.abs ( dy ), 1.5 );

					if ( dy < 0 ) amount = - amount;

					this.listElement.scrollTop -= amount;
				}
			}
		}

		floatingElementObject.prototype.insertItem = function ( position, html, value, referenceObject ) {

			var objectClass = "listItem";

			var object = this.manager.create ( objectClass );
			var element;
			var index;
			var markup = "<DIV class='list-item-not-selected'>" + html + "</DIV>";

			if
				( position == "start" )
			{
				this.listElement.insertAdjacentHTML ( "afterBegin", markup );

				element = this.listElement.children [ 0 ];

				if
					( this.count == 0 )
				{
					this.lowIndex = 0;
					this.highIndex = 0;
					index = 0;
				}
				else
				{
					this.lowIndex--;
					index = this.lowIndex;
				}
			}
			else
			{
				this.listElement.insertAdjacentHTML ( "beforeEnd", markup );

				element = this.listElement.children [ this.listElement.children.length - 1 ];

				if
					( this.count == 0 )
				{
					this.lowIndex = 0;
					this.highIndex = 0;
					index = 0;
				}
				else
				{
					this.highIndex++;
					index = this.highIndex;
				}
			}

			this.count++;
			this.indexToObject [ index ] = object

			if
				( value != null )
			{
				this.valueToObject [ value ] = object;
			}

			object.container = this;
			object.handleInContainer = index;
			object.valueInContainer = value;
			object.referenceObject = referenceObject;

			object.start ( element, objectClass );

			if
				( this.visible )
			{
				this.manager.addTask ( this.createCallback ( "dynamicSize" ) );
			}
		}

		floatingElementObject.prototype.onClick = function () {

			if
				( this.dragMode == "start" )
			{
				if ( this.focusOnClick ) this.manager.setGlobalFocus ( this.manager, this );
			}
		}

		floatingElementObject.prototype.itemClicked = function ( index ) {

			if
				( this.dragMode == "start" )
			{
				this.onClick ();
				this.select ( index );
				this.selectionCallback ();
			}
		}

		floatingElementObject.prototype.itemHovered = function ( index ) {

			if
				( this.active || this.selectOnHover )
			{
				this.select ( index );
			}
		}

		floatingElementObject.prototype.focusIn = function () {
		
			this.active = true;
		}

		floatingElementObject.prototype.focusOut = function () {
		
			this.active = false;

			if
				( this.referenceObject )
			{
//				this.referenceObject.selectionMade ( null );
			}
		}

		floatingElementObject.prototype.select = function ( index, dontReport ) {

			if
				( index != this.selectedIndex )
			{
				var oldObject = null;
				var newObject = null;
				
				if
					( this.selectedIndex != null )
				{
					oldObject = this.indexToObject [ this.selectedIndex ];
				}

				this.selectedIndex = index;

				if
					( index != null )
				{
					newObject = this.indexToObject [ index ];
				}

				if ( oldObject != null ) oldObject.setSelection ( false );

				if ( newObject != null ) {
				
					newObject.setSelection ( true );

					var top = this.listElement.scrollTop;
					var bottom = top + this.listElement.offsetHeight;
					var itemTop = newObject.outerElement.offsetTop;
					var itemBottom = itemTop + newObject.outerElement.offsetHeight;

					if
						( itemTop < top )
					{
						this.listElement.scrollTop = itemTop;
					}
					else
					if
						( itemBottom > bottom )
					{
						this.listElement.scrollTop += ( itemBottom - bottom );
					}
				}

				if
					( ! dontReport )
				{
					this.selectionChangedCallback ();
				}
			}
		}

		floatingElementObject.prototype.selectionOffsetFromTop = function () {

			if
				( this.selectedIndex != null )
			{
				var o = this.indexToObject [ this.selectedIndex ];
				var result = o.outerElement.offsetTop;
				var scrollTop = this.listElement.scrollTop;

				if
					( scrollTop != null )
				{
					result -= scrollTop;
				}

				return result;
			}

			return null;
		}

		floatingElementObject.prototype.setValue = function ( value ) {

			var object = this.valueToObject [ value ];

			if
				( object != null )
			{
				this.select ( object.handleInContainer );
			}
		}

		floatingElementObject.prototype.getValue = function () {

			if
				( this.selectedIndex != null )
			{
				var object = this.indexToObject [ value ];

				return object.valueInContainer;
			}

			return null;
		}

		floatingElementObject.prototype.getHTML = function () {

			if
				( this.selectedIndex != null )
			{
				var object = this.indexToObject [ value ];

				return object.outerElement.innerHTML;
			}

			return "";
		}

		floatingElementObject.prototype.setNoMoreUp = function () {

			this.noMoreUp = true;
		}

		floatingElementObject.prototype.setNoMoreDown = function () {

			this.noMoreDown = true;
		}

		floatingElementObject.prototype.moveUp = function () {

			if
				( this.selectedIndex == null )
			{
				if
					( this.count == 0 )
				{
					if ( this.noMoreUp ) return false;

					if
						( this.server != null )
					{
						this.server.getMoreUp ( this );
					}
				}

				if
					( this.count != 0 )
				{
					this.select ( this.highIndex );
				}
			}
			else
			{
				if
					( this.selectedIndex == this.lowIndex )
				{
					if ( this.noMoreUp ) return false;

					if
						( this.server != null )
					{
						this.server.getMoreUp ( this );
					}
				}

				if
					( this.selectedIndex > this.lowIndex )
				{
					this.select ( this.selectedIndex - 1 );
				}
			}

			return true;
		}

		floatingElementObject.prototype.moveDown = function () {

			if
				( this.selectedIndex == null )
			{
				if
					( this.count == 0 )
				{

					if ( this.noMoreDown ) return false;

					if
						( this.server != null )
					{
						this.server.getMoreDown ( this );
					}
				}

				if
					( this.count != 0 )
				{
					this.select ( this.lowIndex );
				}
			}
			else
			{
				if
					( this.selectedIndex == this.highIndex )
				{
					if ( this.noMoreDown ) return false;

					if
						( this.server != null )
					{
						this.server.getMoreDown ( this );
					}
				}

				if
					( this.selectedIndex < this.highIndex )
				{
					this.select ( parseInt ( this.selectedIndex ) + 1 );
				}
			}

			return true;
		}

		floatingElementObject.prototype.makeSelection = function () {

			this.selectionCallback ();
		}

		floatingElementObject.prototype.onKeyDown = function () {
		
			var code = event.keyCode;

			if
				( ( code == 37 ) && ( this.inputElement == null ) )
			{
				this.doCancel ();
				
				return true;
			}
			else
			if
				( ( code == 39 ) && ( this.inputElement == null ) )
			{
				this.selectionCallback ();
				
				return true;
			}
			else
			if
				( code == 38 )
			{
				// Up arrow

				this.moveUp ();

				return true;
			}
			else
			if
				( code == 40 )
			{
				// Down arrow

				this.moveDown ();

				return true;
			}
			
			return false;
		}

		floatingElementObject.prototype.selectionCallback = function () {

			if ( this.inputElement != null ) {

				if ( ! this.inputIsPrefix () ) {

					return;
				}
			}

			if
				( this.referenceObject )
			{
				if
					( this.selectedIndex != null )
				{
					var object = this.indexToObject [ this.selectedIndex ]
					
					this.referenceObject.selectionMade ( object.valueInContainer, object.referenceObject );
				}
			}
		}

		floatingElementObject.prototype.selectedText = function () {

			if
				( this.selectedIndex != null )
			{
				var object = this.indexToObject [ this.selectedIndex ]

				return object.asText ();
			}

			return null;
		}

		floatingElementObject.prototype.selectionChangedCallback = function () {

			if ( this.inputElement != null ) {

				if ( this.direction != null ) {

					this.manager.addTask ( this.createCallback ( "moveSelection" ) );
				}
				else
				{
					this.inputElement.value = this.selectedText ();
				}
			}

			if
				( this.referenceObject )
			{
				if
					( this.referenceObject.selectionChanged != null )
				{
					if
						( this.selectedIndex != null )
					{
						var object = this.indexToObject [ this.selectedIndex ]
						
						this.referenceObject.selectionChanged ( object.valueInContainer, object.referenceObject );
					}
				}
			}
		}

		floatingElementObject.prototype.doCancel = function () {

			if
				( this.referenceObject )
			{
				this.referenceObject.selectionMade ( null );
			}
		}

		floatingElementObject.prototype.onKeyPress = function () {
		
			var code = event.keyCode;
			if
				( code == 27 )
			{
				this.doCancel ();
				
				return true;
			}
			else
			if
				( code == 13 )
			{
				this.selectionCallback ();
				
				return true;
			}
			
			return false;
		}

		floatingElementObject.prototype.setServer = function ( server ) {

			this.server = server;
		}

		floatingElementObject.prototype.close = function () {

			this.visible = false;

			for ( var i in this.indexToObject ) {

				this.manager.remove ( this.indexToObject [ i ].handle );
			}

			this.freeDiv ( this.outerElement );
			this.manager.removeLater ( this.handle );
		}

		floatingElementObject.prototype.setInput = function ( text ) {

			if ( this.inputElement != null ) {

				this.inputElement.focus ();

				this.inputElement.value = text;

				this.newInput ();
			}
		}

		floatingElementObject.prototype.newInput = function () {

			var value = this.inputElement.value;

			if ( this.lastInputValue != value ) {

				this.lastInputValue = value;
				this.setDirection ();
			}
		}

		floatingElementObject.prototype.listDirection = function () {

			var text = this.selectedText ();
			
			if ( text != null ) {
			
				var value = this.inputElement.value.toString ().split ( " " ).join ( "" ).toLowerCase ();
				text = text.toString ().split ( " " ).join ( "" ).toLowerCase ();

				if ( text < value ) return "down";
				if ( text > value ) return "up";
				return "correct";
			}

			return "down";
		}

		floatingElementObject.prototype.setDirection = function () {

			this.direction = this.listDirection ();
			this.moveSelection ();
		}

		floatingElementObject.prototype.inputIsPrefix = function () {

			var text = this.selectedText ().toString ().split ( " " ).join ( "" ).toLowerCase ();
			var value = this.inputElement.value.toString ().split ( " " ).join ( "" ).toLowerCase ();

			if ( value.length <= text.length ) {

				if ( text.slice ( 0, value.length ) == value ) {

					return true;
				}
			}

			return false;
		}

		floatingElementObject.prototype.moveSelection = function () {

			if ( this.direction == "correct" ) {

				this.direction = null;
			}
			else
			{
				var direction = this.listDirection ();

				if ( direction != this.direction ) {

					if ( this.inputIsPrefix () ) {

						this.direction = null;

						return;
					}

					this.direction = "correct";
				}

				if ( direction == "down" ) {

					if ( ! this.moveDown () ) {

						this.direction = null;
					}
				}
				
				if ( direction == "up" ) {

					if ( ! this.moveUp () ) {

						this.direction = null;
					}
				}
			}
		}

/*--------------------------------------------------------------*/

		function floatingElementObject2 ()
		{
		}

		floatingElementObject2.prototype = new baseObject ();

		documentManager.registerClass ( "floatingElement2", floatingElementObject2 );

		with ( floatingElementObject2 ) {
			prototype.start = function () {
			}
			prototype.fnInitialise = function ( arrayItems, obOwner, elPosition ) {
				var elDiv = document.createElement ( "div" );
				var elTable = document.createElement ( "table" );
				var elBody = document.createElement ( "div" );
				var elRow = elTable.insertRow ();
				var elLeft = elRow.insertCell ();
				var elRight = elRow.insertCell ();
				var elInput = document.createElement ( "input" );
				var elButton = document.createElement ( "button" );
				var elImage = document.createElement ( "img" );
				this.obOwner = obOwner;
				this.elParent = document.body;
				this.elDiv = elDiv;
				this.elBody = elBody;
				this.elInput = elInput;
				this.elParent.appendChild ( elDiv );
				this.elButton = elButton;
				elDiv.appendChild ( elTable );
				elDiv.appendChild ( elBody );
				elLeft.appendChild ( elInput );
				elRight.appendChild ( elButton );
				elButton.appendChild ( elImage );
				elTable.cellPadding = 0;
				elTable.cellSpacing = 0;
				elTable.style.padding = "0.1em";
				elRight.align = "right";
				elRight.vAlign = "top";
				elImage.src = "/script/sde/bitmaps/close.gif";
				elImage.style.width = "16px";
				elImage.style.height = "16px";
				elButton.style.border = "none";
				elButton.style.width = "16px";
				elButton.style.height = "16px";
				elButton.onclick = this.createCallback ( "fnUserCancel" );

				elDiv.onresize = this.createCallback ( "fnOnResize" );
				elInput.style.fontFamily = "arial";
				elInput.style.fontSize = "80%";
				elInput.style.border = "1 black solid";
				elInput.style.width = "10em";
				elDiv.style.border = "1 gray solid";
				elDiv.style.padding = "0.1em";
				elDiv.style.position = "absolute";
				elDiv.style.backgroundColor = "window";
				elBody.style.fontFamily = "arial";
				elBody.style.fontSize = "80%";
				elBody.style.paddingRight = "3em";
				if ( elPosition != null ) {
					var offset = this.manager.getOffset ( this.elDiv, elPosition );
					var numDelta = elPosition.offsetHeight + 2;
/**/					/*this.elDiv.style.pixelLeft = 2 ; */
					this.elDiv.style.pixelLeft = offset.x + numDelta;
					this.elDiv.style.pixelTop = offset.y + numDelta;										
				}
				this.numMax = 10;
				this.numTop = 0;
				this.numSelected = null;
				this.arrayItems = arrayItems;
				arrayItems.sort ();
				this.fnRedraw ();

				this.allowBackSpace = true;
				this.outerElement = elDiv;
				this.outerElement.style.zIndex = this.manager.nextZIndex ();
				this.localFocusElement = null;
				this.outerElement.objectHandle = this.handle;
				this.outerElement.onselectstart = new Function ( "event.returnValue = false; return false;" );
				this.elInput.focus ();
				this.manager.scrollIntoView ( elDiv );
			}
			prototype.fnRemove = function () {
				this.elButton.onclick = null;
				this.elDiv.onresize = null;
				if ( this.elInput == document.activeElement ) {
					window.focus ();
				}
				this.elParent.removeChild ( this.elDiv );
				this.manager.removeLater ( this.handle );
			}
			prototype.fnRedraw = function () {
				while ( this.elBody.firstChild != null ) {
					this.elBody.removeChild ( this.elBody.firstChild );
				}
				for ( var numIndex = 0; numIndex < this.numMax; numIndex++ ) {
					var numItem = this.numTop + numIndex;
					var obItem = this.arrayItems [ numItem ];
					if ( obItem != null ) {
						this.fnAddToEnd ( obItem, numItem );
					}
				}
				this.fnShowSelected ();
			}
			prototype.fnGetElementForItem = function ( numItem ) {
				return this.elBody.childNodes [ numItem - this.numTop ];
			}
			prototype.fnShowSelected = function () {
				if ( this.numSelected != null ) {
					var el = this.fnGetElementForItem ( this.numSelected );
					if ( el != null ) {
						el.style.backgroundColor = "highlight";
						el.style.color = "highlighttext";
					}
				}
			}
			prototype.fnHideSelected = function () {
				var el = this.fnGetElementForItem ( this.numSelected );
				if ( el != null ) {
					el.style.backgroundColor = "window";
					el.style.color = "windowtext";
				}
			}
			prototype.fnItemClicked = function ( numIndex ) {
				if ( numIndex != null ) {
					if ( this.numSelected != numIndex ) {
						this.fnHideSelected ();
						this.numSelected = numIndex;
						this.fnPositionSelected ();
						this.fnShowSelected ();
						this.fnSetStem ();						
/**/					documentManager.updateFocusRectangle ();
					}
				}
				if ( document.activeElement != this.elInput ) {
					this.elInput.focus ();
				}
				return true;
			}
			prototype.fnNewStemValueEvent = function () {
				if ( this.strLastStem != this.elInput.value ) {
					this.fnPositionOnNewStem ( this.elInput.value );
					this.elInput.style.pixelWidth = "4";
					var numWidth = this.elInput.scrollWidth + 10;
					if ( numWidth < 100 ) numWidth = 100;
					this.elInput.style.pixelWidth = numWidth;
				}
				this.strLastStem = this.elInput.value;
/**/			documentManager.updateFocusRectangle ();
			}
			prototype.fnPositionOnNewStem = function ( strStem ) {
				var numItem = this.fnFindIndexForStem ( strStem );
				if ( numItem != null ) {
					this.fnHideSelected ();
					this.numSelected = numItem;
					this.fnPositionSelected ();
					this.fnShowSelected ();
/**/				documentManager.updateFocusRectangle ();
				}
			}
			prototype.fnSetStem = function () {
				if ( this.numSelected != null ) {
					var obItem = this.arrayItems [ this.numSelected ];
					if ( obItem != null ) {
						var strText = obItem.fnGetText ();
						this.elInput.value = strText;
					}
				}
			}
			prototype.fnFindIndexForStem = function ( strStem ) {
				var arr = this.arrayItems;
				if ( arr.length == 0 ) {
					return null;
				} else {
					var numMin = 0;
					var numMax = arr.length - 1;
					strStem = strStem.toLowerCase ();
					while ( true ) {
						if ( numMax == numMin ) {
							break;
						} else {
							var numIndex = Math.floor ( ( numMax + numMin ) / 2 );
							var strText = arr [ numIndex ].toString ();
							if ( strStem < strText ) {
								if ( numIndex == numMin ) {
									numMax = numMin;
								} else {
									numMax = numIndex;
								}
							} else if ( strText.indexOf ( strStem ) == 0 ) {
								numMax = numMin = numIndex;
							} else {
								if ( numIndex == numMax ) {
									numMin = numMax;
								} else {
									numMin = numIndex + 1;
								}
							}
						}
					}
					return numMin;
				}
			}
			prototype.fnRenderItem = function ( obItem, numIndex ) {
				var elOuter = document.createElement ( "div" );
				var elInner = document.createElement ( "nobr" );
				elOuter.appendChild ( elInner );
				elInner.style.padding = "0.1em";
				obItem.fnRender ( elInner );
				elOuter._numIndex = numIndex;
				return elOuter;
			}
			prototype.fnAddToEnd = function ( obItem, numIndex ) {
				var elNew = this.fnRenderItem ( obItem, numIndex );
				this.elBody.appendChild ( elNew );
			}
			prototype.fnAddToStart = function ( obItem, numIndex ) {
				var elNew = this.fnRenderItem ( obItem, numIndex );
				this.elBody.insertBefore ( elNew, this.elBody.firstChild );
			}
			prototype.fnMoveDown = function ( numDelta ) {
				if ( this.numSelected == null ) {
					if ( this.arrayItems.length != 0 ) {
						this.numSelected = this.numTop;
					}
				} else {
					var numNew = this.numSelected + numDelta;
					if ( numNew >= this.arrayItems.length ) {
						numNew = this.arrayItems.length - 1;
					}
					if ( this.numSelected == numNew ) {
						return;
					} else {
						this.fnHideSelected ();
						this.numSelected = numNew;
					}
				}
				this.fnPositionSelected ();
				this.fnShowSelected ();
				this.fnSetStem ();
/**/			documentManager.updateFocusRectangle ();
			}
			prototype.fnMoveUp = function ( numDelta ) {
				if ( this.numSelected == null ) {
					if ( this.arrayItems.length != 0 ) {
						this.numSelected = this.numTop;
					}
				} else {
					var numNew = this.numSelected - numDelta;
					if ( numNew < 0 ) {
						numNew = 0 ;
					}
					if ( this.numSelected == numNew ) {
						return;
					} else {
						this.fnHideSelected ();
						this.numSelected = numNew;
					}
				}
				this.fnPositionSelected ();
				this.fnShowSelected ();
				this.fnSetStem ();
/**/			documentManager.updateFocusRectangle ();
			}
			prototype.fnPositionSelected = function () {
				var el = this.fnGetElementForItem ( this.numSelected );
				if ( el == null ) {
					if ( ( this.numSelected - this.numTop ) == this.numMax ) {
						this.elBody.removeChild ( this.elBody.firstChild );
						this.fnAddToEnd ( this.arrayItems [ this.numSelected ], this.numSelected );
						this.numTop++;
					} else if ( ( this.numTop - this.numSelected ) == 1 ) {
						this.elBody.removeChild ( this.elBody.lastChild );
						this.fnAddToStart ( this.arrayItems [ this.numSelected ], this.numSelected );
						this.numTop--;
					} else {
						var numTotal = this.arrayItems.length;
						if ( numTotal - this.numSelected > this.numMax ) {
							this.numTop = this.numSelected;
						} else {
							this.numTop = numTotal - this.numMax;
						}
						if ( this.numTop < 0 ) this.numTop = 0;
						this.fnRedraw ();
					}
				}
			}
			prototype.fnUserCancel = function () {
				this.obOwner.selectionMade ( null );
			}
			prototype.fnOnResize = function () {
				if ( this.bActive ) {
					this.manager.updateFocus ();
				}
			}
			/*--------------------------------------------------------*/
			prototype.onKeyDown = function () {
				var code = event.keyCode;
				if ( code == 40 ) {
					this.fnMoveDown ( 1 );
					return true;
				}
				if ( code == 38 ) {
					this.fnMoveUp ( 1 );
					return true;
				}
				return false;
			}
			prototype.onKeyPress = function () {
				var code = event.keyCode;
				if ( code == 27 ) {
					this.fnUserCancel ();
					return true;
				}
				if ( code == 13 ) {
					if ( this.numSelected != null ) {
						var strStem = this.elInput.value.toString ().toLowerCase ();
						if ( this.arrayItems [ this.numSelected ].toString ().indexOf ( strStem ) == 0 ) {
							var obItem = this.arrayItems [ this.numSelected ];
							this.obOwner.selectionMade ( true, obItem );
						}
					}
					return true;
				}
				return false;
			}
			prototype.onKeyUp = function () {
				this.fnNewStemValueEvent ();
			}
			prototype.focusIn = function () {
				if ( document.activeElement != this.elInput ) {
					this.elInput.focus ();
				}
				this.bActive = true;
			}
			prototype.focusOut = function () {
				this.bActive = true;
			}
			prototype.onClick = function () {
				var el = window.event.srcElement;
				this.manager.setGlobalFocus ( this.manager, this );
				while ( el != this.outerElement ) {
					if ( el._numIndex != null ) {
						this.fnItemClicked ( el._numIndex );
						break;
					}
					el = el.parentElement;
				}
				return true;
			}
			prototype.startDrag = function () {
			}
			prototype.stopDrag = function () {
				if ( this.bActive ) {
					this.manager.updateFocus ();
				}
			}
			prototype.doDrag = function ( dx, dy ) {
				this.elDiv.style.pixelLeft += dx;
				this.elDiv.style.pixelTop += dy;
				if ( this.bActive ) {
					this.manager.hideFocus ();
				}
			}
			/*--------------------------------------------------------*/

			prototype.close = function () {
				this.fnRemove ();
			}
			prototype.setInput = function ( strStem ) {
				if ( document.activeElement != this.elInput ) {
					this.elInput.focus ();
				}
				this.elInput.value = strStem;
				var obRange = this.elInput.createTextRange ();
				obRange.collapse ( false );
				obRange.select ();
			}
		}

/*--------------------------------------------------------------*/

		function scrollingBrowseListObject () {}
		scrollingBrowseListObject.prototype = new baseObject ();
		documentManager.registerClass ( "scrollingBrowseList", scrollingBrowseListObject );

		with ( scrollingBrowseListObject ) {
			prototype.start = function ( element, strClass, obContainer ) {
				this.outerElement = element;
				element.objectHandle = this.handle;
				element.hideFocus = true;
				this.localFocusElement = this.outerElement;
				this.bFoundTop = false;
				this.bFoundBottom = false;
				this.numPixelFill = 200;
				this.elBrowseList = this.outerElement;
				this.numBlocks = 0;
				this.strRequestExtra = this.outerElement.getAttribute ( this.manager.attributePrefix + "RequestExtra" );
				this.bPageMode = ( this.outerElement.getAttribute ( this.manager.attributePrefix + "PageBrowse" ) == "1" );
				this.allowBackSpace = true;
				if ( this.strRequestExtra == null ) this.strRequestExtra = "";
				this.bNoFocus = this.outerElement.getAttribute ( this.manager.attributePrefix + "NoFocus" ) == "1";
				this.bNoPreloadAbove = this.outerElement.getAttribute ( this.manager.attributePrefix + "NoPreloadAbove" ) == "1";
				this.bFixedContent = this.outerElement.getAttribute ( this.manager.attributePrefix + "FixedContent" ) == "1";
				if ( this.elBrowseList.firstChild != null ) {
					var elDiv = this.elBrowseList.firstChild;
                    
					if ( elDiv.nodeType == 1 ) {
						this.bFoundTop = ( elDiv.getAttribute ( "bFoundTop" ) == "1" );
						this.bFoundBottom = ( elDiv.getAttribute ( "bFoundBottom" ) == "1" );
					}
				}
				obContainer.traverseChildren ( element ); // Recurse binding to child elements.
				this.bNoScrollBar = this.outerElement.getAttribute ( this.manager.attributePrefix + "NoScrollBar" ) == "1";
				this.strMarkerClass = this.outerElement.getAttribute ( this.manager.attributePrefix + "StopBarClass" );
				this.elBrowseList.style.overflow = this.bNoScrollBar ? "hidden" : "auto";
				this.obAppServer = new cHttpFetcher ( this.manager.getUseScriptHTTPFetcher () );
				this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
				this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );
				this.showFocus = false;
				this.manager.addTask ( this.createCallback ( "fnOnStart" ) );
				this.fnPollCallBack = this.createCallback ( "fnOnPoll" );
				this.strName = element.id;
				if ( this.bFixedContent ) {
					this.bFoundTop = true;
					this.bFoundBottom = true;
				}
			}
			prototype.fnOnStart = function () {
				if ( this.elBrowseList.parentElement == null ) {
					// The page was unloaded before we got a chance to start.
					return;
				}
				if ( document.body.offsetHeight < 20 ) {
					this.manager.addTask ( this.createCallback ( "fnOnStart" ) );
				} else {
					this.elBrowseList.style.pixelHeight = this.elBrowseList.offsetHeight;
					if ( ! this.bPageMode ) {
						this.elBrowseList.style.pixelHeight = this.elBrowseList.offsetHeight;
						this.elTopStop = document.createElement ( "div" );
						this.elBottomStop = document.createElement ( "div" );
						this.elPad = document.createElement ( "div" );
						this.elTopStop.appendChild ( document.createElement ( "br" ) );
						this.elBottomStop.appendChild ( document.createElement ( "br" ) );
						this.elPad.appendChild ( document.createElement ( "br" ) );
						this.elBrowseList.insertBefore ( this.elTopStop, this.elBrowseList.firstChild );
						this.elBrowseList.appendChild ( this.elBottomStop );
						this.elBrowseList.appendChild ( this.elPad );
						if ( this.strMarkerClass != null ) {
							this.elTopStop.className = this.strMarkerClass;
							this.elBottomStop.className = this.strMarkerClass;
						} else {
							this.elTopStop.style.backgroundColor = "scrollbar";
							this.elBottomStop.style.backgroundColor = "scrollbar";
						}
						this.fnColorMarkers ();
						var strDisplay = ( this.bFoundTop && this.bFoundBottom ) ? "none" : "block";
						this.elTopStop.style.display = strDisplay;
						this.elBottomStop.style.display = strDisplay;
						this.elBrowseList.scrollTop = this.elTopStop.offsetHeight;
						this.fnDoResize ();
						this.elBrowseList.onscroll = this.createCallback ( "fnOnScroll" );
						this.elBrowseList.offsetParent.onresize = this.createCallback ( "fnOnResizeParent" );
						if ( this.bNoScrollBar ) {
							this.elBrowseList.onmousewheel = this.createCallback ( "fnOnMouseWheel" );
						}
					}
					if ( ! this.bNoFocus ) {
						this.fnSetFocus ();
					}
					this.fnFill ();
				}
			}
			prototype.fnGetSpareSpace = function () {
				var elOffsetParent = this.elBrowseList.offsetParent;
				return elOffsetParent.clientHeight - elOffsetParent.scrollHeight;
			}
			prototype.fnDoResize = function () {
				var obRect = this.elBrowseList.getBoundingClientRect ();
				var obRectScreen = document.body.getBoundingClientRect ();
				var numScreenHeight = obRectScreen.bottom - obRectScreen.top;
				var numClientHeight = obRect.bottom - obRect.top;
				if ( obRect.bottom > obRectScreen.bottom ) {
					numClientHeight = obRectScreen.bottom - obRect.top;
				}
				this.elBrowseList.style.pixelHeight = numClientHeight;

				var numScroll = this.elBrowseList.scrollTop;

				this.elBrowseList.style.pixelHeight = this.elBrowseList.offsetHeight + this.fnGetSpareSpace ();

				this.elPad.style.pixelHeight = this.elBrowseList.offsetHeight - this.elBottomStop.offsetHeight;
				this.elBrowseList.scrollTop = numScroll;
				if ( this.bNoPreloadAbove ) {
					if ( this.elBrowseList.scrollTop < this.elTopStop.offsetHeight ) {
						this.elBrowseList.scrollTop = this.elTopStop.offsetHeight;
					}
				}
			}
			prototype.fnOnResizeParent = function () {
				if ( ! this.bUpdatingList ) {
					var numPW = this.elBrowseList.offsetParent.offsetWidth;
					var numPH = this.elBrowseList.offsetParent.offsetHeight;
					if ( ( this.numPW != numPW ) || ( this.numPH != numPH ) ) {
						this.numPW = numPW;
						this.numPH = numPH;
						if ( ! this.bScheduledResize ) {
							this.bScheduledResize = true;
							this.manager.addTask ( this.createCallback ( "fnActionResize" ) );
						}
					}
				}
			}
			prototype.fnActionResize = function () {
				this.fnDoResize ();
				this.fnFill ();
				this.bScheduledResize = false;
			}
			prototype.fnOnMouseWheel = function () {
				var numMove = this.elBrowseList.clientHeight * 0.1;
				if ( numMove > 30 ) numMove = 30;
				if ( event.wheelDelta >= 120 ) {
					if ( this.fnGetCanScrollUp () ) {
						this.elBrowseList.scrollTop -= numMove;
					}
				}
				if ( event.wheelDelta <= -120 ) {
					if ( this.fnGetCanScrollDown () ) {
						this.elBrowseList.scrollTop += numMove;
					}
				}
				event.cancelBubble = true;
				event.returnValue = false;
				this.manager.activity ();
			}
			prototype.fnOnScroll = function () {
				if ( this.strPendingRequest != null ) {
					if ( this.obAppServer.IsAsyncWaiting () ) {
						if ( this.obAppServer.IsAsyncReady () ) {
							this.fnProcessResponse ();
						}
					}
				} else {
					if ( ! this.bUpdatingList ) {
						if ( this.bNoPreloadAbove ) {
							if ( this.elBrowseList.scrollTop < this.elTopStop.offsetHeight ) {
								this.bNoPreloadAbove = false;
							}
						}
						this.fnFill ();
					}
				}
			}
			prototype.fnProcessResponse = function () {
				if ( ! this.obAppServer.IsParsedOK () ) {
					this.bBadResponse = true;
				} else {
					var bUp = ( this.strPendingRequest == "up" );
					var elDiv = document.createElement ( "div" );
					var bIsEmpty = false;
					this.bUpdatingList = true;
					if ( bUp ) {
						this.elBrowseList.insertBefore ( elDiv, this.elTopStop.nextSibling );
						elDiv.innerHTML = this.obAppServer.GetResponseBody ();
						if ( elDiv.children.length == 0 ) {
							elDiv.removeNode ( true );
							bIsEmpty = true;
						} else {
							this.elBrowseList.scrollTop += elDiv.scrollHeight;
						}
					} else {
						this.elBrowseList.insertBefore ( elDiv, this.elBottomStop );
						elDiv.innerHTML = this.obAppServer.GetResponseBody ();
						if ( elDiv.children.length == 0 ) {
							elDiv.removeNode ( true );
							bIsEmpty = true;
						}
					}
					if ( ! bIsEmpty ) {
						this.manager.bindChildElements ( elDiv );
                        var to = this.obAppServer.RspGet ( "targetObject", "???" );
                        // it is more sensible to only do this, if we recieve a new target object !!
                        // otherwise we get into a nasty situation where we use an invalid URL and end up in
                        // a loop !!
                        if (to != "???")
                        {
                            elDiv.setAttribute ( "targetObject", to );
                        }
						this.numBlocks++;
						if ( this.obAppServer.RspGet ( "strStartHandle", "" ) != "" ) {
							if ( this.obAppServer.RspGet ( "strEndHandle", "" ) != "" ) {
								elDiv.strStartHandle = this.obAppServer.RspGet ( "strStartHandle", "" );
								elDiv.strEndHandle = this.obAppServer.RspGet ( "strEndHandle", "" );
							}
						}
					}
					if ( this.obAppServer.RspGet ( "bFoundTop", "0" ) == 1 ) {
						this.bFoundTop = true;
					}
					if ( this.obAppServer.RspGet ( "bFoundBottom", "0" ) == 1 ) {
						this.bFoundBottom = true;
					}
					this.fnColorMarkers ();
					delete this.bUpdatingList;
					delete this.strPendingRequest;
					this.fnFill ();
				}
			}
			prototype.fnOnPoll = function () {
				if ( this.elBrowseList.parentElement == null ) {
					// The page was unloaded.
					return;
				}
				if ( this.obAppServer.IsAsyncWaiting () ) {
					if ( ! this.obAppServer.IsAsyncReady () ) {
						window.setTimeout ( this.fnPollCallBack, 10 );
					} else {
						this.fnProcessResponse ();
						if ( this.fnOnMoreCallback != null ) {
							this.fnOnMoreCallback ();
							this.fnOnMoreCallback = null;
						}
					}
				}
			}
			prototype.fnRequestMore = function ( bUp ) {
				if ( ( this.strPendingRequest == null ) && ( ! this.bBadResponse ) ) {
					var el = bUp ? this.elTopStop.nextSibling : this.elBottomStop.previousSibling;
					this.strPendingRequest = bUp ? "up" : "down";
					this.obAppServer.ClearCmd ();
					this.obAppServer.SetUseUTF8Request ( 1 );
					this.obAppServer.SetCmdPrefix ( el.getAttribute ( "targetObject" ) + this.strRequestExtra + "&ResponseEncoding=utf-8" );
					this.obAppServer.CmdSet ( "Method", bUp ? "FetchIncrementalBrowseUp" : "FetchIncrementalBrowseDown" );
					this.obAppServer.SetUseMSXMLHTTPRequest ( 1 );
					if ( this.numBlocks > 5 ) {
						var elBlock = bUp ? this.elBottomStop.previousSibling : this.elTopStop.nextSibling;
						var numStart = parseInt ( elBlock.getAttribute ( "strStartHandle" ) );
						var numEnd = parseInt ( elBlock.getAttribute ( "strEndHandle" ) );
						this.bUpdatingList = true;
						if ( bUp ) {
							this.bFoundBottom = false;
						} else {
							this.bFoundTop = false;
						}
						this.fnColorMarkers ();
						if ( ! ( isNaN ( numStart ) || isNaN ( numEnd ) ) ) {
							this.obAppServer.CmdSet ( "RemoveItemsStart", numStart.toString () );
							this.obAppServer.CmdSet ( "RemoveItemsEnd", numEnd.toString () );
							this.manager.removeChildElements ( elBlock );
							if ( bUp ) {
								elBlock.removeNode ( true );
							} else {
								var numCorrectedScrollTop = this.elBrowseList.scrollTop - elBlock.scrollHeight;
								elBlock.removeNode ( true );
								this.elBrowseList.scrollTop = numCorrectedScrollTop;
							}
							this.numBlocks--;
						}
						delete this.bUpdatingList;
					}
					this.obAppServer.DoCmdAsync ();
					this.fnOnPoll ();
				}
			}
			prototype.fnExternalRequestMore = function ( bUp, fnCallback ) {
				if ( this.bPageMode ) {
					return false;
				} else {
					if ( bUp ) {
						if ( this.bFoundTop ) return false;
					} else {
						if ( this.bFoundBottom ) return false;
					}
					if ( this.strPendingRequest != null ) {
						return false;
					}
					this.bNoPreloadAbove = false;
					this.fnRequestMore ( bUp );
					this.fnOnMoreCallback = fnCallback;
					return true;
				}
			}
			prototype.fnColorMarkers = function () {
				this.elTopStop.style.visibility = this.bFoundTop ? "visible" : "hidden";
				this.elBottomStop.style.visibility = this.bFoundBottom ? "visible" : "hidden";
			}
			prototype.fnGetCanScrollUp = function () {
				with ( this.elBrowseList ) {
					var numAbove = scrollTop;
					var numUp = 0;
					if ( this.bFoundTop ) {
						numUp = this.elTopStop.offsetHeight;
					}
					return numAbove > numUp;
				}
			}
			prototype.fnGetCanScrollDown = function () {
				with ( this.elBrowseList ) {
					var numBelow = ( ( scrollHeight - this.elPad.offsetHeight ) - scrollTop ) - clientHeight;
					return numBelow > 0;
				}
			}
            
            prototype.fnMakeVisible = function (elem,top) {
                // if top then we want to make the top of the item visible otherwise we will make the bottom visible
                var top_y = this.elBrowseList.scrollTop;
                var bot_y = this.elBrowseList.scrollTop+this.elBrowseList.clientHeight;
                var elem_y = elem.offsetTop;
                //debugger;    
                
                var p = elem.offsetParent;
                
                while
                    ((p != null ) && (p != this.elBrowseList )  && (this.elBrowseList.contains(p)))
                {
                    //alert(elem_y);
                    elem_y += p.offsetTop;
                    p = p.offsetParent;
                }
                
                if (p == null )
                {
                    
                    alert("Make visible called on element which is not a child of the browse list");
                    var p = elem.offsetParent;
                    while
                        ((p != null ) && (p != this.elBrowseList ))
                    {
                        alert(p.innerHTML);
                        p = p.offsetParent;
                    }
                    
                }
                
                var elem_by  = elem_y+elem.clientHeight;
                elem_by += this.elBrowseList.scrollTop;
                //alert("top_y is "+ top_y );
                //alert("bot_y is "+ bot_y );
                //alert("elem_y is "+elem_y);
                //alert("elem_by is "+elem_by);
                
                if ( elem_y < top_y )
                {
                   if (elem_y > 100 ) elem_y -= 100;
                   this.elBrowseList.scrollTop = elem_y;
                }
                
                
                if ( elem_y > bot_y )
                {
                    //alert("we need to scroll down");
                    
                    // so we want scroll top to be as follows.
                    
                    var scroll_top = elem_y - bot_y+ this.elBrowseList.scrollTop;
                    scroll_top+=100;
                    
                    //if (scroll_top + this.elBrowseList.clientHeight > this.elBrowseList.offsetHeight )
                    //{
                    //   scroll_top = 
                    
                    //alert(scroll_top);
                    
                    this.elBrowseList.scrollTop = scroll_top;
                }

                
            }
			prototype.fnFill = function () {
				if ( this.strPendingRequest == null ) {
					with ( this.elBrowseList ) {
						if ( ! this.bPageMode ) {
							var numAbove = scrollTop;
							var numBelow = ( ( scrollHeight - this.elPad.offsetHeight ) - scrollTop ) - clientHeight;
							var numPixelFill = this.numPixelFill;
							if ( this.strName != null ) {
								var obUpdate = new updateObject ();
								var numUp = 0;
								if ( this.bFoundTop ) {
									numUp = this.elTopStop.offsetHeight;
								}
								obUpdate.write ( this.strName, "canScrollUp", this.fnGetCanScrollUp () );
								obUpdate.write ( this.strName, "canScrollDown", this.fnGetCanScrollDown () );
								this.manager.interface.syncUpdate ( obUpdate );
							}
							if ( numBelow < numPixelFill ) {
								if ( ! this.bFoundBottom ) {
									this.fnRequestMore ( false );
									return;
								}
							}
							if ( numAbove < numPixelFill ) {
								if ( this.bNoPreloadAbove != true ) {
									if ( ! this.bFoundTop ) {
										this.fnRequestMore ( true );
										return;
									}
								}
							}
						}
					}
				}
			}
			prototype.fnFindTopCandidate = function ( el, elOffsetParent, numTop, numBottom, fnTest ) {
				for ( var elChild = el.firstChild; elChild != null; elChild = elChild.nextSibling ) {
					if ( elChild.nodeType == 1 ) {
						var numChildTop = 0;
						var elP = elChild;
						while ( true ) {
							numChildTop += elP.offsetTop;
							elP = elP.offsetParent;
							if ( elP == elOffsetParent ) break;
							if ( elP == null ) return null;
						}
						if ( numChildTop < numBottom ) {
							var numChildBottom = numChildTop + elChild.offsetHeight;
							if ( numChildBottom > numTop ) {
								var obResult = fnTest ( elChild );
								if ( obResult == null ) {
									obResult = this.fnFindTopCandidate ( elChild, elOffsetParent, numTop, numBottom, fnTest );
								}
								if ( obResult != null ) {
									return obResult;
								}
							}
						}
					}
				}
				return null;
			}
			prototype.fnFindTopObject = function ( fnTest ) {
				var numTop = this.elBrowseList.scrollTop;
				var numBottom = numTop + this.elBrowseList.offsetHeight;
				return this.fnFindTopCandidate ( this.elBrowseList, this.elBrowseList, numTop, numBottom, fnTest );
			}
			prototype.fnGetTopListItemElement = function () {
				var obManager = this.manager;
				var fnTest = function ( el ) {
					if ( el.objectHandle != null ) {
						var ob = obManager.getObject ( el.objectHandle );
						if ( ob != null ) {
							if ( ob.selectable != null ) {
								return ob;
							}
						}
					}
					return null;
				}
				return this.fnFindTopObject ( fnTest );
			}
			prototype.fnGetTopListItemIdentifier = function () {
				var strAttr = this.manager.attributePrefix + "ListItemIdentifier";
				var fnTest = function ( el ) {
					if ( el.nodeType == 1 ) {
						var str = el.getAttribute ( strAttr );
						if ( str != null ) {
							return el;
						}
					}
					return null;
				}
				var el = this.fnFindTopObject ( fnTest );
				if ( el != null ) {
					return el.getAttribute ( strAttr );
				}
				return null;
			}
			prototype.fnSelectTop = function () {
				if ( this.manager.selectedObject == null ) {
					var elTop = this.fnGetTopListItemElement ();
					if ( elTop != null ) {
						this.manager.setSelectedObject ( elTop );
					}
				}
			}
			prototype.fnSetFocus = function () {
				this.fnSelectTop ();
				this.elBrowseList.focus ();
			}
			prototype.fnDoScrollUp = function ( numPixels ) {
				this.elBrowseList.scrollTop -= numPixels;
			}
			prototype.fnDoScrollDown = function ( numPixels ) {
				this.elBrowseList.scrollTop += numPixels;
			}
			prototype.fnGetPercentAsPixels = function ( numPercent ) {
				var numHeight = this.elBrowseList.clientHeight;
				numPercent = parseFloat ( numPercent.toString () );
				return ( numPercent / 100.0 ) * numHeight;
			}
			prototype.fnDoScrollUpPercent = function ( numPercent ) {
				this.fnDoScrollUp ( this.fnGetPercentAsPixels ( numPercent ) );
			}
			prototype.fnDoScrollDownPercent = function ( numPercent ) {
				this.fnDoScrollDown ( this.fnGetPercentAsPixels ( numPercent ) );
			}
			/*--------------------------------------------------------*/
			prototype.onKeyDown = function () {
				var code = event.keyCode;
				return false;
			}
			prototype.onKeyPress = function () {
				var code = event.keyCode;
				return false;
			}
			prototype.onKeyUp = function () {
			}
			prototype.focusIn = function () {
				if ( ! this.bActive ) {
					this.fnSelectTop ();
					this.bActive = true;
				}
			}
			prototype.focusOut = function () {
				this.bActive = true;
			}
		}

/*--------------------------------------------------------------*/

		function browseListScrollButtonObject ()
		{
			this.showHover = true;
			this.disabled = false;
		}
		documentManager.registerClass ( "scrollButton", browseListScrollButtonObject );
		browseListScrollButtonObject.prototype = new baseObject ();

		with ( browseListScrollButtonObject ) {
	
			prototype.start = function ( element ) {
				this.outerElement = element;
				element.objectHandle = this.handle;
				this.localFocusElement = element;
				this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
				this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );
				var tabIndex = this.getInheritedAttribute ( this.manager.attributePrefix + "TabIndex" );
				if ( tabIndex != null ) {
					this.localFocusElement.tabIndex = tabIndex;
				}
				this.strListID = this.outerElement.getAttribute ( this.manager.attributePrefix + "ListID" );
				this.strType = this.outerElement.getAttribute ( this.manager.attributePrefix + "Type" );
				this.showHover = this.outerElement.getAttribute ( this.manager.attributePrefix + "ShowHover" ) == "1";
				this.showFocus = this.outerElement.getAttribute ( this.manager.attributePrefix + "ShowFocus" ) == "1";
				if ( this.strType != null ) {
					this.bUp = this.strType.toLowerCase () == "up"
				}
				this.bDisabled = "unknown";
				this.manager.attatch ( this, false );
				//this.localFocusElement.onclick = this.createCallback ( "fnOnClick" );
				this.localFocusElement.onmousedown = this.createCallback ( "fnOnMouseDown" );
				this.localFocusElement.onmouseup = this.createCallback ( "fnOnMouseUp" );
				this.localFocusElement.onmouseout = this.createCallback ( "fnOnMouseUp" );
				this.fnScrollRepeatCallBack = this.createCallback ( "fnDoScrollRepeat" );
				this.numTickLength = 25;
				this.numTargetScrollPixels = parseFloat ( window.screen.height ) / 150.0;
			}
			prototype.fnGetBrowseListObject = function () {
				if ( this.strListID != null ) {
					var elBrowseList = document.all [ this.strListID ];
					if ( elBrowseList != null ) {
						var numHandle = elBrowseList.objectHandle;
						return documentManager.getObject ( numHandle );
					}
				}
				return null;
			}
			prototype.fnOnMouseUp = function () {
				this.bDown = false;
				this.updateButtonState ();
				return false;
			}
			prototype.fnOnMouseDown = function () {
				if ( ! this.bDown ) {
					this.bDown = true;
					this.updateButtonState ();
					this.fnStartScrollRepeat ();
				}
				return false;
			}
			prototype.fnStartScrollRepeat = function () {
				if ( ! this.bPending ) {
					this.numTime = null;
					this.numScrollPixels = this.numTargetScrollPixels;
					this.fnActionScrollRepeat ();
					this.fnScheduleScrollRepeat ();
				}
			}
			prototype.fnScheduleScrollRepeat = function () {
				this.bPending = true;
				window.setTimeout ( this.fnScrollRepeatCallBack, this.numTickLength );
			}
			prototype.fnDoScrollRepeat = function () {
				this.fnActionScrollRepeat ();
				if ( this.bDown ) {
					this.fnScheduleScrollRepeat ();
				} else {
					this.bPending = false;
				}
			}
			prototype.fnActionScrollRepeat = function () {
				var numNewTime = new Date ().getTime ();
				var numScale = 1.0;
				if ( this.numTime != null ) {
					var numDiff = numNewTime - this.numTime;
					if ( numDiff > this.numTickLength ) {
						numScale = 1.0 + ( ( numDiff - this.numTickLength ) / parseFloat ( this.numTickLength ) );
					}
				}
				var numTargetScrollPixels = numScale * this.numTargetScrollPixels;
				if ( this.numScrollPixels < numTargetScrollPixels ) {
					this.numScrollPixels += 1.0;
				} else {
					this.numScrollPixels -= 1.0;
				}
				this.numTime = numNewTime;
				if ( this.bDown ) {
					if ( this.outerElement == null ) {
						// The page was unloaded.
					} else {
						if ( ! this.bDisabled ) {
							var obList = this.fnGetBrowseListObject ();
							if ( obList != null ) {
								if ( this.bUp ) {
									obList.fnDoScrollUp ( this.numScrollPixels );
								} else {
									obList.fnDoScrollDown ( this.numScrollPixels );
								}
							}
						}
					}
				}
			}
			prototype.notifyChange = function () {
				if ( this.strListID != null ) {
					var bDisabled = false;
					if ( this.bUp ) {
						bDisabled = this.interface.read ( this.strListID, "canScrollUp" ) != true;
					} else {
						bDisabled = this.interface.read ( this.strListID, "canScrollDown" ) != true;
					}
					if ( this.bDisabled != bDisabled ) {
						this.bDisabled = bDisabled;
						this.updateButtonState ();
					}
				}
			}

			prototype.updateButtonState = function () {
				if ( this.bDisabled ) {
					this.localFocusElement.className = "sScrollButtonDisabled";
				} else {
					this.localFocusElement.className = this.bDown ? "sScrollButtonDown" : "sScrollButtonEnabled";
				}
				this.manager.viewUpdated ();
			}
		}

/*--------------------------------------------------------------*/

		function dragHandleObject ()
		{
		}
		
		documentManager.registerClass ( "dragHandle", dragHandleObject );
		
		dragHandleObject.prototype = new baseObject ();
	
		dragHandleObject.prototype.start = function ( element, objectClass ) {

			this.outerElement = element;
			element.objectHandle = this.handle;

			this.localFocusElement = null;

			this.outerElement.onselectstart = new Function ( "return false;" );
			this.outerElement.ondragstart = new Function ( "return false;" );

			this.type = this.getInheritedAttribute ( this.manager.attributePrefix + "Type" );
			this.handler = this.getInheritedAttribute ( this.manager.attributePrefix + "Handler" );
		}
		
		dragHandleObject.prototype.onClick = function () { 

			if
				( this.type.toLowerCase () == "close" )
			{
				this.manager.addImperativeTask ( new Function ( "documentManager.close();" ) );
			}
		}

		dragHandleObject.prototype.doDrag = function ( dx, dy ) {

			var method = this.type.toLowerCase ();

			if ( method != "close" ) {

				var handler = this.handler;

				if ( this.handler == null ) {

					handler = "documentManager";
				}

				this.manager.addImperativeTask ( new Function ( handler + "." + method + " ( " + dx + ", " + dy + " );" ) );
			}
		}

/*--------------------------------------------------------------*/

	function processBaseObject () {
	}

	processBaseObject.prototype.read = function ( fieldName, propertyName ) {

		return this.interface.read ( fieldName, propertyName );
	}

	processBaseObject.prototype.write = function ( fieldName, propertyName, value ) {

		this.interface.write ( fieldName, propertyName, value );
	}

	processBaseObject.prototype.notifyChange = function () {
	}

/*--------------------------------------------------------------*/

	function transactionBaseObject ( updates, database ) {

		this.updates = updates;
		this.database = database;
	}

	transactionBaseObject.prototype.newFieldName = function () {

		return this.database.newFieldName ();
	}

	transactionBaseObject.prototype.read = function ( fieldName, propertyName ) {

		if ( this.updates.isWriteDefined ( fieldName, propertyName ) ) {
			return this.updates.peekWrite ( fieldName, propertyName );
		}
		return this.database.read ( fieldName, propertyName );
	}

	transactionBaseObject.prototype.write = function ( fieldName, propertyName, value ) {

		this.updates.write ( fieldName, propertyName, value );
	}

/*--------------------------------------------------------------*/

	var validatorGlobals = new Object ();

	function validatorBaseObject () {

		this.globals = validatorGlobals;
	}

	validatorBaseObject.prototype.read = function ( propertyName ) {

		return this.interface.read ( this.fieldName, propertyName );
	}

	validatorBaseObject.prototype.write = function ( propertyName, value ) {

		this.interface.write ( this.fieldName, propertyName, value );

		if
			( value == "" )
		{
			if
				( propertyName == "value" )
			{
				this.blank = true;
			}
		}
	}

	validatorBaseObject.prototype.notifyChange = function () {

		if
			( this.interface.read ( this.fieldName, "checked" ) == false )
		{
			var value = this.interface.read ( this.fieldName, "value" );

			if
				( value != null )
			{
				this.interface.write ( this.fieldName, "checked", true );
				this.interface.write ( this.fieldName, "valid", true );
				this.interface.write ( this.fieldName, "advice", "" );
				this.blank = false;

				this.validate ( value );

				if
					( this.blank && ( this.booleanTrue ( this.parameters.AllowBlank ) ) )
				{
					this.interface.write ( this.fieldName, "valid", true );
					this.interface.write ( this.fieldName, "advice", "" );
				}
			}
		}
	}

	validatorBaseObject.prototype.booleanTrue = function ( value ) {

		if
			( value != null )
		{
			if
				( value != 0 )
			{
				if
					( value.toLowerCase () != "false" )
				{
					return true;
				}
			}
		}

		return false;
	}

	validatorBaseObject.prototype.initialise = function () {
	}
	validatorBaseObject.prototype.validate = function () {
	}

/*--------------------------------------------------------------*/

	function defaultValidatorObject () {

		this.parameters = new Object ();
	}

	defaultValidatorObject.prototype = new validatorBaseObject ();

	documentManager.registerType ( "default", defaultValidatorObject );

/*--------------------------------------------------------------*/

	function stringValidatorObject () {

		this.parameters = new Object ();

		this.parameters.Type = null;
		this.parameters.MinimumLength = 0;
		this.parameters.MaximumLength = null;
		this.parameters.RequiredCase = "either";
		this.parameters.ForceInvalid = 0;
		this.parameters.DisallowLeadingWhiteSpace = 0;
		this.parameters.Pattern = null;
	}

	stringValidatorObject.prototype = new validatorBaseObject ();

	documentManager.registerType ( "String", stringValidatorObject );
	documentManager.registerType ( "LongString", stringValidatorObject );

	stringValidatorObject.prototype.validate = function ( value ) {

		var p = this.parameters;

		if
			( this.booleanTrue( p.DisallowLeadingWhiteSpace ) )
		{
			// Remove leading white space
			var newValue = value.replace( /^\s+/g, "" );
			if
				( newValue != value )
			{
				value = newValue;
				this.write ( "value", value );
			}
		}

		if
			( p.Pattern != null )
		{
			var re = new RegExp( "" + p.Pattern, "g" );
			var arr = value.match( re );
			var newValue;
			if ( arr )
				newValue = arr[0];
			else
				newValue = "";
			if
				( newValue != value )
			{
				value = newValue;
				this.write ( "value", value );
			}
		}

		if
			(p.RequiredCase == "upper")
		{
			var newValue = value.toUpperCase();
			if
				( newValue != value )
			{
				value = newValue;
				this.write ( "value", value );
			}
		}
		else
		if
			( p.RequiredCase == "lower" )
		{
			var newValue = value.toLowerCase();
			if
				( newValue != value )
			{
				value = newValue;
				this.write ( "value", value );
			}
		}

		if
			( p.MaximumLength != null )
		{
			if
				( value.length > p.MaximumLength )
			{
				value = value.slice ( 0, p.MaximumLength );
				this.write ( "value", value );
			}
		}

		if
			( p.MinimumLength != null )
		{
			if
				( value.length < p.MinimumLength )
			{
				this.write ( "valid", false );
				this.write ( "advice", "StringTooShort" );
			}
		}

		if
			( this.booleanTrue( p.ForceInvalid ) )
		{
			this.write ( "valid", false );
		}
	}

/*--------------------------------------------------------------*/

	function numberValidatorObject () {

		this.parameters = new Object ();

		this.parameters.Type = null;
		this.parameters.LowerBound = 0;
		this.parameters.UpperBound = null;
		this.parameters.DecimalPlaces = 0;
		this.parameters.AllowBlank = null;
	}

	numberValidatorObject.prototype = new validatorBaseObject ();

	documentManager.registerType ( "Numeric", numberValidatorObject );

	numberValidatorObject.prototype.validate = function ( value ) {

		var p = this.parameters;

		var result = "";
		var foundPoint = false;
		var foundNumber = false;
		var foundMinus = false;
		var places = 0;

		var result = "";

		for
			( var i = 0; i < value.length; i++ )
		{
			var c = value.charAt ( i );

			if
				( ( c >= "0" ) && ( c <= "9" ) )
			{
				foundNumber = true;

				if
					( foundPoint )
				{
					places++;

					if
						( places > p.DecimalPlaces )
					{
						break;
					}
				}
			}
			else
			if
				( c == "." )
			{
				if
					( p.DecimalPlaces == 0 )
				{
					break;
				}
				if
					( foundPoint )
				{
					break;
				}
				foundPoint = true;
			}
			else
			if
				( c == "-" )
			{
				if
					( foundNumber )
				{
					break;
				}
				if
					( foundMinus )
				{
					break;
				}
				foundMinus = true;
			}
			else
			{
				break;
			}

			result += c;
		}

		value = result;

		if
			( ! foundNumber )
		{
			this.write ( "valid", false );
			this.write ( "advice", "NotANumber" );
		}
		else
		{
			if
				( p.UpperBound != null )
			{
				if
					( parseFloat ( value ) > parseFloat ( p.UpperBound ) )
				{
					this.write ( "valid", false );
					this.write ( "advice", "NumberTooLarge" );
				}
			}

			if
				( parseFloat ( value ) < parseFloat ( p.LowerBound ) )
			{
				this.write ( "valid", false );
				this.write ( "advice", "NumberTooSmall" );
			}
		}

		this.write ( "value", value );
	}

/*--------------------------------------------------------------*/

	function dateValidatorObject () {

		this.parameters = new Object ();

		this.parameters.Type = null;
		this.parameters.LowerBound = null;
		this.parameters.UpperBound = null;
		this.parameters.AllowBlank = null;
	}

	dateValidatorObject.prototype = new validatorBaseObject ();

	documentManager.registerType ( "Date", dateValidatorObject );

	dateValidatorObject.prototype.today = function () {

		return this.control.TodayDay + '/' + this.control.CurrentMonth + '/' + this.control.CurrentYear;
	}

	dateValidatorObject.prototype.initialise = function () {

		if
			( this.control == null )
		{
			var controlId = "ALSiDateCheckerControl";

			this.control = document.all [ controlId ];

			if
				( this.control == null )
			{
				document.body.insertAdjacentHTML ( "beforeEnd", "<OBJECT id=" + controlId + " classid='CLSID:0A4B7BA2-26BA-11D2-BC93-00A024A86646' width=0 height=0></OBJECT>" );
				this.control = document.all [ controlId ];
				dateValidatorObject.control = this.control;
			}
		}

		if
			( this.control != null )
		{
			if
				( this.parameters.LowerBound != null )
			{
				if
					( this.parameters.LowerBound.toLowerCase () == "today" )
				{
					this.parameters.LowerBound = this.today ();
				}
			}
			else
			{
				this.parameters.LowerBound = "01/01/1900";
			}

			if
				( this.parameters.UpperBound != null )
			{
				if
					( this.parameters.UpperBound.toLowerCase () == "today" )
				{
					this.parameters.UpperBound = this.today ();
				}
			}
			else
			{
				this.parameters.UpperBound = "31/12/9999";
			}
		}
	}

	dateValidatorObject.prototype.validate = function ( value ) {

		if
			( this.control != null )
		{
			this.control.HBound = this.parameters.UpperBound;
			this.control.LBound = this.parameters.LowerBound;

			this.control.DateStr = value;

			var partial_form = this.control.ValidInput;
			var full_form = this.control.DateStr;

			// We need to go through this to overcome a strange problem with the control...

			this.control.LBound = "01/01/1900";
			this.control.HBound = "01/01/1900";
			this.control.DateStr = "01/01/1900";

			this.control.HBound = this.parameters.UpperBound;
			this.control.LBound = this.parameters.LowerBound;
			this.control.DateStr = full_form;

			// 

			if
				( this.control.Completed == 0 )
			{
				this.write ( "valid", false );
				this.write ( "advice", this.control.StateAsStr );
			}

			if
				( this.read ( "edit" ) == false )
			{
				this.write ( "value", full_form );
			}
			else
			{
				if
					( partial_form != value )
				{
					var done = false;

					if
						( partial_form.charAt ( partial_form.length - 1 ) == "/" )
					{
						if
							( ( partial_form.length - value.length ) == 1 )
						{
							done = true;
						}
						else
						if
							( partial_form.length == value.length )
						{
							{
								value = partial_form + value.charAt ( value.length - 1 );
								done = true;
							}
						}
					}

					if
						( ! done )
					{
						value = partial_form;
					}
				}

				this.write ( "value", value );
			}
		}
	}

/*--------------------------------------------------------------*/

	function controlNumberValidatorObject () {

		this.parameters = new Object ();

		this.parameters.Type = null;
		this.parameters.AllowBlank = null;
	}

	controlNumberValidatorObject.prototype = new validatorBaseObject ();

	documentManager.registerType ( "ItemNo", controlNumberValidatorObject );
	documentManager.registerType ( "BrwrNo", controlNumberValidatorObject );
	documentManager.registerType ( "BacNo", controlNumberValidatorObject );
	documentManager.registerType ( "ReservationNo", controlNumberValidatorObject );
	documentManager.registerType ( "ControlNo", controlNumberValidatorObject );
	documentManager.registerType ( "PrdNo", controlNumberValidatorObject );
	documentManager.registerType ( "ISBN", controlNumberValidatorObject );
	documentManager.registerType ( "RecPtr", controlNumberValidatorObject );
	documentManager.registerType ( "AcqRecPtr", controlNumberValidatorObject );
	documentManager.registerType ( "EANNo", controlNumberValidatorObject );

	controlNumberValidatorObject.prototype.initialise = function () {

		if
			( this.control == null )
		{
			var controlId = "ALSiControlNumberCheckerControl";

			this.control = document.all [ controlId ];

			if
				( this.control == null )
			{
				document.body.insertAdjacentHTML ( "beforeEnd", "<OBJECT id=" + controlId + " CLASSID='CLSID:80E620E0-F631-11D1-A71C-000021750386' width=0 height=0></OBJECT>" );
				this.control = document.all [ controlId ];

				if
					( this.control != null )
				{
					var fail = false;

					if
						( this.globals.BFormat != null )
					{
						this.control.BFormat = this.globals.BFormat;
					}
					else
					{
						fail = true
					}
					if
						( this.globals.LFormat != null )
					{
						this.control.LFormat = this.globals.LFormat;
					}
					else
					{
						fail = true
					}
					if
						( this.globals.CFormats != null )
					{
						this.control.CFormats = this.globals.CFormats;
					}
					else
					{
						fail = true
					}
					if
						( this.globals.AutoCalculateCheckDigit != null )
					{
						this.control.AutoCalculateCheckDigit = this.globals.AutoCalculateCheckDigit;
					}
					else
					{
						fail = true
					}

					if
						( fail )
					{
						alert ( "Warning: some control number formats not specified." );
					}
				}
			}
		}
	}

	controlNumberValidatorObject.prototype.validate = function ( value ) {

		if
			( this.control != null )
		{
			var p = this.parameters;

			this.control.TypeAsStr = p.Type;
			this.control.Value = value;

			if
				( this.control.Completed == 0 )
			{
				this.write ( "valid", false );
				this.write ( "advice", this.control.StateAsStr );

				if
					( this.read ( "edit" ) == true )
				{
					this.write ( "value", this.control.Value );
				}
				else
				{
					this.write ( "value", value );
				}
			}
			else
			{
				if ( this.control.StateAsStr.toUpperCase() != "DONE" )
					this.write ( "advice", this.control.StateAsStr );
				this.write ( "value", this.control.Value );
			}
		}
	}

/*--------------------------------------------------------------*/

	function currencyValidatorObject () {

		this.parameters = new Object ();

		this.parameters.Type = null;
		this.parameters.UpperBound = null;
		this.parameters.LowerBound = null;
		this.parameters.AllowBlank = null;
		this.parameters.ShowSymbol = null;
	}

	currencyValidatorObject.prototype = new validatorBaseObject ();

	documentManager.registerType ( "Currency", currencyValidatorObject );

	currencyValidatorObject.prototype.initialise = function () {

		if
			( this.control == null )
		{
			var controlId = "ALSiCurrencyCheckerControl";

			this.control = document.all [ controlId ];

			if
				( this.control == null )
			{
				document.body.insertAdjacentHTML ( "beforeEnd", "<OBJECT id=" + controlId + " CLASSID='CLSID:920B385F-1BDF-11D2-BC87-00A024A86646' width=0 height=0></OBJECT>" );
				this.control = document.all [ controlId ];

				if
					( this.control != null )
				{
					currencyValidatorObject.control = this.control;

					if
						( this.globals.EuroExchangeRateComment != null )
					{
						this.control.EuroExchangeRateComment = this.globals.EuroExchangeRateComment;
					}

					if
						( this.globals.SetCurrencyRates != null )
					{
						this.globals.SetCurrencyRates ( this.control );
					}

					if
						( this.globals.DefaultCurrency == null )
					{
						this.globals.DefaultCurrency = "DEM";

						alert ( "Warning: currency type defaulting to " + this.globals.DefaultCurrency + "." );
					}
				}
			}
		}

		if
			( this.control != null )
		{
			if
				( this.parameters.UpperBound == null )
			{
				this.parameters.UpperBound = "";
			}
			
			if
				( this.parameters.LowerBound == null )
			{
				this.parameters.LowerBound = "";
			}

			if
				( this.parameters.ShowSymbol == null )
			{
				this.parameters.ShowSymbol = "true";
			}

			this.defaultType = this.globals.DefaultCurrency;
		}
	}

	currencyValidatorObject.prototype.validate = function ( value ) {

		if
			( this.control != null )
		{
			this.control.CurType = "GBP"; // Ensures decimal point notation for ranges...
			this.control.HRange = this.parameters.UpperBound;
			this.control.LRange = this.parameters.LowerBound;

			this.control.CurType = this.defaultType;
			this.control.Value = value;

			if
				( this.read ( "edit" ) == false )
			{
				if
					( value != "" )
				{
					if
						( this.booleanTrue( this.parameters.ShowSymbol ) )
					{
						this.write ( "value", this.control.Value );
					}
					else
					{
						this.write ( "value", this.control.ValueAsStringWithFixedDP );
					}
				}
				else
				{
					this.write ( "valid", false );
					this.write ( "euroValue", null );
					return;
				}
			}
			else
			{
				this.write ( "value", this.control.ValidInput );
			}

			if
				( this.control.Completed == 0 )
			{
				this.write ( "valid", false );
				this.write ( "advice", this.control.StateAsStr );
			}
			else
			{
				if
					( this.globals.AltCurrency != null && this.globals.AltCurrency != "" )
				{
					var normalType = this.control.ISOCurrencyType;
					this.control.ISOCurrencyType = this.globals.AltCurrency;
					var altValue   = this.control.Format ( 1, -1, "" );
					this.control.ISOCurrencyType = normalType;
					this.write ( "advice", altValue );
				}

				if
					( this.control.IsNegative )
				{
					// Change colour ???
				}
			}
		}
	}

	function submitAllFormElements ( formElement ) {

		if
			( formElement != null )
		{
			var elements = formElement.elements;

			var fixed = [];

			for ( var i = 0; i < elements.length; i++ ) {

				var element = elements [ i ];

				if
					( element.disabled )
				{
					fixed [ fixed.length ] = element;

					element.disabled = false;
				}
			}

			formElement.submit ();

			for ( var i = 0; i < fixed.length; i++ ) {

				fixed [ i ].disabled = true;
			}
		}
	}

/*--------------------------------------------------------------*/

	function cPersistentStorageManager ( strStore ) {
		this.strStore = strStore;
	}
	with ( cPersistentStorageManager ) {
		prototype.fnGetPersistTag = function () {
			var strID = "elPersistData";
			var el = document.all [ strID ];
			if ( el == null ) {
				if ( browserVersion < 5.5 ) {
					document.body.insertAdjacentHTML ( "beforeEnd", '<div style="display:none;behavior:url(#default#userdata)" id="' + strID + '"></div>' );
					el = document.all [ strID ];
				} else {
					el = document.createElement ( "DIV" );
					el.style.display = "none";
					el.style.behavior = "url(#default#userdata)";
					el.id = strID;
					document.body.appendChild ( el );
				}
			}
			return el;
		}
		prototype.fnGetPersistDocument = function () {
			var doc = new ActiveXObject ( "MSXML.DOMDocument" );
			var el = this.fnGetPersistTag ();
			try {
				el.load ( this.strStore );
			}
			catch ( obError ) {
				var numCode = obError.number & 0xFFFF;
				if ( numCode == 70 ) {
					// Permission denied
				} else {
					throw ( obError );
				}
			}
			var strXML = el.getAttribute ( "_xml" );
			if ( strXML != null ) {
				if ( doc.loadXML ( strXML ) ) {
					return doc;
				}
			}
			doc.appendChild ( doc.createElement ( "ROOT" ) );
			return doc;
		}
		prototype.fnSetPersistDocument = function ( doc ) {
			var el = this.fnGetPersistTag ();
			el.setAttribute ( "_xml", doc.xml );
			try {
				el.save ( this.strStore );
			}
			catch ( obError ) {
				var numCode = obError.number & 0xFFFF;
				if ( numCode == 70 ) {
					// Permission denied
				} else {
					throw ( obError );
				}
			}
		}
		/*--- PUBLIC ---*/
		prototype.fnGetField = function ( strName ) {
			var elDoc = this.fnGetPersistDocument ().documentElement;
			return elDoc.getAttribute ( strName );
		}
		prototype.fnRemoveField = function ( strName ) {
			var doc = this.fnGetPersistDocument ();
			doc.documentElement.removeAttribute ( strName );
			this.fnSetPersistDocument ( doc );
		}
		prototype.fnSetField = function ( strName, strValue ) {
			var doc = this.fnGetPersistDocument ();
			doc.documentElement.setAttribute ( strName, strValue );
			this.fnSetPersistDocument ( doc );
		}
		prototype.fnClearAll = function () {
			var doc = new ActiveXObject ( "MSXML.DOMDocument" );
			doc.appendChild ( doc.createElement ( "ROOT" ) );
			this.fnSetPersistDocument ( doc );
		}
	}

/*--------------------------------------------------------------*/

/*---BEGIN SCREEN-BUTTON EFFECT WORKAROUND---*/
document.write('<SCRIPT LANGUAGE=VBScript\>\n');
document.write('on error resume next\n');
document.write('Sub fxBack_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxBack_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxHome_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxHome_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxMyZone_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxMyZone_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxSearchZone_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxSearchZone_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxKidsZone_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxKidsZone_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxWordSurfer_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxWordSurfer_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxCorpSearch_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxBack_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('Sub fxGlobalSearch_FSCommand(ByVal command, ByVal args)\n');
document.write(' call fxBack_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('</SCRIPT\>\n');

function fxBack_DoFSCommand(command,args){
				 document.location.href = args;
}
function fxHome_DoFSCommand(command,args){
				 document.location.href = args;
}

function fxMyZone_DoFSCommand(command,args){
				 document.location.href = args;
}

function fxSearchZone_DoFSCommand(command,args){
				 document.location.href = args;
}

function fxKidsZone_DoFSCommand(command,args){
				 document.location.href = args;
}

function fxWordSurfer_DoFSCommand(command,args){
				 document.location.href = args;
}

function fxGlobalSearch_DoFSCommand(command,args){
				 document.location.href = args;
}

function fxCorpSearch_DoFSCommand(command,args){
				 document.location.href = args;
}

/*---END SCREEN-BUTTON EFFECT WORKAROUND---*/


function cHttpFetcher ( bUseScript )
{
    this.obScriptFetcher = new cScriptHttpFetcher();
//		if ( ! bUseScript ) {
//			this.obAppServer = this.fnMakeActiveXAppServer ();
//		} else {
//			this.obScriptFetcher = new cScriptHttpFetcher ();
//		}
}
	with ( cHttpFetcher ) {
		prototype.fnMakeActiveXAppServer = function () {
			var strID = "obAppServer" + ( new Date () ).getTime ();
			document.body.insertAdjacentHTML ( "afterBegin", "<OBJECT id='" + strID + "' classid='clsid:A6DCA047-3979-41C8-A5B6-57013B4EC57C' style='display:none'></OBJECT>" );
			return window [ strID ];
		}
		/*---------------------------------------------*/
		prototype.IsAsyncWaiting = function () {
			if ( this.obAppServer != null ) {
				return this.obAppServer.AsyncWaiting;
			} else {
				return this.obScriptFetcher.IsAsyncWaiting ();
			}
		}
		prototype.IsAsyncReady = function () {
			if ( this.obAppServer != null ) {
				return this.obAppServer.AsyncReady;
			} else {
				return this.obScriptFetcher.IsAsyncReady ();
			}
		}
		prototype.IsParsedOK = function () {
			if ( this.obAppServer != null ) {
				return this.obAppServer.ParsedOK
			} else {
				return this.obScriptFetcher.IsParsedOK ();
			}
		}
		prototype.GetResponseBody = function () {
			if ( this.obAppServer != null ) {
				return this.obAppServer.ResponseBody;
			} else {
				return this.obScriptFetcher.GetResponseBody ();
			}
		}
		prototype.RspGet = function ( strKey, strDefault ) {
			if ( this.obAppServer != null ) {
				return this.obAppServer.RspGet ( strKey, strDefault );
			} else {
				return this.obScriptFetcher.RspGet ( strKey, strDefault );
			}
		}
		prototype.ClearCmd = function () {
			if ( this.obAppServer != null ) {
				this.obAppServer.ClearCmd ();
			} else {
				this.obScriptFetcher.ClearCmd ();
			}
		}
		prototype.SetUseUTF8Request = function ( bSet ) {
			if ( this.obAppServer != null ) {
				this.obAppServer.UseUTF8Request = bSet;
			} else {
				this.obScriptFetcher.SetUseUTF8Request ( bSet );
			}
		}
		prototype.SetCmdPrefix = function ( strPrefix ) {
			if ( this.obAppServer != null ) {
				this.obAppServer.CmdPrefix = strPrefix;
			} else {
				this.obScriptFetcher.SetCmdPrefix ( strPrefix );
			}
		}
		prototype.CmdSet = function ( strKey, strValue ) {
			if ( this.obAppServer != null ) {
				this.obAppServer.CmdSet ( strKey, strValue );
			} else {
				this.obScriptFetcher.CmdSet ( strKey, strValue );
			}
		}
		prototype.SetUseMSXMLHTTPRequest = function ( bSet ) {
			if ( this.obAppServer != null ) {
				this.obAppServer.UseMSXMLHTTPRequest = bSet;
			} else {
				this.obScriptFetcher.SetUseMSXMLHTTPRequest ( bSet );
			}
		}
		prototype.DoCmdAsync = function () {
			if ( this.obAppServer != null ) {
				this.obAppServer.DoCmdAsync ();
			} else {
				this.obScriptFetcher.DoCmdAsync ();
			}
		}
	}

	function cScriptHttpFetcher () {
		this.strIdBase = ( new Date () ).getTime ();
		this.numFrameCount = 0;
	}
	with ( cScriptHttpFetcher ) {
		prototype.fnGetUrl = function () {
			var strArgs = "";
			for ( var strKey in this.mapCmd ) {
				var strValue = this.mapCmd [ strKey ];
				if ( strArgs != "" ) {
					strArgs += "&";
				}
				if ( this.bUseUtf8Request || true ) {
					strValue = fnToUtf8 ( strValue );
				}
				strArgs += strKey + "=" + strValue;
			}
			var strSep = this.strPrefix.indexOf ( "?" ) == -1 ? "?" : "&";
			return this.strPrefix + strSep + strArgs;
		}
		prototype.parseError = {};
		prototype.fnParseVarmap = function ( strMap, i ) {
			var vmp = strMap;
			var root = {};
			var wantName = true;
			var name = "";

			for (; i < vmp.length; i++)
			{
				switch (vmp.charAt (i))
				{
					case ' ':
					case '\t':
					case '\n':
					case '\r':
					case '=':
						break;


					case '}':
						var ret = {};
						ret['i'] = i;
						ret['value'] = root;
						return ret;
						break;


					case '{':
						if (wantName)
						{ // special case for the first brace
						}
						else
						{
							var result = this.fnParseVarmap (vmp, i + 1);
							if ( result == this.parseError ) {
								return this.parseError;
							}
							i = result['i'];
							root[name] = result['value'];
							wantName = true;
						}
						break;


					case '"':
					var token = new String ();
					i++;
					for (; i < vmp.length && vmp.charAt (i) != '"'; i++)
					{
						if (vmp.charAt (i) == "\\")
						{
							i++;
							if (i < vmp.length)
							{
								switch (vmp.charAt(i))
								{
									case 'r':
									token += '\r';
									break;

									case 'n':
									token += '\n';
									break;

									default:
									token += vmp.charAt(i);
									break;
								}
							}
						}
						else
						{
							token += vmp.charAt(i);
						}
					}

					if (wantName)
					{
						name = token;
					}
					else
					{
						root[name] = new String(token);
					}
					wantName = !wantName;
					break;


					default:
						var token = ""
						for (; i < vmp.length && (' \t\r\n={}').indexOf (vmp.charAt (i)) == -1; i++)
						{
							token += vmp.charAt(i);
						}
						if (vmp.charAt (i) == '{' || vmp.charAt (i) == '}')
						{
							i--;
						}

						if (wantName)
						{
							name = token;
						}
						else
						{
							root[name] = new String (token);
						}
						wantName = !wantName;
						break;
				}

			}
			return this.parseError;
		}
		prototype.fnFromMarkup = function ( str ) {
			str = str.replace ( /&amp;/g, "&" );
			str = str.replace ( /&lt;/g, "<" );
			str = str.replace ( /&gt;/g, ">" );
			return str;
		}

		/*----------------------------------------------*/
		prototype.IsAsyncWaiting = function () {
			return this.bWaiting;
		}
		prototype.fnAddToResponseMap = function ( mapResponse, strPrefix, mapData ) {
			for ( var strKey in mapData ) {
				var obValue = mapData [ strKey ];
				var strPath = strKey;
				if ( strPrefix != "" ) {
					strPath = strPrefix + "." + strPath;
				}
				if ( obValue.constructor == String ) {
					mapResponse [ strPath ] = this.fnFromMarkup ( obValue );
				} else {
					this.fnAddToResponseMap ( mapResponse, strPath, obValue );
				}
			}
		}
		prototype.fnIsReasonableResponse = function ( strMap ) {
			var strSpace = " \t\r\n";
			for ( var i = 0; i < strMap.length; i++ )
			{
				var ch = strMap.charAt ( i );
				if ( ! strSpace.indexOf ( ch ) >= 0 ) {
					if ( ch == '{' ) {
						return true;
					} else {
						break;
					}
				}
			}
			return false;
		}
		prototype.IsAsyncReady = function () {
			if ( this.elFrame != null ) {
				if ( this.elFrame.parentElement != null ) {
					if ( this.elFrame.contentWindow != null ) {
						var obWindow = this.elFrame.contentWindow;
						if ( obWindow.document != null ) {
							var obDoc = obWindow.document;
							if ( obDoc.readyState == "complete" ) {
								if ( obDoc.body != null ) {
									var elBody = obDoc.body;
									var strResponse = null;
									if ( elBody.firstChild != null ) {
										var elChild = elBody.firstChild;
										if ( elChild.tagName == "PRE" ) {
											strResponse = elChild.innerText;
										}
									}
									if ( strResponse == null ) {
										strResponse = elBody.innerHTML;
									}
									this.bWaiting = false;
									var obResult = this.parseError;
									if ( this.fnIsReasonableResponse ( strResponse ) ) {
										obResult = this.fnParseVarmap ( strResponse, 0 );
									}
									if ( obResult == this.parseError ) {
										// PARSE ERROR
									} else {
										this.strBody = strResponse.slice ( obResult.i + 1 );
										this.mapResponse = {};
										this.fnAddToResponseMap ( this.mapResponse, "", obResult.value );
									}
									return true;
								}
							}
						}
					}
				}
			}
			return false;
		}
		prototype.IsParsedOK = function () {
			if ( this.elFrame.parentElement != null ) {
				return this.mapResponse != null;
			}
			return false;
		}
		prototype.GetResponseBody = function () {
			return this.strBody;
		}
		prototype.RspGet = function ( strKey, strDefault ) {
			if(this.mapResponse){
                            var strResult = this.mapResponse [ strKey ];
			}
                        if ( strResult == null ) {
				strResult = strDefault;
			}
			return strResult;
		}
		prototype.ClearCmd = function () {
			if ( this.elFrame != null ) {
				this.elFrame.removeNode ();
				this.elFrame = null;
				this.bWaiting = false;
			}
			this.strPrefix = "";
			this.mapCmd = {};
			this.mapResponse = null;
		}
		prototype.SetUseUTF8Request = function ( bSet ) {
			this.bUseUtf8Request = ( bSet == "1" ) || ( bSet == true );
		}
		prototype.SetCmdPrefix = function ( strPrefix ) {
			this.strPrefix = strPrefix;
		}
		prototype.CmdSet = function ( strKey, strValue ) {
			this.mapCmd [ strKey ] = strValue;
		}
		prototype.SetUseMSXMLHTTPRequest = function ( bSet ) {
		}
		prototype.DoCmdAsync = function () {
			if ( this.elFrame == null ) {
				var strId = "_frame_" + this.strIdBase + "_" + this.numFrameCount++;
				var strMarkup = "<IFRAME src='" + this.fnGetUrl () + "' style='display:none' id='" + strId + "'></IFRAME>";
				document.body.insertAdjacentHTML ( "beforeEnd", strMarkup );
				this.elFrame = document.all [ strId ];
				this.bWaiting = true;
			}
		}
	}
	function fnToUtf8( str) {
		var strUtf8 = "";
		for ( var i = 0; i < str.length; i++ )
		{
			var numCode = str.charCodeAt ( i );
			if ( numCode < 0x80 ) {
				strUtf8 += String.fromCharCode ( numCode );
			} else if ( numCode < 0x800 ) {
				strUtf8 += String.fromCharCode ( ( numCode >> 6 ) | 0xc0 );
				strUtf8 += String.fromCharCode ( ( numCode & 0x3f ) | 0x80 );
			} else {
				strUtf8 += String.fromCharCode ( ( numCode >> 12 ) | 0xe0 );
				strUtf8 += String.fromCharCode ( ( ( numCode >> 6 ) & 0x3f ) | 0x80 );
				strUtf8 += String.fromCharCode ( ( numCode & 0x3f ) | 0x80 );
			}
		}
		return strUtf8;
	}
