var brokenstring=new Array();
var subjectname=new Array();
var parentid=new Array();
var xmlhttp;

function starter() {}


function showlevel(thevalue)
{


       if (thevalue == "1" || thevalue == "2")
        {
			document.getElementById('formtype').value = "academicform";
 	       // if (document.all)
 	       // {
 	       //       document.all['academicform'].style.visibility="visible";  // Necessary only for IE4
	       //       document.all['academicform'].style.display="block";  // Necessary only for IE4

 	       //       document.all['nonacademicform'].style.visibility="invisible";  // Necessary only for IE4
               //       document.all['nonacademicform'].style.display="none";  // Necessary only for IE4
 	       // }
 	       // else
 	       // {
 	              document.getElementById('academicform').style.visibility = 'visible';
 	              document.getElementById('academicform').style.display = 'block';

     	              document.getElementById('nonacademicform').style.visibility = 'hidden';
 	              document.getElementById('nonacademicform').style.display = 'none';
		// 	        }

         }
        else
        {
			document.getElementById('formtype').value = "nonacademicform";
 	//        if (document.all)
 	 //       {
 	 //         document.all['academicform'].style.visibility="invisible";  // Necessary only for IE4
         //     document.all['academicform'].style.display="none";  // Necessary only for IE4

 	 //         document.all['nonacademicform'].style.visibility="visible";  // Necessary only for IE4
         //     document.all['nonacademicform'].style.display="block";  // Necessary only for IE4
 	 //       }
 	 //       else
 	 //       {
 	          document.getElementById('academicform').style.visibility = 'hidden';
 	          document.getElementById('academicform').style.display = 'none';

 	          document.getElementById('nonacademicform').style.visibility = 'visible';
 	          document.getElementById('nonacademicform').style.display = 'block';
 	 //       }

         }


 }


function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}





function buildlist(selectbox, str)
{

  brokenstring=str.split("|");
  brokenstring.pop();
  var breakpoint;


 //var theDropDown = document.getElementById("subject_list")
 var numberOfOptions = selectbox.options.length
 for (i=0; i<numberOfOptions; i++)
 {
    //Note: Always remove(0) and NOT remove(i)
    selectbox.remove(0)
 }



    addOption(selectbox,'select:', 'none');


  for (var count = 0 ; count < brokenstring.length ; count ++)
  {
    subjectname = brokenstring[count].split("#");
    addOption(selectbox,subjectname[1], subjectname[0]);
  }
}


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function get_list(selectbox , str)
{

    	xmlhttp=GetXmlHttpObject();

	var url="http://www.tutorhunt.com/gen-list.asp?qu="+str;
	xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4)
    {


	  buildlist(selectbox , xmlhttp.responseText);


    }
    }
	xmlhttp.open("GET",url,true);

    xmlhttp.send(null);

    //alert(brokenstring);

}
