﻿// _kybdCommands.js - JavaScript copyright, Howard Charles Best, 2005 through 2012.
// 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;
itsFirefox9=navigator.userAgent.indexOf('Firefox/9')>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=KCglobalTemp1=currentlyFocusedTextArea=touchScreenMessage1=touchScreenMessage2=keyboardMacroList='';
blockKeyboardCommands=DM=itsAnUndo=itsRecordMode=itsAnATSmenu=omitJ=semicolonPressed=itsAtouchScreen=false;
lastCookie='fhfsm98';
maxAlertsDM=10;
origColor=[];
lastColor=[];
keyboardShortcuts={};
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))});
thisDomainName=location.href.replace(/\/[^\/]*$/,'').replace(/^.*\//,'').replace(/^www\./,'');
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){}
http=itsMSIE?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
originalEA=EA='yourEmailAddress@gmail.com';
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:#';
//alert(CN)
//alert(BG)
 var T2=colorDimmer(CN,BG,88);
//alert(T2)
 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(e){}
 GEBI('textDiv').style.fontWeight=T4;
 try{GEBI('textP').style.fontWeight=T4}catch(e){}
 T17=';font-family:'+T17+';font-weight:'+T4;
 var T18=T13+T17;
 var T19=T16+T17;
 var T20=T1+colorDimmer(CN,BG,60);
 //alert(T20)
 document.body.style.background='#'+T2;
 try{GCD.body.style.background='#'+BG;GCD.body.style.color='#'+CN}catch(e){};
 try{document.body.style.scrollbarBaseColor='#'+T2}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('button{'+T7+'}',theStyles.cssRules.length);
  theStyles.insertRule('input.INP1{'+T10+'}',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.PS3{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('select{'+T10+'}',theStyles.cssRules.length);
  theStyles.insertRule('span{'+T13+'}',theStyles.cssRules.length);
  theStyles.insertRule('span.SS1{'+T3+'}',theStyles.cssRules.length);
  theStyles.insertRule('span.SS2{'+T3+'}',theStyles.cssRules.length);
  theStyles.insertRule('span.SS3{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('span.SS4{'+T20+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.BBOX{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.TS1{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('table.TS2{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('td{'+T19+'}',theStyles.cssRules.length);
  theStyles.insertRule('td.TD1{'+T5+'}',theStyles.cssRules.length);
  theStyles.insertRule('td.TD2{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('td.TD3{'+T11+'}',theStyles.cssRules.length);
  theStyles.insertRule('textarea.TA1{'+T10+'}',theStyles.cssRules.length);
  theStyles.insertRule('textarea.TA2{'+T10+'}',theStyles.cssRules.length);
  }
 else
  {
  if(theStyles.removeRule)
   { // IE:
   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('button',T7);
   addArule('input.INP1',T10);
   addArule('ol',T16);
   addArule('p',T16);
   addArule('p.ColorBox',T14);
   addArule('p.PS3',T11);
   addArule('select',T10);
   addArule('span',T13);
   addArule('span.SS1',T3);
   addArule('span.SS2',T3);
   addArule('span.SS3',T11);
   addArule('span.SS4',T20);
   addArule('table.BBOX',T11);
   addArule('table.TS1',T11);
   addArule('table.TS2',T11);
   addArule('td',T19);
   addArule('td.TD1',T5);
   addArule('td.TD2',T11);
   addArule('td.TD3',T11);
   addArule('textarea.TA1',T10);
   addArule('textarea.TA2',T10);
   }
  }
 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){
 //test1(decimalToHex((parseInt(theForegroundColor.substr(i,2),16)*(100-theDimmingPercent)+parseInt(theBackgroundColor.substr(i,2),16)*theDimmingPercent)/100))
  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));
 //alert(cookieContents);
 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+=(EA!=originalEA)?'&EA='+EA:'';
 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'+
 (JavaScriptForKeyG?'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 the vertical scroll position, etc. within the URL in the "Address Bar" above.\n\n'+
 'V → Restore defaults and delete cookie.\n\n'+
 'W → Display information.\n\n'+
 'X → Switch to randomly generated color scheme.\n\n'+
 (((thisDomainName=='rtvik.com')||(thisDomainName=='feedacow.com'))?'':'\nKEYBOARD MACROS (Available in '+((thisDomainName=='causelessmercy.com')?'':((thisDomainName=='llbest.com')?'most':'many')+' of ')+"this website's text input boxes):\n\n"+keyboardMacroList)+
 '');
 }
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&&currentlyFocusedTextArea)
  {
  //alert(T1)
  try{keyPressed2(T1,theEvent.shiftKey)}catch(e){};
  if((T1==';')||(itsAtouchScreen&&(T1==' ')))
   {
   if(semicolonPressed)
    semicolonPressed=false;
   else
    {
    semicolonPressed=true;
    if(currentlyFocusedTextArea)
     setTimeout("replaceSelectedText(GEBI(currentlyFocusedTextArea),'',1)",1);
    }
   lastKeyCode=T1;
   return;
   }
  if(semicolonPressed&&(T1!='\x10'))
   {
   semicolonPressed=false;
   KCglobalTemp1=keyboardShortcuts[T1];
   if(typeof(KCglobalTemp1)=='undefined')
    KCglobalTemp1=lastKeyCode+T1;
   if(KCglobalTemp1&&currentlyFocusedTextArea)
    setTimeout("replaceSelectedText(GEBI(currentlyFocusedTextArea),KCglobalTemp1,1)",1);
   }
  return;
  }
 else
  {
  if(blockKeyboardCommands)
   return;
  try{T1=keyPressed3(T1)}catch(e){};
  T1=T1.toUpperCase();
  }
 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(itsATS)=='undefined')
  itsATS=false;
 if(typeof(includeSanskrit)=='undefined')
  includeSanskrit=false;
 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";
 var T1,T2,T3,T4,T5,T6;
 try{document.createEvent("TouchEvent");itsAtouchScreen=true;}catch(e){};
 //itsAtouchScreen=true;
 if(itsAtouchScreen)
  {
  try{GEBI('touchScreenSpan1').innerHTML='';touchScreenMessage1='<textarea class="TA2" style="text-align:center;font-family:Tahoma;font-size:16pt;width:410px;height:53px;margin:0px;margin-bottom:5px;overflow:hidden;" onkeyup="GEBI(\'touchScreenSpan1\').innerHTML=touchScreenMessage1">Tap here to bring up the touch screen keyboard. (Then tap \u201cH\u201d for help.)</textarea>';GEBI('touchScreenSpan1').innerHTML=touchScreenMessage1;}catch(e){}
  try{GEBI('touchScreenSpan2').innerHTML='';touchScreenMessage2='<textarea class="TA2" style="text-align:center;font-family:Tahoma;font-size:16pt;width:410px;height:53px;margin:0px;margin-bottom:5px;overflow:hidden;" onkeyup="GEBI(\'touchScreenSpan2\').innerHTML=touchScreenMessage2">Tap here to bring up the touch screen keyboard. (Then tap \u201cH\u201d for help.)</textarea>';GEBI('touchScreenSpan2').innerHTML=touchScreenMessage2;}catch(e){}
  }
 keyboardShortcuts=itsAtouchScreen?{
 ';':';','b':'2','e':'5','f':'6','j':'0','k':'@','o':';','p':'.','q':'"','v':':','w':'?','x':'-','"':'“','\'':'”','(':'‘',')':'’','.':'…','-':'—','$':'¿','!':'™','?':'©','1':'⅛','2':'¼','3':'⅜','4':'½','5':'⅝','6':'¾','7':'⅞','8':'⅓','9':'⅔','0':'°','!':'☺','?':'†',':':'‡','@':'¹','&':'²','$':'♪',',':'³','/':'¢'}:{
 ';':';','[':'“',']':'”','`':'‘','\'':'’','.':'…','-':'—','=':'•',',':'™','/':'©','1':'⅛','2':'¼','3':'⅜','4':'½','5':'⅝','6':'¾','7':'⅞','8':'⅓','9':'⅔','0':'°','b':'☺','e':'†','f':'‡','o':'¹','p':'²','q':'³','j':'<span>','k':'</span>','v':'<i>','w':'</i>','x':'<a href="" title="" target="_blank"></a>','?':'<img src="" alt="">','\\':'<textarea class="TA2" wrap="off" style="height:35px"; readonly="readonly"></textarea>','|':'<table class="BBOX"><td class="BBOX"><button onclick="()" title=""></button></td></table>'};
 if(includeSanskrit||itsAtouchScreen)
  {
  T1=includeSanskrit?{
  'a':'ā','c':'ś','d':'ḍ','g':'ṅ','h':'ḥ','i':'ī','l':'ḷ','m':'ṁ','n':'ṇ','r':'ṛ','s':'ṣ','t':'ṭ','u':'ū','y':'ñ','z':'ṝ','A':'Ā','C':'Ś','D':'Ḍ','G':'Ṅ','H':'Ḥ','I':'Ī','J':'l̐','L':'Ḷ','M':'Ṁ','N':'Ṇ','R':'Ṛ','S':'Ṣ','T':'Ṭ','U':'Ū','Y':'Ñ','Z':'Ṝ'}:{
  'a':'1','c':'3','d':'4','g':'7','h':'8','i':'9','l':'\'','m':'!','n':',','r':'(','s':'[','t':')','u':'$','y':'&','z':']'};
  for(i in T1)
   keyboardShortcuts[i]=T1[i];
  }
 if(includeSanskrit&&itsAtouchScreen)
  {
  keyboardShortcuts['b']='(';
  keyboardShortcuts['e']=')';
  keyboardShortcuts['f']=',';
  keyboardShortcuts['j']='\'';
  }
 if(itsATS)
  {
  keyboardShortcuts['b']='~begin splice~';
  keyboardShortcuts['e']='~end splice~';
  }
 if(itsAtouchScreen)
  keyboardShortcuts=sortHashArray(keyboardShortcuts);
 T2=1;
 T3=itsAtouchScreen?4:5;
 keyboardMacroList='<span>;;</span>&nbsp;→&nbsp;<span>'+(keyboardShortcuts[';'].replace(/</g,'&lt;').replace(/ /g,'&nbsp;'))+'</span>'+((T2%T3)?' &nbsp; ':'<br>');
 for(i in keyboardShortcuts)
  if(itsAtouchScreen||((i!='\\')&&(i!='|')&&(i!='?')&&(i!='b')))
   {
   if(i!=';')
    {
    T2++;
    keyboardMacroList+='<span>;'+i+'</span>&nbsp;→&nbsp;<span>'+(keyboardShortcuts[i].replace(/</g,'&lt;').replace(/ /g,'&nbsp;'))+'</span>'+((T2%T3)?' &nbsp; ':'<br>');
    }
   }
 try{GEBI('macroListID').innerHTML='';T1=includeSanskrit?(itsAtouchScreen?'sixty-seven':'sixty-one'):(itsAtouchScreen?'fifty-one':'thirty');GEBI('macroListID').innerHTML=(includeSanskrit?'Many':'Most')+' of the input text boxes on this website have '+T1+' different keyboard macros available'+(includeSanskrit?', including macros for typing Sanskrit diacritics':'')+'. All '+T1+' of these keyboard macros begin with '+(itsAtouchScreen?'either a semi-colon or a space':'a semi-colon')+':<br><span class=CN style="font-family:Courier New">'+keyboardMacroList+'</span>';}catch(e){}
 keyboardMacroList=keyboardMacroList.replace(/<\/?span>/g,'').replace(/&nbsp;/g,' ').replace(/<br>/g,'   ').replace(/&lt;/g,'<');
 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;
    }
   }
  }
 if(itsFirefox9)
  window.onkeypress=keyPressed;
 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&nbsp;<span>H</span>&nbsp;for&nbsp;help.&nbsp;|'}catch(e){}
 changeStyles();
 if(TP&&(location.href.indexOf('#')<0))
  setTimeout("window.scrollTo(0,TP*GEBI('textDiv').clientHeight/10000)",10);
 helpText1='KEYBOARD COMMANDS (Do not work in text boxes):\n\n';
 try{GEBI('EAID').value=EA}catch(e){}
 }
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 replaceSelectedText(textAreaObject,theReplacement,numberOfTimesToBackspace)
 {
 var T1,T2;
 if(textAreaObject.selectionStart+1)
  {
  T1=textAreaObject.value;
  T2=textAreaObject.selectionStart;
  textAreaObject.value=T1.slice(0,T2-numberOfTimesToBackspace)+theReplacement+T1.slice(textAreaObject.selectionEnd);
  textAreaObject.selectionStart=textAreaObject.selectionEnd=T2+theReplacement.length-numberOfTimesToBackspace;
  if(!numberOfTimesToBackspace&&textAreaObject.setSelectionRange)
   {
   textAreaObject.focus();
   textAreaObject.setSelectionRange(T2,T2+theReplacement.length);
   }
  }
 else
  {
  if(document.selection)
   {
   T1=document.selection.createRange();
   T1.moveStart('character',-numberOfTimesToBackspace);
   T1.text=theReplacement;
   }
  }
 }
function RestoreDefaultColorsEtc()
 {
 var T1=fontWeightIndex,T2=fontIndex,T3=JI,T4=CS,T5=VOL,T6=FSC,T7=EA;
 if(itsAnUndo)
  {
  fontWeightIndex=lastFontWeightIndex;
  fontIndex=lastFontIndex;
  JI=lastJI;
  CS=lastCS;
  VOL=lastVOL;
  FSC=lastFSC;
  EA=lastEA;
  undoColors();
  }
 else
  {
  storeLastColors();
  CS=fontWeightIndex=fontIndex=JI=FSC=0;
  EA=originalEA;
  VOL=initialVOL;
  colorParser(0);
  }
 lastFontWeightIndex=T1;
 lastFontIndex=T2;
 lastJI=T3;
 lastCS=T4;
 lastVOL=T5;
 lastFSC=T6;
 lastEA=T7;
 try{GEBI('EAID').value=EA}catch(e){}
 changeStyles('V key');
 ND=0;
 if((fontWeightIndex!=T1)||(fontIndex!=T2))
  try{NextPresetFont2()}catch(e){}
 }
function retrieveSelectedText(textAreaObject)
 {
 if(textAreaObject.selectionStart+1)
  return(textAreaObject.value.slice(textAreaObject.selectionStart,textAreaObject.selectionEnd));
 else
  if(document.selection)
   return(document.selection.createRange().text);
 }
function SendEmail(myText,WorA)
 {
 var T1,T2,T3;
 T1=myText.substring(0,2048).replace(/\+/g,'vW6Vzh');
 if(T1&&(EA!=originalEA)&&(/^[\w\.]+@\w+\.\w{2,3}$/.test(EA)))
  {
  T2=myText.substring(2048);
  http.open('GET','AJAX/SendAnEmail.php?m='+WorA+'&t='+encodeURIComponent(T1)+'&s='+((T2==0)?'1':'0')+'&e='+EA+'&u=<'+thisDomainName+'/?P='+P+'>',true);
  http.onreadystatechange=function()
   {
   if(http.readyState==4)
    {
    T3=http.responseText;
    if((T3=='Saved')&&T2)
     SendEmail(T2,'a')
    else
     alert(T3);
    }
   }
  http.send(null);
  }
 else
  alert((T1?'Email address is invalid':'No text')+'. Email not sent.')
 }
function setLinkColors()
 {
 LC=CB;
 VLC=CN;
 HLC=(enoughContrast(HLC,BG))?'FF0000':'0000FF';
 ALC=colorDimmer(colorNegative(LC),itsDark(LC)?'FFFFFF':'000000',40);
 }
function storeLastColors()
 {
 for(var i=0;i<colorVariableTags.length;i++)
  eval('lastColor['+i+']='+colorVariableTags[i]);
 }
function sortHashArray(theHashArray)
 {
 var T1=[],T2,i,theNewHashArray={};
 for(i in theHashArray)
  T1.push(i);
 T1.sort();
 for(i in T1)
  {
  T2=T1[i];
  theNewHashArray[T2]=theHashArray[T2];
  }
 return(theNewHashArray);
 }
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);
   if(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');
  }
 }

