function rate(qkey){
    var value;
    for (i = 0; i < document.rateform.ra.length; i++) {
        if (document.rateform.ra[i].checked)
            value = document.rateform.ra[i].value;
    }
    var xmlhttp=false; //Clear our fetching variable
    try {
        xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
    } catch (e) {
        try {
            xmlhttp = new
                      ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
    }
    var file = '/quizrate.html?key='+ qkey +'&ra='+ value; //This is the path to the file we just finished making
    xmlhttp.open('GET', file, true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
            var content = xmlhttp.responseText; //The content data which has been retrieved
            if ( content != 'err' ) { //If the response was not "n" (meaning it worked)
                document.getElementById('ratebox').innerHTML = content; //Set the inner HTML of the div with the old value in it to the new value **
            }
            else
                document.getElementById('ratebox').innerHTML = 'There was an error';
        }
    }
    xmlhttp.send(null) //Nullify the XMLHttpRequest
    return;
}

var http_request = false;
function makePOSTRequest(url, parameters) {
   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');
      return false;
   }
   
   http_request.onreadystatechange = alertContents;
   http_request.open('POST', url, true);
   http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   http_request.setRequestHeader("Content-length", parameters.length);
   http_request.setRequestHeader("Connection", "close");
   http_request.send(parameters);
}

function alertContents() {
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
         //alert(http_request.responseText);
         result = http_request.responseText;
         document.getElementById('fbbox').innerHTML = result;            
      } else {
         alert('There was a problem with the request.');
      }
   }
}

function postFeedback(qkey) {
   var poststr = "comments=" + encodeURI(document.fbform.comments.value)+
                 "&fburl="+ encodeURI(qkey);
                 //"&username=" + encodeURI(document.fbform.username.value) +
                 //"&email=" + encodeURI(document.fbform.email.value);
   makePOSTRequest('/subfeed.php', poststr);
}
