function buildText(){
   var parent = document.getElementById("placeholder");
   var form = document.createElement("form");
   form.setAttribute("method","get");
   form.setAttribute("action","http://bookweb.northoftheyarra.com.au/bookweb/catalog.cgi");
   /*create search button*/
   var search = document.createElement("button");
   search.id = "search";
   var buttonText = document.createTextNode("Search");
   search.appendChild(buttonText);
   if(isIE){
      search.attachEvent('onclick',submitForm);
   }
   form.appendChild(search);
   /*create input for search*/

   var stext = document.createElement("input");
   stext.setAttribute("type","hidden");
   stext.id = "STEXT";
   stext.name = "STEXT";
   stext.value = "EN";
   form.appendChild(stext);

   var stype = document.createElement("input");
   stype.setAttribute("type","hidden");
   stype.id = "STYPE";
   stype.name = "STYPE";
   stype.value = "SU";
   form.appendChild(stype);

   /*create subject search selector*/
   var selector = document.createElement("select");
   selector.id = "select1";

   for(var i=0;i<SubjectMenu.length;i++){
      var option = document.createElement("OPTION");
      var text = document.createTextNode(SubjectMenu[i][1]);
      if(i==0){
         option.selected = true;
      }
      option.value = SubjectMenu[i][0];
      option.appendChild(text);
      selector.appendChild(option);
   }   
   if(isIE){
      selector.attachEvent('onchange',myEvent);
   }
   else{
      selector.onchange = function handler(evt){drawNextGroup(evt.target.selectedIndex);}
   }
   form.appendChild(selector);
   parent.appendChild(form);
   document.getElementById("search").disabled=true;
   drawNextGroup(document.getElementById("select1").selectedIndex);
}

function myEvent(evt){
   drawNextGroup(evt.srcElement.selectedIndex);
}

function drawNextGroup(theIndex){
   var form=document.forms[0];
   var old1 = document.getElementById("select2");
   if(old1)form.removeChild(old1);   
   var selector2=createDropDown(theIndex);
   if(selector2){form.appendChild(selector2);
      updateInputs();
   }   
}

function getFirstIndex(theIndex){
   var tempArray = SubjectMenu[theIndex];
   var size = tempArray.length;
   for(var i=7;i<size; i++){
      if(tempArray[i]!="")
         break;
   }
   return i;
}

function createDropDown(theIndex){
   var tempArray = SubjectMenu[theIndex];
   var size = tempArray.length;
   var selector2 = document.createElement("select");
   selector2.id = "select2";

   var option = document.createElement("OPTION");
   var someText = DropDownText[0];
   var text = document.createTextNode(someText);
   option.value = SubjectMenu[theIndex][0];
   option.appendChild(text);
   selector2.appendChild(option);

   for(var i=indexStart;i<size;i++){
      if(tempArray[i]!=""){
         var option = document.createElement("OPTION");
         var someText = DropDownText[i];
         var text = document.createTextNode(someText);
         option.value = SubjectMenu[theIndex][i];
         option.appendChild(text);
         selector2.appendChild(option);
      }
   }
   if(isIE){
      selector2.attachEvent('onchange',updateInputs);
   }
   else{
      selector2.onchange = updateInputs;
   }
   return selector2;
}

function updateInputs(){
   if(document.getElementById("select2").value.length==2)
      document.getElementById("STYPE").value = "C";
   else
      document.getElementById("STYPE").value = "SU";
   document.getElementById("STEXT").value= document.getElementById("select2").value;
   document.getElementById("search").disabled=false;
}

function submitForm(){
   document.forms[0].submit();
}
