function doPostBack(sEventTarget, sEventArgument)
//	Provided to be called from VbScript functions
{
	__doPostBack(sEventTarget, sEventArgument);
}
///////////////////////////////////////////////////////////
// startup_stiPage()
//	Performed on every page when it opens
///////////////////////////////////////////////////////////
function startup_stiPage()
{
	// break out of frames (does this perform a post-back?
	//if (top != self) top.location.replace(self.location);
	// add extra functionality to string objects
	String.prototype.trimLeft = p_StringTrimLeft;
	String.prototype.trimRight = p_StringTrimRight;
	String.prototype.trim = p_StringTrim;
	String.prototype.replaceAt = p_StringReplaceAt;
	if (typeof HTMLElement != "undefined" && !HTMLElement.prototype.insertAdjacentElement) {
		HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
			switch (where) {
			case 'beforeBegin':
				this.parentNode.insertBefore(parsedNode, this)
				break;
			case 'afterBegin':
				this.insertBefore(parsedNode, this.firstChild);
				break;
			case 'beforeEnd':
				this.appendChild(parsedNode);
				break;
			case 'afterEnd':
				if (this.nextSibling)
					this.parentNode.insertBefore(parsedNode, this.nextSibling);
				else
					this.parentNode.appendChild(parsedNode);
				break;
			}
		}
	}
}
///////////////////////////////////////////////////////////
// writeCookie(sName, oValue, nDays)
//		sName -> name of cookie to be written
//		oValue -> value of cookie to be written
//		nDays -> number of days until cookie expires
//	Creates a cookie (if necessary), and assigns its value
///////////////////////////////////////////////////////////
function writeCookie(sName, oValue, nDays)
{
	var sExpires = "";
	if (nDays)
	{
		var dDate = new Date();
		dDate.setTime(dDate.getTime() + (nDays * 24 * 60 * 60 * 1000));
		sExpires = "; expires=" + dDate.toGMTString();
	}
	document.cookie = sName + "=" + oValue + sExpires + "; path=/";
}
///////////////////////////////////////////////////////////
// readCookie(sName)
//		sName -> name of cookie to be read
//		Return Value: value of cookie, or null if cookie not found
//	Returns the value of a cookie
///////////////////////////////////////////////////////////
function readCookie(sName)
{
	var sRet = null;
	var nameEQ = sName + "=";
	var ca = document.cookie.split(";");
	for (var i=0; i < ca.length; i++)
	{
		var c = ca[i];
		while (c.charAt(0) == " ")
			c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0)
		{
			sRet = c.substring(nameEQ.length, c.length);
			break;
		}
	}
	return sRet;
}
///////////////////////////////////////////////////////////
// deleteCookie(sName)
//		sName -> name of cookie to be deleted
//	Deletes a cookie
///////////////////////////////////////////////////////////
function deleteCookie(sName)
{
	writeCookie(sName, "", -1);
}
///////////////////////////////////////////////////////////
// registerEvent(oElement, sEvent, fpFunc)
//		oElement -> element that event will be added to
//		sEvent -> string name of event to add, ex. "onclick"
//		fpFunc -> function to register with event
//	Registers a function with the specified Event on the specified Element
///////////////////////////////////////////////////////////
function registerEvent(oElement, sEvent, fpFunc)
{
	if (!oElement) return;
	var fpOld = (oElement[sEvent]) ? oElement[sEvent] : function () {};
	oElement[sEvent] = function (e) {if (fpOld(e) == false) return false; else return fpFunc(e)};
}
///////////////////////////////////////////////////////////
// executeEvent(oElement, sEvent, oEvent)
//		oElement -> element that event will be executed on
//		sEvent -> string name of event to execute, ex. "onclick"
//		oEvent -> Optional, object containing event information
//	Executes a function with the specified Event on the specified Element
///////////////////////////////////////////////////////////
function executeEvent(oElement, sEvent, oEvent)
{
	oElement[sEvent](oEvent);
}
///////////////////////////////////////////////////////////
// p_StringTrimLeft()
//		'this' should contain the original string
//		Return Value: string
//	Removes leading spaces from a string
///////////////////////////////////////////////////////////
function p_StringTrimLeft()
{
	var rStr = new String(this);
	while (rStr.length != 0 && rStr.charAt(0) == " ")
		rStr = rStr.substring(1, rStr.length);
	return rStr;
}
///////////////////////////////////////////////////////////
// p_StringTrimRight()
//		'this' should contain the original string
//		Return Value: string
//	Removes trailing spaces from a string
///////////////////////////////////////////////////////////
function p_StringTrimRight()
{
	var rStr = new String(this);
	while (rStr.length != 0 && rStr.charAt(rStr.length - 1) == " ")
		rStr = rStr.substring(0, rStr.length - 1);
	return rStr;
}
///////////////////////////////////////////////////////////
// p_StringTrim()
//		'this' should contain the original string
//		Return Value: string
//	Removes leading & trailing spaces from a string
///////////////////////////////////////////////////////////
function p_StringTrim()
{
	var rStr = new String(this);
	rStr = rStr.trimLeft();
	rStr = rStr.trimRight();
	return rStr;
}
///////////////////////////////////////////////////////////
// p_StringReplaceAt()
//		'this' should contain the original string
//		Return Value: string
//	Replaces the character located at nOrd with cChar; if nOrd is greater than the length of the string, cChar is appended
///////////////////////////////////////////////////////////
function p_StringReplaceAt(nOrd, cChar)
{
	var rStr = new String(this);
	if (nOrd > rStr.length)
		rStr = rStr + cChar;
	else
		rStr = rStr.slice(0, nOrd) + cChar + rStr.slice(nOrd + 1);
	return rStr;
}
///////////////////////////////////////////////////////////
// absLeft(oElement)
//		oElement -> element
//		Return Value: Xpos of element
///////////////////////////////////////////////////////////
function absLeft(oElement)
{
	var nLeftPos = oElement.offsetLeft;
	var eParElement = oElement.offsetParent;
	while (eParElement != null)
	{
		nLeftPos += eParElement.offsetLeft;
		eParElement = eParElement.offsetParent;
	}
	return nLeftPos;
}
///////////////////////////////////////////////////////////
// absTop(oElement)
//		oElement -> element
//		Return Value: Ypos of element
///////////////////////////////////////////////////////////
function absTop(oElement)
{
	var nTopPos = oElement.offsetTop;
	var eParElement = oElement.offsetParent;
	while (eParElement != null)
	{
		nTopPos += eParElement.offsetTop;
		eParElement = eParElement.offsetParent;
	}
	return nTopPos;
}
///////////////////////////////////////////////////////////
// getContainingElement(oElement)
//		oElement -> element
//		sTagName -> string
//		Return Value: containing element of tagName value of sTagName
///////////////////////////////////////////////////////////
function getContainingElement(oElement, sTagName)
{
	var oRet;
	if (oElement.tagName && ((oElement.tagName.toUpperCase() == sTagName.toUpperCase()) || (oElement.tagName.toUpperCase() == "HTML")))
		oRet = oElement;
	else
		oRet = getContainingElement(oElement.parentNode, sTagName);
	return oRet;
}
