var Utils = {
	GetOffsetX : function(Object)
	{
		var intX = 0;
		if (Object)
		{
		if (Object.offsetParent)
			{
				while (Object.offsetParent)
				{
					intX += Object.offsetLeft;
					Object = Object.offsetParent;
				}
			} else if (Object.x) {
				intX = Object.x;
			}
		}
		return intX;
	},
	GetOffsetY : function(Object)
	{
		var intY = 0;
		if (Object)
		{
			if (Object.offsetParent)
			{
				while (Object.offsetParent)
				{
					intY += Object.offsetTop;
					Object = Object.offsetParent;
				}
			} else if (Object.y) {
				intY = Object.y;
			}
		}
		return intY;
	},
	MakeMailto : function(strUser, strHost)
	{
		window.location = "mailto:" + strUser + "@" + strHost;
	},
	MoveTo : function(Element, intEndX, intEndY)
	{
		var intSpeed = arguments.length > 3 ? parseInt(arguments[3]) : 50;
		var intSteps = arguments.length > 4 ? parseInt(arguments[4]) : 3;
		if (Element)
		{
			var intTimes = 0;
			var intStartX = (!isNaN(parseInt(Element.style.left))) ? parseInt(Element.style.left) : 0;
			var intStartY = (!isNaN(parseInt(Element.style.top))) ? parseInt(Element.style.top) : 0;
			var intStepX = !isNaN(intEndX) ? intEndX - intStartX : 0;
			var intStepY = !isNaN(intEndY) ? intEndY - intStartY : 0;
			if (Element.MoveToInterval) clearInterval(Element.MoveToInterval);
			Element.MoveToInterval = setInterval(function()
			{
				if (intTimes <= intSteps)
				{
					if (!isNaN(intEndX)) Element.style.left = (intStartX + ((intStepX / intSteps) * intTimes)) + "px";
					if (!isNaN(intEndY)) Element.style.top = (intStartY + ((intStepY / intSteps) * intTimes)) + "px";
					intTimes++;
				} else {
					clearInterval(Element.MoveToInterval);
				}
			}, intSpeed);
		}
	},
	DeHTML : function(strInput)
	{
		var strInput = new String(strInput);
		strInput = strInput.replace(/<br>/g, "").replace(/<BR>/g, "").replace(/</g, "[").replace(/>/g, "]").replace(/\&amp\;/g, "&").replace(/^\s*|\s*$/g,"");
		strInput = strInput.replace(/\[a href=\"mailto\:(.*)\"\](.*)\[\/a\]/g, "[email=$1]$2[/email]");
		strInput = strInput.replace(/\[a href=\"(.*)\"\](.*)\[\/a\]/g, "[link=$1]$2[/link]");
		return strInput;
	},
	GetXMLNodeFirstChildByTag : function(XMLNode, strTag)
	{
		var strReturnVal = "";
		if (XMLNode)
		{
			var arrElms = XMLNode.getElementsByTagName(strTag);
			if (arrElms.length > 0 && arrElms[0].firstChild && arrElms[0].firstChild.nodeValue)
			{
				strReturnVal = arrElms[0].firstChild.nodeValue;
			}
		}
		return strReturnVal;
	},
	GetButtonObject : function(strIconSrc, strLabel, Reference, strFunction)
	{
		var Table = document.createElement("table");
		Table.setAttribute("cellspacing", 0);
		Table.setAttribute("cellpadding", 0);
		Table.setAttribute("border", 0);
		Table.setAttribute("class", "jehu_button");

		var Row = document.createElement("tr");
		Table.appendChild(Row);
		Table.Row = Row;

		Table.arrLabels = Array();

		Table.AddLabel = function(strIconSrc, strLabel, Reference, strFunction)
		{
			var LeftCell = document.createElement("td");
			var LeftImg = document.createElement("img");
			if (this.arrLabels.length == 0)
			{
				LeftImg.setAttribute("src", "img/Jehu/Button.Left.png");
				LeftImg.setAttribute("width", 7);
				LeftImg.setAttribute("height", 25);
			} else {
				LeftCell.setAttribute("valign", "middle");
				LeftCell.setAttribute("class", "jehu_button_middle");
				LeftImg.setAttribute("src", "img/Jehu/Button.Line.png");
			}
			LeftCell.appendChild(LeftImg);
			this.Row.appendChild(LeftCell);

			if (strIconSrc != "")
			{
				var MiddleCell1 = document.createElement("td");
				MiddleCell1.setAttribute("valign", "middle");
				MiddleCell1.setAttribute("class", "jehu_button_middle");
				var Icon = document.createElement("img");
				Icon.setAttribute("src", strIconSrc);
				MiddleCell1.appendChild(Icon);
				this.Row.appendChild(MiddleCell1);
			}

			var MiddleCell2 = document.createElement("td");
			MiddleCell2.setAttribute("valign", "middle");
			MiddleCell2.setAttribute("class", "jehu_button_middle");
			var Label = document.createElement("a");
			Label.setAttribute("href", "javascript://");
			Label.setAttribute("onclick", "this._JehuReference_." + strFunction);
			Label.appendChild(document.createTextNode(strLabel));
			Label._JehuReference_ = Reference;
			var NoBr = document.createElement("nobr");
			NoBr.appendChild(Label);
			MiddleCell2.appendChild(NoBr);
			this.Row.appendChild(MiddleCell2);

			if (this.RightCell) this.Row.removeChild(this.RightCell);

			var RightCell = document.createElement("td");
			var RightImg = document.createElement("img");
			RightImg.setAttribute("src", "img/Jehu/Button.Right.png");
			RightImg.setAttribute("width", 7);
			RightImg.setAttribute("height", 25);
			RightCell.appendChild(RightImg);
			this.Row.appendChild(RightCell);
			this.RightCell = RightCell;

			this.arrLabels[this.arrLabels.length] = Label;
		}

		Table.SetLabel = function(strLabel)
		{
			var intLabelId = arguments.length > 1 ? arguments[1] : 0;
			var Reference = arguments.length > 2 ? arguments[2] : null;
			var strFunction = arguments.length > 3 ? arguments[3] : "";
			if (this.arrLabels[intLabelId]) this.arrLabels[intLabelId].innerHTML = strLabel;
			if (Reference) this.arrLabels[intLabelId]._JehuReference_ = Reference;
			if (strFunction.length > 0) this.arrLabels[intLabelId].setAttribute("onclick", "this._JehuReference_." + strFunction);
		}
		Table.SetClickEvent = function(EventFunction)
		{
			var intLabelId = arguments.length > 1 ? arguments[1] : 0;
			if (this.arrLabels[intLabelId]) this.arrLabels[intLabelId].onclick = EventFunction;
		}
		Table.AddReference = function(strName, Reference)
		{
			var intLabelId = arguments.length > 2 ? arguments[2] : 0;
			if (this.arrLabels[intLabelId]) eval("this.arrLabels[intLabelId]." + strName + " = Reference;");
		}

		Table.AddLabel(strIconSrc, strLabel, Reference, strFunction);

		return Table;
	},
	GetFlashElement : function(strSrc, strWidth, strHeight)
	{
		var FlashObj = document.createElement("object");
		FlashObj.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
		FlashObj.setAttribute("codebase", "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0");
		FlashObj.setAttribute("width", strWidth);
		FlashObj.setAttribute("height", strHeight);

		var Param = document.createElement("param");
		Param.setAttribute("name", "allowScriptAccess");
		Param.setAttribute("value", "sameDomain");
		FlashObj.appendChild(Param);

		var Param = document.createElement("param");
		Param.setAttribute("name", "src");
		Param.setAttribute("value", strSrc);
		FlashObj.appendChild(Param);

		var Param = document.createElement("param");
		Param.setAttribute("name", "loop");
		Param.setAttribute("value", "false");
		FlashObj.appendChild(Param);

		var Param = document.createElement("param");
		Param.setAttribute("name", "menu");
		Param.setAttribute("value", "false");
		FlashObj.appendChild(Param);

		var Param = document.createElement("param");
		Param.setAttribute("name", "quality");
		Param.setAttribute("value", "high");
		FlashObj.appendChild(Param);

		var Param = document.createElement("param");
		Param.setAttribute("name", "wmode");
		Param.setAttribute("value", "transparent");
		FlashObj.appendChild(Param);
		
		var Param = document.createElement("param");
		Param.setAttribute("name", "bgcolor");
		Param.setAttribute("value", "#ffffff");
		FlashObj.appendChild(Param);

		var FlashEmb = document.createElement("embed");
		FlashEmb.setAttribute("loop", "false");
		FlashEmb.setAttribute("menu", "false");
		FlashEmb.setAttribute("quality", "high");
		FlashEmb.setAttribute("wmode", "transparent");
		FlashEmb.setAttribute("bgcolor", "#ffffff");
		FlashEmb.setAttribute("width", strWidth);
		FlashEmb.setAttribute("height", strHeight);
		FlashEmb.setAttribute("allowScriptAccess", "sameDomain");
		FlashEmb.setAttribute("type", "application/x-shockwave-flash");
		FlashEmb.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
		FlashEmb.setAttribute("src", strSrc);
		FlashObj.appendChild(FlashEmb);

		return FlashObj;
	}
}