	var CookieLife = 90*24*60*60*1000;
//	var CookieLife = 60*1000;

var ButtonFace, ColorPage, ColorHeader, ColorField, ColorGrid, ColorLight, ColorDark, ColorSelected
var ColorVBorder, ColorHBorder;
var isExportBoxCreated = false;
var isExportBoxShown = false;

function GetarrCookies(string,text) {
// splits string at text
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return;
    if (i == -1) {
        arrCookies[CookieIndex++] = string;
        return;
    }
    arrCookies[CookieIndex++] = string.substring(0,i);
    if (i+txtLength < strLength)
        GetarrCookies(string.substring(i+txtLength,strLength),text);
    return;
}

function QueryString(Item) {
	var arrQueryString = new Array();
	var strQueryString = document.location.search.substring(1,document.location.search.length);;
	arrQueryString = strQueryString.split('&')
	var arrPairs = new Array();
	var Pair = '';
	x = '';
    for (c=0; c<arrQueryString.length; c++)	{
		Pair = arrQueryString[c];
		arrPairs = Pair.split('=');
		if (arrPairs[0] == Item) return arrPairs[1];
	}
	return false;
}

function getCurrState(CookieName) {
  var label = CookieName + "=";
  var labelLen = label.length;
  var cLen = document.cookie.length;
  var i = 0;
  while (i < cLen) {
    var j = i + labelLen
    if (document.cookie.substring(i,j) == label) {
      var cEnd = document.cookie.indexOf(";",j)
      if (cEnd == -1) { cEnd = document.cookie.length }
      return unescape(document.cookie.substring(j,cEnd))
    }
    i++
  }
  return ""
}

function setCurrState(CookieName, Setting, Expiration) {	// 7*24*60*60*1000 = expire in 1 week
	var label = CookieName + "=";
	var expire = new Date();
	expire.setTime(expire.getTime() + Expiration);
	document.cookie = label + Setting + "; path=/; expires=" + expire.toGMTString();
}

function SetOptions(mode) {
	var NextCycle = false;
	var BigCookie = '';
	if (mode.value == 'Reset') setCurrState('set','Deleted',-1);
	if (mode.value == 'Save') {
		for (var c=0; c < document.frmOptions.elements.length; c++) {
			if (document.frmOptions.elements[c].name != 'cmd') {
				if (NextCycle) BigCookie = BigCookie + '&'
				if (document.frmOptions.elements[c].type == 'select-one') {		// For <SELECT> object use different method of reading properties
					BigCookie = BigCookie + document.frmOptions.elements[c].name + '=' + escape(document.frmOptions.elements[c][document.frmOptions.elements[c].selectedIndex].value);
				} else {
					BigCookie = BigCookie + document.frmOptions.elements[c].name + '=' + escape(document.frmOptions.elements[c].value);
				}
				NextCycle = true;
			}
		}
		setCurrState('set', BigCookie, CookieLife);
	}
	document.location.reload(true);
}

function EnableOptions() {
	var NextCycle = false;
	var Pair = '';
	var BigCookie = getCurrState('set');
	var arrCookies = new Array();
	var arrPairs = new Array();
	arrCookies = BigCookie.split('&');								// Split array of cookies
    for (var c=0; c<arrCookies.length; c++)	{
		Pair = arrCookies[c];
		arrPairs = Pair.split('=');
		if (arrPairs[0] == 'options') {								// Find apropriate value in the cookie
			arrPairs[1] = 'True';									// Replace apropriate value to the new value
			arrCookies[c] = arrPairs[0] + '=' + arrPairs[1];
		}
	}
	BigCookie = '';
	for (c=0; c<arrCookies.length; c++)	{
		if (NextCycle) BigCookie = BigCookie + '&';
		BigCookie = BigCookie + arrCookies[c]						// Build a string of new values
		NextCycle = true;
	}
	setCurrState('set', BigCookie, CookieLife);						// Store them in the cookies.
	document.location.reload(true);
}

function ChangeValue(obj) {
	obj.value = obj.checked;
	obj.className="changed";
//	ChangeColor(obj);
}

function ChangeColor(obj) {
	obj.className="changed";
}

function ShowHelp(HelpID) {
	WinHeight = 400;
	WinWidth = 550;
//	if (parseInt(navigator.appVersion) >= 4) {
//		if (screen.width < 800) {
//			WinHeight = 400;
//			WinWidth = 550;
//		} else {
//			WinHeight = 600;
//			WinWidth = 800;
//		}
//	}

	WinHelp = window.open('/help.asp?popup=1&id=' + HelpID, 'HelpWin', 'location=no,scrollbars=yes,alwaysRaised=no,resizable=yes,height=' + WinHeight + ',width=' + WinWidth);
	WinHelp.focus();
}

function ShowInventoryHistoryDetail(id) {
	WinHeight = 400;
	WinWidth = 550;
	WinHelp = window.open('/InventoryHistory.Detail.asp?id=' + id, 'HelpWin', 'location=no,scrollbars=yes,alwaysRaised=no,resizable=yes,height=' + WinHeight + ',width=' + WinWidth);
	WinHelp.focus();
}

function PrintPreview(id) {
	var WinHeight = 400;
	var WinWidth = 620;
	WinPreview = window.open('/Projects.Print.asp?id=' + id, 'PreviewWin', 'location=no,toolbar=yes,menubar=yes,scrollbars=yes,alwaysRaised=no,resizable=yes,height=' + WinHeight + ',width=' + WinWidth);
	WinPreview.focus();
}


function ShowStatus(str) {
	window.status = str;
	return true;
}

function ClearStatus() {
	window.status = "";
	return true;
}

function AutoStart(ScriptName) {
	if (ScriptName == '/default.asp') {
		document.frmLogin.LoginName.focus();
	}
}

function InvertCheckBox(FormName) {
// Usage: add this event to the submit button: onClick="InvertCheckBox(frmName);"
	for (var c=0; c < FormName.elements.length; c++) {
		if (FormName.elements[c].type == 'checkbox' && (! FormName.elements[c].checked)) {
			FormName.elements[c].checked = 1;
			FormName.elements[c].value = 'False';
		}
	}
}

function convdec(strng) {
	if (strng == 0) {
		return "0.00";
	} else if (strng < 1) {
		var str = "" + Math.round(strng * 100);
		return('0' + str.substring(0, str.length-2) + "." + str.substring(str.length-2, str.length));
	} else {
		var str = "" + Math.round(strng * 100);
		return(str.substring(0, str.length-2) + "." + str.substring(str.length-2, str.length));
	}
}

function ShowHideExportBox(WhiteStyle) {
	if (! isExportBoxCreated) {
		CreateExportBox(WhiteStyle);
		isExportBoxCreated = true;
	}

//	var box
//		dragObj.elNode = document.getElementById(id);

	var objBox = document.getElementById("ExportBox")

	if (isExportBoxShown) {
		isExportBoxShown = false;
	//	objBox.style.visibility = "hidden";
//		objBox.style.display = "none";
	} else {
		isExportBoxShown = true;
	//	objBox.style.visibility = "visible";
//		objBox.style.display = "";
	}

}

function CreateExportBox(WhiteStyle) {
	var NewElement;

	NewElement = document.createElement("form");
	NewElement.setAttribute("id", "frmExportBox");
	NewElement.setAttribute("style", "width: 200px; margin: 0px; border: 2px solid red;");
	NewElement.innerHTML = "Hi3";
	NewElement.style.color = "#FF00FF";
	NewElement.style.border = "2px solid red";

//	document.getElementById("ExportBox").innerHTML = "123";
	document.getElementById("ExportBox").style.width = "300px";
	document.getElementById("ExportBox").style.height = "140px";
	document.getElementById("ExportBox").style.border = "2px solid navy";
	document.getElementById("ExportBox").appendChild(NewElement);

	NewElement.style.height = "120px";
	NewElement.style.border = "2px solid brown";

//alert(1);
	NewElement = document.createElement("table");
	NewElement.setAttribute("id", "tblExportBox");
	NewElement.setAttribute("cellpadding", "0");
	NewElement.setAttribute("cellspacing", "0");
	NewElement.setAttribute("border", "1");
//	NewElement.setAttribute("class", "ExportBox");
	NewElement.setAttribute("style", "width: 180px; margin: 0px; border: 2px solid blue;");
	document.getElementById("ExportBox").appendChild(NewElement);

	NewElement = document.createElement("tr");
	NewElement.setAttribute("id", "rowHeader");
	document.getElementById("tblExportBox").appendChild(NewElement);

	NewElement = document.createElement("th");
	NewElement.setAttribute("id", "celHeader");
//	NewElement.setAttribute("class", "netHeader");
	NewElement.innerHTML = "Hi2";
	document.getElementById("rowHeader").appendChild(NewElement);

	NewElement = document.createElement("h1");
	NewElement.setAttribute("id", "hi");
	NewElement.innerHTML = "Hi";
	document.getElementById("ExportBox").appendChild(NewElement);
/*
alert(1);

	NewElement = document.createElement("table");
	NewElement.setAttribute("id", "tblHeader");
	NewElement.setAttribute("class", "netHeader");
	NewElement.setAttribute("width", "100%");
	NewElement.setAttribute("cellpadding", "1");
	NewElement.setAttribute("cellspacing", "0");
	document.getElementById("celHeader").appendChild(NewElement);

	NewElement = document.createElement("tr");
	NewElement.setAttribute("id", "rowTitle");
	document.getElementById("tblHeader").appendChild(NewElement);

	NewElement = document.createElement("td");
	NewElement.setAttribute("id", "celTitleL");
	NewElement.setAttribute("class", "netHeaderLeft");
	document.getElementById("rowTitle").appendChild(NewElement);

	NewElement = document.createElement("th");
	NewElement.setAttribute("id", "celTitle");
	NewElement.setAttribute("class", "netHeaderLeft");
	document.getElementById("rowTitle").appendChild(NewElement);
	document.getElementById("rowTitle").innerHTML = "Export Box";

	NewElement = document.createElement("td");
	NewElement.setAttribute("ID", "celTitleL");
	NewElement.setAttribute("CLASS", "netHeaderLeft");
	NewElement.setAttribute("ALIGN", "RIGHT");
	NewElement.innerHTML = "X";
	document.getElementById("rowTitle").appendChild(NewElement);

*/
/*
	os.Add "<TR><TH COLSPAN=4 BGCOLOR=" & ColorHeader & ">"
	os.Add "<TABLE WIDTH=""100%"" BORDER=0 CELLSPACING=0 CELLPADDING=1><TR>" & vbCrLf
	os.Add "<TD><IMG SRC=""/sysimage/_.gif"" WIDTH=13 HEIGHT=1></TD>" & vbCrLf
	os.Add "<TH>" & FontHeader & "Export" & "</FONT></TH>" & vbCrLf
	os.Add "<TD ALIGN=RIGHT><A HREF=""javascript:CloseExportBox();""><IMG SRC=""/sysimage/x13.gif"" WIDTH=13 HEIGHT=13 HSPACE=0 BORDER=0 ALIGN=ABSBOTTOM></A></TD>" & vbCrLf
	os.Add "</TR></TABLE>" & vbCrLf
	os.Add "</TH></TR>" & vbCrLf
*/
}


function GetColorScheme(ColorStyle) {
	if(ColorStyle) {
		ButtonFace		= "#DDDDDD";
		ColorPage		= "#FFFFFF";
		ColorHeader		= "#000080";
		ColorField		= "#EEEEEE";
		ColorGrid		= "#FFF8EF";
		ColorLight		= "#AAAAFF";
		ColorDark		= "#000066";
		ColorSelected	= "#E3FBF7";
		ColorVBorder	= "#AAAAFF";
		ColorHBorder	= "#4464AA";
	} else {
		ButtonFace		= "#D5D5D5";
		ColorPage		= "#C0D0C0";
		ColorHeader		= "#990033";
		ColorField		= "#FCFFE7";
		ColorGrid		= "#FFF8EF";
		ColorLight		= "#F5D78D";
		ColorDark		= "#6C0023";
		ColorSelected	= "#DDFFDD";
		ColorVBorder	= "#F0B7DF";
		ColorHBorder	= "#4464AA";
	}
}
function netAsyncPOST(strURL, strIn, strOut) {
//	alert(strIn);
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			document.getElementById(strOut).innerHTML = self.xmlHttpReq.responseText;
		}
	}
	document.getElementById(strOut).style.display = '';
	document.getElementById(strOut).innerHTML = 'Please wait...';
	self.xmlHttpReq.send(strIn);
}
function netUpdChx(strURL, TheID, Nam, Val) {
	var strIn = "mode=update&submode=chx&col=" + Nam + "&id=" + TheID + "&" + Nam + "=0&chk" + Nam + "=" + (Val ? '1' : '0');
	var objID = Nam + '_' + TheID;
	var xmlHttpReq = false;
	var self = this;
//	document.getElementById("Dbg").innerHTML = strIn;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
	}
//	alert(strURL + '\n' + strIn);
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//	self.xmlHttpReq.setRequestHeader('Content-Type', 'multipart/form-data');

	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			document.getElementById(objID).style.backgroundColor = '#C0FFC0';
		//	alert(self.xmlHttpReq.responseText);
			if (self.xmlHttpReq.responseText == '1') {
				document.getElementById(objID).innerHTML = '<A HREF="javascript:netUpdChx(\'' + strURL + '\', ' + TheID + ',\'' + Nam + '\',0)"><IMG SRC="/sysimage/check13.gif" WIDTH=13 HEIGHT=13 BORDER=0>'
			} else if (self.xmlHttpReq.responseText == '0') {
				document.getElementById(objID).innerHTML = '<A HREF="javascript:netUpdChx(\'' + strURL + '\', ' + TheID + ',\'' + Nam + '\',1)"><IMG SRC="/sysimage/uncheck13.gif" WIDTH=13 HEIGHT=13 BORDER=0>'
			} else {
				document.getElementById(objID).style.backgroundColor = '#FFC000';
			}
		}
	}
	document.getElementById(objID).style.backgroundColor = '#FFC0C0';
	self.xmlHttpReq.send(strIn);
}
function netUpdLab(strURL, Field, Entity, ColName, ColNo) {	//	1,14,3
	var TheID = document.frmAddLabel.TheID.value;
	var objList = eval("document.frmAddLabel." + Field)
	var strIn = "mode=add&submode=lab&col=" + ColNo + "&id=" + TheID + "&Entity=" + Entity + "&" + Field + "=" + objList[objList.selectedIndex].value;
	var objID = ColName + '_' + TheID;
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
	}
//	alert(strURL + '\n' + objID + '\n' + strIn);
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			document.getElementById(objID).style.backgroundColor = '#C0FFC0';
			document.getElementById(objID).innerHTML = self.xmlHttpReq.responseText;
		//	document.getElementById(objID).style.backgroundColor = '#FFC000';
		}
	}
	document.getElementById(objID).style.backgroundColor = '#FFC0C0';
	self.xmlHttpReq.send(strIn);
}
function SiteSelector(strIn) {
	var strURL = '/SiteSelector.asp';
	var strOut = 'SiteSel';
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			document.getElementById(strOut).innerHTML = self.xmlHttpReq.responseText;
		}
	}
//	document.getElementById(strOut).style.display = '';
	document.getElementById(strOut).innerHTML = 'Please wait...';
	self.xmlHttpReq.send(strIn);
}
var PreviousRow2AddLabel = 0;
var AddLabelOpen = '';

function ShowAddLabel(Entity, strURL, TheID) {
	if (PreviousRow2AddLabel > 0) {
		var Row = document.getElementById("Row" + PreviousRow2AddLabel);
		Row.className = 'netRowOdd';
	}
	PreviousRow2AddLabel = TheID;
	var Row = document.getElementById("Row" + TheID);
		Row.className = 'netRowSel';

		var objBox = document.getElementById("AddLabelBox");
			objBox.style.display = '';

	if (AddLabelOpen == Entity) {
		document.frmAddLabel.TheID.value = TheID;
	} else {
		AddLabelOpen = Entity;
		var strIn = "Mode=Add" + Entity + "&SubMode=Add&HighLight=" + TheID;
		//	alert(strURL);
		//	alert(strIn);
			netAsyncPOST(strURL, strIn, 'AddLabelBox')
	}
}
function CloseAddLabel() {
	var objBox = document.getElementById("AddLabelBox");
		objBox.style.display = 'none';
	//	objBox.innerHTML = '';
	//	AddLabelOpen = '';
		document.getElementById("Row" + PreviousRow2AddLabel).className = 'netRowOdd';
}

function CloseRemoveLabel() {
	var objBox = document.getElementById("ConfirmRemoval");
	//	objBox.style.visibility = "hidden";
		objBox.style.display = 'none';
	//	objBox.innerHTML = '';
}
function HideThisBox(BoxID) {	// Used by /Common/UploadForm.asp
	var objBox = document.getElementById(BoxID);
	//	objBox.style.visibility = "hidden";
		objBox.style.display = 'none';
	//	objBox.innerHTML = '';
}
function HideParentBox(BoxID) {	// Used by /Common/UploadForm.asp
	var objBox = window.top.document.getElementById(BoxID);
		objBox.style.display = 'none';
}
//var AlreadyLoaded = false;
function ShowBoxUploadXML() {
//	var objDeb = document.getElementById("FormTest");
//	objDeb.innerHTML = navigator.userAgent;

	var objBox = document.getElementById("boxUploadXML");
		objBox.style.display = "";



//	alert(navigator.userAgent + '\n\n[' + browserr.version + ']\n' + browserr.isNS);


//	document.getElementById("FormTest").innerHTML = browserr.isNS;


	if (browserr.isIE) {	//	alert('ie');
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;		// Error in IE
		y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
//		document.getElementById("FormTest").innerHTML = "IE";
	}
	if (browserr.isNS) {	//	alert('ns');
//		document.getElementById("FormTest").innerHTML = "NS";

		try {

			event = event || window.event; // IE sucks!

			var xx;
//			xx = event.pageX;
		//	x = event.clientX + window.scrollX;
		//	y = event.clientY + window.scrollY;
		} catch (e) {
			document.getElementById("FormTest").innerHTML = "Error";
		}

		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;

	}



	objBox.style.left = x - 100;
	objBox.style.top = y + 10;

	CreateUploadForm();

	return false;
}





var DontAsk = false;
function RemoveLabel(Entity, TheID, LinkID, ColNo, ColName) {
	document.frmRemoveLabel.TheID.value = TheID;
	document.frmRemoveLabel.LinkID.value = LinkID;
	document.frmRemoveLabel.Entity.value = Entity;
	document.frmRemoveLabel.ColNo.value = ColNo;
	document.frmRemoveLabel.ColName.value = ColName;
	if(DontAsk) {
		netRemLab();
	} else {
		var objBox = document.getElementById("ConfirmRemoval");
			objBox.style.display = "";
		//	objBox.style.visibility = "visible";
			document.getElementById("RemoveEntity1").innerHTML = Entity;
			document.getElementById("RemoveEntity2").innerHTML = Entity;

		if (browserr.isIE) {	//	alert('ie');
			x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
			y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}
		if (browserr.isNS) {	//	alert('ns');
			x = event.clientX + window.scrollX;
			y = event.clientY + window.scrollY;
		}

		objBox.style.left = x - 100;
		objBox.style.top = y + 10;
	}
	return false;
}
function netRemLab() {
	if(document.frmRemoveLabel.DontAsk.checked) DontAsk = true;

	var objBox = document.getElementById("ConfirmRemoval");
		objBox.style.display = 'none';

	var strURL = document.frmRemoveLabel.action;
	var TheID = document.frmRemoveLabel.TheID.value;
	var LinkID = document.frmRemoveLabel.LinkID.value;
	var Entity = document.frmRemoveLabel.Entity.value;
	var ColNo = document.frmRemoveLabel.ColNo.value;
	var ColName = document.frmRemoveLabel.ColName.value;
	var strIn = "Mode=Remove&SubMode=lab&Entity=" + Entity + "&Col=" + ColNo + "&id=" + TheID + "&LinkID=" + LinkID;
	var objID = ColName + '_' + TheID;
//	alert(strURL + '\n' + objID + '\n' + strIn + "\n" + e.message);

	var Err = false;
	try {
		document.getElementById(objID).style.backgroundColor = '#FFC0C0';
	} catch (e) {
		Err = true;
		alert("Object " + objID + " doesn't exist.");	// Error name: " + e.name + ". Error message: " + e.message
	}

	if(! Err) {
		netAsyncPOST(strURL, strIn, objID);
		document.getElementById(objID).style.backgroundColor = '#C0FFC0';
	}

//	http://admin.web/AccessMan.asp?Entity=User&mode=remove&id=18&linkid=426&Col=4&SubMode=lab

}

function netChat(isRefresh) {
	if (Processing) return false;
	Processing = true;
	var CookieName = "chat";
	var Expiration = 90 * 24 * 60 * 60 * 1000	// expire in 3 month
	if (isNaN(document.frmChat.ref.value)) document.frmChat.ref.value = document.frmChat.oldref.value;
	if (document.frmChat.ref.value < 10) document.frmChat.ref.value = 10;
	document.frmChat.oldref.value = document.frmChat.ref.value;

	if (isNaN(document.frmChat.rec.value)) document.frmChat.rec.value = 30;
	if (document.frmChat.rec.value < 3) document.frmChat.rec.value = 3;
	if (document.frmChat.rec.value > 100) document.frmChat.rec.value = 100;

	setCurrState(CookieName, "rec=" + document.frmChat.rec.value + "&ref=" + document.frmChat.ref.value, Expiration)

	var strIn
	var strOut = "ChatRoom";
//	var sURL = document.frmChat.action;
	var sURL = document.frmChat.src.value;
	var sRef = document.frmChat.ref.value;
	var sRec = document.frmChat.rec.value;
	var sTid = document.frmChat.tid.value;
	var sMsg = document.frmChat.msg.value;
	sMsg = sMsg.replace(/ /g, '+');
	if (isRefresh) sMsg = '';
	var strIn = "Mode=Send&Msg=" + sMsg + "&Ref=" + sRef + "&Rec=" + sRec + "&Tid=" + sTid;

//	if (! isRefresh) alert(document.frmChat.msg.value + '\n' + strIn);

	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
	}
	self.xmlHttpReq.open('POST', sURL, true);
//	self.xmlHttpReq.setRequestHeader('Content-Type', 'multipart/form-data; charset=utf-8');
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.setRequestHeader('Content-length', sMsg.length);
	self.xmlHttpReq.setRequestHeader('Connection', 'close');

	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
		//	document.getElementById(strOut).innerHTML = ProcessChat(self.xmlHttpReq.responseText);
			ProcessChat(self.xmlHttpReq.responseText);
		}
	}
	self.xmlHttpReq.send(strIn);
	if (! isRefresh) {
		document.frmChat.msg.value = '';
		document.frmChat.msg.focus();
	}
	Processing = false;
	return false;
}function ProcessChat1(ChatData) {
	var arrChat = ChatData.split("\n");
	var arrLine
//	alert(arrChat[2] + "\n" + arrLine[1]);
	var s = '<TABLE ID="Chat" CELLSPACING=0 CELLPADDING=0 CLASS=netTableEditor>';
		s=s+ "<TR><TH>Name</TH><TH>Date</TH><TH>Message</TH></TR>";

	 for(c = arrChat.length - 1; c >= 0 ; c--) {
		arrLine = arrChat[c].split("\f");
		s=s+ '<TR ID="Row' + arrLine[0] + '"><TD>' + arrLine[0] + ': ' + arrLine[1] + '</TD><TD>' + arrLine[2] + '</TD><TD>' + arrLine[3] + '</TD></TR>\n';
	}
		s=s+ "</TABLE>"
	return s
}
function ProcessChat(ChatData) {
	var arrLine, bod, row, col, dat;
	var arrChat = ChatData.split("\n");
	var tbl = document.getElementById("tblChat");

//alert(ChatData + "\n" + arrChat[0]);
	if (ChatData == "OK") {
		var Stat = document.getElementById('Status');
		var Today = new Date();
		var h = Today.getHours();
		if (h >= 12) { var t = " PM"; } else { var t = " AM"; }
		if (h > 12) { h -= 12; }
		if (h == 0) h = 12;
		var m = Today.getMinutes();
		if (m < 10) m = "0" + m;
		var s = Today.getSeconds();
		if (s < 10) s = "0" + s;

	//	Stat.innerHTML = "<B>" + Today.getTime() + "</B>";
		Stat.innerHTML = "<B>" + h + ":" + m + ":" + s + t + "</B>";

	} else {
		var ua = navigator.userAgent;
		var s = "MSIE";
		var isIE = false;
		if ((i = ua.indexOf(s)) >= 0) isIE = true;

//		if(isIE) document.getElementById("dbg1").innerHTML = ChatData;

		var TopID = 0;
		for(c = arrChat.length - 1; c >= 0 ; c--) {
			arrLine = arrChat[c].split("\f");
	        row = document.createElement("tr");
	        for (var i = 0; i < arrLine.length; i++) {
				if(TopID == 0) TopID = arrLine[0];
				if(i == 0) {
					row.setAttribute("ID", "Row" + arrLine[i]);
				} else {
					col = document.createElement("td");
					dat = document.createTextNode(arrLine[i]);
					col.appendChild(dat);
					row.appendChild(col);
				}
			//	s=s+ '<TR ID="Row' + arrLine[0] + '"><TD>' + arrLine[0] + ': ' + arrLine[1] + '</TD><TD>' + arrLine[2] + '</TD><TD>' + arrLine[3] + '</TD></TR>\n';
			}
			bod = document.createElement("tbody");
			bod.appendChild(row);
			tbl.appendChild(bod);
		}

		var DelID = eval(document.frmChat.tid.value - document.frmChat.rec.value + 1);
	//	document.getElementById("dbg1").innerHTML = "DelID=" + DelID + "; TopID=" + TopID;
		try {
			document.getElementById("Row" + DelID).style.display = "none";
		} catch (e) {
	//		document.getElementById("dbg1").innerHTML = e.name + ". " + e.message;
		}
		document.frmChat.tid.value = TopID;
	//	document.getElementById("dbg2").innerHTML = "TopID=" + TopID;
		TopID = 0;
	}
//	alert(c);
}
function Test2() {
    // get the reference for the body
    var body = document.getElementsByTagName("body")[0];

    // creates a <table> element and a <tbody> element
    var tbl     = document.createElement("table");
//    var tblBody = document.createElement("tbody");

    // creating all cells
    for (var j = 0; j < 2; j++) {
        // creates a table row
        var row = document.createElement("tr");

        for (var i = 0; i < 2; i++) {
            // Create a <td> element and a text node, make the text
            // node the contents of the <td>, and put the <td> at
            // the end of the table row
            var cell = document.createElement("td");
            var cellText = document.createTextNode("cell is row "+j+", column "+i);
            cell.appendChild(cellText);
            row.appendChild(cell);
        }

        // add the row to the end of the table body
//        tblBody.appendChild(row);
    }
	var tbl = document.getElementById("tblChat");
//	tbl.appendChild(tblBody);					// put the <tbody> in the <table>
    tbl.appendChild(row);					// put the <tbody> in the <table>
//	body.appendChild(tbl);						// appends <table> into <body>
	tbl.setAttribute("border", "2");			// sets the border attribute of tbl to 2;
}
