Type.registerNamespace('SfWeb');

SfWeb.ClickedOutsideElement = function(evt, element)
{
	if (!element)
		return true;

	var theElem = SfWeb.GetEventTarget(evt);

	while (theElem != null)
	{
		if (theElem.id == element.id)
			return false;

		theElem = theElem.parentNode;
	}

	return true;
}

SfWeb.GetEventTarget = function(evt)
{
	var targ = (evt.target) ? evt.target : evt.srcElement;

	if (targ != null)
	{
		if (targ.nodeType == 3)
			targ = targ.parentNode;
	}

	return targ;
}

SfWeb.IsIE7 = function()
{
	return $.browser.msie && ($.browser.version.substring(0, 1) < '8');
}

/* Begin AutoComplete.js */
SfWeb.AutoComplete = function(id, divResultsId, divResultListId, textBoxValueId, hiddenInputId, noResultsText, containerId, itemSelectedClientMethod)
{
	this.id = id;
	this.divResults = $get(divResultsId);
	this.divResultList = $get(divResultListId);
	this.textBoxValue = $get(textBoxValueId);
	this.hiddenInput = $get(hiddenInputId);
	this.noResultsText = noResultsText;
	this.divContainer = $get(containerId);
	this.timer;
	this.itemSelectedClientMethod = itemSelectedClientMethod;
	this.lastSearchText;

	SfWeb.AutoComplete.prototype.Init = function()
	{
		$addHandler(this.textBoxValue, "focus", new Function(this.id + '.OnFocus()'));
		$addHandler(document.body, "click", new Function('evt', this.id + '.OnBodyClick(evt)'));
	}

	this.GetSelectedValue = function()
	{
		return this.hiddenInput.value;
	}

	this.GetSelectedText = function()
	{
		return this.textBoxValue.value;
	}

	this.OnFocus = function()
	{
		this.OnKeyUp();
		//		this.ShowResults();
	}

	this.OnBodyClick = function(evt)
	{
		if (SfWeb.ClickedOutsideElement(evt, this.divContainer))
		{
			this.HideResults();
		}
	}

	this.SearchResults = function(result)
	{
		var results = result.split(";");
		results.pop(); // last result is always empty
		this.ClearResults();

		if (results.length > 0)
		{
			for (var i = 0; i < results.length; i++)
			{
				var keyValue = results[i].split("::");

				if (keyValue.length != 2 || keyValue[0] == null)
				{
					return;
				}

				var divItem = document.createElement('div');
				divItem.innerHTML = keyValue[1];
				divItem.setAttribute('dataId', keyValue[0]);
				divItem.onclick = new Function(this.id + '.SelectValue(this)');
				divItem.onmouseover = new Function(this.id + '.Hilight(this)');
				divItem.onmouseout = new Function(this.id + '.Unhilight(this)');
				divItem.className = 'AutoCompleteResultItem';
				this.divResultList.appendChild(divItem);

				// if they've hit a single result set the id
				if (results.length == 1)
				{
					this.hiddenInput.value = keyValue[0];
				}
			}
		}
		else
		{
			this.AddNoResults();
		}

		this.ShowResults();
	}

	this.AddNoResults = function()
	{
		var divItem = document.createElement('div');
		divItem.innerHTML = this.noResultsText;
		divItem.className = 'AutoCompleteResultItem';
		this.divResultList.appendChild(divItem);
	}

	this.Hilight = function(target)
	{
		target.className = 'AutoCompleteResultItemOver';
	}

	this.Unhilight = function(target)
	{
		target.className = 'AutoCompleteResultItem';
	}

	this.SelectValue = function(target)
	{
		this.textBoxValue.value = target.innerHTML;
		this.hiddenInput.value = target.getAttribute('dataId');
		this.HideResults();

		if (this.itemSelectedClientMethod != null && this.itemSelectedClientMethod.length > 0)
		{
			eval(this.itemSelectedClientMethod + '()');
		}
	}

	this.Focus = function()
	{
		this.textBoxValue.focus();
	}

	this.ShowResults = function()
	{
		this.divResults.style.display = '';
	}

	this.HideResults = function()
	{
		this.divResults.style.display = 'none';
	}

	this.Clear = function()
	{
		//		this.ClearResults();
		this.ClearValue();
		this.ClearText();
	}

	this.ClearResults = function()
	{
		this.divResultList.innerHTML = '';
	}

	this.ClearValue = function()
	{
		this.hiddenInput.value = '';
	}

	this.ClearText = function()
	{
		this.textBoxValue.value = '';
	}

	this.OnKeyPress = function(e)
	{
		e = (e) ? e : event;
		var code = e.charCode || e.keyCode;

		if (code == Sys.UI.Key.enter)
		{
			return false;
		}

		return true;
	}

	this.ShowSearching = function()
	{
		this.ClearResults();

		var divItem = document.createElement('div');
		divItem.innerHTML = "Searching...";
		divItem.className = 'AutoCompleteResultItem';
		this.divResultList.appendChild(divItem);

		this.ShowResults();
	}

	this.OnKeyUp = function(e)
	{
		if (this.textBoxValue.value == this.lastSearchText)
		{
			return;
		}

		clearTimeout(this.timer);
		var cancel = false;

		var code;
		if (!e) var e = window.event;

		if (e == null) code = null;
		else if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;

		if (code == Sys.UI.Key.esc)
		{
			cancel = true;
			this.HideResults();
		}

		this.ClearValue();

		if (this.textBoxValue.value.length == 0)
		{
			this.HideResults();
			return;
		}

		if (!cancel)
		{
			this.lastSearchText = this.textBoxValue.value;
			this.timer = setTimeout(this.id + '.AsyncSearch()', 1000);
		}
	}
}
SfWeb.AutoComplete.registerClass('SfWeb.AutoComplete');

function ProcessSearchResults(result, context)
{
	context.SearchResults(result);
}
/* End AutoComplete.js */

/* Begin CollapsePanel.js */
SfWeb.CollapsePanel = function(element)
{
	SfWeb.CollapsePanel.initializeBase(this, [element]);

	this.body = null;
	this.footer = null;
	this.toggle = null;
	this.hiddenState = null;
	this.showFooter = true;
	this.defaultButtonClientId = null;
}

SfWeb.CollapsePanel.prototype =
{
    initialize: function() {
        if (this.defaultButtonClientId)
            $addHandler(this.get_element(), 'keypress', Function.createDelegate(this, this.KeyPressHandler));
        SfWeb.CollapsePanel.callBaseMethod(this, 'initialize');
    },

    dispose: function() {
        $clearHandlers(this.get_element());
        SfWeb.CollapsePanel.callBaseMethod(this, 'dispose');
    },

    get_body: function() {
        return this.body;
    },

    set_body: function(value) {
        this.body = value;
    },

    get_footer: function() {
        return this.footer;
    },

    set_footer: function(value) {
        this.footer = value;
    },

    get_toggle: function() {
        return this.toggle;
    },

    set_toggle: function(value) {
        this.toggle = value;
    },

    get_hiddenState: function() {
        return this.hiddenState;
    },

    set_hiddenState: function(value) {
        this.hiddenState = value;
    },

    get_footerVisible: function() {
        if (this.footer)
            return this.footer.style.display = '';

        return false;
    },

    set_footerVisible: function(value) {
        if (this.footer) {
            this.footer.style.display = value ? '' : 'none';
            this.set_showFooter(value);
        }
    },

    get_showFooter: function() {
        return this.showFooter;
    },

    set_showFooter: function(value) {
        this.showFooter = value;
    },

    get_defaultButtonClientId: function() {
        return this.defaultButtonClientId;
    },

    set_defaultButtonClientId: function(value) {
        this.defaultButtonClientId = value;
    },

    ExpandCollapse: function() {
        if (this.body)
            this.body.style.display = (this.body.style.display == '' ? 'none' : '');

        if (this.footer && this.get_showFooter())
            this.footer.style.display = (this.footer.style.display == '' ? 'none' : '');

        if (this.toggle)
            this.toggle.className = this.body.style.display == '' ? 'collapse_panel_close' : 'collapse_panel_open';

        this.hiddenState.value = this.body.style.display == 'none';
    },

    Expand: function() {
        if (this.body)
            this.body.style.display = '';

        if (this.footer && this.get_showFooter())
            this.footer.style.display = '';

        if (this.toggle)
            this.toggle.className = 'collapse_panel_close';

        this.hiddenState.value = 'false';
    },

    Collapse: function() {
        if (this.body)
            this.body.style.display = 'none';

        if (this.footer && this.get_showFooter())
            this.footer.style.display = 'none';

        if (this.toggle)
            this.toggle.className = 'collapse_panel_open';

        this.hiddenState.value = 'true';
    },

    KeyPressHandler: function(evt) {
        return WebForm_FireDefaultButton(evt, this.defaultButtonClientId);
    }
}
SfWeb.CollapsePanel.registerClass('SfWeb.CollapsePanel', Sys.UI.Control);
/* End CollapsePanel.js */

/* Begin ModalDialog.js */
SfWeb.MediasiteModalDialog = function(element)
{
	SfWeb.MediasiteModalDialog.initializeBase(this, [element]);

	this.dialog = null;
}

SfWeb.MediasiteModalDialog.prototype =
{
	initialize: function()
	{
		SfWeb.MediasiteModalDialog.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		SfWeb.MediasiteModalDialog.callBaseMethod(this, 'dispose');
	},

	get_dialog: function()
	{
		return this.dialog;
	},

	set_dialog: function(value)
	{
		this.dialog = value;
	},

	Show: function()
	{
		this.dialog.show();
	},

	Hide: function()
	{
		this.dialog.hide();
	}
}
SfWeb.MediasiteModalDialog.registerClass('SfWeb.MediasiteModalDialog', SfWeb.CollapsePanel);
/* End ModalDialog.js */

/* Begin MediasiteTreeView.js */
SfWeb.TreeNodeImageType = function() { };
SfWeb.TreeNodeImageType.prototype =
{
	Blank: 0,
	IBeam: 1,
	LBeam: 2,
	RBeam: 3,
	TBeam: 4,
	Collapse: 5,
	CollapseR: 6,
	CollapseL: 7,
	CollapseT: 8,
	Expand: 9,
	ExpandL: 10,
	ExpandR: 11,
	ExpandT: 12,
	Collapsed: 13,
	Expanded: 14,
	CollapseNL: 15,
	ExpandNL: 16
}
SfWeb.TreeNodeImageType.registerEnum("SfWeb.TreeNodeImageType");

SfWeb.MediasiteTreeViewNode = function()
{
	SfWeb.MediasiteTreeViewNode.initializeBase(this);

	this.nodes = new Array();
	this.text = null;
	this.value = null;
	this.level = null;
	this.expanded = null;
	this.parentNode = null;
	this.index = null;
	this.treeView = null;
	this.contextMenuId = null;
	this.collapsedImage = null;
	this.expandedImage = null;
	this.showCheckBox = null;
	this.checked = null;
	this.checkBox = null;
	this.childrenRendered = null;
	this.branchContainer = null;
	this.contentContainer = null;
	this.container = null;
	this.dragTimer = null;

	this.expandContainer;
	this.userImage;
}

SfWeb.MediasiteTreeViewNode.prototype =
{
	initialize: function()
	{
		SfWeb.MediasiteTreeViewNode.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		if (this.contentContainer != null)
			$clearHandlers(this.contentContainer);

		if (this.expandContainer)
			$clearHandlers(this.expandContainer);

		if (this.userImage)
			$clearHandlers(this.userImage);

		if (this.checkBox)
			$clearHandlers(this.checkBox);

		this.disposeDraggable();

		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].dispose();
		}

		SfWeb.MediasiteTreeViewNode.callBaseMethod(this, 'dispose');
	},

	disposeDraggable: function()
	{
		var dragDropItem = $('#' + this.get_id());

		if (dragDropItem != null)
		{
			if (dragDropItem.draggable)
				dragDropItem.draggable('destroy');

			if (dragDropItem.droppable)
				dragDropItem.droppable('destroy');
		}
	},

	get_parentNode: function()
	{
		return this.parentNode;
	},

	set_parentNode: function(value)
	{
		this.parentNode = value;
	},

	get_element: function()
	{
		return this.container;
	},

	Reset: function()
	{
		this.childrenRendered = false;

		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].Reset();
		}
	},

	RemoveNode: function(node)
	{
		for (var i = 0; i < this.nodes.length; i++)
		{
			if (this.nodes[i].get_id() == node.get_id())
			{
				this.nodes.splice(i, 1);
				break;
			}
		}

		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].index = i;
		}
	},

	SetDraggable: function()
	{
		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].SetDraggable();
		}

		if (this.treeView)
		{
			var treeView = this.treeView;
			var dragDropItem = $('#' + this.get_id());

			if (!dragDropItem.hasClass('.ui-draggable'))
			{
				if (this.parentNode != null)
				{
					dragDropItem.draggable({
						revert: true,
						revertDuration: 200,
						zIndex: 5000,
						scroll: true,
						scrollSpeed: 10,
						opacity: 0.50,
						helper: 'clone',
						refreshPositions: false,
						cursorAt: { top: -10, left: -15 }
					});
				}

				var overHandler = Function.createDelegate(this, this.dragOver);
				var outHandler = Function.createDelegate(this, this.dragOut);

				dragDropItem.droppable({
					addClasses: false,
					drop: function(evt, ui) { eval($(this)[0].id).OnDrop($(ui.draggable)[0]); },
					over: overHandler,
					out: outHandler,
					tolerance: 'pointer'
				});
			}
		}
	},

	dragOver: function(evt, ui)
	{
		this.treeView.OnMouseOver(this.get_id());

		if (!this.expanded)
		{
			var expandOnDragHandler = Function.createDelegate(this, this.expandOnDrag);
			this.dragTimer = setTimeout(function() { expandOnDragHandler(evt, ui); }, 1000);
		}

		// turn off refreshPositions if its set as it is really expensive operation to 
		// have running at all times
		if (ui.draggable.draggable('option', 'refreshPositions'))
		{
			ui.draggable.draggable('option', 'refreshPositions', false);
		}
	},

	dragOut: function(evt, ui)
	{
		this.treeView.OnMouseOut(this.get_id());
		clearTimeout(this.dragTimer);
	},

	expandOnDrag: function(evt, ui)
	{
		// turn on refreshPositions on expand so the drop spots on the draggable get refreshed
		ui.draggable.draggable('option', 'refreshPositions', true);
		this.treeView.ExpandCollapse(this);
	},

	SetLevel: function(level)
	{
		this.level = level;

		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].SetLevel(this.level + 1);
		}
	},

	OnDrop: function(droppedElement)
	{
		this.treeView.OnMouseOut(this.get_id());

		var dropped = $find(droppedElement.id);
		var parent = this.parentNode;

		while (parent != null)
		{
			if (parent.get_id() == droppedElement.id)
			{
				return;
			}

			parent = parent.parentNode;
		}

		var result = true;

		if (this.treeView.onDroppingMethod != null)
		{
			result = eval(this.treeView.onDroppingMethod + '(droppedElement.id, this.get_id())');
		}

		if (result)
		{
			dropped.parentNode.RemoveNode(dropped);
			dropped.parentNode = eval(this.get_id());
			dropped.SetLevel(this.level + 1);

			// sort new nodes
			var index = 0;

			while ((index < this.nodes.length) && (this.nodes[index].text.toLowerCase() < dropped.text.toLowerCase()))
			{
				index++;
			}

			this.nodes.splice(index, 0, dropped);

			// reindex after sorting
			for (var i = 0; i < this.nodes.length; i++)
			{
				this.nodes[i].index = i;
			}

			if (this.treeView.onDropMethod != null)
			{
				eval(this.treeView.onDropMethod + "(droppedElement.id, this.get_id())");
			}

			this.treeView.Render();
		}
	},

	GetImageUrl: function()
	{
		if (!this.treeView.showLines)
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.Blank];
		}

		if (this.parentNode == null)
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.RBeam];
		}

		if (this.index == (this.parentNode.nodes.length - 1))
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.LBeam];
		}

		return this.treeView.imageArray[SfWeb.TreeNodeImageType.TBeam];
	},

	GetCollapseImageUrl: function()
	{
		if (!this.treeView.showLines)
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.CollapseNL];
		}

		if (this.parentNode == null)
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.CollapseR];
		}

		if (this.index == (this.parentNode.nodes.length - 1))
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.CollapseL];
		}

		return this.treeView.imageArray[SfWeb.TreeNodeImageType.CollapseT];
	},

	GetExpandImageUrl: function()
	{
		if (!this.treeView.showLines)
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.ExpandNL];
		}

		if (this.parentNode == null)
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.ExpandR];
		}

		if (this.index == (this.parentNode.nodes.length - 1))
		{
			return this.treeView.imageArray[SfWeb.TreeNodeImageType.ExpandL];
		}

		return this.treeView.imageArray[SfWeb.TreeNodeImageType.ExpandT];
	},

	GetParents: function()
	{
		var parents = new Array();
		var parent = this.parentNode;

		while (parent != null)
		{
			parents.push(parent);
			parent = parent.parentNode;
		}

		parents.reverse();
		parents.shift();

		return parents;
	},

	Render: function(treeView, parentContainer)
	{
		this.treeView = treeView;

		this.container = document.createElement('div');
		this.container.className = 'mtvTreeNode';

		// start I-beam filler
		var iBeamContainer = document.createElement('span');
		var parents = this.GetParents();

		for (var i = 0; i < this.level; i++)
		{
			var iBeamImage = document.createElement('img');
			iBeamImage.className = 'mtvNodeImage';
			iBeamImage.src = (treeView.showLines ? (parents[i].index == parents[i].parentNode.nodes.length - 1 ? this.treeView.imageArray[SfWeb.TreeNodeImageType.Blank] : this.treeView.imageArray[SfWeb.TreeNodeImageType.IBeam]) : this.treeView.imageArray[SfWeb.TreeNodeImageType.Blank]);
			iBeamContainer.appendChild(iBeamImage);
		}

		this.container.appendChild(iBeamContainer);
		// end I-beam filler

		// start expand/collapse
		this.expandContainer = document.createElement('span');

		if (this.nodes.length > 0)
		{
			$addHandler
			(
				this.expandContainer, 'click',
				Function.createDelegate
				(
					this,
					function()
					{
						$find(this.treeView.get_id()).ExpandCollapse(this);
					}
				)
			);
		}

		var expandImage = document.createElement('img');
		expandImage.id = (this.get_id() + '_img');

		if (this.nodes.length == 0)
		{
			expandImage.setAttribute('src', this.GetImageUrl());
		}
		else if (this.expanded)
		{
			expandImage.setAttribute('src', this.GetCollapseImageUrl());
		}
		else
		{
			expandImage.setAttribute('src', this.GetExpandImageUrl());
		}

		this.expandContainer.appendChild(expandImage);
		this.container.appendChild(this.expandContainer);
		// end expand/collapse

		// start user-supplied image
		var itemContainer = document.createElement('span');
		itemContainer.id = this.get_id();
		this.container.appendChild(itemContainer);

		if ((!this.expanded && ((this.treeView.imageArray[SfWeb.TreeNodeImageType.Collapsed] != null) || this.collapsedImage != null)) || (this.expanded && ((this.treeView.imageArray[SfWeb.TreeNodeImageType.Expanded] != null) || this.expandedImage != null)))
		{
			this.userImage = document.createElement('img');
			this.userImage.id = this.get_id() + '_uimg';
			this.userImage.src =
				(this.expanded && this.nodes.length > 0) ?
					(this.expandedImage != null ? this.expandedImage : this.treeView.imageArray[SfWeb.TreeNodeImageType.Expanded])
					: (this.collapsedImage != null ? this.collapsedImage : this.treeView.imageArray[SfWeb.TreeNodeImageType.Collapsed]);

			if (this.nodes.length > 0)
			{
				$addHandler
				(
					this.userImage, 'click',
					Function.createDelegate
					(
						this,
						function()
						{
							$find(this.treeView.get_id()).ExpandCollapse(this);
						}
					)
				);
			}

			itemContainer.appendChild(this.userImage);
		}
		// end user-supplied image

		// startcheckbox
		if (this.showCheckBox)
		{
			this.checkBox = document.createElement('input');
			this.checkBox.setAttribute('type', 'checkbox');
			$addHandler
			(
				this.checkBox, 'click',
				Function.createDelegate
				(
					this,
					function()
					{
						$find(this.treeView.get_id()).CheckClicked(this.get_id());
					}
				)
			);
			this.checkBox.id = this.get_id() + '_checkbox';
			itemContainer.appendChild(this.checkBox);
			this.checkBox.checked = this.checked;
			DataChangeValidator_AddNoDirtyCheckControl(this.checkBox.id);
		}
		// end checkbox

		// start user content
		this.contentContainer = document.createElement('span');

		// context menu
		if (this.contextMenuId != null)
		{
			$addHandler
			(
				this.contentContainer, 'contextmenu',
				Function.createDelegate
				(
					this,
					function(evt)
					{
						var posx = 0;
						var posy = 0;
						if (!evt)
							var evt = window.event;
						if (evt.pageX || evt.pageY)
						{
							posx = evt.pageX;
							posy = evt.pageY;
						}
						else if (evt.clientX || evt.clientY)
						{
							posx = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
							posy = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop;
						};

						$find(this.contextMenuId).Show(posx, posy);
						$find(this.treeView.get_id()).SetSelectedNode(this.get_id(), true);
						evt.preventDefault();
						return false;
					}
				)
			);
		}

		this.contentContainer.className = (this.selected ? treeView.selectedNodeCssClass : treeView.nodeCssClass);
		$addHandler
		(
			this.contentContainer, 'click',
			Function.createDelegate
			(
				this,
				function()
				{
					$find(this.treeView.get_id()).OnClick(this.get_id());
				}
			)
		);

		$addHandler
		(
			this.contentContainer, 'mouseover',
			Function.createDelegate
			(
				this,
				function()
				{
					$find(this.treeView.get_id()).OnMouseOver(this.get_id());
				}
			)
		);

		$addHandler
		(
			this.contentContainer, 'mouseout',
			Function.createDelegate
			(
				this,
				function()
				{
					$find(this.treeView.get_id()).OnMouseOut(this.get_id());
				}
			)
		);

		this.contentContainer.setAttribute('value', this.value);
		this.contentContainer.innerHTML = this.text.replace('&', '&amp;');

		itemContainer.appendChild(this.contentContainer);
		// end user content

		parentContainer.appendChild(this.container);

		// start sub-branch
		if (this.nodes.length > 0)
		{
			this.branchContainer = document.createElement('div');
			this.branchContainer.id = this.get_id() + '_branch';
			this.branchContainer.className = (this.expanded ? 'mtvTreeBranchVisible' : 'mtvTreeBranchHidden');

			var branchInnerContainer = document.createElement('div');

			if (this.expanded)
			{
				this.RenderChildren();
			}

			this.branchContainer.appendChild(branchInnerContainer);
			parentContainer.appendChild(this.branchContainer);
		}
		// end sub-branch
	},

	RenderChildren: function()
	{
		if (this.childrenRendered)
		{
			return;
		}

		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].Render(this.treeView, this.branchContainer);
		}

		this.childrenRendered = true;
	},

	Focus: function()
	{
		this.treeView.SetSelectedNode(this.get_id());
		this.contentContainer.focus();
	},

	get_cssClass: function()
	{
		return this.contentContainer.className;
	},

	set_cssClass: function(value)
	{
		this.contentContainer.className = value;
	}
}
SfWeb.MediasiteTreeViewNode.registerClass('SfWeb.MediasiteTreeViewNode', Sys.Component);

SfWeb.MediasiteTreeView = function(element)
{
	SfWeb.MediasiteTreeView.initializeBase(this, [element]);

	this.selectedNodeId = null;
	this.focusedNodeId = null;
	this.nodeCssClass = null;
	this.selectedNodeCssClass = null;
	this.nodeHoverCssClass = null;
	this.selectedNodeHoverCssClass = null;
	this.onClickMethod = null;
	this.onDropMethod = null;
	this.showLines = null;
	this.autoPostBack = null;
	this.nodes = new Array();
	this.selectedValueInputId = null;
	this.expandedInputId = null;
	this.checkedInputId = null;
	this.validateUnsavedChanges = null;
	this.enableDragDrop = null;
	this.serverId = null;
	this.onNodeSelectMethod = null;
	this.lastContextMenuId = null;
	this.hasFocus = false;
	this.clickTimeout = null;

	this.keyDownHandler = null;
	this.keyPressHandler = null;

	this.imageArray = new Array();
}

SfWeb.MediasiteTreeView.prototype =
{
	initialize: function()
	{
		this.keyDownHandler = Function.createDelegate(this, this._onKeyDown);
		this.keyPressHandler = Function.createDelegate(this, this._onKeyPress);

		$addHandler(this.get_element(), 'focus', Function.createDelegate(this, this._focus));
		$addHandler(this.get_element(), 'blur', Function.createDelegate(this, this._blur));
		$addHandler(document, 'keydown', this.keyDownHandler);
		$addHandler(document, 'keypress', this.keyPressHandler);

		SfWeb.MediasiteTreeView.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		$clearHandlers(this.get_element());
		$removeHandler(document, 'keydown', this.keyDownHandler);
		$removeHandler(document, 'keypress', this.keyPressHandler);

		for (var i = 0; i < this.nodes.length; i++)
		{
			this.nodes[i].dispose();
		}

		SfWeb.MediasiteTreeView.callBaseMethod(this, 'dispose');
	},

	_onKeyPress: function(evt)
	{
		if (evt.ctrlKey && (evt.charCode == 103 || evt.charCode == 7))
		{
			evt.preventDefault();
			this.SetFocus();
			return false;
		}
	},

	SetFocus: function()
	{
		var container = this.get_element();

		if ((container != null) && (container.getAttribute('TABINDEX') != 0))
		{
			try
			{
				container.focus();
				this._focus();
			}
			catch (ex)
			{
				// do nothing
			}
		}
	},

	_focus: function()
	{
		this.hasFocus = true;
	},

	_blur: function()
	{
		this.hasFocus = false;
	},

	_selectNextNode: function(node)
	{
		if (node == null || node.parentNode == null)
		{
			return;
		}

		var index = node.index + 1;

		if (node.index < node.parentNode.nodes.length - 1)
		{
			this.OnClick(node.parentNode.nodes[index].get_id(), true);
		}
		else
		{
			this._selectNextNode(node.parentNode);
		}
	},

	ScrollIntoView: function()
	{
		var selectedNodeDOM = this.GetSelectedNode().get_element();
		var nodeLoc = Sys.UI.DomElement.getBounds(selectedNodeDOM);

		var container = this.get_element();
		var containerLoc = Sys.UI.DomElement.getBounds(container);
		var nodeTop = nodeLoc.y - containerLoc.y;
		var containerBottom = containerLoc.y + containerLoc.height;

		if (nodeTop < 0)
			container.scrollTop += nodeTop - 5;

		if ((nodeLoc.y + nodeLoc.height) > (containerBottom - 16))
			container.scrollTop += (nodeLoc.y - containerBottom) + nodeLoc.height + 16;
	},

	_onKeyDown: function(evt)
	{
		if (this.hasFocus)
		{
			var code;
			if (!evt) var evt = window.event;

			if (evt == null) code = null;
			else if (evt.keyCode) code = evt.keyCode;
			else if (evt.which) code = evt.which;

			var selectedNode = this.GetSelectedNode();

			if (selectedNode == "")
			{
				return;
			}

			if (code == Sys.UI.Key.up)
			{
				if (selectedNode.index == 0 && selectedNode.parentNode != null)
				{
					this.OnClick(selectedNode.parentNode.get_id(), true);
				}
				else if (selectedNode.parentNode != null && selectedNode.parentNode.nodes.length > 0)
				{
					this.OnClick(selectedNode.parentNode.nodes[selectedNode.index - 1].get_id(), true);
				}

				return false;
			}
			if (code == Sys.UI.Key.down)
			{
				if (selectedNode.expanded && selectedNode.nodes.length > 0)
				{
					this.OnClick(selectedNode.nodes[0].get_id(), true);
				}
				else
				{
					this._selectNextNode(selectedNode);
				}

				return false;
			}
			if (code == Sys.UI.Key.left)
			{
				if (selectedNode.expanded)
				{
					this.ExpandCollapse(selectedNode);
				}

				//				selectedNode.contentContainer.scrollIntoView();
				return false;
			}
			if (code == Sys.UI.Key.right)
			{
				if (!selectedNode.expanded)
				{
					this.ExpandCollapse(selectedNode);
				}

				return false;
			}
		}
	},

	GetSelectedValue: function()
	{
		var node = this.GetSelectedNode();

		if (node != null)
		{
			return node.value;
		}
		else
		{
			return null;
		}
	},

	GetSelectedText: function()
	{
		var node = this.GetSelectedNode();

		if (node != null)
		{
			return node.text;
		}
		else
		{
			return "";
		}
	},

	ExpandCollapse: function(node)
	{
		node.expanded = !node.expanded;
		node.RenderChildren();

		var nodeId = node.get_id();
		var branch = $get(nodeId + "_branch");
		var image = $get(nodeId + "_img");
		var userImage = $get(nodeId + "_uimg");

		if (branch == null)
			return;

		if (branch.className == 'mtvTreeBranchHidden')
		{
			branch.className = 'mtvTreeBranchVisible';

			if (image != null)
			{
				image.src = node.GetCollapseImageUrl();
			}

			if (userImage != null)
			{
				if (node.expandedImage != null)
				{
					userImage.src = node.expandedImage;
				}
				else
				{
					userImage.src = this.imageArray[SfWeb.TreeNodeImageType.Expanded];
				}
			}

			this.saveExpandedState(node);
		}
		else
		{
			branch.className = 'mtvTreeBranchHidden';

			if (image != null)
			{
				image.src = node.GetExpandImageUrl();
			}

			if (userImage != null)
			{
				if (node.collapsedImage != null)
				{
					userImage.src = node.collapsedImage;
				}
				else
				{
					userImage.src = this.imageArray[SfWeb.TreeNodeImageType.Collapsed];
				}
			}

			this.saveCollapsedState(node);
		}

		if (this.enableDragDrop)
		{
			node.SetDraggable();
		}
	},

	saveExpandedState: function(node)
	{
		var expandedInput = $get(this.expandedInputId);
		var ids = expandedInput.value.split('|');
		ids.push(node.get_id());
		expandedInput.value = ids.join('|');
	},

	saveCollapsedState: function(node)
	{
		var expandedInput = $get(this.expandedInputId);
		var ids = expandedInput.value.split('|');
		var nodeId = node.get_id();

		for (var i = 0; i < ids.length; i++)
		{
			if (ids[i] == nodeId)
			{
				Array.removeAt(ids, i);
				break;
			}
		}

		expandedInput.value = ids.join('|');
	},

	CheckClicked: function(nodeId)
	{
		var checkedInput = $get(this.checkedInputId);
		var ids = checkedInput.value.split('|');
		var isChecked = eval(nodeId).checkBox.checked;

		if (!isChecked)
		{
			for (var i = 0; i < ids.length; i++)
			{
				if (ids[i] == nodeId)
				{
					Array.removeAt(ids, i);
					break;
				}
			}
		}
		else
		{
			ids.push(nodeId);
		}

		checkedInput.value = ids.join('|');
	},

	OnMouseOver: function(nodeId)
	{
		var node = $find(nodeId);

		if (nodeId == this.selectedNodeId)
		{
			node.set_cssClass(this.selectedNodeHoverCssClass);
		}
		else
		{
			node.set_cssClass(this.nodeHoverCssClass);
		}
	},

	OnMouseOut: function(nodeId)
	{
		var node = $find(nodeId);

		if (nodeId == this.selectedNodeId)
		{
			node.set_cssClass(this.selectedNodeCssClass);
		}
		else
		{
			node.set_cssClass(this.nodeCssClass);
		}
	},

	GetSelectedNode: function()
	{
		if (this.selectedNodeId == null)
		{
			return '';
		}

		return $find(this.selectedNodeId);
	},

	SetSelectedNode: function(nodeId, expand)
	{
		if (this.selectedNodeId != null)
		{
			var currentNode = $find(this.selectedNodeId);
			currentNode.set_cssClass(this.nodeCssClass);
		}

		this.selectedNodeId = nodeId;
		var selectedNode = $find(nodeId)

		if (selectedNode)
		{
			selectedNode.set_cssClass(this.selectedNodeCssClass);

			if (expand && !selectedNode.expanded)
			{
				this.ExpandCollapse(selectedNode);
			}

			var hiddenInput = $get(this.selectedValueInputId);
			hiddenInput.value = selectedNode.value;
			this.ScrollIntoView();
		}

		if (this.onNodeSelectMethod != null)
		{
			eval(this.onNodeSelectMethod + "()");
		}
	},

	SetSelectedValue: function(value, nodes)
	{
		if (nodes == null)
		{
			this.SetSelectedValue(value, this.nodes);
			return;
		}

		for (var i = 0; i < nodes.length; i++)
		{
			var node = $find(nodes[i].get_id());

			if (node.value == value)
			{
				this.SetSelectedNode(node.get_id(), true);
				return;
			}

			if (node.nodes != null && node.nodes.length > 0)
			{
				this.SetSelectedValue(value, node.nodes);
			}
		}
	},

	OnClick: function(nodeId, delay)
	{
		if (this.clickTimeout != null)
		{
			clearTimeout(this.clickTimeout);
		}

		if (this.validateUnsavedChanges && !ValidateChanges())
		{
			return;
		}

		this.SetSelectedNode(nodeId, !delay);
		this.SetFocus();

		var node = $find(nodeId);

		if (node.contextMenuId != null)
		{
			$find(node.contextMenuId).Hide;
		}

		if (this.autoPostBack)
		{
			if (delay)
				this.clickTimeout = setTimeout('__doPostBack(\'' + this.serverId.replace(/_/g, '$') + '\', \'' + nodeId + '\');', 1000);
			else
				__doPostBack(this.serverId.replace(/_/g, '$'), nodeId);
		}
		else if (this.onClickMethod != null)
		{
			if (delay)
				this.clickTimeout = setTimeout(Function.createDelegate(this, this.onClickMethod), 1000);
			else
				eval(this.onClickMethod + "()");
		}
	},

	Render: function()
	{
		var treeContainer = this.get_element();

		if (treeContainer)
		{
		    if (this.enableDragDrop == true)
		    {
			    treeContainer.style.position = 'relative';	// make sure we're relative for drag and drop
			}

			while (treeContainer.hasChildNodes())
			{
				treeContainer.removeChild(treeContainer.childNodes[0]);
			}

			for (var i = 0; i < this.nodes.length; i++)
			{
				this.nodes[i].Reset();
			}

			for (var i = 0; i < this.nodes.length; i++)
			{
				this.nodes[i].Render(this, treeContainer);

				if (this.enableDragDrop)
				{
					this.nodes[i].SetDraggable();
				}
			}

			this.SetFocus();
		}
	}
}
SfWeb.MediasiteTreeView.registerClass('SfWeb.MediasiteTreeView', Sys.UI.Control);
/* End MediasiteTreeView.js */

/* Start base menu classes */
SfWeb.GetMousePosition = function(evt)
{
	var posx = 0;
	var posy = 0;
	if (!evt)
		var evt = window.event;
	if (evt.pageX || evt.pageY)
	{
		posx = evt.pageX;
		posy = evt.pageY;
	}
	else if (evt.clientX || evt.clientY)
	{
		posx = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	};

	return new Sys.UI.Point(posx, posy);
}

SfWeb.Menu = function(element)
{
	SfWeb.Menu.initializeBase(this, [element]);

	this.onbodyclick = null;
	this.menuItems = new Array();
	this.OnHideMenu = null;
	this.SeparatorUrl = null;
	this.OffsetTop = 0;
	this.OffsetLeft = 0;
	this.visible = false;
	this.menuElement = null;
}

SfWeb.Menu.prototype =
{
	initialize: function()
	{
		this.get_element().removeChild(this.menuElement);
		document.body.appendChild(this.menuElement);

		this.onbodyclick = Function.createDelegate(this, this._onBodyClick);
		$addHandler(this.menuElement, 'mouseover', Function.createDelegate(this, this._onMouseOver));
		$addHandler(this.menuElement, 'mouseout', Function.createDelegate(this, this._onMouseOut));
		$addHandler(document.body, "click", this.onbodyclick);

		this.Render();

		SfWeb.Menu.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		$clearHandlers(this.menuElement);
		$removeHandler(document.body, "click", this.onbodyclick);

		for (var i = 0; i < this.menuItems.length; i++)
		{
			this.menuItems[i].dispose();
		}

		document.body.removeChild(this.menuElement);

		SfWeb.Menu.callBaseMethod(this, 'dispose');
	},

	get_OnHideMenu: function()
	{
		return this.OnHideMenu;
	},

	set_OnHideMenu: function(value)
	{
		this.OnHideMenu = value;
	},

	get_SeparatorUrl: function()
	{
		return this.SeparatorUrl;
	},

	set_SeparatorUrl: function(value)
	{
		this.SeparatorUrl = value;
	},

	get_menuItems: function()
	{
		return this.menuItems;
	},

	set_menuItems: function(value)
	{
		for (var i = 0; i < value.length; i++)
		{
			var item = eval(value[i]);
			item.set_menu(this);
			item.initialize();
			this.menuItems.push(item);
		}
	},

	get_OffsetTop: function()
	{
		return this.OffsetTop;
	},

	set_OffsetTop: function(value)
	{
		this.OffsetTop = value;
	},

	get_OffsetLeft: function()
	{
		return this.OffsetLeft;
	},

	set_OffsetLeft: function(value)
	{
		this.OffsetLeft = value;
	},

	get_menuElement: function()
	{
		return this.menuElement;
	},

	set_menuElement: function(value)
	{
		this.menuElement = value;
	},

	Render: function()
	{
		var container = this.menuElement;

		while (container.hasChildNodes())
		{
			container.removeChild(container.childNodes[0]);
		}

		var menuContainer = document.createElement('div');
		container.appendChild(menuContainer);

		var itemsAreVisible = false;
		for (var i = 0; i < this.menuItems.length; i++)
		{
			if (this.menuItems[i].visible)
			{
				itemsAreVisible = true;
				this.menuItems[i].Render(menuContainer);
			}
		}

		if (!itemsAreVisible)
		{
			this.Hide();
		}
	},

	_onBodyClick: function(evt)
	{
		if (SfWeb.ClickedOutsideElement(evt, this.menuElement) && this.visible)
		{
			this.Hide();

			if (this.OnHideMenu)
			{
				eval(this.OnHideMenu);
			};
		}
	},

	Show: function(x, y)
	{
		var element = this.menuElement;
		Sys.UI.DomElement.setLocation(element, x - this.OffsetLeft, y - this.OffsetTop);
		element.style.display = '';
		this.visible = true;
	},

	Hide: function()
	{
		if (this.visible)
		{
			this.menuElement.style.display = 'none';
			this.visible = false;
		}
	},

	Add_MouseOver: function(handler)
	{
		this.get_events().addHandler('menumouseover', handler);
	},

	Remove_MouseOver: function(handler)
	{
		this.get_events().removeHandler('menumouseover', handler);
	},

	Add_MouseOut: function(handler)
	{
		this.get_events().addHandler('menumouseout', handler);
	},

	Remove_MouseOut: function(handler)
	{
		this.get_events().removeHandler('menumouseout', handler);
	},

	_onMouseOver: function()
	{
		var h = this.get_events().getHandler('menumouseover');
		if (h) h(this, Sys.EventArgs.Empty);
	},

	_onMouseOut: function()
	{
		var h = this.get_events().getHandler('menumouseout');
		if (h) h(this, Sys.EventArgs.Empty);
	}
}
SfWeb.Menu.registerClass('SfWeb.Menu', Sys.UI.Control);

SfWeb.MenuItem = function(id, text, autoPostBack, enabled, cssClass, cssHoverClass, cssDisabledClass, onClickMethod, commandName)
{
	this.id = id;
	this.menuItems = new Array();
	this.text = text;
	this.autoPostBack = autoPostBack;
	this.commandName = commandName;
	this.enabled = enabled;
	this.visible = true;
	this.cssClass = cssClass;
	this.cssHoverClass = cssHoverClass;
	this.cssDisabledClass = cssDisabledClass;
	this.onClickMethod = onClickMethod;
	this.element = null;

	this.menu;
}

SfWeb.MenuItem.prototype =
{
	get_id: function()
	{
		return this.id;
	},

	get_menu: function()
	{
		return this.menu;
	},

	set_menu: function(value)
	{
		this.menu = value;
	},

	initialize: function()
	{
		this.element = document.createElement('div');
		this.element.id = this.get_id();

		$addHandler(this.element, 'mouseout', Function.createDelegate(this, this._onMouseOut));
		$addHandler(this.element, 'mouseover', Function.createDelegate(this, this._onMouseOver));
		$addHandler(this.element, 'click', Function.createDelegate(this, this._onClick));

		for (var i = 0; i < this.menuItems.length; i++)
		{
			this.menuItems[i].initialize();
		}
	},

	dispose: function()
	{
		$clearHandlers(this.element);

		for (var i = 0; i < this.menuItems.length; i++)
		{
			this.menuItems[i].dispose();
		}
	},

	set_enabled: function(value)
	{
		this.enabled = value;
		this.element.className = this.text == '' ? 'sofoContextMenuItemSeparator' : (this.enabled ? this.cssClass : this.cssDisabledClass);
	},

	Render: function(container)
	{
		// create menu
		this.set_enabled(this.enabled);

		if (this.text == '')
		{
			this.element.innerHTML = '&nbsp;';
			this.element.style.backgroundImage = 'url(' + this.menu.SeparatorUrl + ')';
		}
		else
		{
			this.element.innerHTML = this.text;
		}

		container.appendChild(this.element);

		// create submenu
	},

	_onMouseOver: function()
	{
		if (this.text == '' || !this.enabled)
		{
			return;
		}

		this.element.className = this.cssHoverClass;

		if (this.menuItems.length > 0)
		{
			// show submenu
		}
	},

	_onMouseOut: function()
	{
		if (this.text == '' || !this.enabled)
		{
			return;
		}

		this.element.className = this.cssClass;

		if (this.menuItems.length > 0)
		{
			// hide submenu
		}
	},

	_onClick: function()
	{
		if (this.text == '' || !this.enabled)
		{
			return;
		}

		this.menu.Hide();
		var result = true;

		if (this.onClickMethod != null &&
		    this.onClickMethod.length > 0)
		{
			result = eval(this.onClickMethod + '()');
		}

		if ((result != null) && result && this.autoPostBack)
		{
			if (this.commandName == null || this.commandName == '')
			{
				__doPostBack(this.menu.get_id().replace(/_/g, '$'));
			}
			else
			{
				__doPostBack(this.menu.get_id().replace(/_/g, '$'), this.commandName);
			}
		}
	}
}
/* End base menu classes */

/* Start MouseOverMenu.js */

SfWeb.MouseOverMenu = function(element)
{
	SfWeb.MouseOverMenu.initializeBase(this, [element]);

	this.container = null;
	this.contextMenu = null;
	this.hideTimer;
	this.mouseOverHandler = Function.createDelegate(this, this._clearTimeout);
	this.mouseOutHandler = Function.createDelegate(this, this.OnMouseOut);
}

SfWeb.MouseOverMenu.prototype =
{
	initialize: function()
	{
		$addHandler(this.container, "mouseover", Function.createDelegate(this, this.OnMouseOver));
		$addHandler(this.container, "mouseout", Function.createDelegate(this, this.OnMouseOut));
		this.contextMenu.Add_MouseOver(this.mouseOverHandler);
		this.contextMenu.Add_MouseOut(this.mouseOutHandler);

		SfWeb.MouseOverMenu.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		$clearHandlers(this.container);
		this.contextMenu.Remove_MouseOver(this.mouseOverHandler);
		this.contextMenu.Remove_MouseOut(this.mouseOutHandler);

		SfWeb.MouseOverMenu.callBaseMethod(this, 'dispose');
	},

	get_container: function()
	{
		return this.container;
	},

	set_container: function(value)
	{
		this.container = value;
	},

	get_contextMenu: function()
	{
		return this.contextMenu;
	},

	set_contextMenu: function(value)
	{
		this.contextMenu = value;
	},

	_clearTimeout: function()
	{
		clearTimeout(this.hideTimer);
	},

	get_menuItems: function()
	{
		return this.contextMenu.menuItems;
	},

	OnMouseOver: function(evt)
	{
		this._clearTimeout();
		if (!evt) evt = window.event;
		var element = this.get_element();
		var loc = Sys.UI.DomElement.getLocation(element);
		var bounds = Sys.UI.DomElement.getBounds(element);
		this.contextMenu.Show(loc.x, loc.y + bounds.height);
	},

	OnMouseOut: function()
	{
		this.hideTimer = setTimeout(Function.createDelegate(this, function() { this.contextMenu.Hide(); }), 1000);
	}
}
SfWeb.MouseOverMenu.registerClass('SfWeb.MouseOverMenu', Sys.UI.Control);
/* End MouseOverMenu.js */

/* Start ImageWithPopup.js */
SfWeb.ImageWithPopup = function(element)
{
    SfWeb.ImageWithPopup.initializeBase(this, [element]);

	this.Popup = null;
	this.ImageButton = null;
	this.OffsetX = null;
	this.OffsetY = null;
	this.bodyClickHandler = Function.createDelegate(this, this.ClosePopup);
}

SfWeb.ImageWithPopup.prototype =
{
	initialize: function()
	{
	    if (this.ImageButton)
		{
		    $addHandler(this.ImageButton, "click", Function.createDelegate(this, this.TogglePopup));
			$addHandler(document, "click", this.bodyClickHandler);
		}

		SfWeb.ImageWithPopup.callBaseMethod(this, 'initialize');
    },

    get_Popup: function() 
    {
        return this.Popup;
    },

    set_Popup: function(value) 
    {
        this.Popup = value;
    },

    get_ImageButton: function()
    {
        return this.ImageButton;
    },

    set_ImageButton: function(value)
    {
        this.ImageButton = value;
    },

    get_OffsetX: function()
    {
        return this.OffsetX;
    },

    set_OffsetX: function(value)
    {
        this.OffsetX = value;
    },

    get_OffsetY: function()
    {
        return this.OffsetY;
    },

    set_OffsetY: function(value)
    {
        this.OffsetY = value;
    },

	dispose: function()
	{
	    $clearHandlers(this.ImageButton);
		$removeHandler(document, 'click', this.bodyClickHandler);
		SfWeb.ImageWithPopup.callBaseMethod(this, 'dispose');
	},

	TogglePopup: function(evt)
	{
	    if (this.Popup && this.ImageButton)
		{
		    if (this.Popup.style.display == "none" && evt.target == this.ImageButton)
			{
			    var buttonBounds = Sys.UI.DomElement.getBounds(this.ImageButton);
				Sys.UI.DomElement.setLocation(this.Popup, this.OffsetX, (buttonBounds.height + this.OffsetY));
				this.Popup.style.display = "block";
			}
			else
			{
			    if (SfWeb.ClickedOutsideElement(evt, this.Popup))
				{
				    this.Popup.style.display = "none";
				}
			}
		}
	},

	ClosePopup: function(evt)
	{
	    if (this.Popup &&
            evt.target.id != this.ImageButton.id)
		{
		    if (SfWeb.ClickedOutsideElement(evt, this.Popup))
			{
			    this.Popup.style.display = "none";
			}
		}
	}
}
SfWeb.ImageWithPopup.registerClass('SfWeb.ImageWithPopup', Sys.UI.Control);
/* End ImageWithPopup.js */

/* Begin CallbackPanel.js */
SfWeb.CallbackPanel = function(id, containerId)
{
	this.id = id;
	this.containerId = containerId;
}

SfWeb.CallbackPanel.prototype =
{
	RefreshPanel: function(html, context)
	{
		$get(context.containerId).innerHTML = html;
	},

	CallbackError: function(message)
	{
		window.alert('error: ' + message);
	}
}
SfWeb.CallbackPanel.registerClass('SfWeb.CallbackPanel');
/* End CallbackPanel.js */

/* Begin SfUpdatePanel.js */
SfWeb.UpdatePanel = function(element)
{
    // component attached to updatepanel doesn't properly dispose
    if ($find(element.id))
        return;

    SfWeb.UpdatePanel.initializeBase(this, [element]);
    this.callback;
    this.LoadHandler = Function.createDelegate(this, this.HandleCallback);
}

SfWeb.UpdatePanel.prototype =
{
    initialize: function()
    {
        SfWeb.UpdatePanel.callBaseMethod(this, 'initialize');
    },

    dispose: function()
    {
        SfWeb.UpdatePanel.callBaseMethod(this, 'dispose');
    },

    Update: function(argument, callback)
    {
        this.callback = callback;

        if (callback)
            Sys.Application.add_load(this.LoadHandler);

        __doPostBack(this.get_id().replace(/_/g, '$'), argument);
    },

    HandleCallback: function()
    {
        if (this.callback)
        {
            this.callback();
            this.callback = null;
        }

        Sys.Application.remove_load(this.LoadHandler);
    }
}
SfWeb.UpdatePanel.registerClass('SfWeb.UpdatePanel', Sys.UI.Control);
/* End SfUpdatePanel.js */


/* Start MessageDisplay.js */

SfWeb.MessageDisplay = function(element)
{
    SfWeb.MessageDisplay.initializeBase(this, [element]);

    this.MessageArea = null;
    this.CloseArea = null;
    this.AutoClose = null;
    this.AutoCloseInterval = null;
    this.TimerId = null;
}

SfWeb.MessageDisplay.prototype =
{
	initialize: function()
	{
		$addHandler(this.CloseArea, "click", Function.createDelegate(this, this.Close));

		SfWeb.MessageDisplay.callBaseMethod(this, 'initialize');
	},

	get_MessageArea: function()
	{
		return this.MessageArea;
	},

	set_MessageArea: function(value)
	{
		this.MessageArea = value;
	},

	get_CloseArea: function()
	{
		return this.CloseArea;
	},

	set_CloseArea: function(value)
	{
		this.CloseArea = value;
	},

	get_AutoClose: function()
	{
		return this.AutoClose;
	},

	set_AutoClose: function(value)
	{
		this.AutoClose = value;
	},

	get_AutoCloseInterval: function()
	{
		return this.AutoCloseInterval;
	},

	set_AutoCloseInterval: function(value)
	{
		this.AutoCloseInterval = value;
	},

	dispose: function()
	{
		$clearHandlers(this.CloseArea);
		SfWeb.MessageDisplay.callBaseMethod(this, 'dispose');
	},

	Show: function(messages, success)
	{
		if (this.TimerId != null &&
            this.AutoClose)
		{
			clearTimeout(this.TimerId);
		}

		var messageArray = messages.split("|");

		var sb = new Sys.StringBuilder();
		for (var i = 0; i < messageArray.length; i++)
		{
			sb.append("<p " + ((i < messageArray.length - 1) ? "style=\"padding-bottom: 5px;\"" : "") + ">");
			sb.append(messageArray[i]);
			sb.append("</p>");
		}

		if (success)
		{
			this.MessageArea.className = "messageDisplay_success";
		}
		else
		{
			this.MessageArea.className = "messageDisplay_failure";
		}


		this.MessageArea.innerHTML = sb.toString();
		this.get_element().style.display = '';

		if (this.AutoClose)
		{
			this.TimerId = setTimeout(Function.createDelegate(this, this.Close), this.AutoCloseInterval);
		}

		if (typeof(MessageDisplayShow) != 'undefined')
		{
			Sys.Application.remove_load(MessageDisplayShow);
		}
	},

	Close: function()
	{
		if (this.MessageArea != null &&
            this.AutoClose != null)
		{
			this.get_element().style.display = 'none';
			this.MessageArea.innerHTML = '';
		}
	}
}
SfWeb.MessageDisplay.registerClass('SfWeb.MessageDisplay', Sys.UI.Control);
/* End MessageDisplay.js */


/* Start WaitIndicator.js */

SfWeb.WaitIndicator = function(element)
{
    SfWeb.WaitIndicator.initializeBase(this, [element]);

    this.Spinner = null;
    this.display = "";
    this.loadHandler = Function.createDelegate(this, this.StartSpinner);
    this.states = null;
    this.dots = null;
    this.initialStates = null;
}

SfWeb.WaitIndicator.prototype =
{
    initialize: function()
    {
        SfWeb.WaitIndicator.callBaseMethod(this, 'initialize');
        Sys.Application.add_load(this.loadHandler);

        this.states = [1.00, 0.60, 0.30, 0.15, 0.15, 0.15, 0.15, 0.15];
        this.initialStates = [0, 7, 6, 5, 4, 3, 2, 1];
        this.dots = new Array();

    },

    get_Spinner: function()
    {
        return this.Spinner;
    },

    set_Spinner: function(value)
    {
        this.Spinner = value;

    },

    dispose: function()
    {
        SfWeb.WaitIndicator.callBaseMethod(this, 'dispose');
    },

    StartSpinner: function()
    {
        var dotChildren = this.Spinner.childNodes;

        for (var i = 0; i < dotChildren.length; i++)
        {
            Array.add(this.dots, $create(SfWeb.SpinnerDot, { States: this.states, InitialState: this.initialStates[i] }, null, null, dotChildren[i]));
        }

        setInterval(Function.createDelegate(this, this.Spin), 100);
        Sys.Application.remove_load(this.loadHandler);
    },

    Spin: function()
    {
        for (var i=0; i<this.dots.length;i++)
        {
            this.dots[i].StepAnimation();
        }
    }
}
SfWeb.WaitIndicator.registerClass('SfWeb.WaitIndicator', Sys.UI.Control);


SfWeb.SpinnerDot = function(element)
{
    SfWeb.SpinnerDot.initializeBase(this, [element]);

    this.States = null;
    this.InitialState = null;
    this.CurrentState = null;

}

SfWeb.SpinnerDot.prototype =
{
    initialize: function()
    {
        SfWeb.SpinnerDot.callBaseMethod(this, 'initialize');
        this.CurrentState = this.InitialState;
        this._applyCurrentState();
    },

    get_States: function()
    {
        return this.States;
    },

    set_States: function(value)
    {
        this.States = value;

    },

    get_InitialState: function()
    {
        return this.InitialState;
    },

    set_InitialState: function(value)
    {
        this.InitialState = value;

    },

    dispose: function()
    {
        SfWeb.SpinnerDot.callBaseMethod(this, 'dispose');
    },

    StepAnimation: function()
    {
        this._advanceCurrentState();
        this._applyCurrentState();
    },

    _advanceCurrentState: function()
    {
        this.CurrentState++;
        this.CurrentState = this.CurrentState % this.States.length;
    },

    _applyCurrentState: function()
    {
        this._element.style.opacity = this.States[this.CurrentState];
        this._element.style.filter = "alpha(opacity=" + this.States[this.CurrentState] * 100 + ")";
        
    }



}
SfWeb.SpinnerDot.registerClass('SfWeb.SpinnerDot', Sys.UI.Control);
/* End WaitIndicator.js */

/* Begin DayPlanner.js */
SfWeb.PlannerMouseEventArgs = function()
{
	this.id = null;
	this.eventElement = null;
}

SfWeb.PlannerMouseEventArgs.prototype =
{
	get_id: function()
	{
		return this.id;
	},

	set_id: function(value)
	{
		this.id = value;
	},

	get_eventElement: function()
	{
		return this.eventElement;
	},

	set_eventElement: function(value)
	{
		this.eventElement = value;
	}
}
SfWeb.PlannerMouseEventArgs.registerClass('SfWeb.PlannerMouseEventArgs', Sys.EventArgs);

SfWeb.PlannerClickEventArgs = function()
{
	this.date = null;
	this.timeSlot = null;
	this.resourceId = null;
}

SfWeb.PlannerClickEventArgs.prototype =
{
	get_timeSlot: function()
	{
		return this.timeSlot;
	},

	set_timeSlot: function(value)
	{
		this.timeSlot = value;
	},

	get_date: function()
	{
		return this.date;
	},

	set_date: function(value)
	{
		this.date = value;
	},

	get_resourceId: function()
	{
		return this.resourceId;
	},

	set_resourceId: function(value)
	{
		this.resourceId = value;
	}
}
SfWeb.PlannerClickEventArgs.registerClass('SfWeb.PlannerClickEventArgs', Sys.EventArgs);

SfWeb.DayPlanner = function(element)
{
	SfWeb.DayPlanner.initializeBase(this, [element]);
	this.rowHeight = null;
	this.days = 0;
	this.currentTime = 0;
	this.autoResize = null;
	this.height = null;

	this.currentBucket;
	this.lastWidth = 95;
	this.columns = 0;

	this.eventMouseOverHandler = Function.createDelegate(this, this._eventMouseOver);
	this.eventMouseOutHandler = Function.createDelegate(this, this._eventMouseOut);
	this.eventClickHandler = Function.createDelegate(this, this._eventClick);
	this.timeSlotClickHandler = Function.createDelegate(this, this._timeSlotClick);
	this.documentResizeHandler = Function.createDelegate(this, this._documentResize);
	this.setEventsHandler = Function.createDelegate(this, this._setEvents);
}

SfWeb.DayPlanner.prototype =
{
	initialize: function()
	{
		if (this.autoResize)
			$addHandler(window, 'resize', this.documentResizeHandler);

		var timeSlotClickHandler = this.timeSlotClickHandler;
		$('.plannerContainer td', this.get_element()).each(function(i, cell)
		{
			$addHandler(cell, 'click', function(evt) { timeSlotClickHandler(cell, evt) });
		});

		this.renderPlanner();
		this.scrollToCurrentTime();

		SfWeb.DayPlanner.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		if (this.autoResize)
			$removeHandler(window, 'resize', this.documentResizeHandler);

		$('.plannerContainer td,.event', this.get_element()).each(function(i, o)
		{
			$clearHandlers(o);
		});

		SfWeb.DayPlanner.callBaseMethod(this, 'dispose');
	},

	get_days: function()
	{
		return this.days;
	},

	set_days: function(value)
	{
		this.days = value;
	},

	get_currentTime: function()
	{
		return this.currentTime;
	},

	set_currentTime: function(value)
	{
		this.currentTime = value;
	},

	get_rowHeight: function()
	{
		return this.rowHeight;
	},

	set_rowHeight: function(value)
	{
		this.rowHeight = value;
	},

	get_autoResize: function()
	{
		return this.autoResize;
	},

	set_autoResize: function(value)
	{
		this.autoResize = value;
	},

	get_height: function()
	{
		return this.height;
	},

	set_height: function(value)
	{
		this.height = value;
	},

	add_eventMouseOver: function(handler)
	{
		this.get_events().addHandler('eventmouseover', handler);
	},

	remove_eventMouseOver: function(handler)
	{
		this.get_events().removeHandler('eventmouseover', handler);
	},

	add_eventMouseOut: function(handler)
	{
		this.get_events().addHandler('eventmouseout', handler);
	},

	remove_eventMouseOut: function(handler)
	{
		this.get_events().removeHandler('eventmouseout', handler);
	},

	add_eventClick: function(handler)
	{
		this.get_events().addHandler('eventclick', handler);
	},

	remove_eventClick: function(handler)
	{
		this.get_events().removeHandler('eventclick', handler);
	},

	add_timeSlotClick: function(handler)
	{
		this.get_events().addHandler('timeslotclick', handler);
	},

	remove_timeSlotClick: function(handler)
	{
		this.get_events().removeHandler('timeslotclick', handler);
	},

	add_oneTimeOnlyEventClick: function(handler)
	{
		this.get_events().addHandler('onetimeonlyeventclick', handler);
	},

	remove_oneTimeOnlyEventClick: function(handler)
	{
		this.get_events().removeHandler('onetimeonlyeventclick', handler);
	},

	get_eventElementById: function(id)
	{
		return $('#' + id, this.get_element());
	},

	scrollToCurrentTime: function()
	{
		var plannerContainer = $('.plannerContainer', this.get_element());
		var rowOffset = $('tr[bucket=' + this.currentTime + ']', plannerContainer).offset().top - plannerContainer.offset().top - (plannerContainer.height() / 3);
		plannerContainer[0].scrollTop = rowOffset;
	},

	renderPlanner: function()
	{
		var setTableCellHandler = Function.createDelegate(this, this._setTableCell);
		var plannerContainer = $('.plannerContainer', this.get_element());

		if (this.autoResize)
			plannerContainer.height($(window).height() - plannerContainer[0].offsetTop - 20);

		if (SfWeb.IsIE7())
		{
			var planner = $('.planner', plannerContainer[0]);
			planner.width(plannerContainer.width() - 16);
		}

		for (index = 0; index < this.days; index++)
		{
			this.lastWidth = 95;
			this.columns = 0;
			$('.plannerContainer tr', this.get_element()).each(function(i, row)
			{
				$('td', row).eq(index).each(setTableCellHandler);
			});
		}
	},

	_documentResize: function()
	{
		this.renderPlanner();
	},

	_eventMouseOver: function(source, evt)
	{
		evt.stopPropagation();
		evt.cancelBubble = true;

		var h = this.get_events().getHandler('eventmouseover');

		if (h)
		{
			var args = new SfWeb.PlannerMouseEventArgs();
			args.id = source.getAttribute('id');
			args.eventElement = source;
			h(this, args);
		}
	},

	_eventMouseOut: function(source, evt)
	{
		evt.stopPropagation();
		evt.cancelBubble = true;

		var h = this.get_events().getHandler('eventmouseout');
		if (h)
		{
			var args = new SfWeb.PlannerMouseEventArgs();
			args.id = source.getAttribute('id');
			args.eventElement = source;
			h(this, args);
		}
	},

	_eventClick: function(source, evt)
	{
		evt.stopPropagation();
		evt.cancelBubble = true;

		if (source.getAttribute('eventEnabled') == 'true')
		{
			var h = this.get_events().getHandler('eventclick');
			if (h)
			{
				var args = new SfWeb.PlannerMouseEventArgs();
				args.id = source.getAttribute('id');
				h(this, args);
			}
		}
	},

	_timeSlotClick: function(source, evt)
	{
		var h = this.get_events().getHandler('timeslotclick');
		if (h)
		{
			var args = new SfWeb.PlannerClickEventArgs();
			args.set_timeSlot(parseInt(source.parentNode.getAttribute('bucket')));
			args.set_date($('.header:first', this.get_element())[0].cells[source.cellIndex + (source.parentNode.rowIndex % 2)].getAttribute('date'));
			h(this, args);
		}
	},

	_oneTimeOnlyEventClick: function(source, evt)
	{
		evt.stopPropagation();
		evt.cancelBubble = true;

		var h = this.get_events().getHandler('onetimeonlyeventclick');
		if (h)
		{
			var args = new SfWeb.PlannerMouseEventArgs();
			args.id = source.getAttribute('id');
			h(this, args);
		}
	},

	_setTableCell: function(index, cell)
	{
		this.currentBucket = parseInt(cell.parentNode.getAttribute('bucket'));
		$('.event', cell).each(this.setEventsHandler);
	},

	_setEvents: function(index, eventDiv)
	{
		var rowHeight = parseInt(this.rowHeight);
		var duration = parseInt(eventDiv.getAttribute('dur'));
		var segments = Math.ceil(duration / 30);
		var startTime = parseInt(eventDiv.getAttribute('start'));
		var startDiff = startTime - this.currentBucket;

		// need one more segment if the end overhangs into another segment
		if ((startTime + duration) > (this.currentBucket + (30 * segments)))
			segments++;

		var eventDivHeight = (segments * rowHeight) + segments - 1;

		var mouseOverHandler = this.eventMouseOverHandler;
		var mouseOutHandler = this.eventMouseOutHandler;
		var clickHandler = this.eventClickHandler;
		$addHandler(eventDiv, 'mouseover', function(evt) { mouseOverHandler(eventDiv, evt) });
		$addHandler(eventDiv, 'mouseout', function(evt) { mouseOutHandler(eventDiv, evt) });
		$addHandler(eventDiv, 'click', function(evt) { clickHandler(eventDiv, evt) });

		eventDiv.style.height = eventDivHeight + 'px';
		eventDiv.style.visibility = 'visible';

		this.lastWidth = eventDiv.style.width.slice(0, eventDiv.style.width.length - 1);

		if (this.lastWidth != 95 && this.columns == 0)
		{
			this.columns = Math.round(100 / this.lastWidth);
		}

		if (this.columns > 0)
		{
			var bounds = Sys.UI.DomElement.getBounds(eventDiv);
			eventDiv.style.left = ((this.columns - 1) * bounds.width) + 'px';
			this.columns--;
		}

		$('.range', eventDiv).each(function(i, o)
		{
			var minutesPerPixel = 30 / rowHeight;
			var rangeHeight = (duration / minutesPerPixel);
			var rangeOffset = Math.ceil(startDiff / minutesPerPixel);
			var rangeStyleHeight = Math.ceil(rangeHeight) + segments - 1;

			if (rangeStyleHeight < 1)
			{
				// always show 1px high
				rangeStyleHeight = 1;
			}

			o.style.position = 'absolute';
			o.style.height = rangeStyleHeight + 'px';
			o.style.top = rangeOffset + 'px';
		});
	}
}
SfWeb.DayPlanner.registerClass('SfWeb.DayPlanner', Sys.UI.Control);
/* End DayPlanner.js */

/* Begin ResourcePlanner.js */
SfWeb.ResourcePlanner = function(element)
{
	SfWeb.ResourcePlanner.initializeBase(this, [element]);

	this.currentTime = 0;
	this.autoResize = null;

	this.documentResizeHandler = Function.createDelegate(this, this._documentResize);
	this.timeSlotClickHandler = Function.createDelegate(this, this._timeSlotClick);
	this.eventClickHandler = Function.createDelegate(this, this._eventClick);
}

SfWeb.ResourcePlanner.prototype =
{
	initialize: function()
	{
		if (this.autoResize)
			$addHandler(window, 'resize', this.documentResizeHandler);

		var timeSlotClickHandler = this.timeSlotClickHandler;
		$('.resourcePlannerEventContainer td', this.get_element()).each(function(i, cell)
		{
			$addHandler(cell, 'click', function(evt) { timeSlotClickHandler(cell, evt) });
		});

		this.renderPlanner();
		this.scrollToCurrentTime();

		SfWeb.ResourcePlanner.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		if (this.autoResize)
			$removeHandler(window, 'resize', this.documentResizeHandler);

		$('.resourcePlannerEventContainer td, .event', this.get_element()).each(function(i, o)
		{
			$clearHandlers(o);
		});

		SfWeb.ResourcePlanner.callBaseMethod(this, 'dispose');
	},

	get_currentTime: function()
	{
		return this.currentTime;
	},

	set_currentTime: function(value)
	{
		this.currentTime = value;
	},

	get_autoResize: function()
	{
		return this.autoResize;
	},

	set_autoResize: function(value)
	{
		this.autoResize = value;
	},

	add_eventClick: function(handler)
	{
		this.get_events().addHandler('eventclick', handler);
	},

	remove_eventClick: function(handler)
	{
		this.get_events().removeHandler('eventclick', handler);
	},

	add_timeSlotClick: function(handler)
	{
		this.get_events().addHandler('timeslotclick', handler);
	},

	remove_timeSlotClick: function(handler)
	{
		this.get_events().removeHandler('timeslotclick', handler);
	},

	scrollToCurrentTime: function()
	{
		var plannerContainer = $('.resourcePlannerEventContainer', this.get_element());

		// need to add extra height for IE7 to make room for horz. scrollbar
		if (SfWeb.IsIE7())
		{
			plannerContainer.css({ 'padding-bottom': '16px', 'overflow-y': 'hidden' });
		}

		var rowOffset = $('td[bucket=' + this.currentTime + ']', plannerContainer).offset().left - plannerContainer.offset().left - (plannerContainer.width() / 2);
		plannerContainer[0].scrollLeft = rowOffset;
	},

	_documentResize: function()
	{
		this.renderPlanner();
	},

	_eventClick: function(source, evt)
	{
		evt.stopPropagation();
		evt.cancelBubble = true;

		if (source.getAttribute('eventEnabled') == 'true')
		{
			var h = this.get_events().getHandler('eventclick');
			if (h)
			{
				var args = new SfWeb.PlannerMouseEventArgs();
				args.id = source.getAttribute('id');
				h(this, args);
			}
		}
	},

	_timeSlotClick: function(source, evt)
	{
		var h = this.get_events().getHandler('timeslotclick');
		if (h)
		{
			var args = new SfWeb.PlannerClickEventArgs();
			args.set_resourceId(source.parentNode.getAttribute('resource'));
			args.set_timeSlot(parseInt(source.getAttribute('bucket')));
			h(this, args);
		}
	},

	renderPlanner: function()
	{
		var cell = $('.resourcePlannerEventContainer td', this.get_element());

		// IE7 needs to be one px taller for some reason
		if (SfWeb.IsIE7())
		{
			cell.css({ 'height': '31px' });
		}

		var minutesPerPixel = 60 / cell.width(); // each cell represents one hour
		var clickHandler = this.eventClickHandler;

		$('.event', this.get_element()).each(function(i, eventDiv)
		{
			var duration = parseInt(eventDiv.getAttribute('dur'));
			var bucket = parseInt(eventDiv.parentNode.parentNode.getAttribute('bucket'));
			var startTime = parseInt(eventDiv.getAttribute('start'));
			var startDiff = startTime - bucket;
			var segments = Math.ceil(duration / 60);

			// need one more segment if the end overhangs into another segment
			if ((startTime + duration) > (bucket + (60 * segments)))
				segments++;

			$addHandler(eventDiv, 'click', function(evt) { clickHandler(eventDiv, evt) });

			eventDiv.style.width = (duration / minutesPerPixel) + segments - 1 + 'px';
			eventDiv.style.height = cell.height() + 'px';
			eventDiv.style.left = Math.ceil(startDiff / minutesPerPixel) + 'px';
		});
	}
}
SfWeb.ResourcePlanner.registerClass('SfWeb.ResourcePlanner', Sys.UI.Control);
/* End ResourcePlanner.js */
/* Start InlineEditTextBox */

SfWeb.InlineEditTextBox = function(element)
{
    SfWeb.InlineEditTextBox.initializeBase(this, [element]);
    this.labelWrapper = null;
    this.label = null;
    this.labelMaxLength = null;
    this.editImage = null;
    this.textbox = null;
    this.saveImage = null;
    this.cancelImage = null;
    this.originalText = null;
    this.UseCommitButtons = null;
    this.ReadOnly = null;
    this.mode = "display";
}

SfWeb.InlineEditTextBox.prototype =
{
    initialize: function()
    {
        if (!this.ReadOnly)
        {
            $addHandler(this.labelWrapper, 'click', Function.createDelegate(this, this.labelClick));
            $addHandler(this.labelWrapper, 'mouseover', Function.createDelegate(this, this.labelMouseOver));
            $addHandler(this.labelWrapper, 'mouseout', Function.createDelegate(this, this.labelMouseOut));

            if (this.UseCommitButtons)
            {
                $addHandler(this.saveImage, 'click', Function.createDelegate(this, this.saveImageClick));
                $addHandler(this.cancelImage, 'click', Function.createDelegate(this, this.cancelImageClick));
            }

            if (!this.UseCommitButtons)
            {
                $addHandler(this.textbox, 'blur', Function.createDelegate(this, this.textSaved));
            }

            $addHandler(this.textbox, 'keypress', Function.createDelegate(this, this.textboxKeyPress));
        }

        SfWeb.InlineEditTextBox.callBaseMethod(this, 'initialize');


    },

    dispose: function()
    {
        if (!this.ReadOnly)
        {
            $clearHandlers(this.labelWrapper);

            if (this.UseCommitButtons)
            {
                $clearHandlers(this.saveImage);
                $clearHandlers(this.cancelImage);
            }

            $clearHandlers(this.textbox);
        }

        SfWeb.InlineEditTextBox.callBaseMethod(this, 'dispose');
    },

    get_labelWrapper: function()
    {
        return this.labelWrapper;
    },

    set_labelWrapper: function(value)
    {
        this.labelWrapper = value;
    },

    get_label: function()
    {
        return this.label;
    },

    set_label: function(value)
    {
        this.label = value;
    },

    get_labelMaxLength: function()
    {
        return this.labelMaxLength;
    },

    set_labelMaxLength: function(value)
    {
        this.labelMaxLength = value;
    },

    get_editImage: function()
    {
        return this.editImage;
    },

    set_editImage: function(value)
    {
        this.editImage = value;
    },

    get_textbox: function()
    {
        return this.textbox;
    },

    set_textbox: function(value)
    {
        this.textbox = value;
    },

    get_saveImage: function()
    {
        return this.saveImage;
    },

    set_saveImage: function(value)
    {
        this.saveImage = value;
    },

    get_cancelImage: function()
    {
        return this.cancelImage;
    },

    set_cancelImage: function(value)
    {
        this.cancelImage = value;
    },

    get_originalText: function()
    {
        return this.originalText;
    },

    set_originalText: function(value)
    {
        this.originalText = value;
    },

    get_UseCommitButtons: function()
    {
        return this.UseCommitButtons;
    },

    set_UseCommitButtons: function(value)
    {
        this.UseCommitButtons = value;
    },

    get_ReadOnly: function()
    {
        return this.ReadOnly;
    },

    set_ReadOnly: function(value)
    {
        this.ReadOnly = value;
    },

    Add_TextSaved: function(handler)
    {
        this.get_events().addHandler('textsaved', handler);
    },

    Remove_TextSaved: function(handler)
    {
        this.get_events().removeHandler('textsaved', handler);
    },

    get_text: function()
    {
        return this.textbox.value;
    },

    labelClick: function(event)
    {
        this.Toggle();
        event.stopPropagation();
    },

    labelMouseOver: function()
    {
        this.labelWrapper.className = "labelMouseOver";
        this.editImage.style.display = "";

        var labelWrapperBounds = Sys.UI.DomElement.getBounds(this.labelWrapper);
        var editImageLeft = labelWrapperBounds.width - this.editImage.width;
        Sys.UI.DomElement.setLocation(this.editImage, editImageLeft, 0);
    },

    labelMouseOut: function()
    {
        this.labelWrapper.className = "labelMouseOut";
        this.editImage.style.display = "none";
    },

    saveImageClick: function()
    {
        this.textSaved();
    },

    cancelImageClick: function()
    {
        this.cancelText();
        this.Toggle();
    },

    textSaved: function()
    {
        this.saveText();
        this.Toggle();

        var h = this.get_events().getHandler('textsaved');
        if (h) h(this, Sys.EventArgs.Empty);
    },

    saveText: function()
    {
        this.textbox.value = this.textbox.value.trim();

        if (this.textbox.value.length > this.labelMaxLength)
        {
            var tempText = !this.textbox.value ? 'No Text' : this.textbox.value.replace(/\n/g, '<br>');
            this.label.innerHTML = tempText.substring(0, this.labelMaxLength) + "...";
        }
        else
        {
            this.label.innerHTML = !this.textbox.value ? 'No Text' : this.textbox.value.replace(/\n/g, '<br>');
        }
    },

    cancelText: function()
    {
        this.textbox.value = this.originalText;
    },

    textboxKeyPress: function(event)
    {

        var charCode = (event.which) ? event.which : window.event.keyCode;

        if (charCode == Sys.UI.Key.enter)
        {
            this.textSaved();
        }

    },

    Toggle: function()
    {
        if (this.labelWrapper.style.display == '')
        {
            this.originalText = this.textbox.value;
            this.labelWrapper.style.display = 'none';
            this.editImage.style.display = "none";

            if (this.UseCommitButtons)
            {
                this.saveImage.style.display = '';
                this.cancelImage.style.display = '';
            }

            this.textbox.style.display = '';
            this.textbox.focus();
            this.textbox.select();

            this.mode = "edit";
        }
        else
        {
            if (this.UseCommitButtons)
            {
                this.saveImage.style.display = 'none';
                this.cancelImage.style.display = 'none';
            }

            this.textbox.style.display = 'none';
            this.labelWrapper.style.fontStyle = !this.textbox.value ? 'italic' : 'normal';
            this.labelWrapper.style.display = '';

            this.mode = "display";
        }
    }
}
SfWeb.InlineEditTextBox.registerClass('SfWeb.InlineEditTextBox', Sys.UI.Control);

/* End InlineEditTextBox */

/* Begin JobProgressBar.js */
SfWeb.JobProgressBar = function(element)
{
	SfWeb.JobProgressBar.initializeBase(this, [element]);
	this.displayControl = null;
	this.showOnLoad = false;
}

SfWeb.JobProgressBar.prototype =
{
	initialize: function()
	{
		if (this.showOnLoad)
			this.Show();

		if (!this.displayControl)
			this.get_element().style.display = '';

		SfWeb.JobProgressBar.callBaseMethod(this, 'initialize');
	},

	dispose: function()
	{
		SfWeb.JobProgressBar.callBaseMethod(this, 'dispose');
	},

	get_displayControl: function()
	{
		return this.displayControl;
	},

	set_displayControl: function(value)
	{
		this.displayControl = value;
	},

	get_showOnLoad: function()
	{
		return this.showOnLoad;
	},

	set_showOnLoad: function(value)
	{
		this.showOnLoad = value;
	},

	Hide: function()
	{
		if (this.displayControl)
		{
			this.get_element().style.display = 'none';
			this.displayControl.style.display = '';
		}
	},

	Show: function()
	{
		if (this.displayControl)
		{
			this.get_element().style.display = '';
			this.displayControl.style.display = 'none';
		}
	}
}
SfWeb.JobProgressBar.registerClass('SfWeb.JobProgressBar', Sys.UI.Control);
/* End JobProgressBar.js */