﻿// _kybdCommands.js - JavaScript copyright, Howard Charles Best, 2005 through 2011.
// The following JavaScript code tested using Firefox and Internet Explorer.
// Please feel free to copy / use / modify it in any way that you see fit for your own application(s)/web pages(s) as long as "Howard Charles Best (http://LLBest.com/)" is given credit in a comment, the same as or similar to this one, at the beginning of the copied / modified code.
var _uacct;
itsMSIE=navigator.userAgent.indexOf('MSIE')>0;
itsOpera=navigator.userAgent.indexOf("Opera")>=0;
document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></scr'+'ipt>');
FW='normal,bold'.split(','); // Available font weights
cookieVar='No cookies read or written so far.';
CS=fontWeightIndex=fontIndex=JI=lastJI=TP=lastFontIndex=lastFontWeightIndex=FSC=lastFSC=ND=FS=SM=0;
theKeyCode=lastKeyCode=temp1=temp9=diagVar=PL=SB=lastFunction=MM='';
blockKeyboardCommands=DM=itsAnUndo=itsRecordMode=itsAnATSmenu=omitJ=false;
lastCookie='fhfsm98';
maxAlertsDM=10;
origColor=[];
lastColor=[];
numberOfColors=256*256*256;
colorVariableTags=new Array('BGI','BG','CN','CB','LC','ALC','VLC','HLC');
colorTitles=new Array('Background image number','Background color','Text color','Bold text color','Link text color','Active link text color','Visited link text color','Hover link text color');
thisFileName=location.href.replace(/[\?#].*$/,'').replace(/^.*[\/\\]/,function(temp1){thisPathName=temp1;return('')}).replace(/%[0-9A-F]{2}/g,function(temp1){return String.fromCharCode(parseInt(temp1.substring(1),16))});
thisFileName=(thisFileName=='undefined')?'.':thisFileName;
thisURL2=thisPathName+thisFileName;
thisFileName=thisFileName?thisFileName:'.';
thisFileNameP=location.href.replace(/^.*?\?P=/,'').replace(/&.*$/,'');
theCookieName=document.title.replace(/ .*$/,'');
(cookieAndURLparser1(cookieRead(theCookieName))).replace(/^;?DM=([^;]*)/,function(temp1){DM=temp1.slice(3)});
location.search.replace(/[\?&]DM=([^&]*)/,function(temp1){DM=temp1.slice(4)});
try{eval('DM='+DM)}catch(e){}
function alertDM(theMessage)
 {
 if(maxAlertsDM)
  {
  alert(theMessage);
  maxAlertsDM--;
  }
 else
  changeDM();
 }
function changeStyles(calledBy)
 {
 styleRulesCount2=theStyles.cssRules?theStyles.cssRules.length /* Firefox */ :theStyles.rules.length /* IE */ ;
 var T1='color:#';
 var T2='';
 for(var i=0;i<6;i+=2)
  T2+=('0'+(parseInt((parseInt(CN.substring(i,i+2),16)+parseInt(BG.substring(i,i+2),16)*7)/8+0.5)).toString(16)).slice(-2).toUpperCase();
 var T3=T1+CN;
 var T4=';background:#';
 var T5='text-align:center';
 var T7=T3+T4+BG;
 var T9=';border-color:#'+CB;
 var T10=T7+T9;
 var T11=T3+T4+T2+T9;
 var T12=T4+BG+';background-image:url('+homeDir+'/'+imageFolder+G[BGI]+')';
 var T13=T1+CB+';';
 var T14=T13+T9+T4+T2;
 var T15=T3+';background:transparent';
 var T16=T3+';text-align:'+J[JI];
 T4=FW[fontWeightIndex];
 var T17=FF[fontIndex]+','+AF;
 GEBI('textDiv').style.fontFamily=T17;
 try{GEBI('textP').style.fontFamily=T17}catch(er){}
 GEBI('textDiv').style.fontWeight=T4;
 try{GEBI('textP').style.fontWeight=T4}catch(er){}
 T17=';font-family:'+T17+';font-weight:'+T4;
 T18=T13+T17;
 T19=T16+T17;
 document.body.style.background='#'+T2;
 try{GCD.body.style.background='#'+BG;GCD.body.style.color='#'+CN}catch(e){};
 if(theStyles.deleteRule)
  { // Firefox:
  for(i=styleRulesCount2-1;i>=styleRulesCount;i--)
   theStyles.deleteRule(i);
  theStyles.insertRule('a:active{'+T1+ALC+'}',theStyles.cssRules.length);
  theStyles.insertRule('a:hover{'+T1+HLC+'}',theStyles.cssRules.length);
  theStyles.insertRule('a:link{'+T1+LC+'}',theStyles.cssRules.length);
  theStyles.insertRule('a:visited{'+T1+VLC+'}',theStyles.cssRules.length);
  theStyles.insertRule('div{'+T12+'}',theStyles.cssRules.length);
  theStyles.insertRule('h1{'+T18+'}',theStyles.cssRules.length);
  theStyles.insertRule('h2{'+T18+'}',theStyles.cssRules.length);
  theStyles.insertRule('h3{'+T18+'}',theStyles.cssRules.length);
  theStyles.insertRule('hr{'+T13+'}',theStyles.cssRules.length);
  theStyles.insertRule('iframe{'+T9+'}',theStyles.cssRules.length);
  theStyles.insertRule('img{'+T9+'}',theStyles.cssRules.length);
  theStyles.insertRule('input{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('input.INP1{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('input.INP2{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('input.INP3{'+T15+'}',theStyles.cssRules.length);
  theStyles.insertRule('input.INP5{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('ol{'+T16+'}',theStyles.cssRules.length);
  theStyles.insertRule('p{'+T16+'}',theStyles.cssRules.length);
  theStyles.insertRule('p.ColorBox{'+T14+'}',theStyles.cssRules.length);
  theStyles.insertRule('p.TBOX{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('select{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('span{'+T13+'}',theStyles.cssRules.length);
  theStyles.insertRule('span.CN{'+T3+'}',theStyles.cssRules.length);
  theStyles.insertRule('span.G{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.BBOX{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.TS4{'+T10+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.TS5{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.TS6{'+T11+'}',theStyles.cssRules.length);
  //theStyles.insertRule('td{'+T19+'}',theStyles.cssRules.length);
  theStyles.insertRule('td.center{'+T5+'}',theStyles.cssRules.length);
  theStyles.insertRule('td.change{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('textarea.TA2{'+T10+'}',theStyles.cssRules.length);
  theStyles.insertRule('textarea.TA3{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('textarea.TA4{'+T10+'}',theStyles.cssRules.length);
  theStyles.insertRule('tt{'+T3+'}',theStyles.cssRules.length);
  }
 else
  {
  if(theStyles.removeRule)
   { // IE:
   try{GCD.body.style.scrollbarBaseColor='#'+T2}catch(e){};
   for(i=styleRulesCount2-1;i>=styleRulesCount;i--)
    removeArule(i);
   addArule('a:active',T1+ALC);
   addArule('a:hover',T1+HLC);
   addArule('a:link',T1+LC);
   addArule('a:visited',T1+VLC);
   addArule('body','scrollbar-base-color:'+T2);
   addArule('div',T12);
   addArule('h1',T18);
   addArule('h2',T18);
   addArule('h3',T18);
   addArule('hr',T13);
   addArule('iframe',T9);
   addArule('img',T9);
   addArule('input',T7);
   addArule('input.INP1',T7);
   addArule('input.INP2',T7);
   addArule('input.INP3',T15);
   addArule('input.INP5',T7);
   addArule('ol',T16);
   addArule('p',T16);
   addArule('p.ColorBox',T14);
   addArule('p.TBOX',T11);
   addArule('select',T7);
   addArule('span',T13);
   addArule('span.CN',T3);
   addArule('span.G',T11);
   addArule('table.BBOX',T11);
   addArule('table.TS4',T10);
   addArule('table.TS5',T11);
   //addArule('td',T19);
   addArule('td.center',T5);
   addArule('td.change',T11);
   addArule('.TA2',T10);
   addArule('.TA3',T7);
   addArule('.TA4',T10);
   addArule('tt',T3);
   }
  }
 cookieParamsWrite(calledBy);
 }
function changeDM()
 {
 DM=!DM
 alert(DM?'Diagnostic mode started. Press "Shift+D" to stop.\ndiagVar = "'+diagVar+'"\nAutomatically stopped after '+maxAlertsDM+' alerts in order to prevent infinite loop.':'Diagnostic mode stopped. Press "Shift+D" to restart.');
 cookieParamsWrite('changeDM()');
 }
function chooseRandomColor(min,max)
 {
 return(('00000'+(min+Math.floor(Math.random()*(max-min))).toString(16)).slice(-6).toUpperCase());
 }
function colorDimmer(theForegroundColor,theBackgroundColor,theDimmingPercent)
 {
 var T1='';
 for(var i=0;i<theForegroundColor.length;i+=2)
  T1+=decimalToHex((parseInt(theForegroundColor.substr(i,2),16)*(100-theDimmingPercent)+parseInt(theBackgroundColor.substr(i,2),16)*theDimmingPercent)/100);
 return(T1);
 }
function colorNameToCode(theColor)
 {
 var T1=document.bgColor,T2=theColor;
 T2=T2.replace(/^[0-9a-fA-F]{1,6}$/,function(T1){return((T1+'00000').replace(/^(......).*$/,'#$1'))});
 try
  {
  if(itsMSIE)
   {
   document.body.style.backgroundColor=T2;
   T2=document.bgColor.replace(/^#/,'');
   document.body.style.backgroundColor=T1;
   }
  else
   {
   document.bgColor=T2;
   T2=document.bgColor.replace(/^#/,'');
   document.bgColor=T1;
   }
  }
 catch(e)
  {
  T2='000000';
  }
 return(T2.toUpperCase());
 }
function colorNegative(theColor)
 {
 if(theColor.length==6)
  {
  var T1=theColor.split('');
  for(var i=0;i<T1.length;i++)
   T1[i]=(15-parseInt(T1[i],16)).toString(16).toUpperCase();
  return(T1.join(''));
  }
 else
  {
  alert('"'+theColor+'" is not a valid color code.');
  return(theColor);
  }
 }
function colorParser(theIncrement)
 {
 CS|=0;
 CS=(CS+theIncrement+C.length)%C.length;
try{eval(C[CS].replace(/=/g,'="').replace(/&/g,'";')+'"')}catch(e){alert(e)};
 BGI|=0;
 for(i=0;i<colorVariableTags.length;i++)
  eval('origColor['+i+']='+colorVariableTags[i]);
 }
function colorShift(theColor)
 {
 var T1=[theColor.slice(2,4),theColor.slice(-2),theColor.slice(0,2)];
 return(T1.join(''));
 }
function ComplimentaryColors()
 {
 for(var i=1;i<colorVariableTags.length-2;i++)
  eval(colorVariableTags[i]+'=colorNegative('+colorVariableTags[i]+')');
 BGI=(BGI==1)?2:(BGI==2)?1:0;
 changeStyles();
 }
function cookieAndURLparser1(theString)
 {
 return(theString?(theString.replace(/=/g,'="').replace(/;/g,'";')+'";'):'');
 }
function cookieAndURLparser2(theString)
 {
 return(theString?(theString.replace(/^\??/,';').replace(/&/g,'";').replace(/;AM=/g,';MM=').slice(1).replace(/=/g,'="').replace(/\+/g,' ')+'";'):'');
 }
function cookieParamsWrite(calledBy)
 {
 theCookie=encodeURL('dhr6344qq','cookieParamsWrite() / '+calledBy,'').slice(1).replace(/&/g,';')
 if(theCookie!=lastCookie)
  {
  cookieWrite(theCookieName,theCookie,8,calledBy);
  lastCookie=theCookie;
  }
 }
function cookieRead(cookieName)
 {
 var T1=document.cookie,T2=cookieName+'=',T3='',T4,T5='';
 if(T1)
  {
  T3=T1.indexOf(T2);
  if(T3+1)
   { 
   T3+=T2.length;
   T4=T1.indexOf(";",T3);
   if(!(T4+1))
    T4=T1.length;
   T5=unescape(T1.substring(T3,T4));
   cookieVar='Cookie "'+cookieName+'" containing "'+T5+'" read.\n';
   if(DM)
    alertDM(cookieVar);
   }
  }
 return(T5);
 }
function cookieWrite(cookieName,cookieContents,numberOfDaysToKeep,calledBy)
 {
 if(!calledBy)
  calledBy='';
 var T1=new Date();
 T1.setTime(T1.getTime()+86400000*((cookieContents)?numberOfDaysToKeep:0));
 document.cookie=cookieName+'='+escape(cookieContents)+"; expires="+T1.toUTCString()+';path=/';
 cookieVar='Cookie "'+cookieName+'" '+(cookieContents?' containing "'+cookieContents+'" written':'deleted')+'.\n';
 if(DM)
  alertDM(cookieVar);
 if(!cookieContents&&(calledBy=='V key'))
  alert('Defaults restored and cookie deleted.');
 }
function decimalToHex(decNum)
 {
 var T1=(decNum|0).toString(16).toUpperCase();
 return(((T1.length<2)?'0':'')+T1);
 }
function encodeURL(theFileName,calledBy,parameters,evalString)
 {
 if(!calledBy)
  calledBy='';
 var T1='',T2,T3;
 if(DM)
  alertDM('_kybdCommands.js - encodeURL()\ncalledBy = "'+calledBy+'"\nparameters = "'+parameters+'"');
 if(parameters)
  {
  T2=parameters.split(/,/);
  for(i in T2)
   {
   T3=T2[i];
   //test('T1+='+T3+"?'&"+T3+"='+"+eval(T3)+":'';");
   eval('T1+='+T3+"?'&"+T3+"='+'"+eval(T3)+"':'';");
   }
  }
 if(evalString)
  eval(evalString);
 T2=FFT[fontIndex]+fontWeightIndex;
 T1+=(T2==FFT[0]+0)?'':'&F='+T2;
 T1+=CS?'&CS='+CS:'';
 T1+=DM?'&DM='+DM:'';
 T1+=(JI&&(!FS))?'&JI='+JI:'';
 for(var i=0;i<origColor.length;i++)
  {
  T2=colorVariableTags[i];
  eval('T1+=(origColor['+i+']=='+T2+')?"":"&'+T2+'='+eval(T2)+'"');
  }
 if(calledBy.substr(0,17)=='cookieParamsWrite')
  {
  T1+=(VOL!=initialVOL)?'&VOL='+VOL:'';
  T1+=((itsAnATSmenu&&GEBI('FScheckBoxID').checked)||(!itsAnATSmenu&&FSC))?'&FSC=1':'';
  }
 else
  {
  //test(calledBy);
  T2=(calledBy=='S key')?Math.round((Math.max(document.documentElement.scrollTop,document.body.scrollTop)/GEBI('textDiv').clientHeight*10000)):0;
  //test(T2);
  T1+=T2?'&TP='+T2:'';
  T1+=ND?'&ND='+ND:'';
  }
 return(T1);
 }
function enoughContrast(color1,color2)
 {
 var T1=0;
 for(var i=0;i<color1.length;i+=2)
  T1+=Math.abs(parseInt(color1.substr(i,2),16)-parseInt(color2.substr(i,2),16));
 // T1 ranges from 0 to 765
 return(T1>=255)
 }
function EnterColorsManually()
 {
 var T1=BGI;
 if(itsAnUndo)
  {
  BGI=lastBGI;
  undoColors();
  }
 else
  {
  storeLastColors();
  var T2,T3,T4;
  for(var i=0;i<colorVariableTags.length;i++)
   {
   T2=colorVariableTags[i];
   T3=T2=='BG';
   T4=prompt(colorTitles[i]+':',(eval(T2)));
   if(T4==null)
    break;
   eval(T2+((T2=='BGI')?'=(T4|0);if(isNaN('+T2+')){'+T2+'=0}':'=colorNameToCode(T4)'));
   if(T2=='BGI')
    {   
    T2=BGI;
    T3=Math.min(T2,G.length-1);
    if(T2)
     BGI=T3;
    }
   changeStyles();
   T1=BGI;
   }
  }
 lastBGI=T1;
 changeStyles();
 }
function GEBI(theID)
 {
 return(document.getElementById(theID));
 }
function helpText2(omitTheJ)
 {
 var T1=(fontWeightIndex+1+FW.length)%FW.length,T2=C.length;
 CS|=0;
 return('C - Switch to #'+((CS+1+T2)%T2)+' out of '+T2+' preset color schemes.\n\n'+
 (thereAreDiacritics?'D - '+(ND?'Restore':'Remove')+' diacritics.\n\n':'')+
 'F - Switch to '+FF[(fontIndex+(T1?0:1)+FF.length)%FF.length]+' ('+FW[T1]+') font.\n\n'+
 'G - Go to index / home page.\n\n'+
 'H - This help window.\n\n'+
 'K - Switch to complimentary colors.\n\n'+
 'I - Cycle through the '+(G.length-1)+' background images.\n\n'+
 (omitTheJ?'':'J - Cycle through 4 types of text justification.\n\n')+
 'M - Enter colors manually.\n\n'+
 'Q - Undo.\n\n'+
 'S - Store (bookmark) the vertical scroll position and the current subtitle number within the URL in the "Address Bar" above. If you are going to want to return to this same web page / scroll position / subtitle number on...\n  1. ...this computer, then save the newly created URL as a "Favorite" / "Bookmark".\n  2. ...a DIFFERENT computer, then copy / paste the URL into an email message and send it to yourself.\n\n'+
 'V - Restore defaults and delete cookie.\n\n'+
 'W - Display information.\n\n'+
 'X - Switch to randomly generated color scheme.\n\n'+
 '');
 }
function Hex()
 {
 theCount=0;
 assignNewDataToTextBox(GEBI('TXTBOX').value
  .replace(/[\x80-\xff]/g,function(T1){theCount++;return "\\x"+T1.charCodeAt().toString(16).toUpperCase()})
  .replace(/[\u0100-\u0fff]/g,function(T1){theCount++;return "\\u0"+T1.charCodeAt().toString(16).toUpperCase()})
  .replace(/[\u1000-\uffff]/g,function(T1){theCount++;return "\\u"+T1.charCodeAt().toString(16).toUpperCase()})
  );
 displayCharactersChanged();
 }
function itsDark(theColor)
 {
 if(theColor.toLowerCase()=="transparent")
  return(255+255+255);
 else
  {
  var T1=0;
  for(var j=0;j<theColor.length;j+=2)
   T1+=parseInt(theColor.substr(j,2),16);
  // T1 ranges from 0 to 765
  return(T1<384);
  }
 }
function keyPressed(theEvent)
 {
 var T1=itsMSIE?theEvent.keyCode:theEvent.which;
 T1=String.fromCharCode(T1);
 if(blockKeyboardCommands)
  {
  try{keyPressed2(T1,theEvent.shiftKey)}catch(e){};
  return;
  }
 else
  try{T1=keyPressed3(T1)}catch(e){};
 if(theEvent.ctrlKey||theEvent.altKey)
  return;
 if(theEvent.shiftKey&&(T1=='D'))
  {
  changeDM();
  return;
  }
 sw(T1);
 }
  
function loadIt(theFileName,calledBy,parameters)
 {
 if(typeof(calledBy)=='undefined')
  calledBy='';
 if(typeof(parameters)=='undefined')
  parameters='';
 var T1=encodeURL(theFileName,calledBy,parameters+((!calledBy||(calledBy=='S key'))?(parameters?',':'')+'P':''),'');
 location=((theFileName?theFileName:'.')+(T1?'?'+T1.slice(1):'')).replace(/(#.*?)(\?.*$)/,'$2$1');
 }
function NextBackgroundImage()
 {
 var T1=BGI;
 BGI=itsAnUndo?lastBGI:(BGI+1)%G.length;
 lastBGI=T1;
 changeStyles();
 }
function NextPresetColorScheme()
 {
 var T1;
 if(itsAnUndo)
  {
  lastCSincrement=-lastCSincrement;
  T1=lastCSincrement;
  }
 else
  lastCSincrement=T1=1;
 colorParser(T1);
 changeStyles();
 }
function NextPresetFont()
 {
 var T1=fontWeightIndex,T2=fontIndex;
 if(itsAnUndo)
  {
  fontWeightIndex=lastFontWeightIndex;
  fontIndex=lastFontIndex;
  }
 else
  {
  fontWeightIndex++;
  fontWeightIndex=(fontWeightIndex+FW.length)%FW.length;
  if(!fontWeightIndex)
   {
   fontIndex++;
   fontIndex=(fontIndex+FF.length)%FF.length;
   }
  }
 lastFontWeightIndex=T1;
 lastFontIndex=T2;
 changeStyles();
 try{NextPresetFont2()}catch(e){}
 }
function pageLoaded()
 {
 if(typeof(homeDir)=='undefined')
  homeDir='.';
 if(typeof(defaultVOL)=='undefined')
  defaultVOL=25;
 if(typeof(VOL)=='undefined')
  VOL=defaultVOL;
 initialVOL=lastVOL=defaultVOL;
 if(typeof(J)=='undefined')
  J='justify,center,left,right'.split(',');
 if(typeof(P)=='undefined')
  P=0;
 if((thisFileName!='.')||(typeof(thereAreDiacritics)=='undefined'))
  thereAreDiacritics=false;
 if(typeof(JavaScriptForKeyG)=='undefined')
  JavaScriptForKeyG="loadIt('.','G key'); // _kybdCommands.js";
 if(typeof(JavaScriptForKeyS)=='undefined')
  JavaScriptForKeyS="loadIt(thisFileName,'S key'); // _kybdCommands.js";
 if(itsOpera)
  GEBI('theBodyID').style.fontSize='79%';
 var T1,T2,T3,T4,T5,T6;
 // iPhone, iPad, BlackBerry Storm 
 try{if(navigator.userAgent.match(/(iPhone|iPad|BlackBerry9530)/i)){GEBI('touchScreenSpan1').innerHTML=GEBI('touchScreenSpan2').innerHTML='<textarea class=TA4 style="text-align:center;font-family:Tahoma;font-size:16pt;width:410;line-height:1.2em;border:solid;border-width:1;margin:0;margin-bottom:5;overflow:hidden;" rows="2" readonly="readonly">Tap here to bring up the touch screen keyboard. (Then tap \u201cH\u201d for help.)</textarea>'}}catch(e){};
 try{_uacct=GA;}catch(e){};
 try{urchinTracker()}catch(e){}  // Call Google Analytics function
 diagVar='';
 colorParser(0);
 T1=BG;
 BG=F=j=0;
 lastCookie=cookieRead(theCookieName);
 T4=cookieAndURLparser1(lastCookie);
 T5=cookieAndURLparser2(location.search);
 temp1=T6='';
 try{eval(T4)}catch(e){}
 try{eval(T5)}catch(e){}
 if(CS)
  {
  CS|=0;
  CS=(CS+C.length)%C.length;
  colorParser(0);
  T1=BG;
  try{eval(T4)}catch(e){}
  try{eval(T5)}catch(e){}
  }
 if(F)
  {
  T6=(F.slice(-1))|0;
  T5=(F&&(!isNaN(T6)))?T6:0;
  fontWeightIndex=Math.min(FW.length-1,Math.max(0,T5));
  T6=F.slice(0,-1);
  for(i=0;i<FF.length;i++)
   {
   if(T6==FFT[i])
    {
    fontIndex=i;
    //fontName=FF[fontIndex];
    break;
    }
   }
  }
 BG=BG?BG:T1
 BGI|=0;
 if(j)
  JI|=0;
 if(JI>=J.length)
  JI=0;
 ND|=0;
 try{eval('DM='+DM)}catch(e){}
 if(DM)
  {
  DM=false;
  changeDM();
  }
 VOL|=0;
 theStyles=document.styleSheets[0];
 styleRulesCount=theStyles.cssRules?theStyles.cssRules.length /* Firefox */ :theStyles.rules.length /* IE */ ;
 if(theStyles.addRule)
  { // IE:
  addArule=theStyles.addRule;
  removeArule=theStyles.removeRule;
  }
 try{GEBI('pressH1').innerHTML=GEBI('pressH2').innerHTML='Press <span>H</span> for help. |'}catch(er){}
 changeStyles();
 if(TP&&(location.href.indexOf('#')<0))
  setTimeout("window.scrollTo(0,TP*GEBI('textDiv').clientHeight/10000)",10);
 helpText1='AVAILABLE KEYBOARD COMMANDS:\n\n';
 }
function RandomColorScheme()
 {
 if(itsAnUndo)
  {
  undoColors();
  }
 else
  {
  storeLastColors();
  var T2;
  CS=0;
  colorParser(0);
  BGI=0;
  var T4=Math.random()>0.5;
  var T5=Math.random()>0.5;
  for(var T3=1;;T3++)
   {
   BG=chooseRandomColor(0,numberOfColors);
   CB=chooseRandomColor(0,numberOfColors);
   if(T4)
    {
    CN=colorDimmer(CB,T5?BG:itsDark(BG)?'FFFFFF':'000000',50);
    T2='bold font'+(T5?'/background':'');
    }
   else
    {
    CN=itsDark(BG)?'FFFFFF':'000000';
    T2='background';
    }
   if(enoughContrast(BG,CB)&&enoughContrast(BG,CN)&&enoughContrast(CB,CN))
    break;
   }
  setLinkColors();
  }
 changeStyles();
 }
function RestoreDefaultColorsEtc()
 {
 var T1=fontWeightIndex,T2=fontIndex,T3=JI,T4=CS,T5=VOL,T6=FSC;
 if(itsAnUndo)
  {
  fontWeightIndex=lastFontWeightIndex;
  fontIndex=lastFontIndex;
  JI=lastJI;
  CS=lastCS;
  VOL=lastVOL;
  FSC=lastFSC;
  undoColors();
  }
 else
  {
  storeLastColors();
  CS=fontWeightIndex=fontIndex=JI=FSC=0;
  VOL=initialVOL;
  colorParser(0);
  }
 lastFontWeightIndex=T1;
 lastFontIndex=T2;
 lastJI=T3;
 lastCS=T4;
 lastVOL=T5;
 lastFSC=T6;
 changeStyles('V key');
 ND=0;
 if((fontWeightIndex!=T1)||(fontIndex!=T2))
  try{NextPresetFont2()}catch(e){}
 }
function SearchUsingFreeFind(theID)
 {
 location.href='http://search.freefind.com/find.html?id='+theID+'&pageid=r&mode=ALL&n=0&_charset_=utf-8&bcd=%C3%B7&query='+SearchStringURLPrep(document.theForm.SearchString.value);
 }
function SearchStringURLPrep(SearchString)
 {
 return(SearchString.replace(/[ \xA0]/g,'+').replace(/"/g,'%22').replace(/[\xA1-\uffff]/g,function(T1){var T2=T1.charCodeAt();var T3=T2>>6;var T4=T3>>6;var T5=T1>'\u0fff';return(((T5?'%'+(224+T4).toString(16):'')+'%'+(T3-((T4-(T5?2:3))<<6)).toString(16)+'%'+(T2-((T3-2)<<6)).toString(16)).toUpperCase())}));
 }
function setLinkColors()
 {
 LC=CB;
 VLC=CN;
 HLC=(enoughContrast(HLC,BG))?'FF0000':'0000FF';
 ALC=colorDimmer(colorNegative(LC),itsDark(LC)?'FFFFFF':'000000',40);
 }
function storeLastColors()
 {
 //alert(5342);
 for(var i=0;i<colorVariableTags.length;i++)
  eval('lastColor['+i+']='+colorVariableTags[i]);
 } 
 
function sw(theKeyCode)
 {
 //alert(theKeyCode);
 if(theKeyCode=='Q')
  {
  itsAnUndo=true;
  theKeyCode=lastKeyCode;
  if(!theKeyCode)
   {
   if(lastFunction)
    {
    eval(lastFunction);
    itsAnUndo=false;
    }
   return;
   }
  }
 try{if(sw2(theKeyCode)){return}}catch(e){};
 switch(theKeyCode)
  {
  case'C':
   NextPresetColorScheme();
   break;
  case'D':
   toggleDiac();
   break;
  case'F':
   NextPresetFont();
   break;
  case'G':
   //test1(JavaScriptForKeyG);
   eval(JavaScriptForKeyG);
   break;
  case'H':
   alert(helpText1+helpText2(omitJ));
   break;
  case'I':
   NextBackgroundImage();
   break;
  case'J':
   TextJustification();
   break;
  case'K':
   ComplimentaryColors();
   break;
  case'M':
   EnterColorsManually('changeStyles()');
   break;
  case'S':
   //test1(JavaScriptForKeyS);
   eval(JavaScriptForKeyS);
   break;
  case'V':
   RestoreDefaultColorsEtc();
   break;
  case'W': // (Insert)
   alert('Screen resolution: '+screen.width+'x'+screen.height+'\nAvailable: '+screen.availWidth+'x'+screen.availHeight+'\nThis file name: '+thisFileName+'\nCurrent font: '+FF[fontIndex]+' ('+FW[fontWeightIndex]+')\nText justification: '+J[JI]+'\nURL: '+location);
   break;
  case'X':
   RandomColorScheme();
   break;
  default:
   return;
  }
 lastKeyCode=theKeyCode;
 itsAnUndo=false;
 }
function test1(t)
 {
 alert(t+' '+typeof(t));
 }
function TextJustification()
 {
 var T1=JI;
 JI=itsAnUndo?lastJI:(JI+1)%J.length;
 lastJI=T1;
 changeStyles();
 }
function toggleDiac()
 {
 if(thereAreDiacritics)
  {
  //test1(ND);
  ND=ND?0:1;
  eval(JavaScriptForKeyS);
  }
 }
function undoColors()
 {
 var T1,T2;
 for(var i=0;i<colorVariableTags.length;i++)
  {
  T1=colorVariableTags[i];
  eval('T2='+T1);
  eval(T1+'=lastColor['+i+']');
  eval('lastColor['+i+']=T2');
  }
 }

