// read a particular cookie (jea:7/31/00)
// returns string --------------------------------------------------------
function getCookie(sName) {
	re = new RegExp(sName + "=(\\S+)[\\;\\b]");
	if (re.test(unescape(document.cookie))) {
		var aMatch = re.exec(unescape(document.cookie));
		return(aMatch[1]);
	}
	return "";
}

// save a cookie (jea:8/14/00)
// updates collection ----------------------------------------------------
function setCookie(sName, sValue, sExpire) {
	document.cookie = sName + "=" + escape(sValue);
}

// erase pharmacy cookies(jea:8/22/00)
// VBS not available in .js so can't use constants
// updates collection ----------------------------------------------------
function delRxCookies() {
	var aCookies = ["WID","WFROM","PT","PN","PATIENTID","PAY","STORE","RID","OID","GID","FLOW"];
	for (var x in aCookies) {
		delCookie(aCookies[x]);
	}
}

// erase cookie (jea:8/22/00)
// updates collection ----------------------------------------------------
function delCookie(sName) {
    document.cookie = sName + "=; expires=Thu, 01-Jan-80 00:00:01 GMT";
}

// read query string value (jea:8/29/00)
// returns string --------------------------------------------------------
function getQS(sName) {
// [&\\b]
	re = new RegExp("[&?]" + sName + "=(\\w+)\\b");
	if (re.test(unescape(location.search))) {
		var aMatch = re.exec(unescape(location.search));
		return(aMatch[1]);
	}
	return "";
}