
function CloseMe() {
	window.opener = "whatever";
	window.close();
}

function SetTextForID(strID, strText) {
	var objID = document.getElementById(strID);
	objID.firstChild.nodeValue = strText;
}

function SetStyleForID(strID, strStyle) {
	var objID = document.getElementById(strID);
	objID.setAttribute('className', strStyle);
}

function SetButtonCaptionForID(strID, strCaption, bEnabled) {
	document.getElementById(strID).value = strCaption;
	document.getElementById(strID).setAttribute('disabled', !bEnabled);
}

function GetXMLTag(strXML, strTag) {
  // This should really be in string.js, instead of being in both jsServer and jsClient.
	var strResult = "";
	var nAt = strXML.indexOf("<" + strTag + ">");
	if (nAt > -1) {
		var strRest = strXML.substring(nAt + strTag.length + 2);
		var strTagName = strTag;
		if (strTagName.indexOf(" ") > -1)
		  strTagName = strTagName.substring(0, strTagName.indexOf(" "));
		nAt = strRest.indexOf("</" + strTagName + ">");
		if (nAt > -1)
			strResult = strRest.substring(0, nAt);
	}
	return strResult;
}

function RequestXML() {
	// Requires "strRequestURL" to be setup before using.
	// Before calling, add the current time onto the URL so it isn't cached:
	var dtNow = new Date();
	var strURL2 = strRequestURL;
	if (strURL2.indexOf("?") == -1) {
		strURL2 = strURL2 + "?";
	}
	else
	{
		strURL2 = strURL2 + "&";
	}
	http.open("GET", strURL2 + "time=" + dtNow.getTime(), true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}

function isNS()
{
  // Is this at least NS4?
  return (document.layers) ? 1 : 0;
}

function isIE()
{
  // Is this at least IE4?
  return (document.all) ? 1 : 0;
}

function getWindowWidth()
{
  // This has been superceded by getInnerWidth, remove it once all callers have been uploaded:
  if (isIE())
    return document.body.offsetWidth;
  else if (isNS())
    return window.innerWidth;
  else
    return(-1);
}

function getInnerWidth()
{
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getInnerHeight()
{
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function jsOpenWindow(strURL, nWidth, nHeight)
{
  link = window.open(strURL, "Link", "toolbar=no, menu=yes, height=" + nHeight + ", width=" + nWidth + ", resizable=yes, scrollbars=yes");
}

function findPos(obj) {
  // Returns an array with the absolute position of the given object.
  // arr[0] is .left, arr[1] is .top.
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

