	function Trim(sIn)
	{
	  var c;
	  var sOut;
	  for(var i=0, c=sIn.charAt(i); i<sIn.length, c==" "; i++, c=sIn.charAt(i));
	  sOut = sIn.substr(i);
	  for(i=sOut.length-1, c=sOut.charAt(i); i>=0, c==" "; i--, c=sOut.charAt(i));
	  sOut = sOut.substr(0, i+1);
	  return sOut;
	}

	// Definition de l'objet Collection
	function Collection()
	{
		var _objCol = new Array();

		function Item(Index)
		{
			if( isNaN(Index) || Index >= _objCol.length )
				return null;
			else
				return _objCol[Index];
		}

		function FindIndexByName(Name)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i].Name == Name )
					return i;
			}
			return -1;
		}
		
		function FindIndexByID(id)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i].id == id )
					return i;
			}
			return -1;
		}
		
		function FindIndex(Object)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i] == Object )
					return i;
			}
			return -1;
		}

		function Find(Object)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i] == Object )
					return _objCol[i];
			}
			return null;
		}

		function FindByName(Name)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i].Name == Name )
					return _objCol[i];
			}
			return null;
		}
		
		function FindByID(id)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i].id == id )
					return _objCol[i];
			}
			return null;
		}		
		
		function FindByControlID(id)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i].ControlId == id )
					return _objCol[i];
			}
			return null;
		}
		
		function Add(Object)
		{
			var ArraySize = _objCol.length;
			_objCol[ArraySize] = Object;
			return _objCol[ArraySize];
		}

		function Remove(Index)
		{
			var i;
			if( Index >= 0 && Index <_objCol.length )
			{
				for( i=Index; i<_objCol.length-1; i++ )
					_objCol[i] = _objCol[i+1];
				_objCol.length --;
			}
		}
		
		function RemoveByName(Name)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i].Name == Name )
				{
					Remove(i);
					return;
				}
			}			
		}
		
		function RemoveObject(Object)
		{
			var i;
			for( i=0; i<_objCol.length; i++ )
			{
				if( _objCol[i] == Object )
				{
					Remove(i);
					return;
				}
			}
		}
		
		function Clear()
		{
			_objCol.length = 0;
		}
		
		
		function Count()
		{
			return _objCol.length;
		}
		
		this.Find = Find;
		this.FindByName = FindByName;
		this.Add = Add;
		this.Remove = Remove;
		this.Count = Count;
		this.Item = Item;
		this.RemoveByName = RemoveByName;
		this.RemoveObject = RemoveObject;
		this.FindIndex = FindIndex;
		this.FindIndexByName = FindIndexByName;	
		this.FindByControlID = FindByControlID;
		this.FindIndexByID = FindIndexByID;
		this.FindByID = FindByID;
		this.Clear = Clear;
	}
	
	
	function Property(strProperty)
	{
		this.propertyName = strProperty
		this.value = '';
	}	

	function PropertiesCollection()
	{
		var _list = new Collection();

		function FindProperty(Index)
		{
			if( isNaN(Index) )
			{
				var i;
				for( i=0; i < _list.Count(); i++ )
				{
					if (_list.Item(i).propertyName == Index)
						return i;
				}
				return -1;
			}
			else
			{
				if (Index < 0 || Index >= _list.Count())
					return -1;
				else
					return Index;
			}
		}


		function Add(strProperty)
		{
			var index;
			var property;

			index = FindProperty(strProperty);
			if( index >= 0 )
				return _list.Item(index);
			property = new Property(strProperty);
			_list.Add(property);
			this.Count = _list.Count();
			return property;
		}

		function Remove(strProperty)
		{	
			_list.Remove(FindProperty(strProperty));
			this.Count = _list.Count();
		}
		
		function Clear()
		{
			while( _list.count > 0 )
				_list.remove(0);
		}

		function Item(Index)
		{
			var propertyIndex;
			propertyIndex = FindProperty(Index);
			if( propertyIndex >= 0)
				return _list.Item(propertyIndex);
			else
				return null;
		}

		this.Item = Item;
		this.Add = Add;
		this.Remove = Remove;
		this.Clear = Clear;
		this.Count = _list.Count();

}          
