	function getURLparams(name) {
	    // Get URL Parameters where "name" is the parameter name whose value is to be returned
	    //alert("INSIDE getURLparams - name =" + name);   // for debugging only
	    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
	    var results = regex.exec(window.location.href);
	    if (results == null) {
	        return "";
	    } else {
		var value = results[1].replace(/%20/g, " ");
	        return value;
	    }
	}

	JSON = {
	  // workaround because IE doesn't support toSource
	  encode : function(input) {
	    if (!input) return 'null'
	    switch (input.constructor) {
	      case String: return '"' + input + '"'
	      case Number: return input.toString()
	      case Array :
		var buf = []
		for (i in input)
		  buf.push(JSON.encode(input[i]))
		    return '[' + buf.join(', ') + ']'
	      case Object:
		var buf = []
		for (k in input)
		  buf.push(k + ' : ' + JSON.encode(input[k]))
		    return '{ ' + buf.join(', ') + '} '
	      default:
		return 'null'
	    }
	  }
	}

	var xmlhttp;

	function loadXMLDoc(url) {
	    xmlhttp = null;
	    if (window.XMLHttpRequest) {
		// code for all new browsers
		xmlhttp = new XMLHttpRequest();
	    } else if (window.ActiveXObject) {
		// code for IE5 and IE6
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    if (xmlhttp != null) {
		xmlhttp.open("GET", url, false);
		xmlhttp.send(null);
		if ( ! xmlhttp.getResponseHeader("Date")) {
		    var cached = xmlhttp;
		    xmlhttp = new XMLHttpRequest();
		    var ifModifiedSince = cached.getResponseHeader("Last-Modified") || new Date(0);   // January 1, 1970
		    xmlhttp.open("GET", url, false);
		    xmlhttp.setRequestHeader("If-Modified-Since", ifModifiedSince);
		    xmlhttp.send("");
		    if (xmlhttp.status == 304) {
			xmlhttp = cached;
		    }
		}
		//alert("loadXMLDoc:  status = " + xmlhttp.status + " (" + xmlhttp.statusText + "), response = " + xmlhttp.responseText);
		return xmlhttp.responseText;
	    } else {
		alert("Your browser does not support XMLHTTP.");
	    }
	}


	String.prototype.trim = function () {
	    return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}

	function getTagValue(id) {
	    var pTag = document.getElementById(id);
	    return pTag.value;
	}

	function setTagValue(id, newVal, useInnerHTML) {
	    var pTag = document.getElementById(id);
	    if (pTag.value == newVal) {
		// avoid triggering onChange event for same value
	    } else {
	        pTag.setAttribute('value', newVal);
		if (useInnerHTML) {
	            pTag.innerHTML = newVal;   // necessary for FF3 but breaks IE7 for some elements
		} else {
		    if (pTag.innerText) {   // test if innerText is supported (e.g., Safari doesn't have it)
			pTag.innerText = newVal;   // ineffective for FF3 but necessary for IE7 for some elements
		    } else if (pTag.textContent) {   // test if textContent is supported (e.g., Safari doesn't have it)
			pTag.textContent = newVal;   // should work for FF
		    }
		}
	    }
        }

	var validate = function(newVal, lowerBound, upperBound) {
	    if (newVal < lowerBound) {
	        return lowerBound;
	    } else if (newVal > upperBound) {
	        return upperBound;
	    } else {
	        return newVal;
	    }
        }

	var plural = function(count) {
	    if (count == 1) {
	        return '';
	    } else {
	        return 's';
	    }
        }

	function hide(id) {
	    document.getElementById(id).style.display = 'none';
	}

	function show(id) {
	    document.getElementById(id).style.display = '';
	}

/*
	************************************************************
	If onBlur & onChange are triggered at the same time, they can execute asynchronously.
	However, since javascript doesn't have locking mechanisms, there's no way to control
	order of execution nor prevent downstream functions from being called multiple times.
	************************************************************
	Calling alert can interfere with onClick handling.
	If onChange and onClick both fire, but the onChange function calls alert,
        it prevents the onClick function from being called.
	************************************************************
*/


