//Variable needed for all functions
var sectionMenu;   //This is the global AJAX handler

//***************************************MENU ONLY*************************************************************
//This function gets the edition and the section and sends that data to /misc/ajax/selector.php to scan the
//directory and compile the available page numbers into a dropdown.
function generatechoices(edition, section) {
  sectionMenu=GetXmlHttpObject()
  if (sectionMenu==null) {
    alert ("Browser does not support HTTP Request")
    return
  } 
  if (section == '') {
	document.getElementById("pages").innerHTML = 'none';
	return;
  }

  var url="/misc/ajax/previewselector.php?edition=" + edition + "&section=" + section;
  sectionMenu.onreadystatechange=menustateChanged;
  sectionMenu.open("GET",url,true);
  sectionMenu.send(null);
}

//Send the pagenumber dropdown generated from the function above back to the web page for display
function menustateChanged() { 
  if (sectionMenu.readyState==4 || sectionMenu.readyState=="complete") { 
    document.getElementById("pages").innerHTML=sectionMenu.responseText
  } 
}
//************************************************END MENU******************************************************

//*******************************************AJAX HANDLER******************************************************
function GetXmlHttpObject(handler) { 
  var objXMLHttp=null
  //This will work for all browsers except IE
  if (window.XMLHttpRequest) {
    objXMLHttp=new XMLHttpRequest()
  }
  //This is needed for I
  else if (window.ActiveXObject) {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
  return objXMLHttp
}
//**************************************************************************************************************