// debug alerts through # 10

var checkboxToDebugScripts = false; // false for public release
var debugAllScripts = false; // false for public release

// top.js - top level js. Parsing of molecule specified in ?mol=
// and decision tree for action, depending on configuration specified
// in config.js. Getting pixel dimensions for Jmol from window size.

// Note: variables that depend on server configuration are
// defined in config.js

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
var fgijVersion = "0.991";

// usingFrames is defined in fg.htm etc.

var usingSignedApplet = false;
var usingCIF = false;
var debuggingFG = false;

// modes: nf = no frames; f = frames; r = rcsb mock up.
var fgijMode = "nf"; 

var isServed = (document.location.href.indexOf("http://") == 0);

var currentView = "cartoonSpt"; 


// CHECKBOX MODIFICATIONS OF VIEWS
var showNonStandardResidues = false;
var starNonStandardResidues = true;

var waterIsSmall = false;
var ligandIsSmall = false;
var allWireframe = false;
var sidechainsVisible = true;
var hydrogensVisible = true; // for Vines

var hideMode = ""; // none, c (chain), g (group), a (atom)
var lastHideMode = "";
var hiddenChains = new Array();
var hiddenGroups = new Array();
var hiddenAtoms = new Array();

var hideProtein = false;
var hideDNA = false;
var hideRNA = false;
var hideCarbohydrate = false;
var hideHydrogen = false;

var selectMode = ""; // blank, c, g, a (same as hideMode)
var selectedChains = new Array();
var selectedGroups = new Array();
var selectedAtoms = new Array();
var selectedFound = "";
var selectedRanges = new Array();
var selectedRangeStart = "";
var selectedWater = false;

var axesOn = false;
var unitcellOn = false;
var boundboxOn = false;

var slabThickness = "10";
var toFind = "";

var forceBackgroundBlack = false;
var contactsShowing = false;
var markContactsTargets = false;
var backboneContacts = true;
var labelContacts = false;
var hydrogensContacts = false;

var targetSF = true;
var targetCPK = false;
var contactingSF = true;
var contactingCPK = false;
var contactsRadioViews = false;

var showContactsHBonds = true; // hbonds + metal bonds
var showContactsMeMi   = true; // metals + misc
var showContactsHphob  = true; // hydrophobic
var showContactsSB     = true; // salt bridges
var showContactsCatPi  = true; // cation pi interactions
var showContactsSticks = true;
var showContactsWater  = true;
var showWaterBridges   = true;

var preContactsView = "sf";
var preContactsWater = false;

var showCatPi = false; // false shows salt bridges
var colorCatPiSBChain = false;
var showCatPiSBBackbones = true;

var showAnomalous = true;
var anomalousDots = true;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//variables for buttons for A, P, E site tRNA Nt Selector in Help
//The A site tRNA variables
var trnabuttona1 = true; 
var trnabuttona2 = true; 
var trnabuttona3 = true; 
var trnabuttona4 = true; 
var trnabuttona5 = true; 
var trnabuttona6 = true; 
var trnabuttona7 = true; 
var trnabuttona8 = true; 
var trnabuttona9 = true; 
var trnabuttona10 = true; 
var trnabuttona11 = true; 
var trnabuttona12 = true; 
var trnabuttona13 = true; 
var trnabuttona14 = true; 
var trnabuttona15 = true; 
var trnabuttona16 = true; 
var trnabuttona17 = true; 
var trnabuttona18 = true; 
var trnabuttona19 = true; 
var trnabuttona20 = true; 
var trnabuttona21 = true; 
var trnabuttona22 = true; 
var trnabuttona23 = true; 
var trnabuttona24 = true; 
var trnabuttona25 = true; 
var trnabuttona26 = true; 
var trnabuttona27 = true; 
var trnabuttona28 = true; 
var trnabuttona29 = true; 
var trnabuttona30 = true; 
var trnabuttona31 = true; 
var trnabuttona32 = true; 
var trnabuttona33 = true; 
var trnabuttona34 = true; 
var trnabuttona35 = true; 
var trnabuttona36 = true; 
var trnabuttona37 = true; 
var trnabuttona38 = true; 
var trnabuttona39 = true; 
var trnabuttona40 = true; 
var trnabuttona41 = true; 
var trnabuttona42 = true; 
var trnabuttona43 = true; 
var trnabuttona44 = true; 
var trnabuttona45 = true; 
var trnabuttona46 = true; 
var trnabuttona47 = true; 
var trnabuttona48 = true; 
var trnabuttona49 = true; 
var trnabuttona50 = true; 
var trnabuttona51 = true; 
var trnabuttona52 = true; 
var trnabuttona53 = true; 
var trnabuttona54 = true; 
var trnabuttona55 = true; 
var trnabuttona56 = true; 
var trnabuttona57 = true; 
var trnabuttona58 = true; 
var trnabuttona59 = true; 
var trnabuttona60 = true; 
var trnabuttona61 = true; 
var trnabuttona62 = true; 
var trnabuttona63 = true; 
var trnabuttona64 = true; 
var trnabuttona65 = true; 
var trnabuttona66 = true; 
var trnabuttona67 = true; 
var trnabuttona68 = true; 
var trnabuttona69 = true; 
var trnabuttona70 = true; 
var trnabuttona71 = true; 
var trnabuttona72 = true; 
var trnabuttona73 = true; 
var trnabuttona74 = true; 
var trnabuttona75 = true; 
var trnabuttona76 = true; 
//P site tRNA variables
var trnabuttonp1 = true; 
var trnabuttonp2 = true; 
var trnabuttonp3 = true; 
var trnabuttonp4 = true; 
var trnabuttonp5 = true; 
var trnabuttonp6 = true; 
var trnabuttonp7 = true; 
var trnabuttonp8 = true; 
var trnabuttonp9 = true; 
var trnabuttonp10 = true; 
var trnabuttonp11 = true; 
var trnabuttonp12 = true; 
var trnabuttonp13 = true; 
var trnabuttonp14 = true; 
var trnabuttonp15 = true; 
var trnabuttonp16 = true; 
var trnabuttonp17 = true; 
var trnabuttonp18 = true; 
var trnabuttonp19 = true; 
var trnabuttonp20 = true; 
var trnabuttonp21 = true; 
var trnabuttonp22 = true; 
var trnabuttonp23 = true; 
var trnabuttonp24 = true; 
var trnabuttonp25 = true; 
var trnabuttonp26 = true; 
var trnabuttonp27 = true; 
var trnabuttonp28 = true; 
var trnabuttonp29 = true; 
var trnabuttonp30 = true; 
var trnabuttonp31 = true; 
var trnabuttonp32 = true; 
var trnabuttonp33 = true; 
var trnabuttonp34 = true; 
var trnabuttonp35 = true; 
var trnabuttonp36 = true; 
var trnabuttonp37 = true; 
var trnabuttonp38 = true; 
var trnabuttonp39 = true; 
var trnabuttonp40 = true; 
var trnabuttonp41 = true; 
var trnabuttonp42 = true; 
var trnabuttonp43 = true; 
var trnabuttonp44 = true; 
var trnabuttonp45 = true; 
var trnabuttonp46 = true; 
var trnabuttonp47 = true; 
var trnabuttonp48 = true; 
var trnabuttonp49 = true; 
var trnabuttonp50 = true; 
var trnabuttonp51 = true; 
var trnabuttonp52 = true; 
var trnabuttonp53 = true; 
var trnabuttonp54 = true; 
var trnabuttonp55 = true; 
var trnabuttonp56 = true; 
var trnabuttonp57 = true; 
var trnabuttonp58 = true; 
var trnabuttonp59 = true; 
var trnabuttonp60 = true; 
var trnabuttonp61 = true; 
var trnabuttonp62 = true; 
var trnabuttonp63 = true; 
var trnabuttonp64 = true; 
var trnabuttonp65 = true; 
var trnabuttonp66 = true; 
var trnabuttonp67 = true; 
var trnabuttonp68 = true; 
var trnabuttonp69 = true; 
var trnabuttonp70 = true; 
var trnabuttonp71 = true; 
var trnabuttonp72 = true; 
var trnabuttonp73 = true; 
var trnabuttonp74 = true; 
var trnabuttonp75 = true; 
var trnabuttonp76 = true; 
//E site tRNA variables
var trnabuttone1 = true; 
var trnabuttone2 = true; 
var trnabuttone3 = true; 
var trnabuttone4 = true; 
var trnabuttone5 = true; 
var trnabuttone6 = true; 
var trnabuttone7 = true; 
var trnabuttone8 = true; 
var trnabuttone9 = true; 
var trnabuttone10 = true; 
var trnabuttone11 = true; 
var trnabuttone12 = true; 
var trnabuttone13 = true; 
var trnabuttone14 = true; 
var trnabuttone15 = true; 
var trnabuttone16 = true; 
var trnabuttone17 = true; 
var trnabuttone18 = true; 
var trnabuttone19 = true; 
var trnabuttone20 = true; 
var trnabuttone21 = true; 
var trnabuttone22 = true; 
var trnabuttone23 = true; 
var trnabuttone24 = true; 
var trnabuttone25 = true; 
var trnabuttone26 = true; 
var trnabuttone27 = true; 
var trnabuttone28 = true; 
var trnabuttone29 = true; 
var trnabuttone30 = true; 
var trnabuttone31 = true; 
var trnabuttone32 = true; 
var trnabuttone33 = true; 
var trnabuttone34 = true; 
var trnabuttone35 = true; 
var trnabuttone36 = true; 
var trnabuttone37 = true; 
var trnabuttone38 = true; 
var trnabuttone39 = true; 
var trnabuttone40 = true; 
var trnabuttone41 = true; 
var trnabuttone42 = true; 
var trnabuttone43 = true; 
var trnabuttone44 = true; 
var trnabuttone45 = true; 
var trnabuttone46 = true; 
var trnabuttone47 = true; 
var trnabuttone48 = true; 
var trnabuttone49 = true; 
var trnabuttone50 = true; 
var trnabuttone51 = true; 
var trnabuttone52 = true; 
var trnabuttone53 = true; 
var trnabuttone54 = true; 
var trnabuttone55 = true; 
var trnabuttone56 = true; 
var trnabuttone57 = true; 
var trnabuttone58 = true; 
var trnabuttone59 = true; 
var trnabuttone60 = true; 
var trnabuttone61 = true; 
var trnabuttone62 = true; 
var trnabuttone63 = true; 
var trnabuttone64 = true; 
var trnabuttone65 = true; 
var trnabuttone66 = true; 
var trnabuttone67 = true; 
var trnabuttone68 = true; 
var trnabuttone69 = true; 
var trnabuttone70 = true; 
var trnabuttone71 = true; 
var trnabuttone72 = true; 
var trnabuttone73 = true; 
var trnabuttone74 = true; 
var trnabuttone75 = true; 
var trnabuttone76 = true; 




//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//The A site toggles for tRNAs in HElp
function toggletrnaa1 () 
{
   if (trnabuttona1)
   { 
    trnabuttona1= false;
    scriptToJmol("select 1:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona1= true;
    scriptToJmol("select 1:b and model=2; spacefill off;");
    }
}
function toggletrnaa2 () 
{
   if (trnabuttona2)
   { 
    trnabuttona2= false;
    scriptToJmol("select 2:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona2= true;
    scriptToJmol("select 2:b and model=2; spacefill off;");
    }
}
function toggletrnaa3 () 
{
   if (trnabuttona3)
   { 
    trnabuttona3= false;
    scriptToJmol("select 3:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona3= true;
    scriptToJmol("select 3:b and model=2; spacefill off;");
    }
}
function toggletrnaa4 () 
{
   if (trnabuttona4)
   { 
    trnabuttona4= false;
    scriptToJmol("select 4:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona4= true;
    scriptToJmol("select 4:b and model=2; spacefill off;");
    }
}
function toggletrnaa5 () 
{
   if (trnabuttona5)
   { 
    trnabuttona5= false;
    scriptToJmol("select 5:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona5= true;
    scriptToJmol("select 5:b and model=2; spacefill off;");
    }
}
function toggletrnaa6 () 
{
   if (trnabuttona6)
   { 
    trnabuttona6= false;
    scriptToJmol("select 6:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona6= true;
    scriptToJmol("select 6:b and model=2; spacefill off;");
    }
}
function toggletrnaa7 () 
{
   if (trnabuttona7)
   { 
    trnabuttona7= false;
    scriptToJmol("select 7:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona7= true;
    scriptToJmol("select 7:b and model=2; spacefill off;");
    }
}
function toggletrnaa8 () 
{
   if (trnabuttona8)
   { 
    trnabuttona8= false;
    scriptToJmol("select 8:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona8= true;
    scriptToJmol("select 8:b and model=2; spacefill off;");
    }
}
function toggletrnaa9 () 
{
   if (trnabuttona9)
   { 
    trnabuttona9= false;
    scriptToJmol("select 9:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona9= true;
    scriptToJmol("select 9:b and model=2; spacefill off;");
    }
}
function toggletrnaa10 () 
{
   if (trnabuttona10)
   { 
    trnabuttona10= false;
    scriptToJmol("select 10:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona10= true;
    scriptToJmol("select 10:b and model=2; spacefill off;");
    }
}
function toggletrnaa11 () 
{
   if (trnabuttona11)
   { 
    trnabuttona11= false;
    scriptToJmol("select 11:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona11= true;
    scriptToJmol("select 11:b and model=2; spacefill off;");
    }
}
function toggletrnaa12 () 
{
   if (trnabuttona12)
   { 
    trnabuttona12= false;
    scriptToJmol("select 12:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona12= true;
    scriptToJmol("select 12:b and model=2; spacefill off;");
    }
}
function toggletrnaa13 () 
{
   if (trnabuttona13)
   { 
    trnabuttona13= false;
    scriptToJmol("select 13:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona13= true;
    scriptToJmol("select 13:b and model=2; spacefill off;");
    }
}
function toggletrnaa14 () 
{
   if (trnabuttona14)
   { 
    trnabuttona14= false;
    scriptToJmol("select 14:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona14= true;
    scriptToJmol("select 14:b and model=2; spacefill off;");
    }
}
function toggletrnaa15 () 
{
   if (trnabuttona15)
   { 
    trnabuttona15= false;
    scriptToJmol("select 15:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona15= true;
    scriptToJmol("select 15:b and model=2; spacefill off;");
    }
}
function toggletrnaa16 () 
{
   if (trnabuttona16)
   { 
    trnabuttona16= false;
    scriptToJmol("select 16:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona16= true;
    scriptToJmol("select 16:b and model=2; spacefill off;");
    }
}
function toggletrnaa17 () 
{
   if (trnabuttona17)
   { 
    trnabuttona17= false;
    scriptToJmol("select 17:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona17= true;
    scriptToJmol("select 17:b and model=2; spacefill off;");
    }
}
function toggletrnaa18 () 
{
   if (trnabuttona18)
   { 
    trnabuttona18= false;
    scriptToJmol("select 18:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona18= true;
    scriptToJmol("select 18:b and model=2; spacefill off;");
    }
}
function toggletrnaa19 () 
{
   if (trnabuttona19)
   { 
    trnabuttona19= false;
    scriptToJmol("select 19:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona19= true;
    scriptToJmol("select 19:b and model=2; spacefill off;");
    }
}
function toggletrnaa20 () 
{
   if (trnabuttona20)
   { 
    trnabuttona20= false;
    scriptToJmol("select 20:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona20= true;
    scriptToJmol("select 20:b and model=2; spacefill off;");
    }
}
function toggletrnaa21 () 
{
   if (trnabuttona21)
   { 
    trnabuttona21= false;
    scriptToJmol("select 21:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona21= true;
    scriptToJmol("select 21:b and model=2; spacefill off;");
    }
}
function toggletrnaa22 () 
{
   if (trnabuttona22)
   { 
    trnabuttona22= false;
    scriptToJmol("select 22:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona22= true;
    scriptToJmol("select 22:b and model=2; spacefill off;");
    }
}
function toggletrnaa23 () 
{
   if (trnabuttona23)
   { 
    trnabuttona23= false;
    scriptToJmol("select 23:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona23= true;
    scriptToJmol("select 23:b and model=2; spacefill off;");
    }
}
function toggletrnaa24 () 
{
   if (trnabuttona24)
   { 
    trnabuttona24= false;
    scriptToJmol("select 24:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona24= true;
    scriptToJmol("select 24:b and model=2; spacefill off;");
    }
}
function toggletrnaa25 () 
{
   if (trnabuttona25)
   { 
    trnabuttona25= false;
    scriptToJmol("select 25:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona25= true;
    scriptToJmol("select 25:b and model=2; spacefill off;");
    }
}
function toggletrnaa26 () 
{
   if (trnabuttona26)
   { 
    trnabuttona26= false;
    scriptToJmol("select 26:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona26= true;
    scriptToJmol("select 26:b and model=2; spacefill off;");
    }
}
function toggletrnaa27 () 
{
   if (trnabuttona27)
   { 
    trnabuttona27= false;
    scriptToJmol("select 27:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona27= true;
    scriptToJmol("select 27:b and model=2; spacefill off;");
    }
}
function toggletrnaa28 () 
{
   if (trnabuttona28)
   { 
    trnabuttona28= false;
    scriptToJmol("select 28:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona28= true;
    scriptToJmol("select 28:b and model=2; spacefill off;");
    }
}
function toggletrnaa29 () 
{
   if (trnabuttona29)
   { 
    trnabuttona29= false;
    scriptToJmol("select 29:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona29= true;
    scriptToJmol("select 29:b and model=2; spacefill off;");
    }
}
function toggletrnaa30 () 
{
   if (trnabuttona30)
   { 
    trnabuttona30= false;
    scriptToJmol("select 30:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona30= true;
    scriptToJmol("select 30:b and model=2; spacefill off;");
    }
}
function toggletrnaa31 () 
{
   if (trnabuttona31)
   { 
    trnabuttona31= false;
    scriptToJmol("select 31:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona31= true;
    scriptToJmol("select 31:b and model=2; spacefill off;");
    }
}
function toggletrnaa32 () 
{
   if (trnabuttona32)
   { 
    trnabuttona32= false;
    scriptToJmol("select 32:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona32= true;
    scriptToJmol("select 32:b and model=2; spacefill off;");
    }
}
function toggletrnaa33 () 
{
   if (trnabuttona33)
   { 
    trnabuttona33= false;
    scriptToJmol("select 33:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona33= true;
    scriptToJmol("select 33:b and model=2; spacefill off;");
    }
}
function toggletrnaa34 () 
{
   if (trnabuttona34)
   { 
    trnabuttona34= false;
    scriptToJmol("select 34:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona34= true;
    scriptToJmol("select 34:b and model=2; spacefill off;");
    }
}
function toggletrnaa35 () 
{
   if (trnabuttona35)
   { 
    trnabuttona35= false;
    scriptToJmol("select 35:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona35= true;
    scriptToJmol("select 35:b and model=2; spacefill off;");
    }
}
function toggletrnaa36 () 
{
   if (trnabuttona36)
   { 
    trnabuttona36= false;
    scriptToJmol("select 36:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona36= true;
    scriptToJmol("select 36:b and model=2; spacefill off;");
    }
}
function toggletrnaa37 () 
{
   if (trnabuttona37)
   { 
    trnabuttona37= false;
    scriptToJmol("select 37:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona37= true;
    scriptToJmol("select 37:b and model=2; spacefill off;");
    }
}
function toggletrnaa38 () 
{
   if (trnabuttona38)
   { 
    trnabuttona38= false;
    scriptToJmol("select 38:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona38= true;
    scriptToJmol("select 38:b and model=2; spacefill off;");
    }
}
function toggletrnaa39 () 
{
   if (trnabuttona39)
   { 
    trnabuttona39= false;
    scriptToJmol("select 39:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona39= true;
    scriptToJmol("select 39:b and model=2; spacefill off;");
    }
}
function toggletrnaa40 () 
{
   if (trnabuttona40)
   { 
    trnabuttona40= false;
    scriptToJmol("select 40:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona40= true;
    scriptToJmol("select 40:b and model=2; spacefill off;");
    }
}
function toggletrnaa41 () 
{
   if (trnabuttona41)
   { 
    trnabuttona41= false;
    scriptToJmol("select 41:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona41= true;
    scriptToJmol("select 41:b and model=2; spacefill off;");
    }
}
function toggletrnaa42 () 
{
   if (trnabuttona42)
   { 
    trnabuttona42= false;
    scriptToJmol("select 42:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona42= true;
    scriptToJmol("select 42:b and model=2; spacefill off;");
    }
}
function toggletrnaa43 () 
{
   if (trnabuttona43)
   { 
    trnabuttona43= false;
    scriptToJmol("select 43:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona43= true;
    scriptToJmol("select 43:b and model=2; spacefill off;");
    }
}
function toggletrnaa44 () 
{
   if (trnabuttona44)
   { 
    trnabuttona44= false;
    scriptToJmol("select 44:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona44= true;
    scriptToJmol("select 44:b and model=2; spacefill off;");
    }
}
function toggletrnaa45 () 
{
   if (trnabuttona45)
   { 
    trnabuttona45= false;
    scriptToJmol("select 45:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona45= true;
    scriptToJmol("select 45:b and model=2; spacefill off;");
    }
}
function toggletrnaa46 () 
{
   if (trnabuttona46)
   { 
    trnabuttona46= false;
    scriptToJmol("select 46:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona46= true;
    scriptToJmol("select 46:b and model=2; spacefill off;");
    }
}
function toggletrnaa47 () 
{
   if (trnabuttona47)
   { 
    trnabuttona47= false;
    scriptToJmol("select 47:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona47= true;
    scriptToJmol("select 47:b and model=2; spacefill off;");
    }
}
function toggletrnaa48 () 
{
   if (trnabuttona48)
   { 
    trnabuttona48= false;
    scriptToJmol("select 48:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona48= true;
    scriptToJmol("select 48:b and model=2; spacefill off;");
    }
}
function toggletrnaa49 () 
{
   if (trnabuttona49)
   { 
    trnabuttona49= false;
    scriptToJmol("select 49:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona49= true;
    scriptToJmol("select 49:b and model=2; spacefill off;");
    }
}
function toggletrnaa50 () 
{
   if (trnabuttona50)
   { 
    trnabuttona50= false;
    scriptToJmol("select 50:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona50= true;
    scriptToJmol("select 50:b and model=2; spacefill off;");
    }
}
function toggletrnaa51 () 
{
   if (trnabuttona51)
   { 
    trnabuttona51= false;
    scriptToJmol("select 51:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona51= true;
    scriptToJmol("select 51:b and model=2; spacefill off;");
    }
}
function toggletrnaa52 () 
{
   if (trnabuttona52)
   { 
    trnabuttona52= false;
    scriptToJmol("select 52:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona52= true;
    scriptToJmol("select 52:b and model=2; spacefill off;");
    }
}
function toggletrnaa53 () 
{
   if (trnabuttona53)
   { 
    trnabuttona53= false;
    scriptToJmol("select 53:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona53= true;
    scriptToJmol("select 53:b and model=2; spacefill off;");
    }
}
function toggletrnaa54 () 
{
   if (trnabuttona54)
   { 
    trnabuttona54= false;
    scriptToJmol("select 54:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona54= true;
    scriptToJmol("select 54:b and model=2; spacefill off;");
    }
}
function toggletrnaa55 () 
{
   if (trnabuttona55)
   { 
    trnabuttona55= false;
    scriptToJmol("select 55:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona55= true;
    scriptToJmol("select 55:b and model=2; spacefill off;");
    }
}
function toggletrnaa56 () 
{
   if (trnabuttona56)
   { 
    trnabuttona56= false;
    scriptToJmol("select 56:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona56= true;
    scriptToJmol("select 56:b and model=2; spacefill off;");
    }
}
function toggletrnaa57 () 
{
   if (trnabuttona57)
   { 
    trnabuttona57= false;
    scriptToJmol("select 57:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona57= true;
    scriptToJmol("select 57:b and model=2; spacefill off;");
    }
}
function toggletrnaa58 () 
{
   if (trnabuttona58)
   { 
    trnabuttona58= false;
    scriptToJmol("select 58:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona58= true;
    scriptToJmol("select 58:b and model=2; spacefill off;");
    }
}
function toggletrnaa59 () 
{
   if (trnabuttona59)
   { 
    trnabuttona59= false;
    scriptToJmol("select 59:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona59= true;
    scriptToJmol("select 59:b and model=2; spacefill off;");
    }
}
function toggletrnaa60 () 
{
   if (trnabuttona60)
   { 
    trnabuttona60= false;
    scriptToJmol("select 60:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona60= true;
    scriptToJmol("select 60:b and model=2; spacefill off;");
    }
}
function toggletrnaa61 () 
{
   if (trnabuttona61)
   { 
    trnabuttona61= false;
    scriptToJmol("select 61:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona61= true;
    scriptToJmol("select 61:b and model=2; spacefill off;");
    }
}
function toggletrnaa62 () 
{
   if (trnabuttona62)
   { 
    trnabuttona62= false;
    scriptToJmol("select 62:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona62= true;
    scriptToJmol("select 62:b and model=2; spacefill off;");
    }
}
function toggletrnaa63 () 
{
   if (trnabuttona63)
   { 
    trnabuttona63= false;
    scriptToJmol("select 63:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona63= true;
    scriptToJmol("select 63:b and model=2; spacefill off;");
    }
}
function toggletrnaa64 () 
{
   if (trnabuttona64)
   { 
    trnabuttona64= false;
    scriptToJmol("select 64:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona64= true;
    scriptToJmol("select 64:b and model=2; spacefill off;");
    }
}
function toggletrnaa65 () 
{
   if (trnabuttona65)
   { 
    trnabuttona65= false;
    scriptToJmol("select 65:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona65= true;
    scriptToJmol("select 65:b and model=2; spacefill off;");
    }
}
function toggletrnaa66 () 
{
   if (trnabuttona66)
   { 
    trnabuttona66= false;
    scriptToJmol("select 66:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona66= true;
    scriptToJmol("select 66:b and model=2; spacefill off;");
    }
}
function toggletrnaa67 () 
{
   if (trnabuttona67)
   { 
    trnabuttona67= false;
    scriptToJmol("select 67:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona67= true;
    scriptToJmol("select 67:b and model=2; spacefill off;");
    }
}
function toggletrnaa68 () 
{
   if (trnabuttona68)
   { 
    trnabuttona68= false;
    scriptToJmol("select 68:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona68= true;
    scriptToJmol("select 68:b and model=2; spacefill off;");
    }
}
function toggletrnaa69 () 
{
   if (trnabuttona69)
   { 
    trnabuttona69= false;
    scriptToJmol("select 69:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona69= true;
    scriptToJmol("select 69:b and model=2; spacefill off;");
    }
}
function toggletrnaa70 () 
{
   if (trnabuttona70)
   { 
    trnabuttona70= false;
    scriptToJmol("select 70:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona70= true;
    scriptToJmol("select 70:b and model=2; spacefill off;");
    }
}
function toggletrnaa71 () 
{
   if (trnabuttona71)
   { 
    trnabuttona71= false;
    scriptToJmol("select 71:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona71= true;
    scriptToJmol("select 71:b and model=2; spacefill off;");
    }
}
function toggletrnaa72 () 
{
   if (trnabuttona72)
   { 
    trnabuttona72= false;
    scriptToJmol("select 72:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona72= true;
    scriptToJmol("select 72:b and model=2; spacefill off;");
    }
}
function toggletrnaa73 () 
{
   if (trnabuttona73)
   { 
    trnabuttona73= false;
    scriptToJmol("select 73:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona73= true;
    scriptToJmol("select 73:b and model=2; spacefill off;");
    }
}
function toggletrnaa74 () 
{
   if (trnabuttona74)
   { 
    trnabuttona74= false;
    scriptToJmol("select 74:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona74= true;
    scriptToJmol("select 74:b and model=2; spacefill off;");
    }
}
function toggletrnaa75 () 
{
   if (trnabuttona75)
   { 
    trnabuttona75= false;
    scriptToJmol("select 75:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona75= true;
    scriptToJmol("select 75:b and model=2; spacefill off;");
    }
}
function toggletrnaa76 () 
{
   if (trnabuttona76)
   { 
    trnabuttona76= false;
    scriptToJmol("select 76:b and model=2; spacefill on;");
    }
   else
   { 
    trnabuttona76= true;
    scriptToJmol("select 76:b and model=2; spacefill off;");
    }
}
//P-site tRNA scrips for HELP CONTROL
function toggletrnap1 () 
{
   if (trnabuttonp1)
   { 
    trnabuttonp1= false;
    scriptToJmol("select 1:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp1= true;
    scriptToJmol("select 1:c and model=2; spacefill off;");
    }
}
function toggletrnap2 () 
{
   if (trnabuttonp2)
   { 
    trnabuttonp2= false;
    scriptToJmol("select 2:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp2= true;
    scriptToJmol("select 2:c and model=2; spacefill off;");
    }
}
function toggletrnap3 () 
{
   if (trnabuttonp3)
   { 
    trnabuttonp3= false;
    scriptToJmol("select 3:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp3= true;
    scriptToJmol("select 3:c and model=2; spacefill off;");
    }
}
function toggletrnap4 () 
{
   if (trnabuttonp4)
   { 
    trnabuttonp4= false;
    scriptToJmol("select 4:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp4= true;
    scriptToJmol("select 4:c and model=2; spacefill off;");
    }
}
function toggletrnap5 () 
{
   if (trnabuttonp5)
   { 
    trnabuttonp5= false;
    scriptToJmol("select 5:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp5= true;
    scriptToJmol("select 5:c and model=2; spacefill off;");
    }
}
function toggletrnap6 () 
{
   if (trnabuttonp6)
   { 
    trnabuttonp6= false;
    scriptToJmol("select 6:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp6= true;
    scriptToJmol("select 6:c and model=2; spacefill off;");
    }
}
function toggletrnap7 () 
{
   if (trnabuttonp7)
   { 
    trnabuttonp7= false;
    scriptToJmol("select 7:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp7= true;
    scriptToJmol("select 7:c and model=2; spacefill off;");
    }
}
function toggletrnap8 () 
{
   if (trnabuttonp8)
   { 
    trnabuttonp8= false;
    scriptToJmol("select 8:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp8= true;
    scriptToJmol("select 8:c and model=2; spacefill off;");
    }
}
function toggletrnap9 () 
{
   if (trnabuttonp9)
   { 
    trnabuttonp9= false;
    scriptToJmol("select 9:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp9= true;
    scriptToJmol("select 9:c and model=2; spacefill off;");
    }
}
function toggletrnap10 () 
{
   if (trnabuttonp10)
   { 
    trnabuttonp10= false;
    scriptToJmol("select 10:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp10= true;
    scriptToJmol("select 10:c and model=2; spacefill off;");
    }
}
function toggletrnap11 () 
{
   if (trnabuttonp11)
   { 
    trnabuttonp11= false;
    scriptToJmol("select 11:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp11= true;
    scriptToJmol("select 11:c and model=2; spacefill off;");
    }
}
function toggletrnap12 () 
{
   if (trnabuttonp12)
   { 
    trnabuttonp12= false;
    scriptToJmol("select 12:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp12= true;
    scriptToJmol("select 12:c and model=2; spacefill off;");
    }
}
function toggletrnap13 () 
{
   if (trnabuttonp13)
   { 
    trnabuttonp13= false;
    scriptToJmol("select 13:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp13= true;
    scriptToJmol("select 13:c and model=2; spacefill off;");
    }
}
function toggletrnap14 () 
{
   if (trnabuttonp14)
   { 
    trnabuttonp14= false;
    scriptToJmol("select 14:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp14= true;
    scriptToJmol("select 14:c and model=2; spacefill off;");
    }
}
function toggletrnap15 () 
{
   if (trnabuttonp15)
   { 
    trnabuttonp15= false;
    scriptToJmol("select 15:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp15= true;
    scriptToJmol("select 15:c and model=2; spacefill off;");
    }
}
function toggletrnap16 () 
{
   if (trnabuttonp16)
   { 
    trnabuttonp16= false;
    scriptToJmol("select 16:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp16= true;
    scriptToJmol("select 16:c and model=2; spacefill off;");
    }
}
function toggletrnap17 () 
{
   if (trnabuttonp17)
   { 
    trnabuttonp17= false;
    scriptToJmol("select 17:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp17= true;
    scriptToJmol("select 17:c and model=2; spacefill off;");
    }
}
function toggletrnap18 () 
{
   if (trnabuttonp18)
   { 
    trnabuttonp18= false;
    scriptToJmol("select 18:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp18= true;
    scriptToJmol("select 18:c and model=2; spacefill off;");
    }
}
function toggletrnap19 () 
{
   if (trnabuttonp19)
   { 
    trnabuttonp19= false;
    scriptToJmol("select 19:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp19= true;
    scriptToJmol("select 19:c and model=2; spacefill off;");
    }
}
function toggletrnap20 () 
{
   if (trnabuttonp20)
   { 
    trnabuttonp20= false;
    scriptToJmol("select 20:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp20= true;
    scriptToJmol("select 20:c and model=2; spacefill off;");
    }
}
function toggletrnap21 () 
{
   if (trnabuttonp21)
   { 
    trnabuttonp21= false;
    scriptToJmol("select 21:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp21= true;
    scriptToJmol("select 21:c and model=2; spacefill off;");
    }
}
function toggletrnap22 () 
{
   if (trnabuttonp22)
   { 
    trnabuttonp22= false;
    scriptToJmol("select 22:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp22= true;
    scriptToJmol("select 22:c and model=2; spacefill off;");
    }
}
function toggletrnap23 () 
{
   if (trnabuttonp23)
   { 
    trnabuttonp23= false;
    scriptToJmol("select 23:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp23= true;
    scriptToJmol("select 23:c and model=2; spacefill off;");
    }
}
function toggletrnap24 () 
{
   if (trnabuttonp24)
   { 
    trnabuttonp24= false;
    scriptToJmol("select 24:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp24= true;
    scriptToJmol("select 24:c and model=2; spacefill off;");
    }
}
function toggletrnap25 () 
{
   if (trnabuttonp25)
   { 
    trnabuttonp25= false;
    scriptToJmol("select 25:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp25= true;
    scriptToJmol("select 25:c and model=2; spacefill off;");
    }
}
function toggletrnap26 () 
{
   if (trnabuttonp26)
   { 
    trnabuttonp26= false;
    scriptToJmol("select 26:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp26= true;
    scriptToJmol("select 26:c and model=2; spacefill off;");
    }
}
function toggletrnap27 () 
{
   if (trnabuttonp27)
   { 
    trnabuttonp27= false;
    scriptToJmol("select 27:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp27= true;
    scriptToJmol("select 27:c and model=2; spacefill off;");
    }
}
function toggletrnap28 () 
{
   if (trnabuttonp28)
   { 
    trnabuttonp28= false;
    scriptToJmol("select 28:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp28= true;
    scriptToJmol("select 28:c and model=2; spacefill off;");
    }
}
function toggletrnap29 () 
{
   if (trnabuttonp29)
   { 
    trnabuttonp29= false;
    scriptToJmol("select 29:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp29= true;
    scriptToJmol("select 29:c and model=2; spacefill off;");
    }
}
function toggletrnap30 () 
{
   if (trnabuttonp30)
   { 
    trnabuttonp30= false;
    scriptToJmol("select 30:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp30= true;
    scriptToJmol("select 30:c and model=2; spacefill off;");
    }
}
function toggletrnap31 () 
{
   if (trnabuttonp31)
   { 
    trnabuttonp31= false;
    scriptToJmol("select 31:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp31= true;
    scriptToJmol("select 31:c and model=2; spacefill off;");
    }
}
function toggletrnap32 () 
{
   if (trnabuttonp32)
   { 
    trnabuttonp32= false;
    scriptToJmol("select 32:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp32= true;
    scriptToJmol("select 32:c and model=2; spacefill off;");
    }
}
function toggletrnap33 () 
{
   if (trnabuttonp33)
   { 
    trnabuttonp33= false;
    scriptToJmol("select 33:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp33= true;
    scriptToJmol("select 33:c and model=2; spacefill off;");
    }
}
function toggletrnap34 () 
{
   if (trnabuttonp34)
   { 
    trnabuttonp34= false;
    scriptToJmol("select 34:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp34= true;
    scriptToJmol("select 34:c and model=2; spacefill off;");
    }
}
function toggletrnap35 () 
{
   if (trnabuttonp35)
   { 
    trnabuttonp35= false;
    scriptToJmol("select 35:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp35= true;
    scriptToJmol("select 35:c and model=2; spacefill off;");
    }
}
function toggletrnap36 () 
{
   if (trnabuttonp36)
   { 
    trnabuttonp36= false;
    scriptToJmol("select 36:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp36= true;
    scriptToJmol("select 36:c and model=2; spacefill off;");
    }
}
function toggletrnap37 () 
{
   if (trnabuttonp37)
   { 
    trnabuttonp37= false;
    scriptToJmol("select 37:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp37= true;
    scriptToJmol("select 37:c and model=2; spacefill off;");
    }
}
function toggletrnap38 () 
{
   if (trnabuttonp38)
   { 
    trnabuttonp38= false;
    scriptToJmol("select 38:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp38= true;
    scriptToJmol("select 38:c and model=2; spacefill off;");
    }
}
function toggletrnap39 () 
{
   if (trnabuttonp39)
   { 
    trnabuttonp39= false;
    scriptToJmol("select 39:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp39= true;
    scriptToJmol("select 39:c and model=2; spacefill off;");
    }
}
function toggletrnap40 () 
{
   if (trnabuttonp40)
   { 
    trnabuttonp40= false;
    scriptToJmol("select 40:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp40= true;
    scriptToJmol("select 40:c and model=2; spacefill off;");
    }
}
function toggletrnap41 () 
{
   if (trnabuttonp41)
   { 
    trnabuttonp41= false;
    scriptToJmol("select 41:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp41= true;
    scriptToJmol("select 41:c and model=2; spacefill off;");
    }
}
function toggletrnap42 () 
{
   if (trnabuttonp42)
   { 
    trnabuttonp42= false;
    scriptToJmol("select 42:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp42= true;
    scriptToJmol("select 42:c and model=2; spacefill off;");
    }
}
function toggletrnap43 () 
{
   if (trnabuttonp43)
   { 
    trnabuttonp43= false;
    scriptToJmol("select 43:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp43= true;
    scriptToJmol("select 43:c and model=2; spacefill off;");
    }
}
function toggletrnap44 () 
{
   if (trnabuttonp44)
   { 
    trnabuttonp44= false;
    scriptToJmol("select 44:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp44= true;
    scriptToJmol("select 44:c and model=2; spacefill off;");
    }
}
function toggletrnap45 () 
{
   if (trnabuttonp45)
   { 
    trnabuttonp45= false;
    scriptToJmol("select 45:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp45= true;
    scriptToJmol("select 45:c and model=2; spacefill off;");
    }
}
function toggletrnap46 () 
{
   if (trnabuttonp46)
   { 
    trnabuttonp46= false;
    scriptToJmol("select 46:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp46= true;
    scriptToJmol("select 46:c and model=2; spacefill off;");
    }
}
function toggletrnap47 () 
{
   if (trnabuttonp47)
   { 
    trnabuttonp47= false;
    scriptToJmol("select 47:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp47= true;
    scriptToJmol("select 47:c and model=2; spacefill off;");
    }
}
function toggletrnap48 () 
{
   if (trnabuttonp48)
   { 
    trnabuttonp48= false;
    scriptToJmol("select 48:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp48= true;
    scriptToJmol("select 48:c and model=2; spacefill off;");
    }
}
function toggletrnap49 () 
{
   if (trnabuttonp49)
   { 
    trnabuttonp49= false;
    scriptToJmol("select 49:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp49= true;
    scriptToJmol("select 49:c and model=2; spacefill off;");
    }
}
function toggletrnap50 () 
{
   if (trnabuttonp50)
   { 
    trnabuttonp50= false;
    scriptToJmol("select 50:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp50= true;
    scriptToJmol("select 50:c and model=2; spacefill off;");
    }
}
function toggletrnap51 () 
{
   if (trnabuttonp51)
   { 
    trnabuttonp51= false;
    scriptToJmol("select 51:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp51= true;
    scriptToJmol("select 51:c and model=2; spacefill off;");
    }
}
function toggletrnap52 () 
{
   if (trnabuttonp52)
   { 
    trnabuttonp52= false;
    scriptToJmol("select 52:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp52= true;
    scriptToJmol("select 52:c and model=2; spacefill off;");
    }
}
function toggletrnap53 () 
{
   if (trnabuttonp53)
   { 
    trnabuttonp53= false;
    scriptToJmol("select 53:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp53= true;
    scriptToJmol("select 53:c and model=2; spacefill off;");
    }
}
function toggletrnap54 () 
{
   if (trnabuttonp54)
   { 
    trnabuttonp54= false;
    scriptToJmol("select 54:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp54= true;
    scriptToJmol("select 54:c and model=2; spacefill off;");
    }
}
function toggletrnap55 () 
{
   if (trnabuttonp55)
   { 
    trnabuttonp55= false;
    scriptToJmol("select 55:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp55= true;
    scriptToJmol("select 55:c and model=2; spacefill off;");
    }
}
function toggletrnap56 () 
{
   if (trnabuttonp56)
   { 
    trnabuttonp56= false;
    scriptToJmol("select 56:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp56= true;
    scriptToJmol("select 56:c and model=2; spacefill off;");
    }
}
function toggletrnap57 () 
{
   if (trnabuttonp57)
   { 
    trnabuttonp57= false;
    scriptToJmol("select 57:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp57= true;
    scriptToJmol("select 57:c and model=2; spacefill off;");
    }
}
function toggletrnap58 () 
{
   if (trnabuttonp58)
   { 
    trnabuttonp58= false;
    scriptToJmol("select 58:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp58= true;
    scriptToJmol("select 58:c and model=2; spacefill off;");
    }
}
function toggletrnap59 () 
{
   if (trnabuttonp59)
   { 
    trnabuttonp59= false;
    scriptToJmol("select 59:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp59= true;
    scriptToJmol("select 59:c and model=2; spacefill off;");
    }
}
function toggletrnap60 () 
{
   if (trnabuttonp60)
   { 
    trnabuttonp60= false;
    scriptToJmol("select 60:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp60= true;
    scriptToJmol("select 60:c and model=2; spacefill off;");
    }
}
function toggletrnap61 () 
{
   if (trnabuttonp61)
   { 
    trnabuttonp61= false;
    scriptToJmol("select 61:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp61= true;
    scriptToJmol("select 61:c and model=2; spacefill off;");
    }
}
function toggletrnap62 () 
{
   if (trnabuttonp62)
   { 
    trnabuttonp62= false;
    scriptToJmol("select 62:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp62= true;
    scriptToJmol("select 62:c and model=2; spacefill off;");
    }
}
function toggletrnap63 () 
{
   if (trnabuttonp63)
   { 
    trnabuttonp63= false;
    scriptToJmol("select 63:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp63= true;
    scriptToJmol("select 63:c and model=2; spacefill off;");
    }
}
function toggletrnap64 () 
{
   if (trnabuttonp64)
   { 
    trnabuttonp64= false;
    scriptToJmol("select 64:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp64= true;
    scriptToJmol("select 64:c and model=2; spacefill off;");
    }
}
function toggletrnap65 () 
{
   if (trnabuttonp65)
   { 
    trnabuttonp65= false;
    scriptToJmol("select 65:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp65= true;
    scriptToJmol("select 65:c and model=2; spacefill off;");
    }
}
function toggletrnap66 () 
{
   if (trnabuttonp66)
   { 
    trnabuttonp66= false;
    scriptToJmol("select 66:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp66= true;
    scriptToJmol("select 66:c and model=2; spacefill off;");
    }
}
function toggletrnap67 () 
{
   if (trnabuttonp67)
   { 
    trnabuttonp67= false;
    scriptToJmol("select 67:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp67= true;
    scriptToJmol("select 67:c and model=2; spacefill off;");
    }
}
function toggletrnap68 () 
{
   if (trnabuttonp68)
   { 
    trnabuttonp68= false;
    scriptToJmol("select 68:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp68= true;
    scriptToJmol("select 68:c and model=2; spacefill off;");
    }
}
function toggletrnap69 () 
{
   if (trnabuttonp69)
   { 
    trnabuttonp69= false;
    scriptToJmol("select 69:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp69= true;
    scriptToJmol("select 69:c and model=2; spacefill off;");
    }
}
function toggletrnap70 () 
{
   if (trnabuttonp70)
   { 
    trnabuttonp70= false;
    scriptToJmol("select 70:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp70= true;
    scriptToJmol("select 70:c and model=2; spacefill off;");
    }
}
function toggletrnap71 () 
{
   if (trnabuttonp71)
   { 
    trnabuttonp71= false;
    scriptToJmol("select 71:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp71= true;
    scriptToJmol("select 71:c and model=2; spacefill off;");
    }
}
function toggletrnap72 () 
{
   if (trnabuttonp72)
   { 
    trnabuttonp72= false;
    scriptToJmol("select 72:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp72= true;
    scriptToJmol("select 72:c and model=2; spacefill off;");
    }
}
function toggletrnap73 () 
{
   if (trnabuttonp73)
   { 
    trnabuttonp73= false;
    scriptToJmol("select 73:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp73= true;
    scriptToJmol("select 73:c and model=2; spacefill off;");
    }
}
function toggletrnap74 () 
{
   if (trnabuttonp74)
   { 
    trnabuttonp74= false;
    scriptToJmol("select 74:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp74= true;
    scriptToJmol("select 74:c and model=2; spacefill off;");
    }
}
function toggletrnap75 () 
{
   if (trnabuttonp75)
   { 
    trnabuttonp75= false;
    scriptToJmol("select 75:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp75= true;
    scriptToJmol("select 75:c and model=2; spacefill off;");
    }
}
function toggletrnap76 () 
{
   if (trnabuttonp76)
   { 
    trnabuttonp76= false;
    scriptToJmol("select 76:c and model=2; spacefill on;");
    }
   else
   { 
    trnabuttonp76= true;
    scriptToJmol("select 76:c and model=2; spacefill off;");
    }
}

// THE E site toggle functions for HELP tRNA nt Selector
function toggletrnae1 () 
{
   if (trnabuttone1)
   { 
    trnabuttone1= false;
    scriptToJmol("select 1:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone1= true;
    scriptToJmol("select 1:d and model=2; spacefill off;");
    }
}
function toggletrnae2 () 
{
   if (trnabuttone2)
   { 
    trnabuttone2= false;
    scriptToJmol("select 2:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone2= true;
    scriptToJmol("select 2:d and model=2; spacefill off;");
    }
}
function toggletrnae3 () 
{
   if (trnabuttone3)
   { 
    trnabuttone3= false;
    scriptToJmol("select 3:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone3= true;
    scriptToJmol("select 3:d and model=2; spacefill off;");
    }
}
function toggletrnae4 () 
{
   if (trnabuttone4)
   { 
    trnabuttone4= false;
    scriptToJmol("select 4:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone4= true;
    scriptToJmol("select 4:d and model=2; spacefill off;");
    }
}
function toggletrnae5 () 
{
   if (trnabuttone5)
   { 
    trnabuttone5= false;
    scriptToJmol("select 5:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone5= true;
    scriptToJmol("select 5:d and model=2; spacefill off;");
    }
}
function toggletrnae6 () 
{
   if (trnabuttone6)
   { 
    trnabuttone6= false;
    scriptToJmol("select 6:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone6= true;
    scriptToJmol("select 6:d and model=2; spacefill off;");
    }
}
function toggletrnae7 () 
{
   if (trnabuttone7)
   { 
    trnabuttone7= false;
    scriptToJmol("select 7:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone7= true;
    scriptToJmol("select 7:d and model=2; spacefill off;");
    }
}
function toggletrnae8 () 
{
   if (trnabuttone8)
   { 
    trnabuttone8= false;
    scriptToJmol("select 8:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone8= true;
    scriptToJmol("select 8:d and model=2; spacefill off;");
    }
}
function toggletrnae9 () 
{
   if (trnabuttone9)
   { 
    trnabuttone9= false;
    scriptToJmol("select 9:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone9= true;
    scriptToJmol("select 9:d and model=2; spacefill off;");
    }
}
function toggletrnae10 () 
{
   if (trnabuttone10)
   { 
    trnabuttone10= false;
    scriptToJmol("select 10:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone10= true;
    scriptToJmol("select 10:d and model=2; spacefill off;");
    }
}
function toggletrnae11 () 
{
   if (trnabuttone11)
   { 
    trnabuttone11= false;
    scriptToJmol("select 11:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone11= true;
    scriptToJmol("select 11:d and model=2; spacefill off;");
    }
}
function toggletrnae12 () 
{
   if (trnabuttone12)
   { 
    trnabuttone12= false;
    scriptToJmol("select 12:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone12= true;
    scriptToJmol("select 12:d and model=2; spacefill off;");
    }
}
function toggletrnae13 () 
{
   if (trnabuttone13)
   { 
    trnabuttone13= false;
    scriptToJmol("select 13:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone13= true;
    scriptToJmol("select 13:d and model=2; spacefill off;");
    }
}
function toggletrnae14 () 
{
   if (trnabuttone14)
   { 
    trnabuttone14= false;
    scriptToJmol("select 14:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone14= true;
    scriptToJmol("select 14:d and model=2; spacefill off;");
    }
}
function toggletrnae15 () 
{
   if (trnabuttone15)
   { 
    trnabuttone15= false;
    scriptToJmol("select 15:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone15= true;
    scriptToJmol("select 15:d and model=2; spacefill off;");
    }
}
function toggletrnae16 () 
{
   if (trnabuttone16)
   { 
    trnabuttone16= false;
    scriptToJmol("select 16:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone16= true;
    scriptToJmol("select 16:d and model=2; spacefill off;");
    }
}
function toggletrnae17 () 
{
   if (trnabuttone17)
   { 
    trnabuttone17= false;
    scriptToJmol("select 17:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone17= true;
    scriptToJmol("select 17:d and model=2; spacefill off;");
    }
}
function toggletrnae18 () 
{
   if (trnabuttone18)
   { 
    trnabuttone18= false;
    scriptToJmol("select 18:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone18= true;
    scriptToJmol("select 18:d and model=2; spacefill off;");
    }
}
function toggletrnae19 () 
{
   if (trnabuttone19)
   { 
    trnabuttone19= false;
    scriptToJmol("select 19:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone19= true;
    scriptToJmol("select 19:d and model=2; spacefill off;");
    }
}
function toggletrnae20 () 
{
   if (trnabuttone20)
   { 
    trnabuttone20= false;
    scriptToJmol("select 20:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone20= true;
    scriptToJmol("select 20:d and model=2; spacefill off;");
    }
}
function toggletrnae21 () 
{
   if (trnabuttone21)
   { 
    trnabuttone21= false;
    scriptToJmol("select 21:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone21= true;
    scriptToJmol("select 21:d and model=2; spacefill off;");
    }
}
function toggletrnae22 () 
{
   if (trnabuttone22)
   { 
    trnabuttone22= false;
    scriptToJmol("select 22:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone22= true;
    scriptToJmol("select 22:d and model=2; spacefill off;");
    }
}
function toggletrnae23 () 
{
   if (trnabuttone23)
   { 
    trnabuttone23= false;
    scriptToJmol("select 23:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone23= true;
    scriptToJmol("select 23:d and model=2; spacefill off;");
    }
}
function toggletrnae24 () 
{
   if (trnabuttone24)
   { 
    trnabuttone24= false;
    scriptToJmol("select 24:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone24= true;
    scriptToJmol("select 24:d and model=2; spacefill off;");
    }
}
function toggletrnae25 () 
{
   if (trnabuttone25)
   { 
    trnabuttone25= false;
    scriptToJmol("select 25:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone25= true;
    scriptToJmol("select 25:d and model=2; spacefill off;");
    }
}
function toggletrnae26 () 
{
   if (trnabuttone26)
   { 
    trnabuttone26= false;
    scriptToJmol("select 26:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone26= true;
    scriptToJmol("select 26:d and model=2; spacefill off;");
    }
}
function toggletrnae27 () 
{
   if (trnabuttone27)
   { 
    trnabuttone27= false;
    scriptToJmol("select 27:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone27= true;
    scriptToJmol("select 27:d and model=2; spacefill off;");
    }
}
function toggletrnae28 () 
{
   if (trnabuttone28)
   { 
    trnabuttone28= false;
    scriptToJmol("select 28:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone28= true;
    scriptToJmol("select 28:d and model=2; spacefill off;");
    }
}
function toggletrnae29 () 
{
   if (trnabuttone29)
   { 
    trnabuttone29= false;
    scriptToJmol("select 29:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone29= true;
    scriptToJmol("select 29:d and model=2; spacefill off;");
    }
}
function toggletrnae30 () 
{
   if (trnabuttone30)
   { 
    trnabuttone30= false;
    scriptToJmol("select 30:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone30= true;
    scriptToJmol("select 30:d and model=2; spacefill off;");
    }
}
function toggletrnae31 () 
{
   if (trnabuttone31)
   { 
    trnabuttone31= false;
    scriptToJmol("select 31:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone31= true;
    scriptToJmol("select 31:d and model=2; spacefill off;");
    }
}
function toggletrnae32 () 
{
   if (trnabuttone32)
   { 
    trnabuttone32= false;
    scriptToJmol("select 32:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone32= true;
    scriptToJmol("select 32:d and model=2; spacefill off;");
    }
}
function toggletrnae33 () 
{
   if (trnabuttone33)
   { 
    trnabuttone33= false;
    scriptToJmol("select 33:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone33= true;
    scriptToJmol("select 33:d and model=2; spacefill off;");
    }
}
function toggletrnae34 () 
{
   if (trnabuttone34)
   { 
    trnabuttone34= false;
    scriptToJmol("select 34:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone34= true;
    scriptToJmol("select 34:d and model=2; spacefill off;");
    }
}
function toggletrnae35 () 
{
   if (trnabuttone35)
   { 
    trnabuttone35= false;
    scriptToJmol("select 35:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone35= true;
    scriptToJmol("select 35:d and model=2; spacefill off;");
    }
}
function toggletrnae36 () 
{
   if (trnabuttone36)
   { 
    trnabuttone36= false;
    scriptToJmol("select 36:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone36= true;
    scriptToJmol("select 36:d and model=2; spacefill off;");
    }
}
function toggletrnae37 () 
{
   if (trnabuttone37)
   { 
    trnabuttone37= false;
    scriptToJmol("select 37:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone37= true;
    scriptToJmol("select 37:d and model=2; spacefill off;");
    }
}
function toggletrnae38 () 
{
   if (trnabuttone38)
   { 
    trnabuttone38= false;
    scriptToJmol("select 38:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone38= true;
    scriptToJmol("select 38:d and model=2; spacefill off;");
    }
}
function toggletrnae39 () 
{
   if (trnabuttone39)
   { 
    trnabuttone39= false;
    scriptToJmol("select 39:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone39= true;
    scriptToJmol("select 39:d and model=2; spacefill off;");
    }
}
function toggletrnae40 () 
{
   if (trnabuttone40)
   { 
    trnabuttone40= false;
    scriptToJmol("select 40:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone40= true;
    scriptToJmol("select 40:d and model=2; spacefill off;");
    }
}
function toggletrnae41 () 
{
   if (trnabuttone41)
   { 
    trnabuttone41= false;
    scriptToJmol("select 41:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone41= true;
    scriptToJmol("select 41:d and model=2; spacefill off;");
    }
}
function toggletrnae42 () 
{
   if (trnabuttone42)
   { 
    trnabuttone42= false;
    scriptToJmol("select 42:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone42= true;
    scriptToJmol("select 42:d and model=2; spacefill off;");
    }
}
function toggletrnae43 () 
{
   if (trnabuttone43)
   { 
    trnabuttone43= false;
    scriptToJmol("select 43:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone43= true;
    scriptToJmol("select 43:d and model=2; spacefill off;");
    }
}
function toggletrnae44 () 
{
   if (trnabuttone44)
   { 
    trnabuttone44= false;
    scriptToJmol("select 44:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone44= true;
    scriptToJmol("select 44:d and model=2; spacefill off;");
    }
}
function toggletrnae45 () 
{
   if (trnabuttone45)
   { 
    trnabuttone45= false;
    scriptToJmol("select 45:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone45= true;
    scriptToJmol("select 45:d and model=2; spacefill off;");
    }
}
function toggletrnae46 () 
{
   if (trnabuttone46)
   { 
    trnabuttone46= false;
    scriptToJmol("select 46:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone46= true;
    scriptToJmol("select 46:d and model=2; spacefill off;");
    }
}
function toggletrnae47 () 
{
   if (trnabuttone47)
   { 
    trnabuttone47= false;
    scriptToJmol("select 47:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone47= true;
    scriptToJmol("select 47:d and model=2; spacefill off;");
    }
}
function toggletrnae48 () 
{
   if (trnabuttone48)
   { 
    trnabuttone48= false;
    scriptToJmol("select 48:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone48= true;
    scriptToJmol("select 48:d and model=2; spacefill off;");
    }
}
function toggletrnae49 () 
{
   if (trnabuttone49)
   { 
    trnabuttone49= false;
    scriptToJmol("select 49:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone49= true;
    scriptToJmol("select 49:d and model=2; spacefill off;");
    }
}
function toggletrnae50 () 
{
   if (trnabuttone50)
   { 
    trnabuttone50= false;
    scriptToJmol("select 50:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone50= true;
    scriptToJmol("select 50:d and model=2; spacefill off;");
    }
}
function toggletrnae51 () 
{
   if (trnabuttone51)
   { 
    trnabuttone51= false;
    scriptToJmol("select 51:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone51= true;
    scriptToJmol("select 51:d and model=2; spacefill off;");
    }
}
function toggletrnae52 () 
{
   if (trnabuttone52)
   { 
    trnabuttone52= false;
    scriptToJmol("select 52:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone52= true;
    scriptToJmol("select 52:d and model=2; spacefill off;");
    }
}
function toggletrnae53 () 
{
   if (trnabuttone53)
   { 
    trnabuttone53= false;
    scriptToJmol("select 53:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone53= true;
    scriptToJmol("select 53:d and model=2; spacefill off;");
    }
}
function toggletrnae54 () 
{
   if (trnabuttone54)
   { 
    trnabuttone54= false;
    scriptToJmol("select 54:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone54= true;
    scriptToJmol("select 54:d and model=2; spacefill off;");
    }
}
function toggletrnae55 () 
{
   if (trnabuttone55)
   { 
    trnabuttone55= false;
    scriptToJmol("select 55:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone55= true;
    scriptToJmol("select 55:d and model=2; spacefill off;");
    }
}
function toggletrnae56 () 
{
   if (trnabuttone56)
   { 
    trnabuttone56= false;
    scriptToJmol("select 56:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone56= true;
    scriptToJmol("select 56:d and model=2; spacefill off;");
    }
}
function toggletrnae57 () 
{
   if (trnabuttone57)
   { 
    trnabuttone57= false;
    scriptToJmol("select 57:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone57= true;
    scriptToJmol("select 57:d and model=2; spacefill off;");
    }
}
function toggletrnae58 () 
{
   if (trnabuttone58)
   { 
    trnabuttone58= false;
    scriptToJmol("select 58:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone58= true;
    scriptToJmol("select 58:d and model=2; spacefill off;");
    }
}
function toggletrnae59 () 
{
   if (trnabuttone59)
   { 
    trnabuttone59= false;
    scriptToJmol("select 59:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone59= true;
    scriptToJmol("select 59:d and model=2; spacefill off;");
    }
}
function toggletrnae60 () 
{
   if (trnabuttone60)
   { 
    trnabuttone60= false;
    scriptToJmol("select 60:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone60= true;
    scriptToJmol("select 60:d and model=2; spacefill off;");
    }
}
function toggletrnae61 () 
{
   if (trnabuttone61)
   { 
    trnabuttone61= false;
    scriptToJmol("select 61:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone61= true;
    scriptToJmol("select 61:d and model=2; spacefill off;");
    }
}
function toggletrnae62 () 
{
   if (trnabuttone62)
   { 
    trnabuttone62= false;
    scriptToJmol("select 62:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone62= true;
    scriptToJmol("select 62:d and model=2; spacefill off;");
    }
}
function toggletrnae63 () 
{
   if (trnabuttone63)
   { 
    trnabuttone63= false;
    scriptToJmol("select 63:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone63= true;
    scriptToJmol("select 63:d and model=2; spacefill off;");
    }
}
function toggletrnae64 () 
{
   if (trnabuttone64)
   { 
    trnabuttone64= false;
    scriptToJmol("select 64:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone64= true;
    scriptToJmol("select 64:d and model=2; spacefill off;");
    }
}
function toggletrnae65 () 
{
   if (trnabuttone65)
   { 
    trnabuttone65= false;
    scriptToJmol("select 65:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone65= true;
    scriptToJmol("select 65:d and model=2; spacefill off;");
    }
}
function toggletrnae66 () 
{
   if (trnabuttone66)
   { 
    trnabuttone66= false;
    scriptToJmol("select 66:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone66= true;
    scriptToJmol("select 66:d and model=2; spacefill off;");
    }
}
function toggletrnae67 () 
{
   if (trnabuttone67)
   { 
    trnabuttone67= false;
    scriptToJmol("select 67:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone67= true;
    scriptToJmol("select 67:d and model=2; spacefill off;");
    }
}
function toggletrnae68 () 
{
   if (trnabuttone68)
   { 
    trnabuttone68= false;
    scriptToJmol("select 68:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone68= true;
    scriptToJmol("select 68:d and model=2; spacefill off;");
    }
}
function toggletrnae69 () 
{
   if (trnabuttone69)
   { 
    trnabuttone69= false;
    scriptToJmol("select 69:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone69= true;
    scriptToJmol("select 69:d and model=2; spacefill off;");
    }
}
function toggletrnae70 () 
{
   if (trnabuttone70)
   { 
    trnabuttone70= false;
    scriptToJmol("select 70:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone70= true;
    scriptToJmol("select 70:d and model=2; spacefill off;");
    }
}
function toggletrnae71 () 
{
   if (trnabuttone71)
   { 
    trnabuttone71= false;
    scriptToJmol("select 71:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone71= true;
    scriptToJmol("select 71:d and model=2; spacefill off;");
    }
}
function toggletrnae72 () 
{
   if (trnabuttone72)
   { 
    trnabuttone72= false;
    scriptToJmol("select 72:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone72= true;
    scriptToJmol("select 72:d and model=2; spacefill off;");
    }
}
function toggletrnae73 () 
{
   if (trnabuttone73)
   { 
    trnabuttone73= false;
    scriptToJmol("select 73:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone73= true;
    scriptToJmol("select 73:d and model=2; spacefill off;");
    }
}
function toggletrnae74 () 
{
   if (trnabuttone74)
   { 
    trnabuttone74= false;
    scriptToJmol("select 74:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone74= true;
    scriptToJmol("select 74:d and model=2; spacefill off;");
    }
}
function toggletrnae75 () 
{
   if (trnabuttone75)
   { 
    trnabuttone75= false;
    scriptToJmol("select 75:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone75= true;
    scriptToJmol("select 75:d and model=2; spacefill off;");
    }
}
function toggletrnae76 () 
{
   if (trnabuttone76)
   { 
    trnabuttone76= false;
    scriptToJmol("select 76:d and model=2; spacefill on;");
    }
   else
   { 
    trnabuttone76= true;
    scriptToJmol("select 76:d and model=2; spacefill off;");
    }
}


//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 

var jmolWidth, jmolHeight;

var pdbToLoad; // Query paramerer "mol=". Can be PDB Id or filename/URL.

var pdbId; // filename (.pdb removed) derived from pdbToLoad.
// When mol=url/filename.pdb, pdbId is "filename".
// pdbId may not be a valid PDB Id.

var validPDBId = ""; // Contains a valid PDB Id if pdbToLoad was a valid PDB Id,
// or if the first four characters of pdbId are a valid PDB Id. Else blank.

var pdbURL; // URL Jmol uses to fetch the molecule.

var molIncludesDotPDB; // True if pdbToLoad includes ".pdb".
var molIncludesDot; // True if pdbToLoad includes ".".
var molIncludesHTTP; // http:// in pdbToLoad
var molIncludesFTP;  //  ftp:// in pdbToLoad
var molIncludesSlash; // relative path (if no TP)
var usePDBId; // get PDB from RCSB

var helpTarget;

var DOC_WIDTH, DOC_HEIGHT;

var centerMode = false;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function initialize()
{
	top.get_dimensions();
	top.getMolToLoad();
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function initHelpTarget()
{
	if (top.usingFrames)
	{
		helpTarget = top.frameLeft.frameLeftBottom;
	}
	else
	{
		if (document.layers) // true in N4; false in IE, Gecko
		{
			helpTarget = document.layers['helpDiv'];
//			alert("top.js #2 document.layers 'true'");
//			alert("top.js #2a: " + document.layers['helpDiv']);
		}

		else
		{
			helpTarget = top.document.getElementById('helpDiv');
//			alert("top.js #2b document.layers 'false'");
		}
	}

//	alert("top.js #8: " + top.helpTarget);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function getMolToLoad()
{
	var qs = document.location.search; // qp query parameters
	var ieq, iaa, ipdb, islash;

	if (qs.indexOf("appl=s") != -1)
		usingSignedApplet = true;

	if (qs.indexOf("cif=1") != -1)
		usingCIF = true;

	if (qs.indexOf("db=1") != -1)
		debuggingFG = true;

	// qs: mode is now handled in gallery.js

	// mol=http://... will be escaped: colon -> %3A.
	pdbToLoad = unescape(qs); // ?mol=1d66&mode=x

	// Extract mol=...&...
	if ((ieq = pdbToLoad.indexOf("mol=")) != -1)
		pdbToLoad = pdbToLoad.substring(ieq + 4);
	else
	{
		alert("ERROR: No PDB file specified, for example\n" +
			"fg.htm?mol=1d66.pdb");
		document.location.replace("index.htm");
	}

	// trim off trailing &...
	if ((iaa = pdbToLoad.indexOf("&")) != -1)
		pdbToLoad = pdbToLoad.substring(0, iaa);

	// Note type of PDB URL
	molIncludesDotPDB = (pdbToLoad.indexOf(".pdb") != -1); // NOT USED
	molIncludesDot = (pdbToLoad.indexOf(".") != -1);
	molIncludesHTTP = (pdbToLoad.indexOf("http://") != -1);
	molIncludesFTP = (pdbToLoad.indexOf("ftp://") != -1);
	molIncludesSlash = (pdbToLoad.indexOf("/") != -1);

	if ((molIncludesHTTP && !apacheGeneralRewriteRulesAvailable) ||
		molIncludesFTP)
	{
		if (!usingSignedApplet)
		{
			if (confirm(
"Obtaining this PDB file requires the Signed Jmol\n" +
"Applet. Click OK to use Signed Jmol, then agree\n" +
"only if you do trust the source of this applet."))
				usingSignedApplet = true;

			// else continue with unsigned applet, which will fail
			else alert("You have declined to use the signed applet.\n" +
				"The unsigned applet will be unable to obtain\n" +
				"this molecule from the source specified!");
		}
	}

	// Get pdbId for display at top of Jmol
	pdbId = pdbToLoad;
	// Trim off ".pdb"
	if ((ipdb = pdbId.indexOf(".pdb")) != -1)
		pdbId = pdbId.substring(0, ipdb);
	// Trim off leading path
	if ((islash = pdbId.lastIndexOf("/")) != -1)
		pdbId = pdbId.substring(islash + 1);
	pdbId = pdbId.toUpperCase();

	// Set PDB Id to be loaded by Jmol applet
	usePDBId = isValidPDBId(pdbToLoad);

	// Attempt to get valid PDB Id.
	validPDBId = "";
	if (usePDBId)
		validPDBId = pdbId;
		
	else
	{
		validPDBId = pdbId.substring(0, 4);
		if (!isValidPDBId(validPDBId))
			validPDBId = "";
	}

	// DECIDED THAT "words" ARE NOT ILLEGAL.
	// Exclude "words" that lack a file extension and are not URL's.
//	if (!usePDBId && !molIncludesDot && !molIncludesHTTP &&
//		!molIncludesFTP && !molIncludesSlash && isServed)
//	{
//		alert(
//"ERROR: The atomic coordinate data file is given
//in an illegal format: \"" + pdbToLoad + "\"\n" +
//FirstGlance does not know how to obtain it.");
//		pdbURL = "";
//	}

	//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
	// Construct URL for use by Jmol

	var signedTail = rcsbURLSignedTail;
	var localTail = localPDBCodesPathTail;
	var rcsbTail = rcsbPathTail;
	if (usingCIF)
	{
		signedTail = rcsbURLSignedTailCIF;
		localTail = localPDBCodesPathTailCIF;
		rcsbTail = rcsbPathTailCIF;
	}

	// SIGNED APPLET
	if (usingSignedApplet)
	{
		if (usePDBId)
		{
			if (localPDBCodesAvailable)
				pdbURL = localPDBCodesPathHead + pdbId + localTail;
			else
				pdbURL = rcsbURLSignedHead + pdbId + signedTail;
		}
		else if (molIncludesHTTP) // http://...
			pdbURL = pdbToLoad;
		else if (molIncludesSlash) // relative URL
			pdbURL = pdbToLoad;
		else // no slash, just filename, assume local
			pdbURL = localPDBFiles + pdbToLoad;
	}
	// FTP DISALLOWED (signed applet CAN use FTP)
	else if (molIncludesFTP)
	{
		alert("Sorry, this PDB file URL requires FTP\n" +
			"(File Transfer Protocol), but the\n" +
			"unsigned Jmol applet cannot use this method.");
		pdbURL = "";
	}
	// UNSIGNED APPLET
	else if (usePDBId)
	{
		if (isServed)
		{
			if (localPDBCodesAvailable)
				pdbURL = localPDBCodesPathHead + pdbId + localTail;

			else if (apacheRCSBRewriteRulesAvailable)
				pdbURL = rcsbPathHead + pdbId + rcsbTail;

			else
			{
				alert(
"Sorry, this installation of FirstGlance has no\n" +
"method for obtaining a PDB Id code!");
				pdbURL = "";
			}
		}
		else // use test location for local PDB files
			pdbURL = localTestPDBFiles + pdbToLoad + ".pdb";
	}
	else if (molIncludesHTTP)
	{
		if (!apacheGeneralRewriteRulesAvailable && !usingSignedApplet)
			pdbURL = ""; // already warned above
		else
			pdbURL = generalPathHead + pdbToLoad.substring(7); // trim off http://
	}
	else if (molIncludesSlash) // relative URL, OK isServed or not.
	{
		pdbURL = pdbToLoad;

		if (!usingSignedApplet && !isServed && pdbToLoad.indexOf("..") != -1)
		{
			if (confirm(
"Obtaining this PDB file requires the Signed Jmol\n" +
"Applet. Click OK to use Signed Jmol, then agree,\n" +
"if you are asked to trust it."))

			usingSignedApplet = true;

			else pdbURL = "";
		}
	}
	else // typically pdbToLoad will end ".pdb", but not required as long
	// as the complete filename and extension (if there is one) is given.
		pdbURL = localPDBFiles + pdbToLoad;

	if (debuggingFG)
	{
		alert("top.js #3" +
			",\n pdbToLoad="         + pdbToLoad +
			",\n usePDBId="          + usePDBId +
			",\n pdbId="             + pdbId +
			",\n molIncludesDotPDB=" + molIncludesDotPDB +
			",\n molIncludesHTTP="     + molIncludesHTTP +
			",\n molIncludesFTP="     + molIncludesFTP +
			",\n molIncludesSlash="  + molIncludesSlash +
			",\n pdbURL="            + pdbURL +
			"");
	}
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function isValidPDBId(pid)
{
	if (pid.length != 4)
		return(false);

	pid = pid.toUpperCase();

	// First character must be 1-9
	if (pid.charAt(0) < '1' || pid.charAt(0) > '9')
		return(false);
	// Last three characters must be 1-9 or A-Z
	if (!pdbIdAlphaNum(pid, 1))
		return(false);
	if (!pdbIdAlphaNum(pid, 2))
		return(false);
	if (!pdbIdAlphaNum(pid, 3))
		return(false);

	// all tests passed		
	return(true);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function pdbIdAlphaNum(pid, pos)
{
	var x = pid.charAt(pos);
	if ((x >= '0' && x <= '9') ||
		(x >= 'A' && x <= 'Z'))
		return true;
	else return false;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function get_dimensions()
{
	get_applet_dimensions(); // and DOC_HEIGHT, DOC_WIDTH

	if (outerTable)
	{
		// get helpHeight, used only in RCSB mock up fgijr.htm
		// The last term is a fudge factor because we're not in fact limiting
		// FGiJ by the full heightDecrement.
		// heightDecrement was already subtracted.
		helpHeight = DOC_HEIGHT - controlsHeight +	helpHeightFudge;
	}
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function get_applet_dimensions()
{
	DOC_WIDTH = 790; 
	DOC_HEIGHT = 400; 

	if (typeof window.innerWidth != 'undefined')
	{ 
		DOC_WIDTH = window.innerWidth; 
		DOC_HEIGHT = window.innerHeight; 
	} 
 
	else if (typeof document.documentElement.offsetWidth != 'undefined')
	{ 
		DOC_WIDTH = document.documentElement.offsetWidth;  
		DOC_HEIGHT = document.documentElement.offsetHeight;  
	} 
 
	else
	{ 
		DOC_WIDTH = document.body.offsetWidth;  
		DOC_HEIGHT = document.body.offsetHeight;  
	} 
 
//	alert ('top.js #4 DOC_WIDTH=' + DOC_WIDTH + ', DOC_HEIGHT=' + DOC_HEIGHT); 

	if (outerTable)
	{
		DOC_WIDTH -= widthDecrement;
		DOC_HEIGHT -= heightDecrement;
	}
 
	jmolWidth = parseInt( DOC_WIDTH * 0.56 ); // 0.56
	jmolHeight = parseInt( (DOC_HEIGHT * 0.95) - 30 ); // 0.95

// These dimensions are for a square applet, full window height "Tshirt"
//	jmolWidth = parseInt( DOC_WIDTH * 0.72 ); // 0.56
//	jmolHeight = parseInt(DOC_HEIGHT);

//	alert ('top.js #5 jmolWidth=' + jmolWidth + ', jmolHeight=' + jmolHeight); 
 
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function showHelp(h)
{
	if (usingFrames)
		top.frameLeft.frameLeftTop.showHelp2(h);
	else
		showHelp2(h);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function aboutFG()
{
	window.open("about.htm");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function openOptions()
{
	window.open("options.htm");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggletrnaandStarsOff() // tRNA and crosses off for 5.5 ribosome tRNAs
{
	starNonStandardResidues = false;
	doMolViewSpt(trnasOffSpt); // star rendering is done in scriptToJmol()
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggletrnaandStarsOn() // tRNA and crosses off for 5.5 ribosome tRNAs
{
	starNonStandardResidues = true;
	doMolViewSpt(trnasSpt); // star rendering is done in scriptToJmol() as a last thing
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function trnadimandStarsOff() // tRNA dimmed and crosses off for 5.5 ribosome tRNAs
{
	starNonStandardResidues = false;
	doMolViewSpt(trnadimSpt); // star rendering is done in scriptToJmol()
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggleNSRStars() // crosses
{
	if (starNonStandardResidues)
		starNonStandardResidues = false;
	else
		starNonStandardResidues = true;

	doMolViewSpt(""); // star rendering is done in scriptToJmol() as a last thing
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggleNonStandardResidues()
{
//	alert("top.js #7 showNonStandardResidues = " +
//		showNonStandardResidues);

	if (showNonStandardResidues)
		showNonStandardResidues = false;
	else
		showNonStandardResidues = true;

	// This function can be called when Ligands help, or More Views are displayed.
	// The currentView can be anything.
	// When the currentView is changed, it will either hide ligands+
	// (including non-standard residues), or if it leaves ligands+ displayed,
	// it will add script commands for non-standard residues if they are shown.

	// Modify currentView to show/hide non-standard residues.
	// Display is either spacefill or ball and stick.
	// Colors (when shown) are always CPK.

	var nsrSpt = selectNonStandardResiduesSpt;
	if (showNonStandardResidues)
	{
			nsrSpt += ballAndStickSpt;
	}
	else // hide
	{
		nsrSpt += hideBSSpt;
	}

	doMolViewSpt(nsrSpt);	
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function cancelCentering()
{
	cancelCenteringNoHelp();
	showHelp('centeringCancelledHelp');
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function centerAll()
{
	scriptToJmol(top.centerAllSpt);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function cancelHiding()
{
	cancelHidingNoHelp();
	showHelp('makeHideNoMoreHelp()');
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function cancelHidingNoHelp()
{
	top.lastHideMode = top.hideMode;
	top.hideMode = "";
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function changeHideRadio()
{
//	alert("top.js #9a entering changeHideRadio()");

	hideMode = getRadioValue(top.document.hideForm.hidewhat);

//	alert("top.js #9b hideMode = " + hideMode);

	showHelp("makeHideHelp()");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function changeSelectRadio()
{
	selectMode = getRadioValue(top.document.contactsForm.selectwhat);
	showHelp("makePreContactsHelp()"); // in changeSelectRadio()
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function clearSelectedArrays()
{
	selectedChains.length = 0;
	selectedGroups.length = 0;
	selectedAtoms.length = 0;
	selectedFound = "";
	selectedRanges.length = 0;
	selectedRangeStart = "";
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function clearSelected()
{
	clearSelectedArrays();
	scriptToJmol(makeSelectSpt()); // to regen. ~targ_current (in clearSelected())
	top.showHelp2("makePreContactsHelp()"); // in clearSelected()
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
// direction is "" or "-"
function doZoom(direction)
{
	centerMode = false; // scriptToJmol turns off picking center
	scriptToJmol("move 0 0 0 " + direction + "30 0 0 0 0 1;");
	showHelp('zoomHelp');
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function showWaterSmall()
{
	if (waterIsSmall)
	{
		doMolViewSpt(bigWaterSpt);
		waterIsSmall = false;
	}
	else
	{
		doMolViewSpt(smallWaterSpt);
		waterIsSmall = true;
	}

}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function showLigandSmall()
{
	if (ligandIsSmall)
	{
		doMolViewSpt(bigLigandSpt);
		ligandIsSmall = false;
	}
	else
	{
		doMolViewSpt(smallLigandSpt);
		ligandIsSmall = true;
	}

}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggleWireframeAll() // more detail
{
//	alert("top.js #6 allWireframe = " + allWireframe);

	if (allWireframe) // more detail to less
	{
		allWireframe = false;
		doMolViewSpt(makeVineSpt());
	}
	else // less detail to more
	{
		allWireframe = true;
		doMolViewSpt(makeWireframeAllSpt());
	}
	showHelp("makeVinesHelp()");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggleHydrogens()
{
	if (hydrogensVisible)
	{
		hydrogensVisible = false;
		doMolViewSpt(hideHydrogensSpt);
	}
	else
	{
		hydrogensVisible = true;
		if (allWireframe)
			doMolViewSpt(makeWireframeAllSpt());
		else
			doMolViewSpt(makeVineSpt());
	}
	showHelp("makeVinesHelp()");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function toggleSidechains()
{
	if (sidechainsVisible)
	{
		sidechainsVisible = false;
		doMolViewSpt(makeHideSidechainsSpt());
	}
	else
	{
		sidechainsVisible = true;
		if (allWireframe)
			doMolViewSpt(makeWireframeAllSpt());
		else
			doMolViewSpt(makeVineSpt());
	}
	showHelp("makeVinesHelp()");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
// scriptToJmol() is the main function to send a script to jmol.
// Scripts that change the molecular view should come through doMolViewSpt().
// See techinfo.htm for more.
// (just for finding while developing: stj, s2j)

function scriptToJmol(spt)
{
	spt += "#begin scriptToJmol() additions\n";

	if (!centerMode)
		spt += "set picking on;\n"; // cancels centering by picking

	if (!labelContacts) // MARK TARGETS WITH *
	{
//		alert("top.js scriptToJmol() 10:" +
//			"\n selectMode = " + selectMode +
//			"\n markContactsTargets = " + markContactsTargets +
//			"\n contactsShowing = " + contactsShowing);

		spt +=
			"select all;\n" +
			"labels off;\n" +
			"select none;\n"; // scriptToJmol()

		if (selectMode != "" || (markContactsTargets && contactsShowing))
		{
			spt += "select ~targ_current;\n"; // in scriptToJmol()
			spt += markSelected();
		}
	}

	// MARK NONSTANDARD RESIDUES WITH STARS
	if (starNonStandardResidues)
		spt += starNonStandardResiduesSpt;
	else
		spt += unStarNonStandardResiduesSpt;

	// MUST BE LAST SO HALOS REFLECT SELECTED
	// toFind is blanked in  doViewLink() when selectMode goes on.
	if (toFind != "") 
		spt += makeFindSpt();
	else
		spt += "set display normal;\n"; // scriptToJmol()

	if (debugAllScripts)
	{
//		alert("top.js #1: scriptToJmol()\n" + spt);
		showSptInWindow(spt);
	}


	if (top.usingFrames)
		top.frameRight.document.applets[0].script(spt);
	else
		top.document.applets[0].script(spt);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function returnToIntro()
{
	hideMode = "";
	cancelCenteringNoHelp(); // sends script set picking on
	showHelp('makeIntroHelp()');
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function getRadioValue(rObj)
{
	var val=null;
	for (var i=0; i<rObj.length; i++)
	{
		if (rObj[i].checked)
		{
			val = rObj[i].value;
			break;
		}
	}
	return(val);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function makeEchoSpt(txt)
{
	var echoColor = top.getEchoColor();

	var ecs =
"set echo bottom left;\
font echo 20 sanserif bold;\
color echo " + echoColor + ";\
echo \" " + txt + "\";\n";

	return ecs;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function firstWord(smw)
{
	var spn = smw.indexOf(" ");
	if (spn == -1)
	{
		alert("Programmer's error: firstWord() finds no space!");
		return(smw);
	}
	var fw = smw.substring(0, spn);
//	alert(fw + " " + fw.length);
	return fw;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function setDebugScripts()
{
	debugAllScripts =
		document.controlsForm.debugSpts.checked;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function showSptInWindow(spt)
{
		var debugWin = window.open("");
		with (debugWin.document)
		{
			writeln("<pre>\n" + spt + "</pre>");
		}
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function makeNotesLink(descrip, targ, tail, ttl)
{
	var towr = "<a href='notes.htm";

	if (validPDBId != "")
		towr += "?mol=" + validPDBId;
	
	if (targ != "")
		towr += "#" + targ;

	towr += "' target=_blank";

	if (typeof(ttl) != "undefined")
		towr += " title='" + ttl + "'"

	towr += ">" + descrip + "</a>";

	if (typeof(tail) != "undefined")
		towr += tail;

	return (towr);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function writeNotesLink(descrip, targ, tail, ttl)
{
	document.writeln(makeNotesLink(descrip, targ, tail, ttl));
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

