function ajaxRequest() {
	// Creating request
	this.init =
	function() {
		if (window.XMLHttpRequest) {
			this.request = new XMLHttpRequest();
				if (this.request.overrideMimeType) {
					this.request.overrideMimeType('text/xml');
				}
		} else if (window.ActiveXObject) {
			try {
				this.request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					this.request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	}

	// Path to the script to send request to
	this.target;

	// Setting content type
	this.contentType = "application/x-www-form-urlencoded; charset=UTF-8";

	// Send method (GET/POST)
	this.method;

	// Query for POST/GET methods, which can be set via setQuery function
	this.query = "";
}

ajaxRequest.prototype.setQuery = 
	function(queryArray) {
		this.query = "";
		for(var keyVar in queryArray) {
			this.query += "&" + keyVar + "=" + encodeURIComponent(queryArray[keyVar]) ;
		}
		// Remove the starting '&'
		this.query = this.query.substr(1);
	}

ajaxRequest.prototype.send = 
	function() {
		var date = new Date();
		var timestamp = date.getTime();
		if (this.method == "POST") {
			this.request.open("POST", this.target + "?timestamp=" + timestamp, true);
			this.request.setRequestHeader("Content-Type", this.contentType);
			this.request.setRequestHeader("Content-length", this.query.length);
			this.request.setRequestHeader("Connection", "close");
			this.request.send(this.query);
		} else if (this.method == "GET") {
			this.request.open("GET", this.target + "?timestamp=" + timestamp + "&" + this.query, true); 
			this.request.send(null);
		}
	}

ajaxRequest.prototype.getPuzzle =
	function () {
		if(puzzle.request.readyState == 4) {
			if(puzzle.request.status == 200) {
				var PGN = puzzle.request.responseText.match(/<pgn>([\W\w]*)<\/pgn>/)[1];
				//var xmlDoc = puzzle.request.responseXML;

				//alert(puzzle.request.responseText);
				//var PGN = xmlDoc.getElementsByTagName("pgn")[0].firstChild.nodeValue;
				parser.loadPGN(PGN);
				if (firsttime) {
					newPuzzle();
					firsttime = false;
				}
				//var gs = document.getElementById("gamestate");
				//gs.firstChild.nodeValue = "Find the best move for " + game.currentMove;
				
			} else {
				alert("Unable to get response");
			}
		} 
	}

ajaxRequest.prototype.getStats =
	function () {
		if(puzzle.request.readyState == 4) {
			if(puzzle.request.status == 200) {
			}
		} 
	}
