	var CookieLife = 90*24*60*60*1000;
//	var CookieLife = 60*1000;
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.toLowerCase() == '/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 {
		var str = "" + Math.round(strng * 100);
		return(str.substring(0, str.length-2) + "." + str.substring(str.length-2, str.length));
	}
}
