//////////////////////////////////////////////
// ColumnBrowser Object VERSION_0.8
//////////////////////////////////////////////
//
// The ColumnBrowser is the the column container
// component that handles the slice layout, population
// etc
//
// Ali Russell 10.2006
//
//////////////////////////////////////////////

var Column = Class.create();
Column.prototype = {
//
// Member Variables
m_controlSurface: null,
m_minColumnWidth: 200,
m_Uri: "ColumnUri",
m_Label: "ColumnLabel",
m_isDragging: false,
m_mouseDownXOffset: 0,
m_mouseDownYOffset: 0,
m_list: null,
m_contentLoaded: false,
m_xmlRequest: new XMLHttpRequest(),
m_loadingText: "Loading Initial Contents...",
m_showContents: false,
m_isOpen: false,
m_filterMessage: "Filter column...",
m_tooltipTimeout: 0,
m_filterTypeSelect: 0,
m_persistantButtons: false,
m_isColumnLoading: false,

m_thinColWidth: 90,
m_normalColWidth: 150,
m_thickColWidth: 200,
m_minColWidth: 180,
m_currentWidth: 180,

//
// Constructor
initialize: function(objectOptions)
	{
		
		//Override the defatul object parameters, with those from the objectOptions.
		ParseOptions(objectOptions, this);
		
		
		//Check the width column parameter to determine what the minimum size for the col is
	
		if (this.m_cwd==0)
		{
			this.m_minColWidth = this.m_thinColWidth;
		}
		else if (this.m_cwd==1)
		{
			this.m_minColWidth = this.m_normalColWidth;
		}
		else if (this.m_cwd==2)
		{
			this.m_minColWidth = this.m_thickColWidth;
		}
		
		
		///////////////// LOAD THE COLUMN BROWSER STATUS  ///////////////
		/////////////////////////////////////////////////////////////////
		
		//Create the column container div
		this.m_controlSurface = createDiv("Column", true);
		
		//Create the content spacer
		this.m_columnContentSpacer = createDiv("ColumnSpacer", true);
		this.m_controlSurface.appendChild(this.m_columnContentSpacer);
		
		
		//Create the header
		this.m_columnHeader= createDiv("Header", true);	
		this.m_columnHeader.title = "Click and drag to re-order columns"; 
		
		this.m_columnContentSpacer.appendChild(this.m_columnHeader);
		
		
		
		
		//Add the search bar
		this.m_columnSearch= createDiv("Search", true);	
		this.m_columnSearch.style.display = "none";	
		
		this.m_filterClear = createDiv("FilterClear", true);
		this.m_filterClear.title = "Remove filtering";
		this.m_columnSearch.appendChild(this.m_filterClear);

		this.m_filterType = createDiv("FilterType", true);
		this.m_filterType.className = "FilterTypeAll";
		this.m_filterType.title = "Match any part - click to change";
		this.m_columnSearch.appendChild(this.m_filterType);
		
		this.m_inputCont= createDiv("inputContainer", true);
		this.m_columnSearch.appendChild(this.m_inputCont);
		
		this.m_searchTextBox = document.createElement("input");
		this.m_searchTextBox.value = this.m_filterMessage;
		this.m_inputCont.appendChild(this.m_searchTextBox);
		
		this.m_columnContentSpacer.appendChild(this.m_columnSearch);
		
		
		
		//Create the content spacer div
		this.m_columnContentHolderDiv= createDiv("ContentHolder", true);
		
		this.m_columnContentSpacer.appendChild(this.m_columnContentHolderDiv);
		
		//Create the content div
		this.m_columnContent= createDiv("Content", true);
		
		this.m_columnContentHolderDiv.appendChild(this.m_columnContent);	
		
		//Create the Column Header Contents
		////////////////////////////////////
		
		
		
		this.m_moveLeftBtn= createDiv("MoveLeftBtn", true);
		this.m_moveLeftBtn.title = "Move column to the left";
		this.m_columnHeader.appendChild(this.m_moveLeftBtn);
		
		this.m_headerLabel= createDiv("HeaderLabel", true);
		this.m_headerLabel.innerHTML = this.m_Label;
		this.m_columnHeader.appendChild(this.m_headerLabel);		
		
		this.m_moveRightBtn= createDiv("MoveRightBtn", true);
		this.m_moveRightBtn.title = "Move column to the right";
		this.m_columnHeader.appendChild(this.m_moveRightBtn);
		
		this.m_closeBtn= createDiv("CloseBtn", true);
		this.m_closeBtn.title = "Close this column";
		this.m_columnHeader.appendChild(this.m_closeBtn);		
		
		this.m_filterBtn= createDiv("FilterBtn", true);
		this.m_filterBtn.title = "Filter this column";
		this.m_columnHeader.appendChild(this.m_filterBtn);

		this.m_allBtn= createDiv("AllBtn", true);
		this.m_allBtn.title = "Deselect all items this column";
		this.m_columnHeader.appendChild(this.m_allBtn);	
		
		this.m_loadingBtn= createDiv("LoadingDiv", true);
		this.m_loadingBtn.style.display = "none";
		this.m_columnHeader.appendChild(this.m_loadingBtn);		

		this.m_noResults = createDiv("NoResults", true);
		this.m_noResults.innerHTML = "No Results";
		this.m_noResults.style.display = "none";
		this.m_columnContent.appendChild(this.m_noResults);
		
		//Create the list control
		objectOptions.parentColumn = this;
		this.m_list = new List(objectOptions);
		var thisObj = this;
		//this.m_list.AddFilter({ object: "Column.TextFilter", func: function(params, flag) { return thisObj.ApplyFilter(params, flag); } });
		this.m_columnContent.appendChild(this.m_list.m_controlSurface);
		
		
		
		
		
		
			if (!this.m_persistantButtons)
			{
				this.m_moveLeftBtn.style.visibility = "hidden";
				this.m_moveRightBtn.style.display = "none";
				this.m_closeBtn.style.display = "none";
				this.m_filterBtn.style.display = "none";
				this.m_allBtn.style.display = "none";			
			}
		
		
		
		
		
		
		
		
		//Register custom events
		////////////////////////
		mSpaceApplication.Subscribe("mSpaceApplication.PageResize", this);
		
		mSpaceApplication.Subscribe("mSpaceApplication.MouseMove", this);
		
		mSpaceApplication.Subscribe("Data.Filter.Add", this);
		mSpaceApplication.Subscribe("Data.Filter.Remove", this);
		mSpaceApplication.Subscribe("Data.Filter.Apply", this);

		mSpaceApplication.Subscribe("Column.SetOpen", this);
		mSpaceApplication.Subscribe("Column.SetClosed", this);
		
		//Register DOM events
		/////////////////////
		
		RegisterEvent(this.m_controlSurface, "click", this, "MouseClick");
		
		RegisterEvent(this.m_moveLeftBtn, "click", this, "MouseClick");
		RegisterEvent(this.m_moveRightBtn, "click", this, "MouseClick");
		RegisterEvent(this.m_closeBtn, "click", this, "MouseClick");
		RegisterEvent(this.m_allBtn, "click", this, "MouseClick");
		RegisterEvent(this.m_filterBtn, "click", this, "MouseClick");
		RegisterEvent(this.m_filterType, "click", this, "MouseClick");
		RegisterEvent(this.m_filterClear, "click", this, "MouseClick");
		
		RegisterEvent(this.m_headerLabel, "mousedown", this, "MouseDown");
		RegisterEvent(this.m_headerLabel, "mouseup", this, "MouseUp");
		
		RegisterEvent(this.m_searchTextBox, "keyup", this, "SearchUpdate", true);
		RegisterEvent(this.m_searchTextBox, "click", this, "MouseClick", true);
		//RegisterEvent(this.m_searchTextBox, "mouseover", this, "MouseOver", true);
		//RegisterEvent(this.m_searchTextBox, "mousedown", this, "mouseDown", true);
		//RegisterEvent(this.m_searchTextBox, "mouseup", this, "mouseUp", true);

		RegisterEvent(this.m_moveLeftBtn, "mouseover", this, "MouseOver", true);
		RegisterEvent(this.m_moveRightBtn, "mouseover", this, "MouseOver", true);
		RegisterEvent(this.m_closeBtn, "mouseover", this, "MouseOver", true);
		RegisterEvent(this.m_allBtn, "mouseover", this, "MouseOver", true);
		RegisterEvent(this.m_filterBtn, "mouseover", this, "MouseOver", true);
		RegisterEvent(this.m_columnHeader, "mouseover", this, "MouseOver", true);
		RegisterEvent(this.m_controlSurface, "mouseover", this, "MouseOver", true);

		RegisterEvent(this.m_moveLeftBtn, "mouseout", this, "MouseOut", true);
		RegisterEvent(this.m_moveRightBtn, "mouseout", this, "MouseOut", true);
		RegisterEvent(this.m_closeBtn, "mouseout", this, "MouseOut", true);
		RegisterEvent(this.m_allBtn, "mouseout", this, "MouseOut", true);
		RegisterEvent(this.m_filterBtn, "mouseout", this, "MouseOut", true);
		RegisterEvent(this.m_columnHeader, "mouseout", this, "MouseOut", true);
		RegisterEvent(this.m_controlSurface, "mouseout", this, "MouseOut", true);
		

		
		
	},
	
GetLeftoverWidth: function(width)
	{		
		return width - this.m_minColWidth;
	},
	
Resize: function(extraWidth, height)
	{
		if ((extraWidth=="undefined") || (height=="undefined"))
			return;
		//width = (width>0) ? width : 0;
		//height = (height>0) ? height : 0;
		
		var width = this.m_minColWidth + extraWidth;
		
		if (isNaN(width))
			return;
		
		this.m_currentWidth = width;
		
		
		if (width>0)		
			this.m_controlSurface.style.width = width + "px";
		if (height>0)		
			this.m_controlSurface.style.height = height + "px";
		
		var spacerPadding = 0;
		//Getting the padding only works in ie, so this compensates for the lack of 
		//moz-box-typ.? css style
		if(browserDetails[0]=="safari")
			var styleString = getStyle(this.m_columnContentSpacer, "padding-top");	// Safari does not compound the paddings if they are equal - so get the padding-top instead
		else
			var styleString = getStyle(this.m_columnContentSpacer, "padding");

		if ((styleString!="undefined") && (styleString!=""))
		{
			spacerPadding = parseInt(styleString);
		}

		// Resize filter
		this.m_inputCont.style.width = (this.m_columnSearch.clientWidth - this.m_filterType.offsetWidth - this.m_filterClear.offsetWidth) + "px";
		//this.m_searchTextBox.style.width = width - 54 + "px";
		//this.m_filterType.style.width = "30px";
		//this.m_filterClear.style.width = "12px";
		
		if (height>0)
		{
			// Safari Fix
			var searchHeight = 0;
			if(this.m_columnSearch.offsetHeight)
				searchHeight = this.m_columnSearch.offsetHeight;	// Safari falls over if offsetHeight is unset
			
			this.m_columnContentSpacer.style.height = (height-this.m_columnHeader.offsetHeight-searchHeight - (spacerPadding*2))+ "px";
			this.m_columnContentHolderDiv.style.height = "100%";
		}
		//this.m_columnContentHolderDiv.style.height = (this.m_columnContentSpacer.offsetHeight-this.m_columnHeader.offsetHeight-10)  + "px";
		
		var labelWidth = this.m_columnHeader.clientWidth - (this.m_moveLeftBtn.offsetWidth + this.m_moveRightBtn.offsetWidth + this.m_closeBtn.offsetWidth + this.m_filterBtn.offsetWidth + this.m_allBtn.offsetWidth + this.m_loadingBtn.offsetWidth)
		this.m_headerLabel.style.width = labelWidth + "px";
		
		//this.m_list.m_controlSurface.width = (this.m_controlSurface.clientWidth -20 )+ "px";
		
	},
	
Notify: function(eventName, eventParams)
	{
		switch(eventName)
		{
			case 'mSpaceApplication.PageResize' : this.Resize(); break;
			case 'mSpaceApplication.MouseMove' : this.MouseMove(eventParams); break;
			case 'Data.Filter.Add' : this.FilterAdd(eventParams); break;
			case 'Data.Filter.Remove' : this.FilterRemove(eventParams); break;
			case 'Data.Filter.Apply' : this.FilterApply(eventParams); break;
			case 'Column.SetOpen' : this.SetOpen(eventParams); break;
			case 'Column.SetClosed' : this.SetClosed(eventParams); break;
			default: break;
		}
	},

MouseOver: function(e, element)
	{
		if(element==this.m_moveLeftBtn)
		{
			mSpaceApplication.FireEvent("Cursor.Change", "w-resize");
		}
		else if(element==this.m_moveRightBtn)
		{
			mSpaceApplication.FireEvent("Cursor.Change", "e-resize");
		}
		else if(element==this.m_closeBtn)
		{
			mSpaceApplication.FireEvent("Cursor.Change", "pointer");
		}
		else if(element==this.m_allBtn)
		{
			mSpaceApplication.FireEvent("Cursor.Change", "pointer");
		}
		else if(element==this.m_filterBtn)
		{
			mSpaceApplication.FireEvent("Cursor.Change", "pointer");
		}
		else if(element==this.m_columnHeader)
		{
			mSpaceApplication.FireEvent("Cursor.Change", "move");		
		}

		if ((!this.m_persistantButtons) && (!this.m_isColumnLoading))
		{
				this.m_moveLeftBtn.style.visibility = "visible";
				this.m_moveRightBtn.style.display = "block";
				this.m_closeBtn.style.display = "block";
				this.m_filterBtn.style.display = "block";
				this.m_allBtn.style.display = "block";	
				
				var labelWidth = this.m_columnHeader.clientWidth - (this.m_moveLeftBtn.offsetWidth + this.m_moveRightBtn.offsetWidth + this.m_closeBtn.offsetWidth + this.m_filterBtn.offsetWidth + this.m_allBtn.offsetWidth + this.m_loadingBtn.offsetWidth)
				this.m_headerLabel.style.width = labelWidth + "px";				
		}				
		

		if(HelpOn && HelpUseHighlight)
		{
			mSpaceApplication.FireEvent("Help.ShowHighlight", {element: this.m_controlSurface, name: "Column.Open"});
		}
	},

MouseOut: function(e, element)
	{
		mSpaceApplication.FireEvent("Cursor.Reset");
		
		if ((element==this.m_controlSurface) || (element==this.m_columnHeader))
		{
			
			if (!this.m_persistantButtons)
			{
				this.m_moveLeftBtn.style.visibility = "hidden";
				this.m_moveRightBtn.style.display = "none";
				this.m_closeBtn.style.display = "none";
				this.m_filterBtn.style.display = "none";
				this.m_allBtn.style.display = "none";		
			}			
			
		}
		
		//if(element==this.m_columnHeader)
		//{
			if(HelpOn && HelpUseHighlight)
			{
				mSpaceApplication.FireEvent("Help.HideHighlight");
			}
		//}
	},

MouseClick: function(e, element)
	{
		if(HelpOn!= null && HelpOn)
		{
				mSpaceApplication.FireEvent("Help.Show", "Column.Open");
				return;
		}

		// Help is not on !!!!
		
		if (element==this.m_moveLeftBtn)
		{
				mSpaceApplication.FireEvent("Column.MoveLeft", this);
		}
		else if (element==this.m_moveRightBtn)
		{
			mSpaceApplication.FireEvent("Column.MoveRight", this);
		}
		else if (element==this.m_closeBtn)
		{
			this.SearchUpdate({keyCode: 27}, null);
			this.m_columnSearch.style.display = "none";
			mSpaceApplication.FireEvent("Column.Close", this);
			this.m_isOpen = false;
		}
		else if (element==this.m_filterBtn)
		{
			if (this.m_columnSearch.style.display=="")
			{
				this.m_columnSearch.style.display = "none";
				if(this.m_searchTextBox.value == this.m_filterMessage)
					this.m_searchTextBox.value = "";

				window.mSpaceApplication.Resize(false);
			}
			else
			{
				this.m_columnSearch.style.display = "";
				if(this.m_searchTextBox.value == "")
					this.m_searchTextBox.value = this.m_filterMessage;
			}
			window.ColumnBrowser.Resize();
			//this.m_list.SetFilter("Item 3");
		}
		else if (element==this.m_filterType)
		{
			this.m_filterTypeSelect += 1;

			if(this.m_filterTypeSelect > 2)
				this.m_filterTypeSelect = 0;

			switch(this.m_filterTypeSelect)
			{
				case 0:
					this.m_filterType.className = "FilterTypeAll";
					this.m_filterType.title = "Match any part - click to change";
					break;

				case 1:
					this.m_filterType.className = "FilterTypeStart";
					this.m_filterType.title = "Match the first letters - click to change";
					break;

				case 2:
					this.m_filterType.className = "FilterTypeEnd";
					this.m_filterType.title = "Match the last letters only - click to change";
					break;
			}
			this.m_list.RefreshFilter(null);
		}
		else if (element==this.m_filterClear)
		{
			this.m_searchTextBox.value = "";
			this.m_filterBtn.className = "FilterBtn";
			this.m_list.ClearTextFilter();

			// Close filter
			this.m_columnSearch.style.display = "none";
			if(this.m_searchTextBox.value == this.m_filterMessage)
				this.m_searchTextBox.value = "";

			window.mSpaceApplication.Resize(false);
		}
		else if (element==this.m_searchTextBox)
		{
			if (this.m_searchTextBox.value==this.m_filterMessage)
			{
				this.m_searchTextBox.value = "";
			}

		}
		else if (element==this.m_allBtn)
		{
			this.m_list.ShowAll();
		}
	},
	
StartDrag: function(xPos, yPos)
	{
		
			this.m_controlSurface.style.visibility = "visible";
		
			this.m_mouseDownXOffset = 30;
			this.m_mouseDownYOffset = 10;
			
			this.m_isDragging = true;
			mSpaceApplication.FireEvent("Column.StartDrag", this);	
			
			this.m_controlSurface.style.left = ((xPos || 0) - 30) + "px";
			this.m_controlSurface.style.top = ((yPos || 0) - 5) + "px";			
	},
	
MouseDown: function(e, element)
	{
		if (element==this.m_headerLabel)
		{
			
			var scrollLeft = this.m_controlSurface.parentNode.parentNode.scrollLeft;
			//alert(scrollLeft);
			
			this.m_mouseDownXOffset = e.X - findPosX(this.m_controlSurface) + scrollLeft;
			this.m_mouseDownYOffset = e.Y - findPosY(this.m_controlSurface);
			
			this.m_isDragging = true;
			mSpaceApplication.FireEvent("Column.StartDrag", this);
			
			this.m_controlSurface.style.left = (e.X - this.m_mouseDownXOffset) + "px";
			this.m_controlSurface.style.top = (e.Y - this.m_mouseDownYOffset) + "px";			
		}
	},
	
MouseUp: function(e, element)
	{
		
		if (element==this.m_headerLabel)
		{
			this.m_isDragging = false;
			mSpaceApplication.FireEvent("Column.StopDrag", this);
			
			this.m_controlSurface.style.left = "0px";
			this.m_controlSurface.style.top = "0px";
		}		
	},
	
MouseMove: function(e)
	{
		if (this.m_isDragging)
		{
			
			
			this.m_controlSurface.style.left = (e.X - this.m_mouseDownXOffset ) + "px";
			this.m_controlSurface.style.top = (e.Y - this.m_mouseDownYOffset) + "px";
			mSpaceApplication.FireEvent("Column.Drag", this);
		}
	},
	
SearchUpdate: function(e, element)
	{		
		if (e.keyCode==27)
		{
			this.m_list.ClearTextFilter();
			this.m_searchTextBox.value = "";
			this.m_filterBtn.className = "FilterBtn";
			return;
		}	
		
		mSpaceApplication.FireEvent("Log.Event", { type: "InteractEvent", message: "[Column Filter] " + this.m_Label + " (" + this.m_searchTextBox.value + ")" });
		
		if (this.m_list)
		{
			this.m_list.SetTextFilter(this.m_searchTextBox.value);
				

			// Turn the filter icon off if the string is empty
			if(this.m_searchTextBox.value == "")
			{
				this.m_filterBtn.className = "FilterBtn";
			}
			else
			{
				this.m_filterBtn.className = "FilterBtnOn";
			}
		}		
		
	},
	
ApplyFilter: function(dataObject, clearFlag)
	{
		if (clearFlag==true)
		{
			this.m_searchTextBox.value = "";
			return false;
		}
		
		if (dataObject==null)
		{
			return false;
		}
		
		if ((this.m_searchTextBox.value=="") || (this.m_searchTextBox.value==this.m_filterMessage))
		{
			return true;
		}
		
		var filterArray = this.m_searchTextBox.value.toLowerCase().split("+");
		var matchesWord = false;
		for (var x =0; x<filterArray.length;x++)
		{
			var filterWord = filterArray[x];
			if (filterWord!="")
			{
				if (dataObject.label)
				{
					var ind = dataObject.label.toLowerCase().indexOf(filterWord);

					// Filter anywhere
					if (ind!=-1 && this.m_filterTypeSelect == 0)
					{
						matchesWord = true;
					}

					// Filter start
					if (ind==0 && this.m_filterTypeSelect == 1)
					{
						matchesWord = true;
					}

					// Filter end
					if (ind==dataObject.label.length-filterWord.length && this.m_filterTypeSelect == 2)
					{
						matchesWord = true;
					}
				}
			}
		}		
		
		return matchesWord;
	},
	
Clear: function()
	{
		this.m_list.Clear();
	},
	
ReplaceItems: function(items)
	{

		this.m_list.ReplaceItems(items);
		
	},
	
GetHistoryObject: function()
	{
		var historyObject = this.m_list.GetHistoryObject();
		historyObject["uri"] = this.m_Uri;
		
		return historyObject;
	},
	
LoadColumnContents: function(historyItems)
	{
			if (this.m_columnsLoaded)
				return;
		
			this.m_columnsLoaded = true;
			var thisObj = this;
			
			this.m_columnContent.removeChild(this.m_list.m_controlSurface);
			this.m_columnContent.innerHTML =  this.m_loadingText;
			
			var getColumnsUrl = "./inc/mspace.php?column=" + URLEncode(this.m_Uri) + "&mSpaceServer=" + mSpaceApplication.GetSetting("serverUrl") + "&action=getcolumn&fpred=" + URLEncode(mSpaceApplication.GetSetting("previewPredicate")) + "&server=" + URLEncode(mSpaceApplication.GetSetting("knowledgeBase")) + "&modeluri=" + URLEncode(mSpaceApplication.GetSetting("dataModel")) + "&previewLimit=4";
			//prompt("",getColumnsUrl);

			// Use the onload function if the browser is anything other than ie <7.0.  Fixes problems on some firefox and mozilla
			// versions
			if ((browserDetails[0]=="msie") && (browserDetails[1]!="7.0"))
			{
				this.m_xmlRequest.onreadystatechange = function() {
					try {
						if(thisObj.m_xmlRequest.readyState == 4 && (thisObj.m_xmlRequest.status == 200 || thisObj.m_xmlRequest.status == 304)) {
							//#################
							//RESULTS
							//#################
							thisObj.LoadColumnData(thisObj.m_xmlRequest.responseText, historyItems);
						}
					}catch (e){
						thisObj.m_columnContent.innerHTML = "Error Loading Columns: " + e;
						throw(e);
					}			  
				};
			}else{
				this.m_xmlRequest.onload = function() {
					try {
						//#################
						//RESULTS
						//#################
						thisObj.LoadColumnData(thisObj.m_xmlRequest.responseText, historyItems);
					}
					catch (e)
					{
						thisObj.m_columnContent.innerHTML = "Error Loading Columns: " + e;
						throw(e);
					}				  
				};			
			}
		
			
			if ((browserDetails[0]=="msie") && (browserDetails[1]!="7.0"))
			{
				window.setTimeout( function()
											{
												thisObj.m_xmlRequest.open('GET', getColumnsUrl);
												thisObj.m_xmlRequest.send(null);
											}
									,500);
			}
			else
			{
				this.m_xmlRequest.open('GET', getColumnsUrl);
				this.m_xmlRequest.send(null);			
			}		
	},
	
LoadColumnData: function(columnDataString, historyItems)
	{
		
		var columns = new Array();
		eval("columns = " + columnDataString);
		
		this.m_columnContent.innerHTML = "";
		this.m_columnContent.appendChild(this.m_list.m_controlSurface);
		
		for (var i=0; i<columns.length; i++)
		{
			var newCol = columns[i];
			if (newCol.Uri==this.m_Uri)		
			{
				this.m_list.LoadContents(newCol);
			}
		}
		
		
		if (historyItems)
		{
			this.m_list.ReplaceItems(historyItems);
		}
		
		mSpaceApplication.Resize(false);
		
		mSpaceApplication.FireEvent("Column.InitialLoad", this);
		

	},	
	
LoadContents: function()
	{
		if (!this.m_contentLoaded)
		{
			this.LoadColumnContents();
			return false;
		}
		return true;
	},
	
SetSelectedItems: function(items)
	{
		if (this.m_list)
		{
			return this.m_list.m_selectedItems = items;
		}		
	},	
	
UpdateColumnData: function(cd, fl)
	{
		if (this.m_list)
		{
			this.m_list.UpdateData(cd, fl);
		}
	},
	
FilterAdd: function(eventParams)
	{
		if (eventParams.uri)
		{
			if ((eventParams.uri == this.m_Uri) || (eventParams.uri == "#All"))
			{
				if (this.m_list)
				{
					this.m_list.AddFilter(eventParams);
				}
			}
		}
	},
	
FilterRemove: function(eventParams)
	{
		if (eventParams.uri)
		{
			if ((eventParams.uri == this.m_Uri) || (eventParams.uri == "#All"))
			{
				if (this.m_list)
				{
					this.m_list.RemoveFilter(eventParams);
				}
			}
		}
	},	
	
FilterApply: function(eventParams)
	{
		if (eventParams.uri)
		{
			if ((eventParams.uri == this.m_Uri) || (eventParams.uri == "#All"))
			{
				if (this.m_list)
				{
					this.m_list.RefreshFilter(eventParams);
				}				
			}
		}
	},

ContainsField: function(field)
	{
			if (this.m_list)
			{
				return this.m_list.ContainsField(field);
			}		
			return false;
	},
	
GetItems: function()
	{
			if (this.m_list)
			{
				return this.m_list.m_allItems;
			}		
			return new Object();		
	},
	
GetDisplayedItems: function()
	{
			if (this.m_list)
			{
				return CloneArray(this.m_list.m_displayedItems);				
			}		
			return new Array();		
	},	
	
GetFilteredItems: function()
	{
			if (this.m_list)
			{
				return CloneArray(this.m_list.m_filteredItems);				
			}		
			return new Array();		
	},
	
GetSelectedItems: function()
	{
		if ((this.m_list) && (this.m_list.m_Selected))
		{
			return this.m_list.GetSelectedItems();
		}
		else
		{
			return new Array();
		}			
	},
	
GetHighlightedItems: function()
	{
			if (this.m_list)
			{
				return this.m_list.m_highlightItems;				
			}		
			return new Object();		
	},
	
ShowContents: function(show)
	{
		this.m_showContents = show;
		if (this.m_list)
		{
			if (this.m_showContents)
			{
				this.m_list.m_controlSurface.style.display = "";
				this.m_list.Resize();
			}
			else
			{
				this.m_list.Clear();
				this.m_list.m_controlSurface.style.display = "none";
			}
		}
	},
	
SetLoading: function(flag, btnOnly)
	{
		this.m_isColumnLoading = flag;
		if (flag)
		{
			this.m_loadingBtn.style.display = "";
			
			//If the iconOnly flag is not set, then set the class for the column, 
			//rather than just the loading button
			if (!btnOnly)
			{
				this.m_columnContent.className = "ContentLoading";
			}
			
				this.m_moveLeftBtn.style.visibility = "hidden";
				this.m_moveRightBtn.style.display = "none";
				this.m_closeBtn.style.display = "none";
				this.m_filterBtn.style.display = "none";
				this.m_allBtn.style.display = "none";	
				
				var labelWidth = this.m_columnHeader.clientWidth - (this.m_moveLeftBtn.offsetWidth + this.m_moveRightBtn.offsetWidth + this.m_closeBtn.offsetWidth + this.m_filterBtn.offsetWidth + this.m_allBtn.offsetWidth + this.m_loadingBtn.offsetWidth)
				this.m_headerLabel.style.width = labelWidth + "px";	
				
		}
		else
		{
			this.m_loadingBtn.style.display = "none";
			
			this.m_columnContent.className = "Content";
			
				
				var labelWidth = this.m_columnHeader.clientWidth - (this.m_moveLeftBtn.offsetWidth + this.m_moveRightBtn.offsetWidth + this.m_closeBtn.offsetWidth + this.m_filterBtn.offsetWidth + this.m_allBtn.offsetWidth + this.m_loadingBtn.offsetWidth)
				this.m_headerLabel.style.width = labelWidth + "px";				
		}
		this.Resize();
	},
	
ClearSelections: function()
	{
		if (this.m_list)
		{
			this.m_list.ClearSelections();				
		}		
	},

SetOpen: function(column)
	{
		if(column.m_Uri == this.m_Uri)
			this.m_isOpen = true;
	},

SetClosed: function(column)
	{
		if(column.m_Uri == this.m_Uri)
			this.m_isOpen = true;
	},
	
GetSliceString: function()
	{
		if (this.m_list)
		{
			return this.m_list.GetSliceString();				
		}	
		
		return null;
	},
	
LoadVisibleListItems: function(coldetails, clear)
	{
		if (this.m_list)
		{
			return this.m_list.LoadVisibleListItems(coldetails, clear);				
		}		
	},
	
Reset: function()
	{
		if (this.m_list)
		{
			this.m_list.Reset();
		}
	},
	
GetFilterUrlText: function()
	{
		if (this.m_list)
		{
			return this.m_list.GetFilterUrlText();
		}
		return "";
	},
	
UpdateTitle: function(selections, highlights)
	{
		this.m_headerLabel.className = "HeaderLabel";
		if (selections)
		{
			$(this.m_headerLabel).addClassName("sel");
		}
		else if (highlights)
		{
			$(this.m_headerLabel).addClassName("hig");
		}
	}

	
}
