<!--
function orForm(what) {
for (var i=0; i<what.options.length; i++) {
        if (what.options[i].selected) {
            document.getElementById(what.options[i].value).style.visibility="visible";
        }
        else {
            document.getElementById(what.options[i].value).style.visibility="hidden";
        }
    }
}
function showmethemoney(what) {
            document.getElementById("q2"+what).style.visibility="visible";
            document.getElementById("q1"+what).style.visibility="hidden";
}

function orForm2(what) {
for (var i=0; i<what.options.length; i++) {
        if (what.options[i].selected) {
            document.getElementById("advancedoptions"+what.options[i].value).style.visibility="visible";
        }
        else {
            document.getElementById("advancedoptions"+what.options[i].value).style.visibility="hidden";
        }
    }
}


function changeForm(what) {
for (var i=0; i<6; i++) {
        if (what.options[i].selected) {
            document.getElementById("part1q"+what.options[i].value).style.visibility="visible";
            document.getElementById("part2q"+what.options[i].value).style.visibility="visible";
           document.getElementById("part3q"+what.options[i].value).style.visibility="visible";
            document.getElementById("part4q"+what.options[i].value).style.visibility="visible";
        }
        else {
            document.getElementById("part1q"+what.options[i].value).style.visibility="hidden";
            document.getElementById("part2q"+what.options[i].value).style.visibility="hidden";
            document.getElementById("part3q"+what.options[i].value).style.visibility="hidden";
          document.getElementById("part4q"+what.options[i].value).style.visibility="hidden";
        }
    }
}

function changeForm2(what) {
for (var i=0; i<what.options.length; i++) {
    if (i == what.options[i].selected) {
            document.getElementById("part1q" + i).style.visibility="visible";
            document.getElementById("part2q" + i).style.visibility="visible";
            document.getElementById("part3q" + i).style.visibility="visible";
            }
            else {
            document.getElementById("part1q" + i).style.visibility="hidden";
            document.getElementById("part2q" + i).style.visibility="hidden";
            document.getElementById("part3q" + i).style.visibility="hidden";
    }
    }

}



//            document.getElementById("part1q" + i).style.visibility="hidden";
//            document.getElementById("part2q" + i).style.visibility="hidden";


function changeURL(what) {
window.location.replace('question_manager.php?' + what.value);

}

//AJAX for submitting and processing questions

                function createquestion(str) {
                   //create_questions.question_options.value=str;
                   //var word4 = create_questions.question_options.value=str;
                  // document.getElementById("question_options").innerHTML=str;
                         //create_questions.question_options.value=str;
                        // document.forms['create_questions'].question_options.value=str;
                        question_add.question_options.value=str;
                   }
                function xmlhttpPost(strURL) {
                    var xmlHttpReq = false;
                    var self = this;
                    // Mozilla/Safari
                    if (window.XMLHttpRequest) {
                        self.xmlHttpReq = new XMLHttpRequest();
                    }
                    // IE
                    else if (window.ActiveXObject) {
                        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    self.xmlHttpReq.open('POST', strURL, true);
                    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    self.xmlHttpReq.onreadystatechange = function() {
                        if (self.xmlHttpReq.readyState == 4) {
                            updatepage(self.xmlHttpReq.responseText);
                        }
                    }
                    self.xmlHttpReq.send(getquerystring());
                }

                function getquerystring() {
                    var form     = document.forms['question_add'];
                    var word = form.question_text.value;
                    var word2 = form.answer_text.value;
                    var word3 = form.question_type.value;
                    var word4 = form.question_options.value;
                    var word5 = form.privacy.checked;
                    var word6 = form.custom_answer.checked;
                    var word7 = form.question_category.value;
                    var word8 = form.event_id.value
                    var word9 = form.questionnaireID.value;
                    var word10 = form.question_create.value;
                    var word11 = form.question_id.value;
                    var word12 = form.question_options1.value;
                    var word13 = form.question_options2.value;
                    var word14 = form.question_options3.value;
                    var word15 = form.visibility.value;
                    var word16 = form.suggestions.value;
                    qstr = 'question_text=' + escape(word)+'&answer_text='+escape(word2)+'&question_type='+escape(word3)+'&question_options='+escape(word4)+'&privacy='+escape(word5)+'&custom_answer='+escape(word6)+'&question_category='+escape(word7)+'&event_id='+escape(word8)+'&questionnaireID='+escape(word9)+'&question_create='+escape(word10)+'&question_id='+escape(word11)+'&question_options1='+escape(word12)+'&question_options2='+escape(word13)+'&question_options3='+escape(word14)+'&visibility='+escape(word15)+'&suggestions='+escape(word16);  // NOTE: no '?' before querystring
                   return qstr;

                }

                function updatepage(str){
                    document.getElementById("showsurveys").innerHTML = str;
                }







//working AJAX - loading question database
                          var xmlHttp

                          function showHint(str)
                          {
                          if (str.length==0)
                            {
                            document.getElementById("showresults").innerHTML="";
                            return;
                            }
                          xmlHttp=GetXmlHttpObject()
                          if (xmlHttp==null)
                            {
                            alert ("Your browser does not support AJAX!");
                            return;
                            }
                          var url="question_manager_show_question_ajax.php";
                          url=url+"?"+str;
                          //url=url+"&sid="+Math.random();
                          xmlHttp.onreadystatechange=stateChanged;
                          xmlHttp.open("GET",url,true);
                          xmlHttp.send(null);
                          }

                          function stateChanged()
                          {
                          if (xmlHttp.readyState==4)
                          {
                          document.getElementById("showresults").innerHTML=xmlHttp.responseText;
                          }
                          }

                          function GetXmlHttpObject()
                          {
                          var xmlHttp=null;
                          try
                            {
                            // Firefox, Opera 8.0+, Safari
                            xmlHttp=new XMLHttpRequest();
                            }
                          catch (e)
                            {
                            // Internet Explorer
                            try
                              {
                              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                              }
                            catch (e)
                              {
                              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                              }
                            }
                          return xmlHttp;
                          }

//Ajax For deleting questions



function delete_question(id,event_id)
            {

            	if (confirm("Are you sure you want to delete this question?"))
            	{
                    showSurvey('question_process.php','showsurveys', 'event_id='+event_id+'&del_question='+id );
            	}
            }

function delete_comment(id,event_id)
            {

            	if (confirm("Are you sure you want to delete this comment?"))
            	{
                    shownav('comments.php','nav4', 'event_id='+event_id+'&del_comment='+id );
            	}
            }


var xmlHttp

function deleteQuestions(str)
{
if (str.length==0)
  {
  document.getElementById("showstatus").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="question_manager_show_question_ajax.php";
url=url+"?"+str;
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("showstatus").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//Ajax for adding questions
            var xmlHttp

            function addQuestions(str)
            {
            if (str.length==0)
              {
              document.getElementById("showstatus").innerHTML="";
              return;
              }
            xmlHttp=GetXmlHttpObject()
            if (xmlHttp==null)
              {
              alert ("Your browser does not support AJAX!");
              return;
              }
            var url="question_manager_show_question_ajax.php";
            url=url+"?"+str;
            //url=url+"&sid="+Math.random();
            xmlHttp.onreadystatechange=stateChanged;
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
            }

            function stateChanged()
            {
            if (xmlHttp.readyState==4)
            {
            document.getElementById("showstatus").innerHTML=xmlHttp.responseText;
            }
            }

            function GetXmlHttpObject()
            {
            var xmlHttp=null;
            try
              {
              // Firefox, Opera 8.0+, Safari
              xmlHttp=new XMLHttpRequest();
              }
            catch (e)
              {
              // Internet Explorer
              try
                {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                }
              catch (e)
                {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
              }
            return xmlHttp;
            }


//Ajax for showing survey
var xmlHttp

          function showSurvey(Url, loca, str)
          {
          var loca = loca;
          if (str.length==0)
            {
            document.getElementById(loca).innerHTML="";
            return;
            }
          xmlHttp=GetXmlHttpObject()
          if (xmlHttp==null)
            {
            alert ("Your browser does not support AJAX!");
            return;
            }
          var Locat = loca;
          var url=Url;
          url=url+"?"+str;
          //url=url+"&sid="+Math.random();
          if (loca == "showresults") {
          xmlHttp.onreadystatechange=stateChanged2;
          }
          else if (loca == "showsurveys") {
          xmlHttp.onreadystatechange=stateChanged3;
          }
          else if (loca == "nav4") {
          xmlHttp.onreadystatechange=stateChanged4;
          }
          xmlHttp.open("GET",url,true);
          xmlHttp.send(null);
          //document.getElementById("showresults").innerHTML=loca;
          }

          function stateChanged2(loca)
          {
          if (xmlHttp.readyState==4)
          {
          //document.getElementById(Locat).innerHTML=xmlHttp.responseText;
          document.getElementById("showresults").innerHTML=xmlHttp.responseText;
          }
          }

          function stateChanged3()
          {
          if (xmlHttp.readyState==4)
          {
          //document.getElementById(loca).innerHTML=xmlHttp.responseText;
          document.getElementById("showsurveys").innerHTML=xmlHttp.responseText;
          }
          }

          function GetXmlHttpObject()
          {
          var xmlHttp=null;
          try
            {
            // Firefox, Opera 8.0+, Safari
            xmlHttp=new XMLHttpRequest();
            }
          catch (e)
            {
            // Internet Explorer
            try
              {
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
              }
            catch (e)
              {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
            }
          return xmlHttp;
          }
//-->
