function newXH() { 
        if (window.XMLHttpRequest) {
        return new XMLHttpRequest();      // code for IE7+, Firefox, Chrome, Opera, Safari
        }
        if (window.ActiveXObject) {
                return new ActiveXObject("Microsoft.XMLHTTP");    // code for IE6, IE5
        }
        return null;
}

function doRequest( thurl, trg ) {
	var xhr=newXH();
	if ( xhr==null ) return false;

	xhr.onreadystatechange = function() {
		alert(xhr.readyState);
		if ( xhr.readyState==4 ) {
			if (xhr.status==200) {
				var theHtml = xhr.responseText;
				swapContent( trg, 'Thanks for rating!');
			}
		}
	};

	xhr.open('GET', thurl, false);
	xhr.send('');
}


function makeRequest(url,theTarget) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Cannot create XMLHTTP instance - Sorry, but your brower does not have the appropriate Javascript compatibility');
		return false;
	}

	http_request.onreadystatechange = function () {
		if ( theTarget==null ){theTarget='contentBox';}
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				result = http_request.responseText;
				swapContent(theTarget, result);
				theTarget=null;
			} else {
				alert('There was a problem with the request.');
			}
		}
	}


	http_request.open('GET', "/handle.php?" + url, true);
	http_request.send(null);
}

function rateGood( i ) {
	makeRequest('f=rate1&q=' + i, 'rateBox');
}

function rateBad( i ) {
	makeRequest('f=rate2&q=' + i, 'rateBox');
}

function toggleBox( t ) {	if ((typeof t) != 'object') t=document.getElementById(t);	t.style.display=='block' ? t.style.display='none' : t.style.display='block';}
function hideBox(b){ if ((typeof b) != 'object')	b = document.getElementById(b);b.style.display='none'; }
function showBox(b){ if ((typeof b) != 'object')	b = document.getElementById(b);b.style.display='block'; }

function swapContent ( targ, newcont ) {
	var ele = document.getElementById( targ );
	ele.innerHTML = newcont;
}