var whichLink = "Surveyq2.asp"
var whichElement = "insert_response"
var xmlHttp
function getCheckedValue(){
         
         for (i=0; i<document.form1.Q1.length; i++)
         {
            if (document.form1.Q1[i].checked==true)
            {
              
               return document.form1.Q1[i].value
            }
         }
         
}

function showData()
{ 
//this shows the "working" graphic when the query page is retrieving data
document.getElementById(whichElement).innerHTML = "<div align=center><b>Sending...</b><br><br></div>"

//by setting these values to "" it prevents an undefined error. Also defining these outside of the function will add existing data to the variable which will cause an error.
var theForm = ""
var howManyElement = ""
var daString = ""
	
	theForm = document.form1;
	howManyElement = theForm.elements.length;
	xmlHttp=GetXmlHttpObject();
	theForm = document.form1
	daString="URL=" + theForm.URL.value + "&WEBSITE=" + theForm.WEBSITE.value
	daString=daString + "&Q1=" + getCheckedValue() + "&comment=" + theForm.comment.value 

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//the 'whichLink' variable is assigned on the page making the request. 
var url=whichLink;
url=url+"?"+daString;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
	//=====I should rework this and convert qresult.asp into a webservice... FVS 9/09
	//xmlHttp.close
	//----next call to results
	//url="http://www.intersilo.com/qresult.asp?id=21"
	//xmlHttp.onreadystatechange=stateChanged;
	//xmlHttp.open("GET",url,true);
	//xmlHttp.send(null);
	//alert(url)//this is used to view the URL being sent to the query page.
theForm.comment.value=" THANK YOU!!";
theForm.B1.style.visibility="hidden";
}
function stateChanged() { 
if (xmlHttp.readyState==4)
{ 
document.getElementById(whichElement).innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject(){
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Let's go on Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer, ahh Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}