function goBack(){
   window.location.href = window.history.go(-1);
}

function goUrl(url){
   var win = window.open("","main","toolbar=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes");
   win.location.href = url;
//   win.focus;
}

/*function viewRes(field, query, start, numMatch){
   mode = 1;
   resWindow = window.open("","Res","");
   resWindow.location.href="resQuery1.html";
   if (resWindow.opener==null) resWindow.opener = self;
   htmlResult1 = opener.document.searchApplet.search(field,query,start,numMatch);
   alert(htmlResult1);
   resWindow.setVariable(htmlResult1);
   alert(htmlResult);
   window.document.write(htmlResult);
   window.document.close();
      res.focus;
} */

function openSearch(){
   win = window.open("","Search","toolbar=no,status=no,resizable=yes,menubar=no,height=125,width=475");
   win.location.href="../search.html";
}

function openAbout(){
  leftPos = 0
  if (screen) {
      leftPos = (screen.width -550)/2;
  }
  win = window.open("","About","toolbar=no,resizable=yes,status=no,scrollbars=yes,menubar=no,width=550,height=600,left="+leftPos);
  win.location.href = "../about.html";
}

function openHelpSearch(){
   win = window.open("","main","toolbar=no,status=no,scrollbars=yes,menubar=no");
   win.window.location.href="helpSrch.html";
}

function openHelpPaper(){
   win = window.open("","HelpPaper","toolbar=no,status=no,scrollbars=yes,menubar=no");
   win.location.href="../helpPaper.html";
}


  function getFields(){
      if (document.searchForm.query.value != ''){
	   field = document.searchForm.fields.options[document.searchForm.fields.selectedIndex].text
	   query = document.searchForm.query.value
           //increment = document.searchForm.increment.options[document.searchForm.increment.selectedIndex].text
           increment = "All"
           startNum = document.searchForm.startNum.value
           getResult(field,query,startNum,increment);
      }
     else{ alert("Input a query");}
  }

  function getResult(field, query, startNum, increment){
        htmlResult = document.searchApplet.search(field,query,startNum,increment);
        leftPos = 0
	topPos = 0
        if (screen) {
           leftPos = (screen.width -450)/2;
           topPos = (screen.height -350)/2;
        }
	resWindow= window.open("","Res","scrollbars=yes,resizable=yes,toolbar=no,status=no,menubar=no,left="+leftPos + ",top=" + topPos);
    resWindow.location.href = "resQuery.html";
  }

  function getIt(){
      return htmlResult;
  }


  function goTrack(){
      //var track = document.trackForm.track.options[document.trackForm.track.selectedIndex].text;
      var numTrack = document.trackForm.track.selectedIndex+1;
      location.href = "track" + numTrack + ".html";
  }

  function goSession(){
      //var track = document.trackForm.track.options[document.trackForm.track.selectedIndex].text;
      var numSess = document.sessForm.sess.selectedIndex;
      location.href = "sess" + numSess + ".html";
  }


  function Keyword(){
      this.key = new Array(arguments[0])
      this.keyId = new Array(arguments[0])
      this.numKeys = 0
      this.addkeyItem = addkeyItem
      this.showKey = showKey
  }

  function stripSpace(key){
      if (key.charAt(0)==' ')
	  key.substr(1)
      else return key
  }
				
  function addkeyItem(){
      var i = this.numKeys
      this.key[i] = stripSpace(arguments[0])
      this.keyId[i] = arguments[1]
      this.numKeys += 1
  }

  function showKey(){
      if (this.numKeys>0){
	  var txt = ''
	  for (var i=0; i<this.numKeys; i++){
	     var find = 0;
	     for (var j=i+1; j<this.key.length;j++){
		if (this.key[i]==this.key[j]) find = 1
	     }

	     if (!find)  txt += "<a href=../key/" + this.keyId[i] + ".html class=elem-ref>" + this.key[i] + "</a>, " 

	  }
	  document.write(txt.substring(0,txt.length-2));
     }
 }

 /*   function openftWindow(url){
     leftPos = 0
     topPos = 0
     if (screen){
        leftPos = (screen.width-200)/2;
	topPos = (screen.height-100)/2;
     }
     ftWindow= window.open(url,"Ftnote","toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=yes,width=200, height=100,left="+leftPos+",top="+topPos);
     ftWindow.focus()
  }*/
				
  function closeftWindow(){
     if (ftWindow) ftWindow.close()
  }

  /*function onRightButton(e){

    if (document.layers &amp;&amp; (e.which == 3 || e.which ==2))
	openToc();
    else if (document.all &amp;&amp; (event.button == 2 || event.button ==3)){ 
        openToc();
    }
    return true;
  }*/
				
  function openToc(id){
     leftPos = 0
     topPos = 0
     if (screen) {
         leftPos = (screen.width -625)/2;
         topPos = (screen.height -250)/2;
     }
     popupWindow = window.open("","toc","toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=yes,height=250,width=625,left="+leftPos+",top="+topPos);
     popupWindow.location.href="../toc/" + id + ".html"
     //popupWindow.focus()
  }
		
