// ------------------------------------------
// Functions to display encyclopadia (glossary) items in x-raymicroanalysis.com
// S H Vale October 2004
// Revision 1
// (c) SH VALE 2004
// ------------------------------------------

// Array of Record objects containing information about each glossary entry

record = new Array();

record[ 0]=new Record("Backscattered electron detector","Introduction", 29, 1);
record[ 1]=new Record("Backscattered electron detector","Scintillator", 29, 2);
record[ 2]=new Record("Backscattered electron detector","Solid state detector", 29, 3);
record[ 3]=new Record("Backscattered electron emission","Introduction", 38, 1);
record[ 4]=new Record("Backscattered electron emission","Atomic number dependence ", 38, 2);
record[ 5]=new Record("Backscattered electron emission","Tilt dependence", 38, 3);
record[ 6]=new Record("Braggs law","Introduction", 15, 1);
record[ 7]=new Record("Braggs law","Interference types", 15, 2);
record[ 8]=new Record("Collimator","Introduction", 16, 1);
record[ 9]=new Record("Collimator","Apertures", 16, 2);
record[ 10]=new Record("Comparison of EDX and WDX","Comparison chart", 49, 1);
record[ 11]=new Record("Digital imaging","Introduction", 1, 1);
record[ 12]=new Record("Digital imaging","Image resolution", 1, 2);
record[ 13]=new Record("EDS components","Introduction", 18, 1);
record[ 14]=new Record("EDS components","Liquid nitrogen level sensor", 18, 11);
record[ 15]=new Record("EDS components","Slide arrangement", 18, 12);
record[ 16]=new Record("EDS components","Pre-amplifier", 18, 13);
record[ 17]=new Record("EDS components","Crystal-FET package", 18, 14);
record[ 18]=new Record("EDS components","Cold finger", 18, 15);
record[ 19]=new Record("EDS components","Window", 18, 16);
record[ 20]=new Record("EDS components","Dewar", 18, 17);
record[ 21]=new Record("EDS components","Electron trap and collimator", 18, 18);
record[ 22]=new Record("EDS detector performance","Crystals", 33, 1);
record[ 23]=new Record("EDS detector performance","Detector resolution", 33, 2);
record[ 24]=new Record("EDS detector performance","Process time", 33, 3);
record[ 25]=new Record("EDS detector performance","Si(Li) crystal detector", 33, 4);
record[ 26]=new Record("EDS detector performance","ISO 15632:2002", 33, 5);
record[ 27]=new Record("Elastic and inelastic scattering","Introduction", 20, 1);
record[ 28]=new Record("Elastic and inelastic scattering","Elastic scattering", 20, 2);
record[ 29]=new Record("Elastic and inelastic scattering","Inelastic scattering", 20, 3);
record[ 30]=new Record("Electromagnetic lenses","Introduction", 30, 1);
record[ 31]=new Record("Electromagnetic lenses","Magnetic lens", 30, 2);
record[ 32]=new Record("Electromagnetic lenses","Condensor lens", 30, 3);
record[ 33]=new Record("Electromagnetic lenses","Objective lens", 30, 4);
record[ 34]=new Record("Electromagnetic lenses","Real and virtual objective apertures", 30, 5);
record[ 35]=new Record("Electron focussing","Introduction", 23, 1);
record[ 36]=new Record("Electron focussing","Electron motion in a magnetic field", 23, 2);
record[ 37]=new Record("Electron focussing","Focusing action", 23, 3);
record[ 38]=new Record("Electron gun","Introduction", 2, 1);
record[ 39]=new Record("Electron gun","Components", 2, 2);
record[ 40]=new Record("Electron gun","Saturation", 2, 3);
record[ 41]=new Record("Electron gun","Tungsten hairpin electron gun", 2, 4);
record[ 42]=new Record("Electron gun","Crossover", 2, 21);
record[ 43]=new Record("Electron gun","High voltage", 2, 22);
record[ 44]=new Record("Electron gun","Anode", 2, 23);
record[ 45]=new Record("Electron gun","Wehnault cylinder", 2, 24);
record[ 46]=new Record("Electron gun","Brightness", 2, 25);
record[ 47]=new Record("Electron gun","Filaments", 2, 26);
record[ 48]=new Record("Electron gun","Lanthanum hexaboride electron gun", 2, 41);
record[ 49]=new Record("Electron gun","Field emission electron gun", 2, 42);
record[ 50]=new Record("Electron hole pairs","Introduction", 17, 1);
record[ 51]=new Record("Electron traps","Introduction", 32, 1);
record[ 52]=new Record("Electron traps","Effect on X-ray spectrum", 32, 2);
record[ 53]=new Record("Geometry","Sample orientation", 3, 11);
record[ 54]=new Record("Geometry","Elevation", 3, 12);
record[ 55]=new Record("Geometry","Azimuth", 3, 13);
record[ 56]=new Record("Geometry","Tilt", 3, 14);
record[ 57]=new Record("Geometry","Sample position", 3, 21);
record[ 58]=new Record("Geometry","Working distance", 3, 22);
record[ 59]=new Record("Geometry","Detector entrance angle", 3, 23);
record[ 60]=new Record("INCA software","Analyzer", 70, 1);
record[ 61]=new Record("INCA software","Automate", 70, 2);
record[ 62]=new Record("INCA software","Cameo+", 70, 3);
record[ 63]=new Record("INCA software","Feature", 70, 4);
record[ 64]=new Record("INCA software","PhaseMap", 70, 5);
record[ 65]=new Record("INCA software","Point & ID", 70, 6);
record[ 66]=new Record("INCA software","SmartMap", 70, 7);
record[ 67]=new Record("INCA software","Wave", 70, 8);
record[ 68]=new Record("Interaction volume","Introduction", 4, 1);
record[ 69]=new Record("Interaction volume","Monte carlo simulation", 4, 2);
record[ 70]=new Record("Interaction volume","X-ray production volume", 4, 4);
record[ 71]=new Record("Interaction volume","X-ray production volume simulation", 4, 5);
record[ 72]=new Record("Matrix corrections","Introduction", 45, 1);
record[ 73]=new Record("Matrix corrections","Electron interaction and X-ray production volumes", 45, 2);
record[ 74]=new Record("Matrix corrections","Atomic number and Fluorescence correction", 45, 3);
record[ 75]=new Record("Matrix corrections","Absorption effect ", 45, 4);
record[ 76]=new Record("Measurement units","Introduction", 12, 1);
record[ 77]=new Record("Microanalysis","Introduction", 40, 1);
record[ 78]=new Record("Resolving power wavelengths","Introduction", 21, 1);
record[ 79]=new Record("Sample charging","Charge build up", 9, 1);
record[ 80]=new Record("Sample charging","Image distortion", 9, 2);
record[ 81]=new Record("Sample charging","Methods of charge reduction", 9, 3);
record[ 82]=new Record("Sample charging","Effects on microanalysis", 9, 4);
record[ 83]=new Record("Sample preparation","Polished sample", 41, 1);
record[ 84]=new Record("Sample preparation","Unpolished sample", 41, 2);
record[ 85]=new Record("Sample preparation","Coating", 41, 3);
record[ 86]=new Record("Scan coils and rastering","Introduction", 8, 1);
record[ 87]=new Record("Scan coils and rastering","Operation of scanning coils", 8, 2);
record[ 88]=new Record("Scan coils and rastering","Full area rastering", 8, 3);
record[ 89]=new Record("Scan coils and rastering","Line scanning", 8, 4);
record[ 90]=new Record("Scan coils and rastering","Spot mode", 8, 5);
record[ 91]=new Record("Scan coils and rastering","Magnification", 8, 6);
record[ 92]=new Record("Scanning electron microscope","Introduction", 48, 1);
record[ 93]=new Record("Secondary electron detector","Introduction", 13, 2);
record[ 94]=new Record("Secondary electron emission","Introduction", 39, 1);
record[ 95]=new Record("Secondary electron emission","Escape depth of secondary electrons", 39, 2);
record[ 96]=new Record("Secondary electron emission","Contrast in secondary electron images", 39, 3);
record[ 97]=new Record("Secondary electron emission","Topographical contrast in secondary electron images", 39, 4);
record[ 98]=new Record("Spectrum artefacts","Introduction", 59, 1);
record[ 99]=new Record("Spectrum artefacts","Escape peaks", 59, 2);
record[ 100]=new Record("Spectrum artefacts","Pile up peaks", 59, 3);
record[ 101]=new Record("Spectrum processing","Introduction", 44, 1);
record[ 102]=new Record("Spectrum processing","Form of background", 44, 2);
record[ 103]=new Record("Spectrum processing","Digital filtering", 44, 3);
record[ 104]=new Record("Spectrum processing","Interactive digital filter", 44, 4);
record[ 105]=new Record("Spectrum processing","Mathematical modelling", 44, 5);
record[ 106]=new Record("Spectrum processing","Peak deconvolution", 44, 6);
record[ 107]=new Record("Transmission electron microscope","Introduction", 61, 1);
record[ 108]=new Record("Types of signals","Introduction", 31, 1);
record[ 109]=new Record("Types of signals","Auger", 31, 2);
record[ 110]=new Record("Types of signals","Cathodoluminescence", 31, 3);
record[ 111]=new Record("Types of signals","Secondary electrons", 31, 4);
record[ 112]=new Record("Types of signals","Backscattered electrons", 31, 5);
record[ 113]=new Record("Types of signals","Characteristic X-rays", 31, 6);
record[ 114]=new Record("Types of signals","Continuous X-ray emission", 31, 7);
record[ 115]=new Record("WDS components","Introduction", 22, 1);
record[ 116]=new Record("WDS components","Diagram", 22, 21);
record[ 117]=new Record("WDS components","Spectrometer", 22, 22);
record[ 118]=new Record("WDS components","Entrance slit", 22, 23);
record[ 119]=new Record("WDS components","Detector", 22, 24);
record[ 120]=new Record("WDS components","Counting electronics", 22, 25);
record[ 121]=new Record("WDS crystals","Introduction", 50, 1);
record[ 122]=new Record("WDX Techniques","Pulse height distribution", 63, 1);
record[ 123]=new Record("WDX Techniques","Defocusing", 63, 3);
record[ 124]=new Record("WDX Techniques","Peak shifts and peak shape changes", 63, 4);
record[ 125]=new Record("WDX Techniques","Satellite lines", 63, 5);
record[ 126]=new Record("Window materials","Introduction", 51, 1);
record[ 127]=new Record("Window materials","Window development", 51, 2);
record[ 128]=new Record("Window materials","Thin film windows", 51, 3);
record[ 129]=new Record("Working distance","Introduction", 10, 1);
record[ 130]=new Record("X-ray generation","Introduction", 11, 1);
record[ 131]=new Record("X-ray generation","Characteristic X-ray emmision", 11, 2);
record[ 132]=new Record("X-ray generation","Continuum X-ray generation", 11, 3);
record[ 133]=new Record("X-ray generation","Atomic structure and energy levels", 11, 4);
record[ 134]=new Record("X-ray generation","Auger emission", 11, 5);

// Constructor for object Record
// section : name of the section
// item : name of the item in this section
// sectionref : index number for this section
// itemref : index number for this item

function Record(section,item,sectionref,itemref){
  this.section = section;
  this.item = item;
  this.sectionref = sectionref;
  this.itemref = itemref;
}

// -------------------------------------------------------------
// Create a list of the glossary sections in the a select object
// sel : select object to create sections in

function createSectionList(sel){
  j=0;
  lastsection="";
  for(i=0;i<record.length;i++){
    if(record[i].section!=lastsection){
      sel.options[j++]=new Option(record[i].section,record[i].sectionref);
      lastsection=record[i].section;
    }
  }
  return true;
}

// -------------------------------------------------------------
//Create a list of the items in a particular section in a select object
// sel : select object to create list in
// sectionref : index to section required
// itemref (optional) : item selected in the list

function createItemList(sel,sectionref,itemref){
  sellength=sel.length;
  //Keep clearing first option because setting options[] to null re-sorts list
  for (i=0;i<sellength;i++){
    sel.options[0]=null;
  }
  j=0;
  for(i=0;i<record.length;i++){
    if(record[i].sectionref==sectionref){
      sel.options[j++]=new Option(record[i].item,record[i].itemref);
    }
  }
  if(itemref!=null){
    for(i=0;i<sel.length;i++){
      if(itemref==sel.options[i].value){
        sel.selectedIndex=i;
        break;
      }
    }
  }
  return true;
}

// -------------------------------------------------------------
//Show the page itemref in the section sectionref
// Show a glossary page
// sectionref : index to section to view
// itemref : index to item in section sectioref to view
// optional - frame : boolean, if true in the current frameset, otherwise open a new window (DEFAULT)

function showGlossaryPage(sectionref,itemref,frame){
  if (sectionref<10){
    strdir = "0"+sectionref;
  }else{
    strdir = sectionref;
  }
  section = getSectionName(sectionref);
  strhtmlpage = "../../Expansions/"+strdir+" "+section+"/Final pages/Sfm/SFM"+strdir+"_"+itemref+".htm";
  if((frame==null) || !frame){
    newwin(strhtmlpage,"glossary",640,550,true);
  }else{
    parent.location.href=strhtmlpage;    
  }
  return;
}

// -------------------------------------------------------------
//Return the glossary section reference for the current document from the name of the parent frames page.

function getSection(){
	ind=indSFM();
      sectionref = parseInt(strloc.substring(ind,ind+2),10);  //base 10 explicitly because number sometimes starts with 0!
      return sectionref;
}
// -------------------------------------------------------------
//Return the item reference for the current document from the name of the parent frames page.
//File name format is ss_ii.htm

function getItem(){
	ind=indSFM();
	strloc=parent.location.href;
	itemref=parseInt(strloc.substring(ind+3,strloc.indexOf(".htm")),10);
	return itemref;
}

// -------------------------------------------------------------
//Return index into document location string where section number starts

function indSFM(){
	strloc = parent.location.href.toUpperCase();
      strsfm = "/SFM/SFM";
      ind = strloc.indexOf(strsfm);
      return ind+strsfm.length
}

// -------------------------------------------------------------
//Return the name of the section sectionref

function getSectionName(sectionref){
  for (i=0;i<record.length;i++){
    if(record[i].sectionref==sectionref){
      section=record[i].section;
      break;
    }
  }
  return section;
}

// -------------------------------------------------------------
//Return the name of the item itemref in the section sectionref

function getItemName(sectionref,itemref){
  for (i=0;i<record.length;i++){
    if( (record[i].sectionref==sectionref)&&(record[i].itemref==itemref) ){
      itemname=record[i].item;  //Note it did not like just using item as the variable name here.
      break;
    }
  }
  return itemname;
}

//NOT USED
function writeFrames(){
  document.write("<frameset rows='94,100%' cols='*' frameborder='NO' border='0'>")
    document.write("<frame src='../../../PS/Sel.htm' name='Page Select' scrolling='NO' frameborder='NO' noresize>")
    document.write("<frameset cols='336,100%' rows='*' frameborder='NO' border='0'>")
      document.write("<frame src='../Pm/PM01_1.htm' name='Pics_Mov' scrolling='NO' noresize>")
      document.write("<frame src='../T/TXT01_1.htm' name='Text' scrolling='AUTO'>")           
    document.write("</frameset>")
  document.write("</frameset>")
}