function xmlhttpPost(block, from, to, action) {
   var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', "http://www.altmc.jp/" + block + "/indexes/cat/threshold.html", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
        	if(self.xmlHttpReq.responseText != "oos" && self.xmlHttpReq.responseText.charAt(1) != '!') {
           	 	document.getElementById("cat" + to).innerHTML = self.xmlHttpReq.responseText;
           	 }
        }
    }
   self.xmlHttpReq.send("from=" + from + "&to=" + to + "&act=" + action);
}

function GenerateSolution(code,params,answers,intermediate) {
   var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', "http://www.altmc.jp/cgi-bin/math/system/tutor.pl", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
        	if(self.xmlHttpReq.responseText != "oos" && self.xmlHttpReq.responseText.charAt(1) != '!') {
           	 	document.getElementById("solution").innerHTML = self.xmlHttpReq.responseText;
           	 }
        }
        else {	document.getElementById("solution").innerHTML = self.xmlHttpReq.responseText; }
    }
   self.xmlHttpReq.send("code=" + code + "&params=" + params+ "&answers=" + answers+ "&intermediate=" + intermediate);
}





