http = getHTTPObject();
 
function getHTTPObject(){
  var xmlhttp;
 
  /*@cc_on
 
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
      try{
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(E){
      xmlhttp = false;
    }
  }
  @else
    xmlhttp = false;
  @end @*/
 
  if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    try {
      xmlhttp = new XMLHttpRequest();
    }catch(e){
      xmlhttp = false;
    }
  }
 
  return xmlhttp;
}

function processScore(base_url){

//  http.open("GET", "http://www.punny.org/bin/loading.php", true);
//  http.onreadystatechange = handleHttpResponse;
 
//  http.send(null);    

//setTimeout("scoreQuestionniare('base_url')",5000)  
scoreQuestionniare('base_url');
}

function scoreQuestionnaire(base_url){

  var url = "http://www.punny.org/bin/" + base_url + ".php?num_qs=" + document.getElementById('num_qs').value;
 
  var this_q = "";
  var num_ans = 0;
  var next_ans = "";
  var this_value = 0;
  var this_measure = document.getElementById('measure').value;
  for (var i = 1; i <= document.getElementById('num_qs').value; i++)
  {
     this_q = this_measure + "_q" + i;
     num_ans = document.getElementsByName(this_q).length;
     for (var j = 1; j <= num_ans; j++)
     {
        next_ans = this_q + "-" + j;
        if ( document.getElementById(next_ans).checked )
        {
           this_value = document.getElementById(next_ans).value;
           url += "&q" + i + "=" + this_value;
        }
     }
  }

  http.open("GET", url, true);
  http.onreadystatechange = handleHttpResponse;
 
  http.send(null);
}
 
function handleHttpResponse(){
  if(http.readyState == 4){
    document.getElementById('answer').innerHTML = http.responseText;
  }
}


