function setHTTPObject() {
     var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp=false;
        }
    }
    if (!xmlhttp && window.createRequest) {
        try {
            xmlhttp = window.createRequest();
        } catch (e) {
            xmlhttp=false;
        }
    }
    return xmlhttp;
}

var queue = new Array();
function getContent(url, target) {
     queue.push(new Array(url,target));
     processQueue();
}

var url;
var target;
var busy;
var xmlhttp;

function processQueue() {
     if(busy) return;
     if(queue.length == 0) return;
     busy = true;
     var item = queue.pop();
     url = item[0];
     target = item[1];
     xmlhttp=setHTTPObject();
     xmlhttp.open("GET", url, true);
     xmlhttp.onreadystatechange=function() {
       if (xmlhttp.readyState==4) {
             document.getElementById(target).innerHTML = xmlhttp.responseText;
             busy = false;
             processQueue();
        }
     }
     xmlhttp.send(null);
 }
 
function processForm() {
    xmlhttp=setHTTPObject();
    var survey_id=document.submitform.survey_id.value;
    var name=document.submitform.name.value;
    var email=document.submitform.email.value;
    var store=document.submitform.store.value;
    var url='../process_survey.php?survey_id='+survey_id+'&name='+name+'&email='+email+'&store='+store;
    
    for (x = 0; x < document.submitform.elements.length; x++) {
        if (document.submitform.elements[x].checked) {
            url=url+'&'+document.submitform.elements[x].name+'='+document.submitform.elements[x].value;
        }
    }
    xmlhttp.open("GET", url, false);
    getContent(url, "thankyou_container")
}
