/* version 1.1.4.0 */

/* common iterator functions */

	function first(col) {
		if (col) {
			if (col.length) {
				return col.length > 0 && col[0];
			}
			else {
				var child = col.firstChild;
				while(child) {
					if (child.nodeType == 1) {
						return child;
					}
					child = child.nextSibling;
				}
			}
		}
		return null;
	}
	
	function map(col, func) {
		var result = [];
		if (col) {
			if (!func) {
				func = function(item) {
					return item;
				}
			}
			var length = col.length;
			if (length) {
				for(var i = 0; i < length; i++) {
					result.push(func(col[i], i, col));
				}
			}
			else {
				var child = col.firstChild;
				var i = 0;
				while(child) {
					if (child.nodeType == 1) {
						result.push(func(child, i, col));
					}
					child = child.nextSibling;
					i++;
				}
			}
		}
		return result;
	}
	
	function filter(col, func) {
		var result = [];
		if (col) {
			var length = col.length;
			if (length) {
				if (!func) {
					func = function() {
						return true;
					}
				}
				for(var i = 0; i < length; i++) {
					var item = col[i];
					if (func(item, i, col)) {
						result.push(item);
					}
				}
			}
		}
		return result;
	}
	
	function foreach(col, func) {
		if (col) {
			var length = col.length;
			if (length) {
				for(var i = 0; i < length; i++) {
					if (func(col[i], i, col)) {
						return true;
					}
				}
			}
			else {
				var child = col.firstChild;
				var i = 0;
				while(child) {
					if (child.nodeType == 1 && func(child, i, col)) {
						return true;
					}
					child = child.nextSibling;
					i++;
				}
			}
		}
	}
	
	function rationalize(col) {
		if (col) {
			if (col.nodeType)
			{
				return col;
			}
			var hasValues;
			if (col.length > 0) {
				foreach(col, function(item) {
					if (item) {
						hasValues = true;
						return true;
					}
				});
				if (hasValues) {
					return col;
				}
			}
		}
	}


window.tilt = new function()
{
	// make sure this constant matches this file's name
	var TILT_FILENAME = "tilt.js";
	var safari = document.childNodes && !document.all && !navigator.taintEnabled;
	var head = document.getElementsByTagName ? document.getElementsByTagName("head")[0] : null;
	var onContentReceivedHandlers = [];
	this.__fire = true;
	
	var scriptBase = function() {
		var scripts = head.getElementsByTagName("script");
		for(var i = 0; i < scripts.length; i++)
		{
			var src = scripts[i].src;
			if (src && src.toLowerCase().indexOf(TILT_FILENAME) >= 0)
			{
				return src.replace(/[Tt]ilt\.js/, "");
			}
		}
		return "";
	}();

	var finalize = function()
	{
		if (document.createStyleSheet && document.createAttribute)
		{
			var hideStyle = document.createStyleSheet();
			if (hideStyle)
			{
/*				var htcUrl = function()
				{
					var scripts = head.getElementsByTagName("script");
					for(var i = 0; i < scripts.length; i++)
					{
						var src = scripts[i].src;
						if (src && src.indexOf(TILT_FILENAME) >= 0)
						{
							return src.replace(/\.js/, ".htc");
						}
					}
				}();
				if (htcUrl)
				{ */
					hideStyle.addRule("html", "display:none;");
					return function() {
						hideStyle.removeRule("html");
					}
/*				} */
			}
		}
		else if (head)
		{
			var link = document.createElement("link");		
			link.rel = "stylesheet";
			link.href = "data:text/css,body%7Bdisplay%3Anone%7D";
			head.appendChild(link);
			return function()
			{
				link.href = "data:text/css,body%7Bdisplay%3Ablock%7D";
//				head.removeChild(link);
			}
		}
		return function(){};
	}();

	this.attachEvent = function()
	{
		if (window.attachEvent)
		{
			return function(element, name, handler)
			{
				if (!attachOnContentReceived(element, name, handler))
				{
					if (name == "DOMContentLoaded" && element === document)
					{
						return;
					}
					element.attachEvent("on" + name, function()
					{
						if (!handler(element, event))
						{
							event.returnValue = false;
							event.cancelBubble = true;
						}
					});
				}
			}
		}
		if (window.addEventListener)
		{
			return function(element, name, handler)
			{
				if (!attachOnContentReceived(element, name, handler))
				{
					element.addEventListener(name, function(e)
					{
						if (!handler(element, e))
						{
							e.stopPropagation();
							e.preventDefault();
						}
					}, false);
				}
/*				else if (onContentReceivedHandlers.length == 1)
				{
					document.addEventListener("DOMContentLoaded", fireOnContentReceivedHandlers, false);
				} */
			}
		}
		if (document.getElementById) // IE Mac
		{
			return function(element, name, handler)
			{
				if (!attachOnContentReceived(element, name, handler))
				{
					var handlerName = "on" + name;
					var oldHandler = element[handlerName];
					if (oldHandler)
					{
						element[handlerName] = function()
						{
							return oldHandler(element) && handler(element);
						}
					}
					else
					{
						element[handlerName] = function()
						{
							return handler(element);
						}
					}
				}
			}
		}
		return function(){};
		
		function attachOnContentReceived(element, name, handler)
		{
			if (name == "contentreceived" && element === document)
			{
				onContentReceivedHandlers[onContentReceivedHandlers.length] = handler;
				return true;
			}
		}
	}();
	
	this.attachEvent(window, "load", fireFire);
		
	function fireFire()
	{
		if (tilt.__fire) {
			tilt.__fire = false;
			fireOnContentReceivedHandlers();
		}
	}

	wait(30000, 100);

	function wait(timeout, delta) {
		if (window.webroot != "yes") {
			var interval = window.setInterval(function() {
				if (document.getElementById("login") || timeout < 0) {
					window.clearInterval(interval);
					window.setTimeout(fireFire, 0);
				}
				timeout -= delta;
				
			}, delta);
		}
	}
	
	function fireOnContentReceivedHandlers()
	{
		for(var i = 0; i < onContentReceivedHandlers.length; i++)
		{
			try
			{
				onContentReceivedHandlers[i]();
			}
			catch(e)
			{
			}
		}
		finalize();
	}
	
	this.detachEvent = function()
	{
		if (window.detachEvent)
		{
			return function(element, name, handler)
			{
				if (!detachOnContentReceived(element, name, handler))
				{
					element.detachEvent("on" + name, handler);
				}
			}
		}
		return function(){};
		
		function detachOnContentReceived(element, name, handler)
		{
			if (name == "contentreceived" && element === document)
			{
				for(var i = 0; i < this.onContentReceivedHandlers.length; i++)
				{
					if (this.onContentReceivedHandlers[i] === handler)
					{
						this.onContentReceivedHandlers.splice(i, 1);
					}
				}
			}
		}
	}();
	
	this.createTable = function(content, className)
	{
		var table = document.createElement("TABLE");
		table.className = "Layout " + (className != null ? className : "");
		table.cellSpacing = 0;
		var tbody = table.appendChild(document.createElement("TBODY"));

		var colCount = 0;
		var needsColspans;
		for(contentMember in content)
		{
			var rowInfo = content[contentMember];
			if (rowInfo)
			{
				var row = tbody.appendChild(document.createElement("TR"));
				row.className = contentMember;
				var runningColCount = 0;
				if (isContent(rowInfo))
				{
					var cell = row.appendChild(document.createElement("TD"));
					appendContent(cell, rowInfo);
					runningColCount++;
				}
				else
				{
					for(rowInfoMember in rowInfo)
					{
						var cellInfo = rowInfo[rowInfoMember];
						if (!isEmpty(cellInfo))
						{
							var cell = row.appendChild(document.createElement("TD"));
							cell.className = rowInfoMember;
							appendContent(cell, cellInfo);
							runningColCount++;
						}
					}
				}
				if (runningColCount != colCount)
				{
					if (colCount > 0)
					{
						needsColspans = true;
					}
					if (runningColCount > colCount)
					{
						colCount = runningColCount;
					}
				}
			}
		}
		if (needsColspans)
		{
			var rows = tbody.rows;
			var emptyRows = [];
			for(var rowIndex = 0; rowIndex < rows.length; rowIndex++)
			{
				var row = rows[rowIndex];
				var cells = row.cells.length == 0 && row.children ? row.children : row.cells;
				if (cells.length == 0)
				{
					emptyRows[emptyRows.length] = row;
				}
				else
				{
					var colSpan = colCount - cells.length + 1;
					if (colSpan > 1)
					{
						cells[cells.length - 1].colSpan = colSpan;
					}
				}
			}
			for(var emptyRowIndex = 0; emptyRowIndex < emptyRows.length; emptyRowIndex++)
			{
				var row = emptyRows[emptyRowIndex];
				row.parentNode.removeChild(row);
			}
		}
		return table;
	}
	
	this.createDiv = function(content, className)
	{
		if (content) {
			var div = document.createElement("div");
			div.className = className;
			appendContent(div, content);
			return div;
		}
	}

	function isEmpty(obj)
	{
		if (obj)
		{
			if (isInstanceOf(obj, Array))
			{
				for(var i = 0; i < obj.length; i++)
				{
					if (obj[i])
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}
		return true;
	}
		
	function isInstanceOf(obj, type)
	{
		return obj.constructor === type;
	}
	
	function isContent(data)
	{
		return isInstanceOf(data,Array) || typeof(data) == "string" || data.nodeName;
	}
	
	function appendContent(node, content)
	{
		if (content)
		{
			var contentType = typeof(content);
			if (contentType == "string")
			{
				node.appendChild(document.createTextNode(content));	
			}
			else if (isInstanceOf(content, Array))
			{
				for(var i = 0; i < content.length; i++)
				{
					appendContent(node, content[i]);
				}
			}
			else if (content.nodeName)
			{
				node.appendChild(content);
			}
		}
	}

	this.createClassNameBag = function(node)
	{
		return new function(node)
		{
			var child = node.firstChild;
			while(child)
			{
				if (child.nodeType == 1 && child.className && child.className.length > 0)
				{
					var classNames = child.className.split(" ");
					for(var i = 0; i < classNames.length; i++)
					{
						var className = classNames[i];
						if (this[className])
						{
							var singleValue = this[className];
							var array = [singleValue,child];
							this[className] = array;
						}
						else
						{
							this[className] = child;				
						}
					}
				}
				child = child.nextSibling;
			}
		}(node);
	};
	
	this.addScript =  safari ? function(script) {
		if (XMLHttpRequest)
		{
			var xhr = new XMLHttpRequest();
			xhr.onreadystatechange = function() {
				if (xhr.readyState == 4) {
					eval(xhr.responseText);
				}
			};
			xhr.open("GET", scriptBase + script, true);
			xhr.send(null);
		}
	}: function(script) {
		if (script && head) {
			var e = head.appendChild(document.createElement("script"));
			e.type = "text/javascript";
			e.src = scriptBase + script;
		}
	}
}