function pop_win(url, width, height) {

	// so that we don't always pop the url into the same window...
	var rnd = "" + Math.round(Math.random(0, 100) * 1000);

	var x = (screen.availWidth - width) / 2;
	var y = (screen.availHeight - height) / 2;
	var w = window
			.open(
					url,
					('window' + rnd),
					('toolbar=no,scrollbars=yes,resizable=no,menubar=no,status=no,directories=no,location=no,width='
							+ width
							+ ',height='
							+ height
							+ ',screenX='
							+ x
							+ ',screenY=' + y + ',left=' + x + ',top=' + y));
	if (window.focus) {
		w.focus();
	} 
	return w;
}

function sendRequest(url, data) {
	var undo=0;
	if (arguments.length ==4) {
		undo = arguments[3];
	}
	var response_element = 0;
	if (sendRequest.arguments.length >= 3) {
		response_element = document.getElementById(sendRequest.arguments[2]);
	}
	if (window.XMLHttpRequest) {
		client = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		try {
			client = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				client = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}
//alert(url);
	client.open("POST", url);

	client.onreadystatechange = function() {// Call a function when the state
											// changes.
		if (client.readyState == 4 && client.status == 200) {
//			alert(client.responseText);
//document.write(client.responseText);
			if ((client.responseText.indexOf('exausted') != -1) && undo) {
				obj = document.getElementById(undo)
				obj.checked = false;
			}
			if (response_element && client.responseText.length) {
				sethtml(response_element, client.responseText);
				// response_element.innerHTML = client.responseText;
			}

		}
	}

	// Send the proper header information along with the request
	client.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	client.setRequestHeader("Content-length", data.length);
	client.setRequestHeader("Connection", "close");
//alert(data);
	client.send(data);
}


//  assign the html to our element.  Evaluate any javascript in the stream.
function sethtml(response_element, content) {
	var search = content;
	var script;
	response_element.innerHTML = content;

	while (script = search.match(/(<script[^>]+javascript[^>]+>\s*(<!--)?)/i)) {
		search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length);

		if (!(endscript = search.match(/((-->)?\s*<\/script>)/)))
			break;

		block = search.substr(0, search.indexOf(RegExp.$1));
		search = search.substring(block.length + RegExp.$1.length);

		var oScript = document.createElement('script');
		oScript.text = block;
		document.getElementsByTagName("head").item(0).appendChild(oScript);
	}

}
