// enl_url.js

function getParamValue(pstrQuery, pstrKey) {
	var pintIdxStart, pintIdx, pintEquIdx, pintSepIdx, pstrPair, pstrValue;
	
	pstrValue = "";
	if (pstrQuery != "" && pstrKey.length > 0) {
		pintIdxStart = 0;
		if (pstrQuery.startsWith("?")) {
			pintIdxStart = 1;
		}
		pintIdx = pintIdxStart;
		pintIdx = pstrQuery.indexOf(pstrKey + "=", pintIdx);
		while (pintIdx != -1 && !((pintIdx == pintIdxStart) || (pintIdx > pintIdxStart && pstrQuery.charAt(pintIdx - 1) == "&"))) {
			pintIdx = pstrQuery.indexOf(pstrKey + "=", pintIdx + pstrKey.length);
		}
		if (pintIdx != -1) {
			pintIdx++;
			pintSepIdx = pstrQuery.indexOf("&", pintIdx + pstrKey.length);
			if (pintSepIdx == -1) {
				pintSepIdx = pstrQuery.length;	//take everything up to the end of the string (this is the last parameter).
			} 
			pstrPair = pstrQuery.substring(pintIdx, pintSepIdx);
			pintEquIdx = pstrPair.indexOf("=");
			if (pintEquIdx != -1) {
				pstrValue = pstrPair.substring(pintEquIdx + 1, pstrPair.length);
			}
		}
	}
	return pstrValue;
}
