var xmlhttp = false;

var selectitemcontent;
var olditemvalues;
var newitemvalues;

var categorykeys;
var categoryvalue = 0;


//Check if we are using IE.
try {
    //If the javascript version is greater than 5.
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    //If not, then use the older active x object.
    try {
        //If we are using IE.
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
        //Else we must be using a non-IE browser.
        xmlhttp = false;
    }
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
}

function submitSurvey(val) 
{ 

	theObject = document.getElementById('surveydiv');

 		params = "name=" + document.forms["surveyForm"].partname.value;
		params = params+ "&" + "tickets=" + document.forms["surveyForm"].tickets.value;
		params = params+ "&" + "button=" + val;

        serverPage = "surveysubmit.php";
        xmlhttp.open("post", serverPage, true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                theObject.innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(params);
}

function setButton(val)
{

  if (document.forms["surveyForm"].partname.value==null||document.forms["surveyForm"].partname.value=="")
    {
    alert("Name and number of attendees is required");
    }
  else
    {
	submitSurvey(val);
    }
}
