function GetXMLFile(sourceURL)	{
	var xmlhttp = null;
	var doc = null;

	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}
	else {
		xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
	}
	if (xmlhttp) {
		xmlhttp.open('GET', sourceURL, false);
		xmlhttp.send(null);
		doc = xmlhttp.responseText;
	}
	return doc;
}

function solvecrossword() {
	// references to save my sanity
	var input = document.getElementById('input').value.toLowerCase();
	answersblurb = document.getElementById('answersblurb');
	var answerslist = document.getElementById('answerslist');

	// clear the previous results
	for (i = answerslist.childNodes.length - 1; i >= 0; i--) {
		if (answerslist.childNodes[i].nodeType == 1) {
			answerslist.removeChild(answerslist.childNodes[i]);
		}
	}
	
	// check it's the right length
	if (input.length == 0) {
		answersblurb.removeChild(answersblurb.firstChild);
		answersblurb.appendChild(document.createTextNode('Sorry, but you need to enter a word!'));
		return false;
	}

	var inputarray = input.split('');
	var regexp = new RegExp('[a-z]');
	for (i = 0; i < inputarray.length; i++) {
		if (!regexp.test(inputarray[i])) {
			inputarray[i] = '.';
		}
	}
	var letters = inputarray.join('');

	// if it works, let them know what's going on
	answersblurb.removeChild(answersblurb.firstChild);

	// process and show the results
	results = GetXMLFile('http://www.dinosaursandmoustaches.com/crosswordfetch.php?input='+letters);
	if (results == 'nomatcheswerefound') {
		answersblurb.appendChild(document.createTextNode('Sorry, but no possible matches were found.'));
		return false;
	}
	words = results.split(',');
	answersblurb.appendChild(document.createTextNode('Here are some possible answers for your word:'));
	for (i = 0; i < words.length; i++) {
		newli = document.createElement('li');
		newli.appendChild(document.createTextNode(words[i]));
		answerslist.appendChild(newli);
	}
}
