/////////////////////////////////////////////////////////
//////////////// GLOBAL VARIABLES ///////////////////////
/////////////////////////////////////////////////////////

// AJAX ///////////////////////////////////
var ajaxActive = false;
var ajaxTOut;

// DONATE/REGISTER/RENEW //////////////////////////////////
var exreceiptaddr = "Your Legal Name\nStreet Address\nCity, State Zip";

// SHARE //////////////////////////////////
var curSort = new Array(2);
var curPage = new Array(2);
var noSearchCurPage = new Array(2);
var noSearchCurSort = new Array(2);
var curSearch = new Array(2);
var numPages = new Array(2);
var allRes = new Array(2);
var results;
var compMode;
var numRows;
var compId;
//var chsnPasSorts = new Array(5);
var numSorts;
var rowHt = 30;
var ealert1 = -1;
var ealert2 = -1;
var ead1;
var ead2;
var disableDoAction = false;
var beforeCompMsg = "<div class=arclistsharedrk>&nbsp;</div><div class=arclistmsg>Click \"Compare\" to search for other arcs of the same passage.</div>";
var compListRow = "<div class=arclistshareROWCOLOR id=bmARCID>BOOKMARKS</div><a href='arc.php?arcid=ARCID&uid=USERID' class=oppcolor><div class=arclistlineROWCOLOR>&nbsp;&nbsp;DATE&nbsp;&nbsp;<i>PASSAGE</i>&nbsp;&nbsp;<b>NAME</b>&nbsp;&nbsp;(AUTHOR)&nbsp;&nbsp;<span class=arclistnote>NOTE</span></div></a>";
var arcListRow = "<div class=arclistshareROWCOLOR><div class=arclistsharecomp><input type=button onclick='goComp(ARCID,EALERT1,EALERT2);' value=CompareDISABLEDSPOT></div>SHARESTATUS. (<a href='javascript:SHAREFUNC;'>SHAREACTION</a>)</div><div class=arclistcheckROWCOLOR>CHECKORX</div><a href='arc.php?arcid=ARCID&uid=USERID' class=oppcolor><div class=arclistlineROWCOLOR>DATE&nbsp;&nbsp;<i>PASSAGE</i>&nbsp;&nbsp;<b>NAME</b>&nbsp;&nbsp;ARCBLOGSTATUS<span class=arclistnote>NOTE</span></div></a>";


// ARC ////////////////////////////////////
/////Temp Use in Prog/////
var mousePosInDivX;
var mousePosInDivY;
var selectedDivObj;
var tmpHtmlStr;
var yTopForLabelMove;
var	yBottomForLabelMove;
var	xLeftForLabelMove;
var	xRightForLabelMove;
var tmpHiddenObj;

/////Initialized in PHP/////
var labelNum;
var numProps;
var colLang;
var startVs;
var endVs;
var passage;
var arcName;
var arcId;
var autoVsNums;
var defaultArcsOnly;
var isSaved;
var loginId;
var saveUserId;
var anothersArc;
var loginName;
var passage_cols;
var colVer;
var author;
var isShared;
var ead1;
var ead2;
var ead3;
var parsing_array;
var newArc;

/////Initialize on Load/////
var arcGraphics;  
var arcArray;
var mainTable2Left = 0;
var mainTable2Top = 0;
var toolbarAutoScroll = 1;
var curTab = 0;
var autosaveTimer;
var parseTimer;
var parseTimer2;
var toolsTimer;
var bookmarkAskTimer;
var relMapTimer;
var relMapTimer2;
var breakPropTimer;
var sugSaveTimer;
var doCTag;

/////Initialize Here/////
var exitMsg = "Your arc is not saved. Leaving this page now will cause you to lose your work.";
var byPassExitCheck = false;
var mouseDownOnLabel = 0;
var selectedPropBreak = -1;
var breakSelected = '';
var rowSelected = '';
var curHelpNum = -1;
var curToolbar = -1;
var postSaveAct = "";
var upOneWk = false;
//var tinysReady = false;
var onloadsDone = false;
var graphicsDone = false;
var askBMarkDone = true;
var badGrkChars = {902:8123,904:8137,905:8139,906:8155,908:8185,910:8171,911:8187,912:8147,940:8049,941:8051, 942:8053,943:8055,944:8163,972:8057,973:8059,974:8061};
var howToParse = "<div class=pHowTo>Hover<br>over a greek<br>word to see<br>its parsing.</div>";
var noParseInfo = "<div class=pNoParse><b>Sorry!</b><br>There is no<br>parsing info<br>for this word.</div>";
var labelOnPallette = false;
var breakEndTemplate = '<div onclick="dotClick(DOTNUM,1);" onmouseover="yDotHover(DOTNUM);" onmouseout="yDotOff(DOTNUM);" id="ydotcoverDOTNUM" class="ydotcover" style="left:XPOSpx; top:YPOSpx;"></div>';

//This first one is for the UBS from morphgnt
/*
var parsingKey = [{"A-":"adjective","C-":"conjunction","D-":"adverb","I-":"interjection","N-":"noun","P-":"preposition","RA":"article","RD":"demonstrative","RI":"pronoun<br><span class=pParsing4>(interrogative/indefinite)</span>","RP":"pronoun<br><span class=pParsing4>(personal/possessive)</span>","RR":"pronoun<br><span class=pParsing4>(relative)</span>","V-":"verb","X-":"particle","--":""},{"1":"1st person<br>","2":"2nd person<br>","3":"3rd person<br>","-":""},{"A":"aorist<br>","F":"future<br>","I":"imperfect<br>","P":"present<br>","X":"perfect<br>","Y":"pluperfect<br>","-":""},{"A":"active<br>","M":"middle<br>","P":"passive<br>","-":""},{"D":"imperative<br>","I":"indicative<br>","N":"infinitive<br>","O":"optative<br>","P":"participle<br>","S":"subjunctive<br>","-":""},{"A":"accusative<br>","D":"dative<br>","G":"genitive<br>","N":"nominative<br>","V":"vocative<br>","-":""},{"P":"plural<br>","S":"singular<br>","-":""},{"F":"feminine<br>","M":"masculine<br>","N":"neuter<br>","-":""},{"C":"comparative","S":"superlative","-":""}];
*/

//This second one is for Tischendorf
var parsingKey = [{"A-":"adjective","C-":"conjunction","D-":"adverb","I-":"interjection","N-":"noun","P-":"preposition","V-":"verb","X-":"particle","?":"condition","M-":"aramaic","H-":"hebrew","PN":"proper noun","#-":"numeral","L-":"letter","XX":"indeclinable","RA":"article","RR":"pronoun<br><span class=pParsing4>(relative)</span>","RE":"pronoun<br><span class=pParsing4>(personal)</span>","RC":"pronoun<br><span class=pParsing4>(reciprocal)</span>","RD":"pronoun<br><span class=pParsing4>(demonstative)</span>","RK":"pronoun<br><span class=pParsing4>(correlative)</span>","RI":"pronoun<br><span class=pParsing4>(interrogative)</span>","RX":"pronoun<br><span class=pParsing4>(indefinite)</span>","RQ":"pronoun<br><span class=pParsing4>(correlative or interrogative)</span>","RF":"pronoun<br><span class=pParsing4>(reflexive)</span>","RP":"pronoun<br><span class=pParsing4>(possessive)</span>"}, {"1":"1st person<br>","2":"2nd person<br>","3":"3rd person<br>","-":""}, {"A":"aorist<br>","F":"future<br>","I":"imperfect<br>","P":"present<br>","X":"perfect<br>","Y":"pluperfect<br>","a":"second aorist<br>","f":"second future<br>","x":"second perfect<br>","y":"second pluperfect<br>","-":""}, {"A":"active<br>","M":"middle<br>","P":"passive<br>","E":"middle/passive<br>","D":"middle deponent<br>","O":"passive deponent<br>","N":"mid/pas deponent<br>","Q":"impersonal active<br>","-":""}, {"D":"imperative<br>","I":"indicative<br>","N":"infinitive<br>","O":"optative<br>","P":"participle<br>","S":"subjunctive<br>","R":"imperative participle<br>","-":""}, {"A":"accusative<br>","D":"dative<br>","G":"genitive<br>","N":"nominative<br>","V":"vocative<br>","-":""}, {"P":"plural<br>","S":"singular<br>","-":""}, {"F":"feminine<br>","M":"masculine<br>","N":"neuter<br>","-":""}, {"C":"comparative","S":"superlative","M":"middle significance","O":"contracted form","T":"transitive","A":"aeolic","G":"attic","F":"apocapated","R":"irregular/impure","B":"abbreviated","I":"interrogative","N":"negative","P":"particle attached","K":"crasis","-":""}];

var vidimgobject = new Array();
//NOT CURRENTLY USED. vidimgobject['mov'] = "<OBJECT id=curVid classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='500' height='269' codebase='http://www.apple.com/qtactivex/qtplugin.cab'><param name='src' value='/video/FILENAME.mov'><param name='autoplay' value='false'><param name='controller' value='true'><param name='loop' value='false'><EMBED src='/video/FILENAME.mov' width='500' height='269' autoplay='false' controller='true' loop='false' pluginspage='http://www.apple.com/quicktime/download/'></EMBED></OBJECT>";
vidimgobject['vimeo'] = '<div id=OBJID class=hidden><object width="500" height="256"><param name="allowfullscreen" value="false" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=NAMEORID&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=BFA894" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=NAMEORID&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=BFA894" type="application/x-shockwave-flash" allowfullscreen="false" allowscriptaccess="always" width="500" height="256"></embed></object></div>';
vidimgobject['jpg'] = "<img src='/images/NAMEORID.jpg' width='500' height='256' id=OBJID class=hidden>";

/////////////////////////////////////////////////////////
//////////////// TOOLBAR INFORMATION ////////////////////
/////////////////////////////////////////////////////////

var helpArray = new Array(30);
var toolbarArray = new Array(4);

function initLeftTbarArray() {
	helpArray[0] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Double-click on the desired cell, edit & click "Update."<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[1] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Click in between words where you desire to split (in both columns if applicable).<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[2] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Click the <img style="width:10px; height:10px;" src="/images/xsymbolsm.jpg"> icon on the left side of the break line in between the propositions you desire to merge.<br>\
	  </td>\
	 </tr>\
	 <tr>\
	  <td class=helpnote>\
	   <b>Note:</b> Any first-level labels associated with these propositions will be automatically deleted.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[3] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Double-click on the verse number you desire to change.<br>\
	  </td>\
	 </tr>\
	 <tr>\
	  <td class=helpnote>\
	   <b>Note:</b> This will turn-off verse number auto-update.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[5] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Click on the right side of the two break lines where you desire an arc to begin and end. (Follow the same procedure to delete.)<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[6] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Click on the title of the arc OR use the <b>Options</b> button.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[7] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Drag the desired label to the desired location.<br>\
	  </td>\
	 </tr>\
	 <tr>\
	  <td class=helpnote>\
	   <b>Note:</b> You can also change the background of a label from clear to white (and vice versa) by double-clicking on it.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[8] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Drag the desired label or note out of the arcing area until it disappears.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[9] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   For notes regarding the entire passage, click the <b>notes</b> tab above the arc table.<br>\
	  </td>\
	 </tr>\
	 <tr>\
	  <td class=helpinfo>\
	   For "sticky notes," use the <b>Options</b> button on the right bar.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[10] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Use the <b>Options</b> button on the right bar to clear all arcs, labels, and notes.<br>\
	  </td>\
	 </tr>\
	 <tr>\
	  <td class=helpnote>\
	   <b>Note:</b> This will not affect the propositions.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[11] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   New to arcing? Try...<div class=paragraphBreak><br></div><center><a href="'+gDirPrefix+'/learn/101/" class=arcing101>ARCING 101</a></center><div class=paragraphBreak><br></div>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[12] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Yes! Use <a style="white-space:nowrap;" href="http://www.google.com/chrome" class=footer onclick="window.open(this.href,\'newwin\'); return false;"><b>Chrome</b></a> to make this arcing widget <b>20x faster</b> than Internet Explorer.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[13] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Use the <b>Options</b> button on the right bar.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[14] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   We have built-in this formatable notes editor so that you can express what your arc has helped you see in the given passage. Notes are of significant benefit to "arcing in community."<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[15] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   What is the one-sentence main idea of what this Bible passage is saying?<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[16] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Were there any choices you made in your arc that require some explanation?<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[17] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   What are the key cross-references that help you understand this passage or fill-out its implications?<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[18] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   What were the surprising discoveries you found in this passage?<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[19] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   What remains unanswered from your study thus far?<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[20] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Use the <b>Options</b> button on the right bar.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[21] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Please keep your comments plainly with reference to the given arc and passage.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[22] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   For God has not destined us for wrath, but to obtain salvation through our Lord Jesus Christ, ... Therefore encourage one another and build one another up, just as you are doing. (1Thes 5:9,11)<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[23] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Love one another with brotherly affection. Outdo one another in showing honor. (Rom 12:10)<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[24] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Please take the time to make your comments understandable and precise.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[25] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   God opposes the proud but gives grace to the humble. (1Pet 5:5)<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[26] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   <b>Note:</b> Do <u>not</u> try to print through your browser.<br>\
	  </td>\
	 </tr>\
	 <tr>\
	  <td class=helpinfo>\
	    Rather, use the <b>Options</b> button on the rightbar, choose "Download this arc," open the downloaded PDF file, and print through your PDF viewer.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	helpArray[27] = '\
	<table cellpadding=0 class=hlpCnt>\
	 <tr>\
	  <td class=helpinfo>\
	   Click <a style="white-space:nowrap;" href="http://www.sbl-site.org/educational/biblicalfonts.aspx" class=footer onclick="window.open(this.href,\'newwin\'); return false;"><b>here</b></a> to download the SBL Greek and Hebrew fonts.<br>\
	  </td>\
	 </tr>\
	</table>\
	 ';
	
	toolbarArray["help"] = '\
	<span class=reallysmalltext>Click on a topic for help.</span><br>\
	<div class=helpArea></div>\
	<a href="javascript:showHelpSection(11);" class=small id=helpTitle11><i>What Do I Do?!</i></a>\
	<div id=helpArea11 class=helpArea></div>\
	<a href="javascript:showHelpSection(27);" class=small id=helpTitle27><i>Font Problems?</i></a>\
	<div id=helpArea27 class=helpArea></div>\
	<a href="javascript:showHelpSection(0);" class=small id=helpTitle0><b>Edit Propositions</b></a>\
	<div id=helpArea0 class=helpArea></div>\
	<a href="javascript:showHelpSection(1);" class=small id=helpTitle1><b>Split Propositions</b></a>\
	<div id=helpArea1 class=helpArea></div>\
	<a href="javascript:showHelpSection(2);" class=small id=helpTitle2><b>Merge Propositions</b></a>\
	<div id=helpArea2 class=helpArea></div>\
	<a href="javascript:showHelpSection(3);" class=small id=helpTitle3><b>Edit Verse Numbers</b></a>\
	<div id=helpArea3 class=helpArea></div>\
	<a href="javascript:showHelpSection(5);" class=small id=helpTitle5><b>Draw/Delete an Arc</b></a>\
	<div id=helpArea5 class=helpArea></div>\
	<a href="javascript:showHelpSection(7);" class=small id=helpTitle7><b>Place a Label</b></a>\
	<div id=helpArea7 class=helpArea></div>\
	<a href="javascript:showHelpSection(13);" class=small id=helpTitle13><b>Make a Custom Label</b></a>\
	<div id=helpArea13 class=helpArea></div>\
	<a href="javascript:showHelpSection(9);" class=small id=helpTitle9><b>Make a Note</b></a>\
	<div id=helpArea9 class=helpArea></div>\
	<a href="javascript:showHelpSection(8);" class=small id=helpTitle8><b>Delete a Label or Note</b></a>\
	<div id=helpArea8 class=helpArea></div>\
	<a href="javascript:showHelpSection(6);" class=small id=helpTitle6><b>Rename Your Arc</b></a>\
	<div id=helpArea6 class=helpArea></div>\
	<a href="javascript:showHelpSection(26);" class=small id=helpTitle26><b>Print Your Arc</b></a>\
	<div id=helpArea26 class=helpArea></div>\
	';
	if(agent == "IE") {
	toolbarArray["help"] += '\
	<a href="javascript:showHelpSection(10);" class=small id=helpTitle10><b>Start Over</b></a>\
	<div id=helpArea10 class=helpArea></div>\
	<a href="javascript:showHelpSection(12);" class=small id=helpTitle12><i>Can It Go Faster?</i></a>\
	<div id=helpArea12 class=canBeEmpty>&nbsp;</div>\
	';
	} else {
	toolbarArray["help"] += '\
	<a href="javascript:showHelpSection(10);" class=small id=helpTitle10><b>Start Over</b></a>\
	<div id=helpArea10 class=canBeEmpty></div>\
	';  
	}
	
	toolbarArray["ideas"] = '\
	<span class=reallysmalltext>Click below for note ideas.</span><br>\
	<div class=helpArea></div>\
	<a href="javascript:showHelpSection(14);" class=small id=helpTitle14><i>Why Notes?!</i></a>\
	<div id=helpArea14 class=helpArea></div>\
	<a href="javascript:showHelpSection(15);" class=small id=helpTitle15><b>The Central Idea</b></a>\
	<div id=helpArea15 class=helpArea></div>\
	<a href="javascript:showHelpSection(16);" class=small id=helpTitle16><b>Explanations</b></a>\
	<div id=helpArea16 class=helpArea></div>\
	<a href="javascript:showHelpSection(17);" class=small id=helpTitle17><b>Cross-References</b></a>\
	<div id=helpArea17 class=helpArea></div>\
	<a href="javascript:showHelpSection(18);" class=small id=helpTitle18><b>Insights</b></a>\
	<div id=helpArea18 class=helpArea></div>\
	<a href="javascript:showHelpSection(19);" class=small id=helpTitle19><b>Questions</b></a>\
	<div id=helpArea19 class=canBeEmpty>&nbsp;</div>\
	';  
	
	toolbarArray["rules"] = '\
	<span class=reallysmalltext>Comment guidelines.</b></span><br>\
	<div class=helpArea></div>\
	<a href="javascript:showHelpSection(21);" class=small id=helpTitle21><b>Relevant</b></a>\
	<div id=helpArea21 class=helpArea></div>\
	<a href="javascript:showHelpSection(22);" class=small id=helpTitle22><b>Edifying</b></a>\
	<div id=helpArea22 class=helpArea></div>\
	<a href="javascript:showHelpSection(23);" class=small id=helpTitle23><b>Respectful</b></a>\
	<div id=helpArea23 class=helpArea></div>\
	<a href="javascript:showHelpSection(24);" class=small id=helpTitle24><b>Clear</b></a>\
	<div id=helpArea24 class=helpArea></div>\
	<a href="javascript:showHelpSection(25);" class=small id=helpTitle25><b>Humble</b></a>\
	<div id=helpArea25 class=helpArea></div><hr class=logR>\
	<span class=reallysmalltext>Please report breaches to these guidelines via the <b>abuse</b> links.<br></span>\
	<div class=canBeEmpty>&nbsp;</div>\
	';
	
	toolbarArray["key"] = '\
	<span class=reallysmalltext>Click a name for more info.<br><i>(opens a new window)</i></span><br>\
	<div class=helpArea></div>\
	<span class=smalltext style="color:green;">S</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/series.php" onclick="window.open(this.href,\'newwin1\'); return false;">Series</a><br>\
	<span class=smalltext style="color:green;">P</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/progression.php" onclick="window.open(this.href,\'newwin2\'); return false;">Progression</a><br>\
	<span class=smalltext style="color:green;">A</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/alternative.php" onclick="window.open(this.href,\'newwin3\'); return false;">Alternative</a><br><hr class=logR>\
	<span class=reallysmalltext><span class=smalltext style="color:blue;">Ac</span>/<span class=smalltext style="color:blue;">Mn</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/actionmanner.php" onclick="window.open(this.href,\'newwin4\'); return false;">Action-Manner</a><br>\
	<span class=smalltext style="color:blue;">Cf</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/comparison.php" onclick="window.open(this.href,\'newwin5\'); return false;">Comparison</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:blue;">-</span>/<span class=smalltext style="color:blue;">+</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/negativepositive.php" onclick="window.open(this.href,\'newwin6\'); return false;">Negative-Positive</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:blue;">Id</span>/<span class=smalltext style="color:blue;">Exp</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/ideaexplanation.php" onclick="window.open(this.href,\'newwin7\'); return false;">Idea-Explanation</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:blue;">Q</span>/<span class=smalltext style="color:blue;">A</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/questionanswer.php" onclick="window.open(this.href,\'newwin8\'); return false;">Question-Answer</a><br><hr class=logR>\
	<span class=smalltext style="color:red;">G</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/ground.php" onclick="window.open(this.href,\'newwin9\'); return false;">Ground</a><br>\
	<img style="width:11px; height:11px;" src="/images/inference.gif"><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/inference.php" onclick="window.open(this.href,\'newwin10\'); return false;">Inference</a><br>\
	<span class=smalltext style="color:red;">BL</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/bilateral.php" onclick="window.open(this.href,\'newwin11\'); return false;">Bilateral</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:red;">Ac</span>/<span class=smalltext style="color:red;">Res</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/actionresult.php" onclick="window.open(this.href,\'newwin12\'); return false;">Action-Result</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:red;">Ac</span>/<span class=smalltext style="color:red;">Pur</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/actionpurpose.php" onclick="window.open(this.href,\'newwin13\'); return false;">Action-Purpose</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:red;">If</span>/<span class=smalltext style="color:red;">Th</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/conditional.php" onclick="window.open(this.href,\'newwin14\'); return false;">Conditional</a><br>\
	<span class=smalltext style="color:red;">T</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/temporal.php" onclick="window.open(this.href,\'newwin15\'); return false;">Temporal</a><br>\
	<span class=smalltext style="color:red;">L</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/locative.php" onclick="window.open(this.href,\'newwin16\'); return false;">Locative</a><br><hr class=logR>\
	<span class=smalltext style="color:#EF6C00;">Csv</span><span class=reallysmalltext> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/concessive.php" onclick="window.open(this.href,\'newwin17\'); return false;">Concessive</a><br>\
	<span class=reallysmalltext><span class=smalltext style="color:#EF6C00;">Sit</span>/<span class=smalltext style="color:#EF6C00;">R</span> - </span><a class=footer href="'+gDirPrefix+'/learn/reference/situationresponse.php" onclick="window.open(this.href,\'newwin18\'); return false;">Situation-Response</a>\
	<br>'; 
	
	toolbarArray["parse"] = '\
	<div class=parseArea id=parseArea>'+howToParse+'</div>\
	';
}

/////////////////////////////////////////////////////////
/////////////// GLOBAL EVENT HANDLING ///////////////////
/////////////////////////////////////////////////////////

if(typeof window.event == 'undefined') {
 document.onkeypress = function(e) {
  var test_var=e.target.nodeName.toUpperCase();
  var test_type;
  if (e.target.type) { test_type=e.target.type.toUpperCase(); }
  if ((test_var == 'INPUT' && (test_type == 'TEXT' || test_type == 'PASSWORD')) || test_var == 'TEXTAREA') {
   return e.keyCode;
  } else if (e.keyCode == 8) {
   e.preventDefault();
  }
 }
} else {
 document.onkeydown = function() {
  var test_var=event.srcElement.tagName.toUpperCase();
  var test_type;
  if (event.srcElement.type) { test_type=event.srcElement.type.toUpperCase(); }
  if ((test_var == 'INPUT' && (test_type == 'TEXT' || test_type == 'PASSWORD')) || test_var == 'TEXTAREA') {
   return event.keyCode;
  } else if (event.keyCode == 8) {
   event.returnValue=false;
  }
 }
}


/////////////////////////////////////////////////////////
///////////////////// FUNCTIONS /////////////////////////
/////////////////////////////////////////////////////////

String.prototype.count=function(s1) { 
	return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
}

function initScroll() {
 if(!EL("arcRightBar")) { return; }
/*
 if(agent == "IE" && version < 8) {
  toolbarAutoScroll = 0;
 } else if(windowWidth() < 1000 || windowHeight() < 520) {
*/
 if(windowWidth() < 1000 || windowHeight() < 520) {
  EL("rToolbar").style.position = "static";
  EL("lToolbar").style.position = "static";
  toolbarAutoScroll = 0;
 } else {
  EL("rToolbar").style.position = "fixed";
  EL("lToolbar").style.position = "fixed";
  EL('rightBarSpacer').style.height = "0px";
  EL('leftBarSpacer').style.height = "40px";
  toolbarAutoScroll = 1;
 } 
 initPasScroll();
}

function initPasScroll() {
	if(!EL("pasToolsDiv1")) { return; }
 pToolHt = 250;
 if(windowHeight() - 285 > 250) { pToolHt = windowHeight() - 285; }
 EL("pasToolsDiv1").style.maxHeight = pToolHt + "px";
/*
 if(agent == "IE") {
  pToolHt = pToolHt-10;
  EL("pasToolsDiv1").style.height = "";
  if(EL("pasToolsDiv1").offsetHeight > pToolHt) {
   EL("pasToolsDiv1").style.height = pToolHt + "px";
  }
  //EL("pasToolbar").style.height = (EL("pasToolsDiv1").offsetHeight+2) + "px";
 }
*/
}

function initArray() {
 arcArray = new Array(numProps);
 for(var x=0; x<numProps; x++) {
  arcArray[x] = new Array(numProps);
 }
}

function initGraphics() {
 if(doCTag) {  
  EL('arcCanvasCont').innerHTML = "";
  //var accPos = findPos(EL('arcCanvasCont'));
  //var ftPos = findPos(EL('footerTd'));
  //var cTagHt = (ftPos[1]-accPos[1]);
  var cTagHt = EL("arcTable").offsetHeight + 30;
  var acw = 246;
  if(colLang[1] == "") { acw = 311; }
  EL('arcCanvasCont').innerHTML = "<canvas id=arcCanvas class=arcCanvas width="+acw+"px height="+cTagHt+"px></canvas>";
  EL('arcCanvasCont').style.paddingLeft = (548-acw) + "px";
  arcGraphics = EL('arcCanvas').getContext('2d');
 } else {
  if(typeof jsGraphics == "undefined") {
   window.setTimeout('initGraphics();',100);
  } else {
   arcGraphics = new jsGraphics(EL("arcCanvas"));  
   arcGraphics.setColor('#241911');
   arcGraphics.setStroke(2);
  }
 }
}

function clearBrks() {
 if(breakSelected) {
  for(var i=1; EL('1'+rowSelected+'-'+i); i++) { EL('1'+rowSelected+'-'+i).className = 'hb'; }
  for(var i=1; EL('2'+rowSelected+'-'+i); i++) { EL('2'+rowSelected+'-'+i).className = 'hb'; }
  breakSelected = "";
  rowSelected = "";
 }
}

function clearYdot() {
 if(selectedPropBreak != -1) {
  EL("ydot"+selectedPropBreak).className = "ydot";
  selectedPropBreak = -1;
 }
}

function dotClick(dotNum, doPaint) {
 clearBrks();
 if(selectedPropBreak == -1) {
  EL("ydot"+dotNum).className = "ydot2";
  selectedPropBreak = dotNum;
 } else {
  if(selectedPropBreak == dotNum) {
   EL("ydot"+dotNum).className = "ydot";
   selectedPropBreak = -1;
  } else {
   defaultArcsOnly = 0;
   var dotOne = selectedPropBreak;
   var dotTwo = dotNum;
   if(dotNum < selectedPropBreak) {
    dotOne = dotNum;
    dotTwo = selectedPropBreak;
   }
   var arcsCrossed = 0;
   for(var i=0; i<dotOne; i++) {
    for(var j=dotOne+1; j<dotTwo; j++) {
     if(arcArray[i][j-1]) { arcsCrossed = 1; }
    }
   }
   for(var i=dotOne+1; i<dotTwo; i++) {
    for(var j=dotTwo+1; j<numProps+1; j++) {
     if(arcArray[i][j-1]) { arcsCrossed = 1; }
    }
   }
   if(arcsCrossed) {
    clearYdot();
    alert("Crossing arcs is not allowed.");
    return;
   }

   if(arcArray[dotOne][dotTwo-1]) {
    if(doCTag) {
     arcArray[dotOne][dotTwo-1] = '';
     clearYdot();
     redrawClearArray(1,-1,0);
    } else {
     arcArray[dotOne][dotTwo-1] = '';
     arcGraphics.setColor("white");
     dotClick(dotNum,1);
     arcArray[dotOne][dotTwo-1] = '';
     window.setTimeout(
      function() {
       redrawClearArray(1,-1,0);
      },1);
    }
   } else {
    var modeOffset = 0;
    if(colLang[1] == "") {
     modeOffset = 65;
    }
    var dotOnePos = findPos(EL("ydot"+dotOne));
    var arcTop = dotOnePos[1];
    var dotTwoPos = findPos(EL("ydot"+dotTwo));
    var arcHeight = dotTwoPos[1] - dotOnePos[1] - 1;
    var arcWidth;
    if(numProps < 10) {
     arcWidth = ((242+modeOffset)/numProps) * (dotTwo-dotOne);
    } else if(dotTwo-dotOne == 1) {
     arcWidth = 25;
    } else if(dotTwo-dotOne == 2) {
     arcWidth = 48;
    } else if(dotTwo-dotOne == 3) {
     arcWidth = 69;
    } else {
     arcWidth = (((173+modeOffset)/(numProps-3)) * (dotTwo-dotOne-3)) + 69;
    }
    var canvasPos = findPos(EL("arcCanvas"));
    var arcYPos = arcTop - canvasPos[1] + 3;

    if(doCTag) {
     drawArc(0,arcYPos,arcWidth,arcHeight,"#241911");
    } else {
     arcGraphics.drawEllipse(0 - arcWidth + 300 - modeOffset, arcYPos-1, arcWidth * 2, arcHeight);
    }
    
    arcArray[dotOne][dotTwo-1] = 1;
    if(doPaint && !doCTag) {
     arcGraphics.paint();
    }
    clearYdot();
   }
   indicateNotSaved();
  }
 }
}

function drawArc(x, y, w, h, color) {
 var wid = w*2;
 var ht = h;
 var scale = wid/ht;
 arcGraphics.save();
 arcGraphics.lineWidth = 1+1/scale;
 arcGraphics.translate(x,y+ht/2);
 arcGraphics.scale(scale,1);
 arcGraphics.beginPath();
 arcGraphics.arc(0, 0, (wid/2)/scale, Math.PI/-2, Math.PI/2, false);
 arcGraphics.strokeStyle = color
 arcGraphics.stroke();
 arcGraphics.restore();
}

function checkyht() {
 var brk2Pos = findPos(EL("ydot0"));
 alert(document.ready());
}
/*
function clearArcs() {
 arcGraphics.clearRect(0,0,100000,100000);
}
*/

function drawSavedArcs(arcsX, arcsY) {
 if(typeof arcGraphics == "undefined") {
  window.setTimeout('drawSavedArcs(['+arcsX.join()+'],['+arcsY.join()+']);',100);
 } else {
  for(var i=0; i<arcsX.length; i++) {
   dotClick(arcsX[i],0);
   dotClick(arcsY[i],0);  
  }
  if(!doCTag) { arcGraphics.paint(); }
  graphicsDone = true;
  endLoad(2);
 }
}

function prep4Dragging() {
 var allElements = document.getElementsByTagName("span");
 for(var x=0; x<allElements.length; x++) {
  if(allElements[x].id == "commentsSpan") {continue;}
  allElements[x].ondrag=function(){return false;};
  allElements[x].onselectstart=function(){return false;};
 }
 var allElements = document.getElementsByTagName("td");
 for(var x=0; x<allElements.length; x++) {
  if(allElements[x].id == "commentsTd" || allElements[x].id == "bigTd" || allElements[x].id == "arcArea") {continue;}
  allElements[x].ondrag=function(){return false;};
  allElements[x].onselectstart=function(){return false;};
 }
 var allElements = document.getElementsByTagName("div");
 for(var x=0; x<allElements.length; x++) {
 	//Next line is new addition for Firefox 3.6
		if(allElements[x].className=="relpalarea" || allElements[x].id=="labels") { allElements[x].onmousedown=function(){return false;}; }
  if(allElements[x].id == "prmptSpot" || allElements[x].id == "prmptSpotCont" || allElements[x].id == "modVsSpot" || allElements[x].id == "editNoteSpot" || allElements[x].id == "modPropSpot" || allElements[x].id == "modPropSpotGkHb") {continue;}
  allElements[x].ondrag=function(){return false;};
  allElements[x].onselectstart=function(){return false;};
 }
}

function drawDefaultArcs(saveStatus) {
 if(typeof arcGraphics == "undefined") {
  window.setTimeout('drawDefaultArcs('+saveStatus+');',100);
 } else {
  for(var i=0; i<numProps; i++) {
   dotClick(i,0);
   dotClick(i+1,0);
  }
  if(numProps>1) {
   dotClick(0,0);
   dotClick(numProps,0);
  }
  if(!doCTag) { arcGraphics.paint(); }
  graphicsDone = true;
  if(saveStatus != -1) { endLoad(saveStatus); }
 }
 defaultArcsOnly = 1;
}

function setResizeVars() {
 var tablePos = findPos(EL("mainTable"));
 mainTable2Left = tablePos[0] + 3;  //add on 3 to properly align re-design
 mainTable2Top = tablePos[1];
 //scrollBarsOn = (windowHeight() != scrollHeight());
}

function startDrag(obj, event) {
 if(obj.innerHTML.substring(0,9).toUpperCase() == "<TEXTAREA") { return; }
 clearYdot();
 clearBrks();
 if (window.event) { event = window.event };
 var pos_x = event.clientX;
 var pos_y = event.clientY;
 mousePosInDivX = pos_x - parseInt(obj.style.left);
 mousePosInDivY = pos_y + scrollTop() - parseInt(obj.style.top);
 mouseDownOnLabel = 1;
 selectedDivObj = obj;
 var desktopPos = findPos(EL("arcDesktop"));
 var rBarPos = findPos(EL("arcRightBar"));
	yTopForLabelMove = desktopPos[1] + 108 + mousePosInDivY;
 yBottomForLabelMove = (desktopPos[1]+EL('arcDesktop').offsetHeight+35) - (selectedDivObj.offsetHeight-mousePosInDivY);
	xLeftForLabelMove = desktopPos[0] + mousePosInDivX;
	xRightForLabelMove = rBarPos[0] - (selectedDivObj.offsetWidth-mousePosInDivX);
 selectedDivObj.focus();
 indicateNotSaved();
 //selectedDivObj.onmouseover = function() { this.style.cursor = "images/transparentpixel.gif"; }
}

function moveLabel(event) {
 if(mouseDownOnLabel) {
  if (window.event) { event = window.event };
  var pos_x = event.clientX;
  var pos_y = event.clientY + scrollTop();
  if(!(pos_y >= yTopForLabelMove && pos_y <= yBottomForLabelMove && pos_x >= xLeftForLabelMove && pos_x <= xRightForLabelMove)) {
	  if(!labelOnPallette) {
	  	if(pos_y < yTopForLabelMove - 60 || pos_y > yBottomForLabelMove + 40) {
	  		pos_y = -100000;
	  	} else if(pos_y < yTopForLabelMove) {
	  		pos_y = yTopForLabelMove;  	  	
	  	} else if(pos_y > yBottomForLabelMove) {
	  		pos_y = yBottomForLabelMove;  	  	
	  	}
	  	if(pos_x < xLeftForLabelMove - 60 || pos_x > xRightForLabelMove + 60) {
	  		pos_x = -100000;  	
	  	} else if(pos_x < xLeftForLabelMove) {
	  		pos_x = xLeftForLabelMove;  	  	
	  	} else if(pos_x > xRightForLabelMove) {
	  		pos_x = xRightForLabelMove;  	  	
	  	}
	  }
  } else {
  	labelOnPallette = false;
  }
  selectedDivObj.style.left = (pos_x - mousePosInDivX) + 'px';
  selectedDivObj.style.top = (pos_y - mousePosInDivY) + 'px';
  selectedDivObj.focus();
 }
}

function endDrag() {
 if(mouseDownOnLabel) {
  mouseDownOnLabel = 0;
  if(labelOnPallette || parseInt(selectedDivObj.style.left) < 0 || parseInt(selectedDivObj.style.top) < 0) {
   if(labelOnPallette || selectedDivObj.className != "mylabel" || selectedDivObj.innerHTML.length < 30 || confirm("Delete this sticky note?")) {
    selectedDivObj.style.visibility = "hidden";
   	selectedDivObj.style.left = "-100000px";
   	selectedDivObj.style.top = "-100000px";
   } else if(selectedDivObj.className == "mylabel" && selectedDivObj.innerHTML.length >= 30) {
		  if(parseInt(selectedDivObj.style.left) < 0) {
    	selectedDivObj.style.left = (windowWidth()/2+70) + "px";
    }
    if(parseInt(selectedDivObj.style.top) < 0) {
    	selectedDivObj.style.top = (scrollTop() + (windowHeight()/2)) + "px";
    }
   }
  }
 	labelOnPallette = false;
	 indicateNotSaved();
 }
}

function createLabel(obj, event) {
	var toolbarLabelPos = findPos(obj);
 if(toolbarAutoScroll) { toolbarLabelPos[1] += scrollTop(); }
 labelNum++;
 var labelDiv = "<div id=label" + labelNum + " class=label style='left:" + (toolbarLabelPos[0]-1) +
   "px; top:" + (toolbarLabelPos[1]-2) + "px; color:" + obj.style.color + ";' " +
   "onmousedown='startDrag(this,event)' onmouseover='this.style.cursor=\"move\"' ondblclick='changeBGColor(this);'>" +
   obj.innerHTML + "</div>";
 EL("labels").innerHTML = EL("labels").innerHTML + labelDiv;
 EL("label"+labelNum).ondrag=function(){return false;};
 EL("label"+labelNum).onselectstart=function(){return false;};
	labelOnPallette = true;
 startDrag(EL("label"+labelNum), event);
}

function changeBGColor(obj) {
 if(obj.style.backgroundColor == "white") {
  obj.style.backgroundColor = "";
 } else {
  obj.style.backgroundColor = "white";
 }
 obj.focus();
 obj.blur();
}

function editMyNote(thisLabelNum) {
  var thisLabel = EL("label"+thisLabelNum);
  //if(thisLabel.innerHTML.substring(0,9).toUpperCase() == "<TEXTAREA") { return; }
  clearYdot();
  clearBrks();
  EL("label"+thisLabelNum).style.visibility = "hidden";
  goBG(2); 
  var desktopPos = findPos(EL("arcDesktop"));
  if(parseInt(thisLabel.style.top) + 170 > desktopPos[1]+EL('arcDesktop').offsetHeight) {
    EL("editNoteSpot").style.top = (desktopPos[1]+EL('arcDesktop').offsetHeight - 170) + 'px';
  } else {
    EL("editNoteSpot").style.top = (parseInt(thisLabel.style.top) - 28) + 'px';
  }
  if(parseInt(thisLabel.style.left) + 220 > windowWidth() - 10) {
    EL("editNoteSpot").style.left = (windowWidth() - 230) + 'px';
  } else {
    EL("editNoteSpot").style.left = thisLabel.style.left;    
  }
  //thisLabel.style.zIndex = "3";
  var ti3 = tinyMCE.get('myNtInput');
  ti3.setContent(EL("label"+thisLabelNum).innerHTML.replace(/<(\/?)FONT/gi,"<$1SPAN"));
  //EL("editNoteSpot").style.visibility = "";
  EL("ti3Done").onclick = function() { writeMyNote(thisLabelNum,0); }
  EL("ti3Cancel").onclick = function() { cnclModSNote(thisLabelNum,1,0); }
  if(agent != "IE") { EL('myNtInput').focus(); }
  tinyMCE.execCommand('mceFocus', false, 'myNtInput');
}

function createMyNote() {
 clearYdot();
 clearBrks();
 labelNum++;
 goBG(2);
 EL("editNoteSpot").style.left = (windowWidth()/2 + 50) + 'px';
 EL("editNoteSpot").style.top = (scrollTop()+200) + 'px';
 var ti3 = tinyMCE.get('myNtInput');
 ti3.setContent("");
 //EL("editNoteSpot").style.visibility = "";
 EL("ti3Done").onclick = function() { writeMyNote(labelNum,1); }
 EL("ti3Cancel").onclick = function() { cnclModSNote(labelNum,0,1); }
 tinyMCE.execCommand('mceFocus', false, 'myNtInput');
}

function eliminateIllTags(htmlStr) {
 htmlStr = htmlStr.replace(/_/gi,"&#95;");

 htmlStr = htmlStr.replace(/-->/gi,"_");
 htmlStr = htmlStr.replace(/<!--[^_]*_/gi,"");
 htmlStr = htmlStr.replace(/_/gi,"-->");

 htmlStr = htmlStr.replace(/<(\/?)(SPAN|FONT)/gi,"_$1$2");
 htmlStr = htmlStr.replace(/<(\/?)(EM|I|B|S|STRIKE|STRONG|U|BDO|BLOCKQUOTE|BIG|CENTER|DEL|H[1-6]|INS|LI|UL|OL|P|Q|SMALL|SUB|SUP)( [^>]*>|>)/gi,"_$1$2$3");
 htmlStr = htmlStr.replace(/<(BR|HR)( ?\/?)>/gi,"_$1$2>");
 htmlStr = htmlStr.replace(/<[^>]*>/gi,"");
 htmlStr = htmlStr.replace(/_/gi,"<");
 
 var SpRE = /(<[^> ]*) ([^>]*>)/gi;
 while(htmlStr.search(SpRE) != -1) { htmlStr = htmlStr.replace(SpRE,"$1_$2"); }

 htmlStr = htmlStr.replace(/_(STYLE)=(["'][^"']*["'])/gi,"_$1!=$2");
 htmlStr = htmlStr.replace(/_[A-Z]*=["'][^"']*["']/gi,"");
 htmlStr = htmlStr.replace(/_(STYLE)!=(["'][^"']*["'])/gi,"_$1=$2");

 htmlStr = htmlStr.replace(/(FONT-STYLE|FONT-WEIGHT|COLOR|TEXT-DECORATION|BACKGROUND-COLOR|FONT-SIZE|PADDING-LEFT)/gi,"$1__");
 var ColRE = /(<[^> ]*):([^_>][^>]*>)/gi;
 while(htmlStr.search(ColRE) != -1) { htmlStr = htmlStr.replace(ColRE,"$1:_$2"); }
 htmlStr = htmlStr.replace(/[-A-Z]+:_[^;"']*;?_?/gi,"");
 htmlStr = htmlStr.replace(/(FONT-STYLE|FONT-WEIGHT|COLOR|TEXT-DECORATION|BACKGROUND-COLOR|FONT-SIZE|PADDING-LEFT)__/gi,"$1");
 htmlStr = htmlStr.replace(/_+STYLE=["']{2}_*/gi,"");

 htmlStr = htmlStr.replace(/_/gi," ");
 htmlStr = htmlStr.replace(/&#95;/gi,"_");
 
 return htmlStr;
}

function writeMyNote(thisLabelNum, newLabel) {
 var ti3 = tinyMCE.get('myNtInput');
 var content = ti3.getContent().replace(/<(\/?)SPAN/gi,"<$1FONT");
 content = content.replace(/(<\/[OU]L>)\n?<DIV><BR[ /]?[ /]?><\/DIV>\n?(<DIV>)?\n?(<[OU]L>)/gi,"$1<BR>$3");
 content = content.replace(/(<DIV>\n?)?(<\/?[OU]L>)(\n?<DIV>(<BR \/>)?)?/gi,"$2");
 content = content.replace(/<DIV>(<BR[ /]?[ /]?><\/DIV>)?/gi,"<BR>")
 content = content.replace(/^(<BR[ \/]*>)+|(<BR[ \/]*>)+$|<\/DIV>/gi,"");
 content = eliminateIllTags(content);
 if(!newLabel) {
  if(trim(content.replace(/<\/?P>/gi,"").replace(/<\/?BR>/gi,"").replace(/&NBSP;/gi,"")) == "") {
   EL("label"+thisLabelNum).style.visibility = "hidden";
   EL("label"+thisLabelNum).style.top = "0px";
   EL("label"+thisLabelNum).style.left = "0px";
  } else {   
   EL("label"+thisLabelNum).innerHTML = content;
   EL("label"+thisLabelNum).style.visibility = "";
/*
   if(agent == "IE") {
    if(EL("label"+thisLabelNum).offsetWidth >= 160) {
     EL("label"+thisLabelNum).style.width = "172px";
    } else {
     EL("label"+thisLabelNum).style.width = "";
    }
   }
*/ 
  }
  indicateNotSaved();
 } else {
  if(trim(content.replace(/<\/?P>/gi,"").replace(/<\/?BR>/gi,"").replace(/&NBSP;/gi,"")) == "") {
   labelNum--;
  } else {   
   var labelDiv = "<div class=mylabel id=label" + thisLabelNum + " style='left:" + (windowWidth()/2 + 50) + "px; top:" + (scrollTop()+228) + "px;' onmousedown='startDrag(this,event);' onmouseover='this.style.cursor=\"move\"; this.filters.alpha.opacity=100; ' onmouseout='this.filters.alpha.opacity=35;' ondblclick='editMyNote("+thisLabelNum+");'>" + content + "</div>"; 
   EL("labels").innerHTML = EL("labels").innerHTML + labelDiv;
   //if(agent == "IE" && EL("label"+thisLabelNum).offsetWidth > 160) { EL("label"+thisLabelNum).style.width = "172px"; }
   indicateNotSaved();
  }
 }
 cnclModSNote(thisLabelNum,0,0);
}

function cnclModSNote(thisLabelNum, doVis, doLabMinus) {
 if(doVis) { EL("label"+thisLabelNum).style.visibility = ""; }
 if(doLabMinus) { labelNum-- }
 //EL("editNoteSpot").style.visibility = 'hidden';
 EL("editNoteSpot").style.left = "0";
 EL("editNoteSpot").style.top = "-1000px";
 noBG(); 
 EL("ti3Done").blur();
}

function createMyLabel(event) {
 clearYdot();
 clearBrks();
 labelNum++;
 var labelDiv = "<div class=label id=label" + labelNum + " style='left:" + (windowWidth()/2 + 50) +
   "px; top:" + (scrollTop()+200) + "px;' onmousedown='startDrag(this,event);' onmouseover='this.style.cursor=\"move\";' " + 
   "ondblclick='changeBGColor(this);'><input style='width:30px;' maxlength=30 id=text"+labelNum+" " +
   "onblur='writeMyLabel("+labelNum+");' onkeypress='handleKeyPress(event,"+labelNum+")'>" + "</div>"; 
 EL("labels").innerHTML = EL("labels").innerHTML + labelDiv;
 //timeout here because that is the only way it would work in IE6.
 window.setTimeout('EL("text"+labelNum).focus();',1);
}

/*
function maxWidthMyNotes() {
 if(agent != "IE") { return; }
 for(b=1; b<=labelNum; b++) {
  if(EL("label"+b).style.visibility == 'hidden' || EL("label"+b).className != "mylabel") { continue; }
  if(EL("label"+b).offsetWidth > 160) { EL("label"+b).style.width = "172px"; }
 }
}
*/

function writeMyLabel(thisLabelNum) {
 EL("label"+thisLabelNum).innerHTML = EL("text"+thisLabelNum).value.replace(/\n/g,'');
 indicateNotSaved();
}

function redrawClearArray(redraw, shiftSpot, shift) {
 if(doCTag) {
  initGraphics(); 
 } else {
 //craziness in next couple lines done to make this part faster.  
  EL("arcCanvas").id = "arcCanvas_old";
  EL("arcCanvasCont_temp").innerHTML = "<div id='arcCanvas' class=arcCanvas>&nbsp;</div>";
  EL("arcCanvas_old").style.visibility = "hidden";
  initGraphics();
  EL("arcCanvasCont").id = "arcCanvas_switching";
  EL("arcCanvasCont_temp").id = "arcCanvasCont";
  EL("arcCanvas_switching").id = "arcCanvasCont_temp";
 }
 var oldArcArray = arcArray;
 initArray();
 if(defaultArcsOnly || redraw == 0) {
  drawDefaultArcs(-1);
 } else {
  if(shift == -1 && !oldArcArray[shiftSpot][shiftSpot+1]) { oldArcArray[shiftSpot][shiftSpot+1] = 1; }
  if(shift > 0) { oldArcArray[shiftSpot][shiftSpot] = ''; }
  for(var x=0; x<oldArcArray.length; x++) {
   for(var y=0; y<oldArcArray.length; y++) {
    if(oldArcArray[x][y]) {
     if(shift >= 0 || (x!=shiftSpot+1 && y!=shiftSpot)) {
      if(shiftSpot != -1 && x>shiftSpot) {
       dotClick(x+shift,0);
      } else {
       dotClick(x,0);
      }
      if(shiftSpot != -1 && y>=shiftSpot) {
       dotClick(y+1+shift,0);
      } else {
       dotClick(y+1,0);
      }
     }
    }
   }
  }
  if(shift > 0) {
   dotClick(shiftSpot,0);
   dotClick(shiftSpot+1,0);
   dotClick(shiftSpot+1,0);
   dotClick(shiftSpot+2,0);
  }
 if(!doCTag) { arcGraphics.paint(); }
 }
 if(!doCTag) {
  window.setTimeout(
   function() {
    EL("arcCanvasCont_temp").innerHTML = "";
   },1500);
 }
}


function prep4Edit(contents) {
 return contents.replace(/-<[Bb][Rr]>/g,'-').replace(/,<[Bb][Rr]>/g,',');
}

function prep4Set(contents) {
 return trim(contents).replace(/</g,"&#60;").replace(/>/g,"&#62;").replace(/_/g,"&#95;").replace(/-/g,"-<BR>").replace(/,/g,",<BR>");
}

function emptyProp(contents) {
  return (contents.toLowerCase() == "<br>" || contents.match(/^&nbsp;<!--vs[0-9]+-->$/i));
}

function prep4Edit2(contents) {
 var newContents = stripLeadSp(contents);
// newContents = newContents.replace(/^<br>$/gi,"").replace(/<SPAN[^>]*>\|<\/SPAN>/gi,"");
 newContents = newContents.replace(/^<br>$|<\/?SPAN[^>]*>|\|/gi,"");
 //newContents = newContents.replace(/<\/?SPAN[^>]*>|\|/gi,"");
 newContents = newContents.replace(/^(<!--vs[0-9]+-->)$/gi,"$1&nbsp;");
 return newContents;
}

function rmForbiddenChars(content) {
 return content.replace(/_/g,"&#95;").replace(/{/g,"&#123;").replace(/}/g,"&#125;").replace(/\|/g,"&#124;");;
}

function delEmpFontTags(pos) {
 while(true) {
  var posAdv = tmpHtmlStr.substr(pos).search(/<\/?FONT/i);
  pos = pos + posAdv;
  if(posAdv == -1) {
   return -1;
  } else if(tmpHtmlStr.substr(pos,7) == "</FONT>") {
   return pos;
  } else if(tmpHtmlStr.substr(pos,6) == "<FONT>") {
   tmpHtmlStr = tmpHtmlStr.substr(0,pos) + tmpHtmlStr.substr(pos+6);
   pos = delEmpFontTags(pos);
   if(pos < 0 || tmpHtmlStr.substr(pos,7) != "</FONT>") { return -2; }
   tmpHtmlStr = tmpHtmlStr.substr(0,pos) + tmpHtmlStr.substr(pos+7);
  } else if(tmpHtmlStr.substr(pos,6) == "<FONT_") {
   pos = delEmpFontTags(pos+6);
   if(pos < 0 || tmpHtmlStr.substr(pos,7) != "</FONT>") { return -2; }
   pos += 7;
  } else {
   return -2;
  }
 }
}

function prep4Set2(contents, objPref) {
 var newContents = contents.replace(/[\n\r]+/gi,"");
 newContents = newContents.replace(/<\/?P>|<\/?BR[ ][\/]>|<\/?DIV>|&NBSP;/gi," ");
 newContents = rmForbiddenChars(newContents);
 newContents = newContents.replace(/^(<!--VS[0-9]+-->) /gi,"$1");

//below is the new part
 newContents = newContents.replace(/<!--(VS[0-9]+)-->/gi,"{$1}");
 newContents = newContents.replace(/-->/gi,"_");
 newContents = newContents.replace(/<!--[^_]*_/gi,"");
 newContents = newContents.replace(/_/gi,"-->");
 newContents = newContents.replace(/{(VS[0-9]+)}/gi,"<!--$1-->");
//above is the new part

 newContents = newContents.replace(/<(\/?)(SPAN|FONT)/gi,"_$1FONT");
 newContents = newContents.replace(/<(\/?)(EM|I|B|S|STRIKE|STRONG|U|DEL)>/gi,"_$1$2>");
 newContents = newContents.replace(/<!--/gi,"_!--");
 newContents = newContents.replace(/<[^>]*>/gi,"");
 newContents = newContents.replace(/_/gi,"<");

 var SpRE = /(<FONT[^> ]*) ([^>]*>)/gi;
 while(newContents.search(SpRE) != -1) { newContents = newContents.replace(SpRE,"$1_$2"); }

 newContents = newContents.replace(/_STYLE=(["'][^"']*["'])/gi,"_STYLE!=$1");
 newContents = newContents.replace(/_[A-Z]*=["'][^"']*["']/gi,"");
 newContents = newContents.replace(/_STYLE!=(["'][^"']*["'])/gi,"_STYLE=$1");

 newContents = newContents.replace(/(FONT-STYLE|FONT-WEIGHT|COLOR|TEXT-DECORATION)/gi,"$1__");
 var ColRE = /(<FONT[^> ]*):([^_>][^>]*>)/gi;
 while(newContents.search(ColRE) != -1) { newContents = newContents.replace(ColRE,"$1:_$2"); }
 newContents = newContents.replace(/[-A-Z]+:_[^;"']*;?_?/gi,"");
 newContents = newContents.replace(/(FONT-STYLE|FONT-WEIGHT|COLOR|TEXT-DECORATION)__/gi,"$1");
 newContents = newContents.replace(/_+STYLE=["']{2}_*/gi,"");
 
 tmpHtmlStr = newContents;
 if(delEmpFontTags(0) == -1) { newContents = tmpHtmlStr; }
 
 newContents = newContents.replace(/  +/g, " ");
 newContents = newContents.replace(/__+/g, "_");
 newContents = trim(newContents);
 
 if(newContents == "") {
  return "<BR>";
 } else {
  var isGrk = false;
  if(objPref.substr(0,1) == 1 && colVer[0] == "greek") { isGrk = true; }
  var newFirHalf;
  var lastspos = 0;
  var spos = newContents.indexOf(' ');
  var breaknum = 1;
  while(spos != -1) {
   var newSecHalf = "<SPAN_id="+objPref+"-"+breaknum+"_class=hb_onclick='brk"+objPref.substring(0,1)+"(this);'>";
   newSecHalf += "|</SPAN>_"+newContents.substring(spos+1);
   if(isGrk) {
    newFirHalf = newContents.substring(0,lastspos)+putSpnAroundWord(newContents.substring(lastspos,spos));
   } else {
    newFirHalf = newContents.substring(0,spos);
   }
   newContents = newFirHalf + newSecHalf;
   spos = newContents.indexOf(' ');
   lastspos = newContents.lastIndexOf('|</SPAN>_') + 9;
   breaknum++;
  }
  if(isGrk) {
   newContents = newContents.substring(0,lastspos)+putSpnAroundWord(newContents.substring(lastspos));
  }
  return "&nbsp;"+newContents.replace(/_/g,' ');
 }
}

function putSpnAroundWord(wordPlus) {
 var befWord = wordPlus.replace(/^((<\/?[^>]*>)*).*/gi,"$1");
 var aftWord = wordPlus.replace(/.*[^>]((<\/?[^>]*>)*)$/gi,"$1");
 var theWord = wordPlus.substring(befWord.length,wordPlus.length-aftWord.length);
 return befWord+"<SPAN_class=pa_onmouseover='pa(this);'>"+theWord+"</SPAN>"+aftWord;
}

function setVs(objId) {
 var mainTableHeight = EL("mainTable").offsetHeight;
 var rowNum = parseInt(objId.substring(8));
 var brk1Pos = findPos(EL("ydot"+rowNum));
 var brk2Pos = findPos(EL("ydot"+(rowNum+1)));
 EL(objId).innerHTML = prep4Set(EL("vsInput").value);
 EL("modVsSpot").style.visibility = 'hidden';
 EL("modVsSpot").style.left = "0px";
 EL("modVsSpot").style.top = "0px";
 EL("vsInput").value = "";
 EL("vsInput").onblur = function() {};
 EL("vsInput").onkeypress = function() {};
 if(EL("mainTable").offsetHeight != mainTableHeight) {
  redrawClearArray(1,-1,0);
  doResizeActions(mainTableHeight,brk1Pos[1],brk2Pos[1],0);
 }
 indicateNotSaved();
	fixArcDesktopHt();
 noBG();
}

function setProp(objId1,objId2,addOn) {
 var mainTableHeight = EL("mainTable").offsetHeight;
 var rowNum = parseInt(objId1.substring(7));
 var brk1Pos = findPos(EL("ydot"+rowNum));
 var brk2Pos = findPos(EL("ydot"+(rowNum+1)));
 var ti2 = tinyMCE.get('mdPrpInput'+addOn);
 var content = prep4Set2(ti2.getContent(),objId1.substring(6))
 EL(objId1).innerHTML = content;
 if(EL("mainTable").offsetHeight != mainTableHeight) {
  redrawClearArray(1,-1,0);
  doResizeActions(mainTableHeight,brk1Pos[1],brk2Pos[1],0);
 }
 indicateNotSaved();
	fixArcDesktopHt();
 cnclModProp(objId1,objId2,addOn);
}

function cnclModProp(objId1,objId2,addOn) {
 //EL("modPropSpot").style.visibility = 'hidden';
 EL(objId1).style.visibility = "";
 EL(objId2).style.backgroundColor = "";
 EL("modPropSpot"+addOn).style.left = "0px";
 EL("modPropSpot"+addOn).style.top = "-1000px";
 noBG();
 window.focus();
}

function handleKeyPress(e,thisLabelNum){
 var key=e.keyCode || e.which;
 if (key==13) {
  if(thisLabelNum == -1) {
   EL("tmpInput").blur();
  } else {
   EL("text"+thisLabelNum).blur();
  }
 }
}

function modVs(obj1, obj2) {
 //if(EL("lock").checked) { return; }
 clearYdot();
 clearBrks();
 if(autoVsNums && !confirm("Modifying verse numbers will disable verse number auto-update (performed when splitting a proposition or removing a break). Are you sure you want to do this?")) { return; }
 goBG(2);
 autoVsNums = 0;
 var objPos = findPos(obj1);
 EL("modVsSpot").style.left = (objPos[0]) + 'px';
 EL("modVsSpot").style.top = (objPos[1] + (obj1.offsetHeight/2) - 10) + 'px'; 
 EL("vsInput").onblur = function() { setVs(obj1.id); };
 EL("vsInput").onkeypress = 
 		function(evt) {
 			var key = evt ? evt.keyCode : event.keyCode; // || event.which;
 			if(key == 13) { setVs(obj1.id); } 
 		};
 EL("vsInput").value = prep4Edit(obj1.innerHTML);
 EL("modVsSpot").style.visibility = "";
 EL("vsInput").focus();
}

function modProp(obj1, obj2, colNum) {
 window.clearTimeout(breakPropTimer); noMsg();  //to prevent accidental split.
 goBG(2); 
 clearYdot();
 clearBrks();
 var addOn = "";
 if(colNum == 1 && (colVer[0] == "greek" || colVer[0] == "hebrew")) { addOn = "GkHb"; } 
 var ti2 = tinyMCE.get('mdPrpInput'+addOn);
 EL("ti2Done"+addOn).onclick = function() { goMsg(1,"Updating...",-1,'setProp("'+obj1.id+'","'+obj2.id+'","'+addOn+'");'); }
 EL("ti2Cancel"+addOn).onclick = function() { cnclModProp(obj1.id,obj2.id,addOn); }
 ti2.setContent(prep4Edit2(obj1.innerHTML).replace(/<(\/?)FONT/gi,"<$1SPAN"));
 var objPos = findPos(obj2);
 if(colVer[1] == "none") { colNum++; }
 EL("modPropSpot"+addOn).style.left = (objPos[0]-50+((colNum-1)*62)) + "px";
 var topPos = objPos[1] + (obj2.offsetHeight/2) - 115;
 if(topPos + 200 + 40 > scrollHeight()) { topPos = scrollHeight()-200-40; }
 EL("modPropSpot"+addOn).style.top = topPos + "px";
 obj2.style.backgroundColor = "#241911";
 obj1.style.visibility = "hidden";
// var newHt = obj2.offsetHeight + 40;
// if(newHt < 123) { newHt = 123; }
/*  
  if(curPrEditHtGkHb != newHt) {
   curPrEditHtGkHb = newHt;
   tinyMCE.execCommand('mceRemoveControl', true, "mdPrpInputGkHb");
   EL("mdPrpInputGkHb").style.height = newHt;
   tinyMCE.execCommand('mceAddControl', false, "mdPrpInputGkHb");
  }
*/
 if(agent != "IE") { EL("mdPrpInput"+addOn).focus(); }
 tinyMCE.execCommand('mceFocus', false, 'mdPrpInput'+addOn);
}

function initTinyObj() {
 tinyMCE_GZ.init({
  themes : 'advanced',
  languages : 'en',
  disk_cache : true,
  debug : true
 });
}

function initTinys() {
 initTinyNtTab();
 initTinyStky();
 initTinyGkHb();
 initTinyEng();    
 //tinysReady=true;
 //endLoad(saveStatus);
/*   
  if(agent == "IE") {
   window.setTimeout("initTinyNtTab(); initTinyStky(); initTinyEng(); initTinyGkHb(); tinysReady=true; endLoad();",1500);
  } else {
   initTinyNtTab();
   initTinyStky();
   initTinyGkHb();
   initTinyEng();    
   tinysReady=true;
  }
*/
}

function initTinyEng() {
//note: a weird clitch is that with the deselector, one class name cannot be contained in another.
 if((colVer[0] == "greek" || colVer[0] == "hebrew") && colVer[1] == "none") { return; }
 EL("mdPrpInput").style.width = EL("tblDef10").offsetWidth + 40 + 'px';
 tinyMCE.init({
  mode : "specific_textareas",
  theme : "advanced",
  editor_deselector : /(mylabel|notes|pgkhb|plain)/,
  theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor",
  theme_advanced_buttons2 : "",
  theme_advanced_buttons3 : "",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "",
  extended_valid_elements : "",
  forced_root_block : "",
  content_css : gDirPrefix+"/css/multiple-content-css.php?f=tinymceen.css|"+cssFile,
  setup : function (ed) {
      ed.onKeyPress.add(
          function (ed, evt) { if(evt.keyCode == 13) { EL("ti2Done").click(); return tinymce.dom.Event.cancel(evt); } }
      );
  }
 });
//  theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor,backcolor",
}

function initTinyGkHb() {
 if(colVer[0] != "greek" && colVer[0] != "hebrew") { return; }
 EL("mdPrpInputGkHb").style.width = EL("tblDef10").offsetWidth + 40 + 'px';
 var cssLangFile = "tinymcegk.css";
 if(colVer[0] == "hebrew") {
  cssLangFile = "tinymcehb";
  if(agent == "IE") { cssLangFile += "_ie"; }
  cssLangFile += ".css";
 }
 tinyMCE.init({
  mode : "specific_textareas",
  theme : "advanced",
  editor_deselector : /(mylabel|notes|props|plain)/,
  theme_advanced_buttons1 : "bold,italic,underline,strikethrough,forecolor",
  theme_advanced_buttons2 : "",
  theme_advanced_buttons3 : "",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "",
  extended_valid_elements : "",
  forced_root_block : "",
  content_css : gDirPrefix+"/css/multiple-content-css.php?f="+cssLangFile+"|"+cssFile,
  setup : function (ed) {
      ed.onKeyPress.add(
          function (ed, evt) { if(evt.keyCode == 13) { EL("ti2DoneGkHb").click(); return tinymce.dom.Event.cancel(evt); } }
      );
  }
 });
}

function initTinyStky() {
 tinyMCE.init({
  mode : "specific_textareas",
  theme : "advanced",
  editor_deselector : /(props|notes|pgkhb|plain)/,
  theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,bullist,numlist,|,forecolor",
  theme_advanced_buttons2 : "",
  theme_advanced_buttons3 : "",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "",
  extended_valid_elements : "",
  forced_root_block : "",
  force_p_newlines : false,
  force_br_newlines : true,
  convert_newlines_to_brs : true,
  remove_linebreaks : true,
  content_css : gDirPrefix+"/css/multiple-content-css.php?f=tinymcestky.css|"+cssFile  
 });  
}


function initTinyNtTab() {
/*
 if(agent == "IE") {
  EL("notesTA").style.height = (windowHeight()-495) + "px";
  EL("notesTA").style.width = EL("notesTA").offsetWidth + "px";
  //EL("notesTD").style.height = EL("notesTD").offsetHeight+4 + "px";  //element does not exist anymore.
  EL("bNts").style.position = "absolute";
 } else {
  EL("notesTA").style.height = (windowHeight()-325) + "px";
 }
*/
	EL("notesTA").style.height = (windowHeight()-325) + "px";
 tinyMCE.init({
  mode : "specific_textareas",
  theme : "advanced",
  editor_deselector : /(mylabel|props|pgkhb|plain)/,
  theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,fontsizeselect,|,forecolor,backcolor,|,bullist,numlist,outdent,indent,hr,|,cleanup,|,undo,redo",
  theme_advanced_buttons2 : "",
  theme_advanced_buttons3 : "",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "",
  extended_valid_elements : "",
  //forced_root_block : "",
  //force_p_newlines : false,
  //force_br_newlines : true,
  //convert_newlines_to_brs : true,
  //remove_linebreaks : true,
  content_css : gDirPrefix+"/css/multiple-content-css.php?f=tinymcents.css|"+cssFile,
		execcommand_callback : "myCustomExecCommandHandler",
	  setup : function(ed) {
	      ed.onChange.add(
	          function (ed, evt) { indicateNotSaved(); /*tinyMCE.execCommand('mceCleanup', true, 'notesTA');*/ }
	      );
	      ed.onKeyPress.add(
	          function (ed, evt) { indicateNotSaved(); }
	      );
	      ed.onPaste.add(
	          function(ed, e, o) { window.setTimeout("cleanUpNote();",1); }
	      );
  	}
 });
}

function cleanUpNote() {
 var tNote = tinyMCE.get('notesTA');
 var beforeElim = tNote.getContent();
 var afterElim = eliminateIllTags(beforeElim);
 if(beforeElim != afterElim) { tNote.setContent(afterElim); } 
}

function myCustomExecCommandHandler(editor_id, elm, command, user_interface, value) {
	indicateNotSaved();
	return false; // Pass to next handler in chain
}

function adjustWithResize() {
 if(curTab == 0) {
  var newPos = findPos(EL("mainTable"));
  newPos[0] += 3;  //add on 3 to properly align re-design
  for(var i=1; i<=labelNum; i++) {
   if(EL("label"+i).style.visibility == 'hidden') { continue; }
   var labelPos = findPos(EL("label"+i));
   EL("label"+i).style.left = (labelPos[0] + (newPos[0] - mainTable2Left)) + 'px';
   EL("label"+i).style.top = (labelPos[1] + (newPos[1] - mainTable2Top)) + 'px';
  }
  mainTable2Left = newPos[0];
  mainTable2Top = newPos[1];
 }
 resizeBG();
 initScroll();
 moveToolbar();
 askToBMark();
}

function adjustWithResizeBlogCmts() {
 resizeBG();
 initScroll();
 moveToolbar();
}

initScroll();
 moveToolbar();

function getSaveParameters() {
 var props_vs = '';
 var props_col1 = '';
 var props_col2 = '';
 var props_height = '';
 var arcs = '';
 var labels = '';

 cleanUpNote();
 var tNote = tinyMCE.get('notesTA');
 var arcNote = esc2(tNote.getContent());
 var ydot2Pos = findPos(EL("ydot0"));
 for(var i=0; i<numProps; i++) {
  props_vs +=  '>' + prep4Edit(EL("verseNum"+i).innerHTML);
  props_col1 += '}' + rmForbiddenChars(prep4Edit2(EL("tblDef1"+i).innerHTML));
  if(colLang[1] != "") {
   props_col2 += '}' + rmForbiddenChars(prep4Edit2(EL("tblDef2"+i).innerHTML));
  }
  var ydot1Pos = ydot2Pos;
  ydot2Pos = findPos(EL("ydot"+(i+1)));
  props_height += '>' + (ydot2Pos[1] - ydot1Pos[1]);
 }
 props_vs = props_vs.substring(1).replace(/&/g,'{A').replace(/"/g,'{Q');
 props_col1 = "{" + colLang[0] + "}" + props_col1.substring(1).replace(/&/g,'{A').replace(/"/g,'{Q');
 props_height = props_height.substring(1);
 if(colLang[1] != "") {
  props_col2 = "{" + colLang[1] + "}" + props_col2.substring(1).replace(/&/g,'{A').replace(/"/g,'{Q');
 } else {
  props_col2 = "<NONE>";
 }
 if(!defaultArcsOnly) {
  for(var x=0; x<arcArray.length; x++) {
   for(var y=0; y<arcArray.length; y++) {
    if(arcArray[x][y]) {
     arcs += '>' + x + '-' + (y+1);
    }
   }
  }
  arcs = arcs.substring(1);
 }
 for(var i=1; i<=labelNum; i++) {
  var thisObj = EL("label"+i);
  if(thisObj.style.visibility == 'hidden') { continue; }
  var labelPos = findPos(thisObj);
  if(labelPos[1] < 0) { labelPos[1] = parseInt(labelPos[1].toString().substring(3)); }
  var isSymbol = 0;
  if(thisObj.style.fontFamily.toUpperCase() == "SYMBOL") { isSymbol = 1; }
  var isMyLabel = 0;
  if(thisObj.className == "mylabel") { isMyLabel = 1; }
  var bgWhite = 0;
  if(thisObj.style.backgroundColor.toUpperCase() == "WHITE") { bgWhite = 1; }
  labels += '>' + (labelPos[0]-mainTable2Left) + '<' + (labelPos[1]-mainTable2Top) + '<' + thisObj.innerHTML.replace(/_/g,'_U').replace(/</gi,'_L').replace(/>/gi,'_R').replace(/&amp;|&/gi,'_A').replace(/"/g,'_Q').replace(/\+/g,'_P') + '<' + thisObj.style.color + '<' + bgWhite + '<' + isSymbol + '<' + isMyLabel;
 }
 labels = labels.substring(1).replace(/&/g,'<');
 return "arcid="+arcId+"&name="+arcName+"&props_vs="+props_vs+"&props_col1="+props_col1+"&props_col2="+props_col2+"&props_height="+props_height+"&arcs="+arcs+"&labels="+labels+"&autoVsNums="+autoVsNums+"&defaultArcs="+defaultArcsOnly+"&note="+arcNote+"&uid="+saveUserId;
}

function doReg() {
 goMsg(2,"Saving arc...",-1,"");
 ajaxSave(true,false); 
 postSaveAct = "register";
}

function ajaxSave(hidden,silent) {
 if(loginId == '' && !hidden) {
  getLoginOrRegistration("login1");
  return;
 }
 if(!hidden && saveUserId == 0) {
 	window.clearTimeout(sugSaveTimer);
 	beginAutoSave();
 }
 var parameters = getSaveParameters();
 parameters += "&paramsdone=true";
 doAjax("save1",gDirPrefix+"/ajaxsave.php",parameters,silent);
 if(EL("tweet1")) {
 	var tweetsEntered = false;
 	for(p=1; !tweetsEntered && EL('tweet'+p); p++) { tweetsEntered = (trim(EL('tweet'+p).value)!=''); }
 	if(tweetsEntered) { postSaveAct = 'saveblog'; }
 }
 if(!hidden) {
	 EL("saveButton").value = "Saving...";
	 EL("saveButton").disabled = "true"; 
	 EL("saveButton").className = ''; 
	}
 isSaved = 1;
}

function ajaxSave2(resp) {
 res = resp.split('>');
 if(res[0] == 'saved') {
  if(isSaved == 1) {
	  isSaved = 2;
		 if(saveUserId != 0) { indicateSaved(); }
  } else if(isSaved == 0) {
	  isSaved = 2;
   indicateNotSaved();
  }
  if(saveUserId != 0) {
   EL("lstModI").innerHTML = res[1];
   EL("saveErrMsg").innerHTML = "";
   if(EL("altS2")) { EL("altS2").className = "alrtSpacer2"; EL("altS2").style.visibility = "hidden";}
   if(EL("altS3")) { EL("altS3").className = "alrtSpacer2"; EL("altS3").style.visibility = "hidden"; }
   if(EL("altS1")) { EL("altS1").className = "alrtSpacer"; EL("altS1").style.visibility = ""; }
  }
  noMsg();
  switch(postSaveAct) {
   case "pdf":
    pdfArcs(arcId);
    break;
   case "register":
    goMsg(2,"Redirecting to registration page...",-1,"");
    byPassExitCheck = true;
    window.location = "https://" + serverName + gDirPrefix + "/register.php?arcId="+arcId;
    break;
   case "email":
    emailArc();
    break;
   case "share":
    shareArc(arcId,passage,arcName,0,1,1);
    break;
   case "submitblog":
   	submitBlog();
   	break;
   case "saveblog":
   	saveBlogInfo();
   	break;
   case "link to":
   	linkArc();
   	break;
  }
  postSaveAct = "";
 } else {
  alert("There was an error. (Error #355)");
  ajaxSaveErr("There was an error while saving.");
 }
}

function ajaxSaveErr(emsg) {
 noMsg();
 isSaved = 2;
 indicateNotSaved();
 postSaveAct = "";
 if(saveUserId != 0) {
	 EL("saveErrMsg").href = 'javascript:alert(\"'+emsg.replace(/\n/gi,'\\n')+'\");';
	 EL("saveErrMsg").innerHTML = "SAVE ERROR!";
	}
}

function ajaxSuccess(act,resp) {
 switch(act) {
  case "save1":
   ajaxSave2(resp);
   break;
  case "login1":
   loginToSave2(resp,true,false);
   break;
  case "login2":
   loginToSave2(resp,false,false);
   break;
  case "login3":
   loginToSave2(resp,false,true);
   break;
  case "unaltered1":
   bringInPas2(resp);
   break;
  case "email1":
   doEmail2ArcPage(resp);
   break;
  case "compare2":
   goComp2(resp);
   break;
  case "unshare2":
   unshareArc2ArcPage(resp);
   break;
  case "comment1":
   putInCmts1();
   break;
  case "getcomments1":
   putInCmts2(resp);
   break;
  case "reply1":
   putInCmts1();
   break;
  case "report1":
   doReport2(resp);
   break;
  case "renew1":
   goRenew2(resp);
   break;
  case "compare1":
   bringInComp2(resp);
   break;
  case "bookmarks1":
   bringInBookmarks2(resp);
   break;
  case "share1":
   doShare2(resp);
   break;
  case "unshare1":
   unshareArc2(resp);
   break;
  case "ealerts1":
   saveEAlerts2(resp);
   break;
  case "email2":
   doEmail2(resp);
   break;
  case "bookmark2":
   yesBMark2();
   break;
  case "bookmark3":
   noBMark2();
   break;
  case "bookmark4":
  	bMarkMyArcs2(resp);
  	break;
  case "submitblog1":
  	submitBlog2();
  	break;
 }
}

function ajaxFail(act,emsg) {
 switch(act) {
  case "save1":
   ajaxSaveErr(emsg);
   break;
  case "login1":
   loginToSaveErr();
   break;
  case "login2":
   loginToSaveErr();
   break;
  case "login3":
   loginToSaveErr();
   break;
  case "compare1":
   noMsg();
   hideComp();
   break;
  case "bookmarks1":
   noMsg();
   hideComp();
   break;
  default:
   noMsg();
   break;
 } 
}

function clearArcsLabels() {
 clearYdot();
 clearBrks();
 if(confirm("Are you sure you want to clear all arcs, labels, and notes? (Default arcs will be redrawn.)")) {
  if(!defaultArcsOnly) {
   redrawClearArray(0,-1,0);
  }
  EL("labels").innerHTML = "";
  labelNum = 0;
 }
 indicateNotSaved();
}

function stripLeadSp(str) {
  if(str.match(/^&nbsp;/i)) {
    return str.substring(6);
  } else if(str.match(/^[\s]/i) || str.charCodeAt(0) == 160) {
    return str.substring(1);
  } else {
    return str;
  }
}

function updateVsNums(splitPropNum) {
 var alphaChars = "abcdefghijklmnopqrstuvwxyz";
 var thisProp = stripLeadSp(EL("tblDef10").innerHTML);
 if(!autoVsNums || thisProp.substring(6,thisProp.indexOf('-->')) != startVs) {
  if(splitPropNum != -1) { EL("verseNum"+splitPropNum).innerHTML = prep4Set(""); }
  autoVsNums = 0;
  return;
 }
 var newVsNums = new Array(numProps);
 var curVs = parseInt(startVs,10);
 var subVsStart = '';
 var propEndVs;
 for(var i=0; i<numProps; i++) {
  propEndVs = curVs;
  if(thisProp.lastIndexOf("<!--vs") != -1) { propEndVs = parseInt(thisProp.substring(thisProp.lastIndexOf("<!--vs")+6,thisProp.lastIndexOf("-->")),10); }
  var atVsBreak = 1;
  if(i+1 < numProps) {
   thisProp = stripLeadSp(EL("tblDef1"+(i+1)).innerHTML);
   if(thisProp.substring(0,6) != "<!--vs") { atVsBreak = 0; }
  }
  if(curVs == propEndVs) {
   if(!atVsBreak && subVsStart == '') { subVsStart = 'a'; }
   newVsNums[i] = curVs + subVsStart;
  } else {
   var subVsEnd = '';
   if(!atVsBreak) { subVsEnd = 'a'; }
   newVsNums[i] = curVs + subVsStart + '-' + propEndVs + subVsEnd;
   subVsStart = subVsEnd;
  }
  if(atVsBreak && i+1 < numProps) {
   subVsStart = '';
   curVs = parseInt(thisProp.substring(6,thisProp.indexOf("-->")),10);
  } else if(i+1 < numProps) {
   subVsStart = alphaChars.charAt(alphaChars.indexOf(subVsStart)+1);
   curVs = propEndVs;
  }
 }
 if(propEndVs != endVs) {
  if(splitPropNum != -1) { EL("verseNum"+splitPropNum).innerHTML = prep4Set(""); }
  autoVsNums = 0;
  return;
 }
 for(var i=0; i<numProps; i++) {
  EL("verseNum"+i).innerHTML = prep4Set(newVsNums[i]);
 }
}

function removePropBreak(breakNum) {
 //if(EL("lock").checked) { return; }
 var intruding = 0;
 for(var i=0; i<breakNum; i++) {
  if(arcArray[i][breakNum]) { intruding = 1; }
 }
 for(var i=breakNum+2; i<numProps; i++) {
  if(arcArray[breakNum+1][i]) { intruding = 1; }
 }
 if(intruding) {
  alert("Please remove all intruding arcs before joining two propositions. (Exception: first-level intruding arcs are ok.)");
  return;
 }
 clearYdot();
 clearBrks();
 //if(!confirm("Are you sure you want to merge these propositions?")) { return; }
 goMsg(1,"Merging...",-1,"removePropBreak2("+breakNum+");");
}

function removePropBreak2(breakNum) {
 var mainTableHeight = EL("mainTable").offsetHeight;
 var brk1Pos = findPos(EL("ydot"+(breakNum)));
 var brk2Pos = findPos(EL("ydot"+(breakNum+2)));
 EL("tblDef1"+breakNum).innerHTML = prep4Set2(prep4Edit2(EL("tblDef1"+breakNum).innerHTML)+' '+
                                                     prep4Edit2(EL("tblDef1"+(breakNum+1)).innerHTML),'1'+breakNum);
 if(colLang[1] != "") {
  EL("tblDef2"+breakNum).innerHTML = prep4Set2(prep4Edit2(EL("tblDef2"+breakNum).innerHTML)+' '+
                                                     prep4Edit2(EL("tblDef2"+(breakNum+1)).innerHTML),'2'+breakNum);
 }
 for(var i=breakNum+2; i<numProps; i++) {
  EL("verseNum"+(i-1)).innerHTML = EL("verseNum"+i).innerHTML;
//  EL("verseNum"+(i-1)).innerHTML = prep4Set(prep4Edit(EL("verseNum"+i).innerHTML));
  var re = new RegExp("(ID=[\"']?1)"+i+"-([0-9])", 'gi');
  EL("tblDef1"+(i-1)).innerHTML = EL("tblDef1"+i).innerHTML.replace(re,"$1"+(i-1)+"-$2");
//  EL("tblDef1"+(i-1)).innerHTML = prep4Set2(prep4Edit2(EL("tblDef1"+i).innerHTML),'1'+(i-1));
  if(colLang[1] != "") {
//   EL("tblDef2"+(i-1)).innerHTML = prep4Set2(prep4Edit2(EL("tblDef2"+i).innerHTML),'2'+(i-1));
   re = new RegExp("(ID=[\"']?2)"+i+"-([0-9])", 'gi');
   EL("tblDef2"+(i-1)).innerHTML = EL("tblDef2"+i).innerHTML.replace(re,"$1"+(i-1)+"-$2");
  }
 } 
 EL("mainTable").deleteRow(numProps*2);
 EL("mainTable").deleteRow(numProps*2-1);
 numProps--;
 updateVsNums(-1); 
 breakSelected = "";
 rowSelected = "";
 redrawClearArray(1,breakNum,-1);
 doResizeActions(mainTableHeight,brk1Pos[1],brk2Pos[1],-1);
 indicateNotSaved();
	fixArcDesktopHt();
}

function splitProp(rowNum) {
 var mainTableHeight = EL("mainTable").offsetHeight;
 var brk1Pos = findPos(EL("ydot"+rowNum));
 var brk2Pos = findPos(EL("ydot"+(rowNum+1)));
 var newRow = EL("mainTable").insertRow(-1);
 var newTD = newRow.insertCell(-1);
 newTD.id = "verseNum"+numProps+"Td";
 newTD.className = "versenum";
 newTD.style.verticalAlign = "middle";
 newTD.align = "center";
 newTD.ondblclick = new Function("modVs(EL(\"verseNum"+numProps+"\"),this)");
 newTD.onmouseover = new Function('this.style.cursor=\"default\"');
 newTD.innerHTML = "\
   <table cellpadding=2>\
    <tr>\
     <td valign=middle align=center>\
      <div id=verseNum"+numProps+" class=vsNum></div>\
     </td>\
    </tr>\
   </table>\
 ";

 if(colLang[1] != "") {

  newTD = newRow.insertCell(-1);
  newTD.id = "tblD1"+numProps;
  newTD.className = "passage";
  newTD.style.verticalAlign = "top";
  newTD.ondblclick = new Function("modProp(EL(\"tblDef1"+numProps+"\"), this, 1)");
  newTD.onmouseover = new Function('this.style.cursor=\"default\"');
  var forInnerHtml = "\
   <table cellpadding=2>\
    <tr>\
     <td>\
      <div class="+colLang[0]+"Pass1 id=tblDef1"+numProps+"></div>\
     </td>\
    </tr>\
   </table>\
  ";
  if(colVer[0]=="greek") { forInnerHtml = forInnerHtml.replace("<td>","<td onmouseout='paOut();'>"); } 
  newTD.innerHTML = forInnerHtml;


  newTD = newRow.insertCell(-1);
  newTD.id = "tblD2"+numProps;
  newTD.className = "passage";
  newTD.style.verticalAlign = "top";
  newTD.ondblclick = new Function("modProp(EL(\"tblDef2"+numProps+"\"), this, 2)");
  newTD.onmouseover = new Function('this.style.cursor=\"default\"');
  newTD.innerHTML = "\
   <table cellpadding=2>\
    <tr>\
     <td>\
      <div id=tblDef2"+numProps+" class="+colLang[1]+"Pass1></div>\
     </td>\
    </tr>\
   </table>\
  ";



 } else {

  newTD = newRow.insertCell(-1);
  newTD.id = "tblD1"+numProps;
  newTD.colSpan = "2";
  newTD.className = "passage";
  newTD.style.verticalAlign = "top";
  newTD.ondblclick = new Function("modProp(EL(\"tblDef1"+numProps+"\"), this, 1)");
  newTD.onmouseover = new Function('this.style.cursor=\"default\"');
  var forInnerHtml = "\
   <table cellpadding=2>\
    <tr>\
     <td>\
      <div id=tblDef1"+numProps+" class="+colLang[0]+"Pass2></div>\
     </td>\
    </tr>\
   </table>\
  ";
  if(colVer[0]=="greek") { forInnerHtml = forInnerHtml.replace("<td>","<td onmouseout='paOut();'>"); } 
  newTD.innerHTML = forInnerHtml;


 }

 var imgDivClass = "xBreak2";
 if(colLang[1] != "") { imgDivClass = "xBreak1"; }
 newTD = newRow.insertCell(-1);
 newTD.className = "removeBreak";
 newTD.align = "left";
 //newTD.style.verticalAlign = "top";
 newTD.innerHTML = "<div class="+imgDivClass+"><div id='rmProp"+(numProps-1)+"' class=xsmall onclick='removePropBreak("+(numProps-1)+");'></div></div>";

 numProps++;
 newRow = EL("mainTable").insertRow(-1);
 newTD = newRow.insertCell(-1);
 newTD.className = "breakLine";
 newTD.align = "right";
 newTD.colSpan = "3";
 newTD.innerHTML = "<div onclick='dotClick("+numProps+",1);' onmouseover='this.style.cursor=\"pointer\"' id=ydot"+numProps+" class=ydot>&nbsp;</div>";
 newTD = newRow.insertCell(-1);

 for(var i=numProps-2; i>rowNum; i--) {
  EL("verseNum"+(i+1)).innerHTML = EL("verseNum"+i).innerHTML;
//  EL("tblDef1"+(i+1)).innerHTML = prep4Set2(prep4Edit2(EL("tblDef1"+i).innerHTML),'1'+(i+1));
  var re = new RegExp("(ID=[\"']?1)"+i+"-([0-9])", 'gi');
  EL("tblDef1"+(i+1)).innerHTML = EL("tblDef1"+i).innerHTML.replace(re,"$1"+(i+1)+"-$2");
  if(colLang[1] != "") {
//   EL("tblDef2"+(i+1)).innerHTML = prep4Set2(prep4Edit2(EL("tblDef2"+i).innerHTML),'2'+(i+1));
   re = new RegExp("(ID=[\"']?2)"+i+"-([0-9])", 'gi');
   EL("tblDef2"+(i+1)).innerHTML = EL("tblDef2"+i).innerHTML.replace(re,"$1"+(i+1)+"-$2");
  }
 }

 //var re = new RegExp(" class=['\"]?" + "vb" + "['\"]?[ >]");
 var tagArray = new Array("B","STRONG","I","EM","U","STRIKE","FONT");
 if(!emptyProp(EL("tblDef1"+rowNum).innerHTML)) {
  var contentArray = EL("tblDef1"+rowNum).innerHTML.split(/ class=['"]?vb['"]?[ >]/);
  var content1 = contentArray[0].substring(0,contentArray[0].toUpperCase().lastIndexOf('<SPAN'));
  var content2 = contentArray[1].substring(contentArray[1].toUpperCase().indexOf('>|</SPAN> ')+10); 
  for(i=0; i<tagArray.length; i++) {
   var tagDif = content1.toUpperCase().count('<'+tagArray[i]) - content1.toUpperCase().count('</'+tagArray[i]);
   while(tagDif > 0) {
    content1 = content1 + '</'+tagArray[i]+'>';
    content2 = '<'+tagArray[i]+'>' + content2;
    tagDif--;
   }
  }
  EL("tblDef1"+rowNum).innerHTML = content1;
  EL("tblDef1"+(rowNum+1)).innerHTML = prep4Set2(prep4Edit2(content2),'1'+(rowNum+1));
 } else {
  EL("tblDef1"+(rowNum+1)).innerHTML = '<br>';  
 }

 if(colLang[1] != "") {
  if(!emptyProp(EL("tblDef2"+rowNum).innerHTML)) {
   contentArray = EL("tblDef2"+rowNum).innerHTML.split(/ class=['"]?vb['"]?[ >]/);
   content1 = contentArray[0].substring(0,contentArray[0].toUpperCase().lastIndexOf('<SPAN'));
   content2 = contentArray[1].substring(contentArray[1].toUpperCase().indexOf('>|</SPAN> ')+10);
   for(i=0; i<tagArray.length; i++) {
    var tagDif = content1.toUpperCase().count('<'+tagArray[i]) - content1.toUpperCase().count('</'+tagArray[i]);
    while(tagDif > 0) {
     content1 = content1 + '</'+tagArray[i]+'>';
     content2 = '<'+tagArray[i]+'>' + content2;
     tagDif--;
    }
   }
   EL("tblDef2"+rowNum).innerHTML = content1;
   EL("tblDef2"+(rowNum+1)).innerHTML = prep4Set2(prep4Edit2(content2),'2'+(rowNum+1));
  } else {
   EL("tblDef2"+(rowNum+1)).innerHTML = '<br>';  
  }
 }

 updateVsNums(rowNum+1); 
 breakSelected = "";
 rowSelected = "";
 redrawClearArray(1,rowNum,1);
 doResizeActions(mainTableHeight,brk1Pos[1],brk2Pos[1],1);
 indicateNotSaved();
	fixArcDesktopHt();
}



function toggleBreak(obj, kind) {
 //if(EL("lock").checked) { return; }
 if(obj.className == "vb") {
  obj.className = "hb";
  breakSelected = "";
  rowSelected = "";
 } else if(obj.className == "hb") {
  clearYdot();
  if(breakSelected == kind) {
   alert("To split a proposition, you must choose a split location in both columns.");
  } else if(breakSelected) {
   if(obj.id.substring(1,obj.id.indexOf('-')) != rowSelected) {
    alert("To split a proposition, you must choose a split location for each column in the same row.");
   } else {
    obj.className = "vb";
    goMsg(1,"Splitting...",-1,"splitProp("+parseInt(obj.id.substring(1,obj.id.indexOf('-')),10)+");");
   }
  } else if(colLang[1] == "" || emptyProp(EL('tblDef2'+obj.id.substring(1,obj.id.indexOf('-'))).innerHTML) || emptyProp(EL('tblDef1'+obj.id.substring(1,obj.id.indexOf('-'))).innerHTML)) {
   obj.className = "vb";
   breakSelected = kind;
   rowSelected = obj.id.substring(1,obj.id.indexOf('-'));
   goMsg(-1,"Splitting...",-1,"");
   breakPropTimer = window.setTimeout('splitProp('+parseInt(obj.id.substring(1,obj.id.indexOf('-')),10)+'); noMsg();',330);
  } else {
   obj.className = "vb";
   breakSelected = kind;
   rowSelected = obj.id.substring(1,obj.id.indexOf('-'));
  }
 }
}

function brk1(obj) {
 toggleBreak(obj, 1);
}

function brk2(obj) {
 toggleBreak(obj, 2);
}

function subStrCount(thisString, thisSep) {
 return thisString.split(thisSep).length;
}

function doResizeActions(mainTableHeight, brk1Pos, brk2Pos, shiftInOut) {
 //fixBrowsDisp();
 if(mainTableHeight != 0) {
  var distChanged = EL("mainTable").offsetHeight-mainTableHeight;
  var thisLabel = EL("label1");
  for(var i=2; thisLabel; i++) {
   var labelPos = findPos(thisLabel);
   var midYPos = labelPos[1] + (thisLabel.offsetHeight/2);
   if(midYPos >= brk2Pos+2) {
    thisLabel.style.top = (labelPos[1] + distChanged) + 'px';
   } else if(midYPos > brk1Pos+2 && midYPos < brk2Pos+2) {
    thisLabel.style.top = (labelPos[1] + (distChanged * ((midYPos-(brk1Pos+2))/(brk2Pos-brk1Pos)))) + 'px';
    if(shiftInOut) {
     var modeOffset = 0;
     var arcWidthOffset;
     if(colLang[1] == "" && !doCTag) { modeOffset = 65; }
     var canvasPos = findPos(EL("arcCanvas"));
     if(doCTag) { canvasPos[0] -= 300; }
     if(numProps < 10) {
      if(shiftInOut == -1 && labelPos[0] < canvasPos[0] + (280-modeOffset) + (242+modeOffset)/numProps) {
       if(thisLabel.className != "mylabel") {
         thisLabel.style.visibility = "hidden";
         thisLabel.style.top = "0px";
         thisLabel.style.left = "0px";
       }
      } else {
       arcWidthOffset = parseInt((((242+modeOffset)/(numProps))*2) - (242+modeOffset)/(numProps-1));
      }
     } else if(labelPos[0] < canvasPos[0] + 315) {
      if(shiftInOut == 1) {
       arcWidthOffset = 23;
      } else {
       if(thisLabel.style.width.substring(0,3) != "200") {
         thisLabel.style.visibility = "hidden";
         thisLabel.style.top = "0px";
         thisLabel.style.left = "0px";
       }
      }
     } else if(labelPos[0] < canvasPos[0] + 340) {
      if(shiftInOut == 1) {
       arcWidthOffset = 21;
      } else {
       arcWidthOffset = 23;
      }
     } else if(labelPos[0] < canvasPos[0] + 360 && shiftInOut == -1) {
      arcWidthOffset = 21;
     } else {
      arcWidthOffset = parseInt((((218+modeOffset)/(numProps-1))*2) - (218+modeOffset)/(numProps-2));
     }
     if(thisLabel.className != "mylabel" && thisLabel.style.visibility != "hidden") {
      thisLabel.style.left = (labelPos[0] + (arcWidthOffset*shiftInOut)) + "px";
     }
    }
   }
   thisLabel = EL("label"+i);
  }
  placeBreakEnds();
 }
 /*
 window.setTimeout(
  function() {
   if((windowHeight() != scrollHeight()) != scrollBarsOn) {
    scrollBarsOn = (windowHeight() != scrollHeight());
    adjustWithResize();
   }
  },1);
 */
}

function windowWidth() {
	//document.body.offsetWidth
	//document.body.clientWidth
	return document.documentElement.clientWidth;
}

function windowHeight() {
	//document.body.offsetHeight
	//document.body.clientHeight
	return document.documentElement.clientHeight;
}

function scrollWidth() {
	//document.documentElement.scrollWidth
	return document.body.scrollWidth;
}

function scrollHeight() {
	//document.documentElement.scrollHeight
	return document.body.scrollHeight;
}

function scrollTop() {
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    return window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    //DOM compliant
    return document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    return document.documentElement.scrollTop;
  } else {
  		return 0;
  }
}

function scrollLeft() {
  if( typeof( window.pageXOffset ) == 'number' ) {
    //Netscape compliant
    return window.pageXOffset;
  } else if( document.body && document.body.scrollLeft) {
    //DOM compliant
    return document.body.scrollLeft;
  } else if( document.documentElement && document.documentElement.scrollLeft ) {
    //IE6 standards compliant mode
    return document.documentElement.scrollLeft;
  } else {
  		return 0;
  }
}

function moveToolbar() {
 noToolsNow();
 if(toolbarAutoScroll) { return; }
 if(mouseDownOnLabel) { endDrag(); }
 var ltPos = findPos(EL("lToolbar"));
 var rtPos = findPos(EL("rToolbar"));
 var heightBase = scrollTop() - 75;
 if(heightBase < 0) { heightBase = 0; }
 if(EL('rightBarSpacer') && (EL('rightBarSpacer').offsetHeight>heightBase || scrollHeight()>rtPos[1]+EL("rToolbar").offsetHeight+100)) { 
  EL('rightBarSpacer').style.height = heightBase + "px";
 }
 heightBase = scrollTop() - 85;
 if (heightBase < 0) { heightBase = 0; }
 if(EL('leftBarSpacer') && (EL('leftBarSpacer').offsetHeight>heightBase+40 || scrollHeight()>ltPos[1]+EL("lToolbar").offsetHeight+100)) {
  EL('leftBarSpacer').style.height = heightBase + 40 + "px";
 }
}

function exitCheck() {
 return ((agent == 'IE' && document.activeElement.href && document.activeElement.href.match(/^javascript:/i)!=null) || byPassExitCheck || (isSaved == 2 && loginId > 0 && loginId == saveUserId));
}

function indicateNotSaved() {
 if(author) { return; }
 if(isSaved == 2 && EL("saveButton")) {
  EL("saveButton").value = "Save";
  EL("saveButton").disabled = ""; 
  EL("saveButton").className = "bold"; 
 }
 isSaved = 0;
}

function indicateSaved() {
 if(author) { return; }
 EL("saveButton").value = "Saved.";
 EL("saveButton").className = "bold";
 EL("saveButton").disabled = "true";
}

function loginToSave(act) {
 if(!EL("emailaddr") || !EL("password") || !EL("keeplogin")) {
  alert("There was an error. (Error #344)");
  return;
 }
 var loginEmail = trim(EL("emailaddr").value);
 var loginPass = EL("password").value;
 if(loginEmail == '' || loginPass == '') {
  alert("You must enter an email address and password");
  return;
 }
 if(!validEmail(loginEmail,false)) { return; }
 var parameters = "emailaddr="+loginEmail+"&password="+loginPass+"&keeplogin="+EL("keeplogin").checked+"&fromarcpage=1&submit=1";
 doAjax(act,gDirPrefix+"/login.php",parameters,false);
 EL("loginButton").value = "Logging-in...";
 EL("loginButton").disabled = "true"; 
}

function loginToSave2(resp,doSave,refreshPg) {
 loginId = resp.substring(0,resp.indexOf('-'));
 loginName = resp.substring(resp.indexOf('>')+1);
 EL("abovenavmsg").innerHTML = '\
  		[ <a class=supernav href="'+gDirPrefix+'/logout.php">logout</a> | \
  		<a class=supernav href="'+gDirPrefix+'/account.php?uid='+loginId+'">account</a> ] \
  		<i>Welcome, '+loginName+'.</i>\
  ';
 var daysLeft = resp.substring(resp.indexOf('-')+1,resp.indexOf('>'));
 if(daysLeft != "-1") { alert("Note: You have "+daysLeft+" day(s) left to confirm your email."); }
 if(EL("toolsLink")) {
	 EL("toolsLink").className = 'toolitem';
	 EL("toolsLink").innerHTML = EL("toolsLink").innerHTML.replace(/ \([^)]*\)$/, '');
	}
 if(EL("toolsEmail")) {
	 EL("toolsEmail").className = 'toolitem';
	 EL("toolsEmail").innerHTML = EL("toolsEmail").innerHTML.replace(/ \([^)]*\)$/, '');
	}
 noPrmpt();
 if(doSave) { ajaxSave(false,false); }
 if(refreshPg) { goMsg(1,"Reloading page...",-1,""); location.reload(true); }
}

function loginToSaveErr() {
 EL("loginButton").value = "Login";
 EL("loginButton").disabled = ""; 
}

function gotoForgotPass2() {
 if(EL("loginButton").value == "Login") {
  EL("emailaddr").value = trim(EL("emailaddr").value);
  if(!EL("emailaddr").value) {
   alert("Please fill in an email address.");
	 } else if(validEmail(EL("emailaddr").value,false)) {
   alert("Once you have chosen a new password, return to this window and login.");
   window.open("forgotpassword.php?email="+EL("emailaddr").value,"newwin");
  }
 }
}

function getLoginOrRegistration(act) {
 var content = '<form onsubmit="isSaved=0;loginToSave(\''+act+'\');return false;"><table cellpadding=4 class=fw>';
 content += '<tr><td colspan=2 align=center style="padding-top:0px;"><span class=heading1>Login';
 if(act == "login1") { content += ' Required.'; }
 content += '</span></td></tr>';
 content += '<tr><td align=right><span><b>Email Address:</b></span></td><td><input type=text id=emailaddr name=emailaddr style="width:200px;"></td></tr>';
 content += '<tr><td align=right><span><b>Password:</b></span></td><td><input type=password id=password name=password style="width:90px;" maxlength=20></td></tr>';
 content += '<tr><td align=center colspan=2><input type=checkbox id=keeplogin name=keeplogin><span class=smalltext> auto-login on this computer</span></td></tr>';
 content += '<tr><td align=center colspan=2 style="padding:4px;">';
 content += '<input class=bold type=submit value=Login name=loginButton id=loginButton> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr>';
 content += '<tr><td align=center colspan=2 style="padding-top:10px;"><span><i>Don\'t have an account?&nbsp;&nbsp;</i><a href="javascript:doReg();">Register</a> now.';
 if(act != "login3") { content += ' (Arc will be saved.)'; }
 content += '</span></td></tr>';
 content += '<tr><td align=center colspan=2 style="padding-top:5px;"><span><i>Forgot your password?&nbsp;&nbsp;</i>Enter email & click <a href="javascript:gotoForgotPass2();">here</a>.</span></td></tr></table></form>';
 goPrmpt(3,content,450);
 EL("emailaddr").focus();
 return false;
}

function getArcName(extraFunc) {
 var curName = arcName;
 if(curName == passage) { curName = ""; }
 var content = '<form onsubmit="javascript:if(doRename()) {'+extraFunc+'} return false;"><table cellpadding=4 class=fw>';
 content += '<tr><td align=center style="padding-top:0px;"><span><b>';
 if(arcName == "") {
  content += 'What would you like to name this arc?';
 } else {
  content += 'Rename your arc below.';
 }
 content += '</b></span></td></tr>';
 content += '<tr><td align=center><input type=text id=nameAsk name=nameAsk style="width:200px;" value="'+curName+'" maxlength=30></td></tr>';
 content += '<tr><td align=center>';
 content += '<input class=bold type=submit value=';
 if(extraFunc != "") {
  content += 'Save';
 } else if(arcName == "") {
  content += 'Name';
 } else  {
  content += 'Rename';
 }
 content += '> <input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr>';
 content += '<tr><td style="padding-top:10px; padding-bottom:5px;"><hr>';
 content += '</td></tr><tr><td class=em1>';
 content += '<b><u>Choosing a name</u>:</b> If you plan on sharing, you must choose a descriptive name. ';
 content += 'The name cannot contain the passage reference and should say something about what you have ';
 content += 'discovered through this arc. For example: <i>From Wrath to Kindness</i> or <i>Jesus is a Treasure</i>. ';
 content += '</td></tr></table></form>';
 goPrmpt(3,content,350);
 EL("nameAsk").focus();
}

function doRename() {
 if(!validArcName(EL("nameAsk").value)) { EL("nameAsk").focus(); return false; }
 arcName = trim(EL("nameAsk").value);
 //if(arcName == "") { arcName = passage; }
 if(arcName == '') {
  EL("nametitle").innerHTML = passage;
  EL("passagetitle").innerHTML = '';
 } else {
  EL("nametitle").innerHTML = arcName + '&nbsp;';
  EL("passagetitle").innerHTML = '(' + passage + ')';
 }
 noPrmpt();
 indicateNotSaved();
 return true;
}

function showHelpSection(num) {
 if(EL("helpArea"+curHelpNum)) {
  EL("helpArea"+curHelpNum).innerHTML = "";
  EL("helpTitle"+curHelpNum).style.color = "#900000";
 }
 if(curHelpNum == num) {
  curHelpNum = -1;
 } else {
  EL("helpArea"+num).innerHTML = helpArray[num];
  EL("helpTitle"+num).style.color = "black";
  curHelpNum = num;
 }
 EL("helpTitle"+num).blur();
}

function initBars() {
 changeLeftTabs(0);
 toggleLeftTab(0);
 if(author) {
  toggleWork("relPallette","pasPallette");
 }
 fixArcDesktopHt();
}

function toggleLeftTab(num) {
 //if(!EL("leftToolbar") || EL('arclefttab'+num+'_0') == '') { return; }
 if(EL('arclefttab'+num+'_0').innerHTML == '') { num = 0; }
 EL("leftToolbar").innerHTML = toolbarArray[EL('arclefttab'+num+'_0').innerHTML];
	switchTab('arclefttab',num);
 curHelpNum = -1;
}

function toggleRightTab(num) {
 //if(!EL("leftToolbar")) { return; }
 if(!EL("arcrighttab1_0")) { return; }
 EL("pasToolsDiv2").innerHTML = passage_cols[num];
 EL("pasToolsDiv2").className = "pTools2"+colLang[num];
	switchTab('arcrighttab',num);
 //if(agent == "IE") { initPasScroll(); }
}

function adjustLabels4Browser(heights) {
 var hts = heights+'>';
 var brk1Pos = '';
 var brk2Pos = findPos(EL("ydot0"));
 for(var i=0; hts != ''; i++) {
  brk1Pos = brk2Pos;
  brk2Pos = findPos(EL("ydot"+(i+1)));
  var adjAmt = parseInt(hts.substring(0,hts.indexOf('>')))-(brk2Pos[1]-brk1Pos[1]);
  if(adjAmt) {
   doResizeActions(EL("mainTable").offsetHeight + adjAmt,brk1Pos[1],brk2Pos[1],0);
  }
  hts = hts.substring(hts.indexOf('>')+1);
 } 
}

function fixTblHghts() {
 if(EL("commentsTable")) {
  var ctpos = findPos(EL("commentsTable"));
  EL("commentsTable").style.position = "absolute";
  EL("commentsTable").style.top = ctpos[1] + "px";
 }
 if(EL("notesTable")) { 
  var ntpos = findPos(EL("notesTable"));
  EL("notesTable").style.position = "absolute";
  EL("notesTable").style.top = ntpos[1] + "px";
 }
 EL("mainTable").style.position = "absolute";
 for(var i=0; i<numProps; i++) {
  EL("df1"+i).style.width = EL("df1"+i).offsetWidth-5;
  if(colLang[1] != "") {
   EL("df2"+i).style.width = EL("df2"+i).offsetWidth-5;
  }
  var adj = 0;
  if(i%4 == 3) { adj = 1; }
  EL("verseNum"+i+"Td").style.height = EL("verseNum"+i+"Td").offsetHeight-adj;

  EL("tblDef1"+i).style.position = "absolute";
  EL("tblDef1"+i).style.width = EL("tblDef1"+i).offsetWidth + 7;
  if(colVer[0] == "hebrew") {
    var td1pos = findPos(EL("tblDef1"+i));
    EL("tblDef1"+i).style.left = (td1pos[0]-7) + "px";
  }
  if(colLang[1] != "") {
   EL("tblDef2"+i).style.position = "absolute";
   EL("tblDef2"+i).style.width = EL("tblDef2"+i).offsetWidth + 7;
  }
 }
}

function initAutoSave(startautosave) {
 if(saveUserId == 0) {
		 sugSaveTimer = window.setTimeout("suggestSave();",185000);
 }
 autosaveTimer = window.setInterval("doAutoSave();",5000);
}

function endLoad(saveStatus) {
 if(!onloadsDone || !graphicsDone) { return; }
 isSaved = saveStatus;
 if(saveUserId != 0) { indicateSaved(); }
 EL("loading").style.width = "0px";
 EL("loading").style.height = "0px";
 EL("loading").className = "hidden";
}

function googStuff() {
	var pageTracker = _gat._getTracker("UA-5578051-1");
	pageTracker._trackPageview();
}

function toggleWork(off,on) {
 if(off) {
  EL(off).className = "hidden";
  EL(off).style.visibility = "hidden";
 }
 if(on) {
  if(EL(on).id == "arcCanvas") {
   EL(on).className = "arcCanvas";
  } else {
   EL(on).className = "";
  }
  EL(on).style.visibility = "";
 }
}

function showHideLabels(vis) {
 //EL("labels").style.visibility = vis;
 for(var i=1; i<=labelNum; i++) {
  if(EL("label"+i).style.visibility != "hidden") {
   if(vis == "hidden") {
    //EL("label"+i).style.top = '-' + EL("label"+i).style.top;
    EL("label"+i).style.top = '-99' + EL("label"+i).style.top;
   } else {
    //EL("label"+i).style.top = EL("label"+i).style.top.substring(1);
    EL("label"+i).style.top = EL("label"+i).style.top.substring(3);
   }
  }
 }
}

function changeLeftTabs(maintabnum) {
	var switchThisTab = -1;
	for(g=0; leftTabs[maintabnum][g]; g++) {
		if(EL('arclefttab'+g+'_0').className == 'tabsel' && EL('arclefttab'+g+'_0').innerHTML != leftTabs[maintabnum][g][0]) { 
			switchThisTab = g; 
		}
		EL('arclefttab'+g+'_0').innerHTML = leftTabs[maintabnum][g][0];
		EL('arclefttab'+g+'_0').style.width = leftTabs[maintabnum][g][1]+'px';
		EL('arclefttab'+g+'_1').style.width = leftTabs[maintabnum][g][1]+'px';
	}
	if(switchThisTab != -1) { toggleLeftTab(switchThisTab); }
}


function toggleTab(tab) {
 if(curTab == tab) { return; }
 switch(tab) {
  case 0:
   showHideLabels("");   
   toggleWork("notesTable","arcTable");
   toggleWork("commentsTable","arcCanvas");
   if(EL("bloggerTable")) { toggleWork("bloggerTable",0); }
   if(!author) { toggleWork("pasPallette","relPallette"); }
   if(EL("toolsArcTabOnly")) { EL("toolsArcTabOnly").className = ''; }
			placeBreakEnds();
   break;
  case 1:  
   toggleWork("arcTable","notesTable");
   toggleWork("commentsTable",0);
   toggleWork("arcCanvas",0);
   if(EL("bloggerTable")) { toggleWork("bloggerTable",0); }
   if(curTab == 0) {
    showHideLabels("hidden");
    toggleWork("relPallette","pasPallette");
   }
   if(EL("toolsArcTabOnly")) { EL("toolsArcTabOnly").className = 'hidden'; }
			clearBreakEnds();
   break;
 	case 2:
   toggleWork("arcTable","commentsTable");
   toggleWork("notesTable",0);
   toggleWork("arcCanvas",0);
   if(EL("bloggerTable")) { toggleWork("bloggerTable",0); }
   if(curTab == 0) {
    showHideLabels("hidden");
    toggleWork("relPallette","pasPallette");
   }
   if(EL("toolsArcTabOnly")) { EL("toolsArcTabOnly").className = 'hidden'; }
			clearBreakEnds();
   break;
 	case 3:
   toggleWork("arcTable","bloggerTable");
   toggleWork("notesTable",0);
   toggleWork("commentsTable",0);
   toggleWork("arcCanvas",0);
   if(curTab == 0) {
    showHideLabels("hidden");
    toggleWork("relPallette","pasPallette");
   }
   if(EL("toolsArcTabOnly")) { EL("toolsArcTabOnly").className = 'hidden'; }
			clearBreakEnds();
   break;
 }
	changeLeftTabs(tab);
	switchTab("arctab",tab);
 curTab = tab; 
 if(curTab == 0) { window.setTimeout('adjustWithResize();',1); }
 fixArcDesktopHt();
}

function bringInPas() {
 if(EL("col1Ind").selectedIndex == 0 || (EL("col2Ind").value != "none" && EL("col2Ind").selectedIndex == 0)) {
  alert('Please indicate the text(s) for each column and then click "Submit".');
  return;
 }
 if(!confirm("Please confirm that you have selected the correct texts that were used for this arc.\n\n(You will not be able to undo this.)")) { return; }
 goMsg(2,"Loading text(s)..",-1,"");
 var parameters = "col1=" + EL("col1Ind")[EL("col1Ind").selectedIndex].id;
 if(EL("col2Ind").value == "none") {
  parameters += "&col2=none"
 } else {
  parameters += "&col2=" + EL("col2Ind")[EL("col2Ind").selectedIndex].id;
 }
 parameters += "&arcid="+arcId+"&uid="+saveUserId;
 doAjax("unaltered1",gDirPrefix+"/getunaltered.php",parameters,false);
}

function onParseTab() {
	for(i=0; EL('arclefttab'+i+'_0'); i++) {
		if(EL('arclefttab'+i+'_0').className == 'tabsel') {
			if(EL('arclefttab'+i+'_0').innerHTML == 'parse') {
				return true;
			} else {
				return false;
			}
		}
	}
	return false;
}

function pa(obj) {
 window.clearTimeout(parseTimer);
 window.clearTimeout(parseTimer2);
	if(!onParseTab()) { return; }
 var theWord = obj.innerHTML.replace(/<[^>]*>/gi,"");
 theWord = theWord.replace(/,|;|\.|·/g,"");
 for(y=0; y<theWord.length; y++) {
  if(badGrkChars[theWord.charCodeAt(y)]) {
   theWord = theWord.substr(0,y) + String.fromCharCode(badGrkChars[theWord.charCodeAt(y)]) + theWord.substr(y+1);
  }
 }
 if(!parsing_array[theWord]) { setOpacity(EL("parseArea"),100); EL("parseArea").innerHTML = noParseInfo; return; }
 var parseInfo = "<div class=pWord";
 if(theWord.length > 7) { parseInfo += " style='font-size:"+(28-parseInt(Math.sqrt((theWord.length-7)*18)))+"px;'"; }
 parseInfo += ">"+theWord+"</div>";
 parseInfo += "<div class=pLex1>lexical form:</div><div class=pLex2";
 if(parsing_array[theWord][0].length > 13) { parseInfo += " style='font-size:"+(20-parseInt((parsing_array[theWord][0].length-13)*1.2))+"px;'"; }
 parseInfo += ">"+parsing_array[theWord][0]+"</div>";
 parseInfo += "<div class=pDef>"+parsing_array[theWord][2]+"</div>";
 parseInfo += "<div class=pParsing1>"+parsingKey[0][parsing_array[theWord][1].substr(0,2)]+"</div>";
 parseInfo += "<div class=pParsing2>";
 parseInfo += parsingKey[2][parsing_array[theWord][1].substr(3,1)];
 parseInfo += parsingKey[3][parsing_array[theWord][1].substr(4,1)];
 parseInfo += parsingKey[4][parsing_array[theWord][1].substr(5,1)];
 parseInfo += parsingKey[1][parsing_array[theWord][1].substr(2,1)];
 parseInfo += parsingKey[7][parsing_array[theWord][1].substr(8,1)];
 parseInfo += parsingKey[6][parsing_array[theWord][1].substr(7,1)];
 parseInfo += parsingKey[5][parsing_array[theWord][1].substr(6,1)];
 parseInfo += "</div><div class=pParsing3>";
 parseInfo += parsingKey[8][parsing_array[theWord][1].substr(9,1)];
 parseInfo += "</div>";
 EL("parseArea").innerHTML = parseInfo;
 setOpacity(EL("parseArea"),100);
}

function paOut() {
 window.clearTimeout(parseTimer);
 window.clearTimeout(parseTimer2);
	if(!onParseTab() || EL("parseArea").innerHTML.replace(/<[^>]*>/g,'') == howToParse.replace(/<[^>]*>/g,'')) { return; }
 parseTimer = window.setTimeout('paFadeOut(100,5,"'+howToParse+'");',300);
 parseTimer2 = window.setTimeout('paDone("'+howToParse+'");',800);
}

function paFadeOut(curOp,incr,fadeInCnt) {
  window.clearTimeout(parseTimer);
		if(!onParseTab()) { return; }
  if(curOp > 0) {
   parseTimer = window.setTimeout('paFadeOut('+(curOp-incr)+','+incr+',"'+fadeInCnt+'");',10);
   setOpacity(EL("parseArea"),curOp-incr);
  } else {
   parseTimer = window.setTimeout('paFadeIn(0,'+incr+');',10);
   EL("parseArea").innerHTML = fadeInCnt;
  }
}

function paFadeIn(curOp,incr) {
  window.clearTimeout(parseTimer);
		if(!onParseTab()) { return; }
  if(curOp < 100) {
   parseTimer = window.setTimeout('paFadeIn('+(curOp+incr)+','+incr+');',10);
   setOpacity(EL("parseArea"),curOp+incr);
  }
}

function paDone(fadeInCnt) {
  window.clearTimeout(parseTimer);
  window.clearTimeout(parseTimer2);
		if(!onParseTab()) { return; }
  EL("parseArea").innerHTML = fadeInCnt;
  setOpacity(EL("parseArea"),100);
}

function setOpacity(oObj,oValue) {
 oObj.style.opacity = oValue/100;
 oObj.style.filter = 'alpha(opacity=' + oValue + ')';
}

function bringInPas2(resp) {
 window.location = "arc.php?arcid="+arcId+"&uid="+loginId;
}

function mtsCrtria(act) {
 if(loginId == '') {
  var almsg = "Before you "+act+" this arc, you must save it.\n\nNote: If you do not wish to have a registered account with BibleArc.com, you will not be able to "+act+" arcs directly. ";
  if(act == "email") { almsg += "(The reason behind this is to prevent BibleArc.com from becoming a conduit for unwanted emails.) "; }
  almsg += "Nonetheless, you are still able to download your arc as a PDF and then email the downloaded file to friends.";
  alert(almsg);
  return false;
 }
 if(colVer[0] == "unknown") {
  alert("Before you "+act+" this arc, please indicate which translation(s) were used.\n\n(Do so on the right bar of the \"Notes\" tab.)");
  toggleTab(1);
  return false;
 }
 if(act == "share") {
  if(defaultArcsOnly || numProps<3 || EL("labels").innerHTML.length<500) {
   alert("Before you "+act+" this arc, please spend some more time wrestling with it on your own.\n\n(i.e. Break the passage up into propositions, draw some arcs where you think they belong, and add some logical relationships--even if they are not much more than guesses. If even this seems too much for you, please visit the LEARN section of this website.)");
   toggleTab(0);
   return false; 
  }
  var tNote = tinyMCE.get('notesTA');
  var isNotes = (trim(tNote.getContent()) != "");
  if(!isNotes) {
   alert("Before you "+act+" this arc, please add some notes that tell us more about what you are seeing.\n\n(For more help on what to include, see the \"ideas\" tab on the left bar.)");
   toggleTab(1);
   if(colVer[0] == 'greek') { toggleLeftTab(2); } else { toggleLeftTab(1); }
   return false;
  }
 }
 if(saveUserId == 0) {
  alert("Before you "+act+" this arc, you must save it.");
  return false;
 } else if(isSaved != 2) {
  goMsg(2,"Saving...",-1,"");
  ajaxSave(false,false);
  postSaveAct = act;
  return false; 
 }
 return true;
}

function initCmp() {
 EL("cmpSpot").style.height = (9*30+4) + "px";
 EL("cmpSpot").innerHTML = putInRowsArcPage(false);
}

function putInRowsArcPage(arcList) {
  var numBlnk = 9;
  var content = "";
  var cls = "oddRow";
  for(var row=0; row<numBlnk || (arcList && arcList[row] && arcList[row] != ""); row++) {
    if(!arcList || !arcList[row] || arcList[row] == "") {
      content += "<tr><td class="+cls+">";
      if(arcList && row==0) {
       if(!EL("overlap").checked) {
         content += "<span>No arcs found. Would you like to ";
         content += "<a href='javascript:checkOverlapArcPage();'> include overlapping passages</a>?</span>";     
       } else {
         content += "<span>Sorry, there are no arcs to compare with at this time. <a href='javascript:eAlerts();'>Email alerts</a>?</span>";
       }
      }
      content += "</td><td class="+cls+"><input type=button value=C class=hide></td></tr>";
    } else {      
      var samePasName = (arcList[row][1] == arcList[row][2]);
      if(EL('overlap').checked) {
       arcList[row][1] = arcList[row][1].substring(arcList[row][1].indexOf(' ',2)+1);
      }
      content += "<tr><td class="+cls+" colspan=2>";
      content += "<table cellpadding=0 class=fw><tr><td><div class=aList style='width:";
//      if(parseInt(arcList[row][5]) == 0) {
//       content += 475 - (67);
//      } else {
//       content += 475 - (parseInt(arcList[row][5])*18);
//      }
      content += "465px;'>";
      content += "<input type=button value=Open onclick='openArc("+arcList[row][4]+",1);'>";
      content += "<span class=va>&nbsp;&nbsp;"+arcList[row][0]+"&nbsp;&nbsp;";
      if(EL('overlap').checked) {
       content += "<i>"+arcList[row][1]+"</i>&nbsp;&nbsp;";
      }
      content += "<b>"+arcList[row][2]+"</b>";
      content += "&nbsp;&nbsp;("+arcList[row][3];
      content += ")</span></div></td><td class=ar>";
      content += "</td></tr></table></td></tr>";
    }
    if(cls == 'oddRow') {
      cls = "evenRow";
    } else {
      cls = "oddRow";
    }
  }
  return "<table cellpadding=0 class=arcList2>"+content+"</table>";
}

function openArc(id,newwin) {
 if(newwin) {
  window.open("arc.php?arcid="+id+"&uid="+loginId);
 } else {
  window.location = "arc.php?arcid="+id+"&uid="+loginId;
 }
}

function checkOverlapArcPage() {
 EL("overlap").checked = "checked";
 bringInComp(arcId,2);
}

function goComp2(resp) {
 var compRes = resp.split('<3');
 for(p=0; p<compRes.length; p++) {
   compRes[p] = compRes[p].split('<2');
   for(q=0; q<compRes[p].length; q++) {
     compRes[p][q] = compRes[p][q].split('<1');
   } 
 }
 EL("cmpSpot").innerHTML = putInRowsArcPage(compRes[4]);
 noMsg();
}

function linkArc() {
 if(!mtsCrtria("link to")) { return false; }
	var content = '<div class=prmtHd>Link to Your Arc</div>';
	content += '<div class=prmtExplanation>Copy the following text to share a link of your arc with others.</i> ';
	content += '<input type=text class=prmtShortLink id=shortlink onclick="this.select();" value="http://'+serverName.replace(/www\./i,'')+'?'+shortLinkCode+'"></div>';
	content += '<div class=prmtExpSm>(We made your link especially small for Twitter.)</div>';
 content += '<div class=ctr><input type=button value="Close" onclick="noPrmpt();"></div>';
 goPrmpt(3,content,320);
 EL("shortlink").focus();
 EL("shortlink").select();
}

function emailArc() {
 if(!mtsCrtria("email")) { return false; }
 var content = '<table cellpadding=0 class=fw><tr><td class=ctr style="font-size:16px;">';
 content += '<b>Email This Arc To Friend(s)</b></td></tr>';
 content += '<tr><td style="padding-top:10px;">';
 content += 'Enter up to 10 email addresses, <i>separated by commas.</i>';
 content += '</td></tr><tr><td>';
 content += '<textarea id=eaddrs style="width:100%; height:50px;"></textarea>';
 content += '</td></tr><tr><td style="padding-top:8px;"><table cellpadding=0><tr><td class=em1>';
 content += 'Send to addresses:&nbsp;&nbsp;</td><td class=em1>';
 content += '<input type=radio id=grp name=mthd checked=checked></td><td class=em1>As a group&nbsp;&nbsp;</td><td class=em1>';
 content += '<input type=radio id=ind name=mthd></td><td class=em1>Individually';
 content += '</td></tr></table></td></tr><tr><td style="padding-top:8px;">';
 content += 'Enter a personal message. <span class=smalltext>(Optional)</span>';
 content += '</td></tr><tr><td>';
 content += '<textarea id=pmsg style="width:100%; height:80px;"></textarea>';
 content += '</td></tr><tr><td style="padding:5px; padding-top:15px;" class=ctr>';
 content += '<input class=bold value="Send Email(s)" type=button onclick="doEmailArcPage('+arcId+');"> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr>'; 
 content += '</table>';
 goPrmpt(3,content,400);
 EL("eaddrs").focus();
}

function doEmailArcPage(theId) {
 if(trim(EL("eaddrs").value) == "") {
  alert("Please enter the email(s) you wish to send this arc to.");
  return;
 }
 var emls = EL("eaddrs").value.replace(/^\n+|\n+$/g,"").replace(/\n/g,",").split(',');
 if(emls.length > 10) {
  alert("You may only email up to 10 people at a time.");
  return;
 }
 for(w=0; w<emls.length; w++) {
  emls[w] = trim(emls[w]);
  if(!validEmail(emls[w],true)) { return false; }
 }
 goMsg(2,"Emailing...",-1,"");
 var parameters = "arcid=" + theId + "&toaddrs=" + emls.toString() + "&pmsg=" + esc2(trim(EL("pmsg").value)) + "&uid=" + loginId;
 if(EL("ind").checked) { parameters += "&method=ind"; } else { parameters += "&method=grp"; }
 doAjax("email1",gDirPrefix+"/emailarc.php",parameters,false);
}

function doEmail2ArcPage(resp) {
 noMsg();
 noPrmpt();
 if(resp == "later") {
  alert("Email(s) to be sent shortly.\n\nDue to unusually high activity, there may be some delay.");
 } else {
  alert("Email(s) sent successfully!");
 }
}

function makeCmt(typ) {
 var content = '';
 if(arcId < 0) { content += "<div style='border:1px solid #241911; background-color:#F0DBC7; padding:7px;'>"; }
 content += "<div style='padding-bottom:5px;'>Title: <input type=text id=cmtINP style='width:180px;' maxlength=30> ";
 content += "<span class=smalltext>(i.e. your <b>"+typ+"</b> in a nutshell)</span></div>";
 content += "<textarea id=cmtTA style='width:100%; height:65px;'></textarea>";
 content += "<div class=med style='padding-top:0px;'><input type=checkbox id=ea3";
 if(ead3) { content += " checked=checked"; }
 content += "> Receive email alerts when others reply to this comment.</div>";
 content += "<div style='text-align:right; padding-top:10px;'>";
 content += "<input class=bold type=button value='Add "+typ+"' onclick='doCmt(\""+typ+"\");'>&nbsp;&nbsp;";
 content += "<input type=button value='Cancel' onclick='cancelCmt();'></div>";
 if(arcId < 0) { content += "</div>"; }
 EL("addCmtCont").innerHTML = content;
 fixArcDesktopHt();
 EL("cmtINP").focus();
}

function doCmt(typ) {
 if(trim(EL("cmtTA").value) == "" && trim(EL("cmtINP").value) == "") {
  cancelCmt();
  return;
 } else if(trim(EL("cmtTA").value) == "") {
  alert("You must enter content to your comment.");
  return;
 } else if(trim(EL("cmtINP").value) == "") {
  alert("You must enter a title to your comment.");
  return;
 }
 goMsg(2,"Adding comment...",-1,"");
 EL("cmtTA").value = EL("cmtTA").value.replace(/([^ ]{25})/g,"$1 ");
 EL("cmtINP").value = EL("cmtINP").value.replace(/([^ ]{15})/g,"$1 ");
 var parameters = "arcid=" + arcId + "&type=" + typ + "&ea3=" + EL("ea3").checked;
 parameters += "&title=" + esc3(EL("cmtINP").value) + "&cmt=" + esc3(EL("cmtTA").value) + "&uid=" + loginId;
 doAjax("comment1",gDirPrefix+"/addcomment.php",parameters,false);
}

function putInCmts1() {
 var parameters = "arcid=" + arcId + "&author=" + author;
 if(arcId < 0) { parameters += "&blogcommentsmode=true"; }
 parameters += "&uid=" + loginId;
 doAjax("getcomments1",gDirPrefix+"/getcomments.php",parameters,false);
}

function putInCmts2(resp) {
 EL("cmtCont").innerHTML = resp;
 fixArcDesktopHt();
 noMsg();
}

function cancelCmt() {
	clsAddOn = (arcId < 0) ? '2' : '';
 var content = '<div class=addCmt'+clsAddOn+'>Add your own ';
 content += '<a href="javascript:makeCmt(\'Question\');">Question</a>, ';
 content += '<a href="javascript:makeCmt(\'Encouragement\');">Encouragement</a>, ';
 content += '<a href="javascript:makeCmt(\'Disagreement\');">Disagreement</a> or ';
 content += '<a href="javascript:makeCmt(\'Information\');">Information</a>.</div>';
 EL("addCmtCont").innerHTML = content;
}

function makeRpy(cid) {
 var content = "<div style='padding:8px; padding-top:6px; padding-bottom:0px;'><textarea id=rpyTA style='width:100%; height:65px;'></textarea></div>";
 content += "<div class=med style='font-weight:normal;'><input type=checkbox id=ea3";
 if(ead3) { content += " checked=checked"; }
 content += "> Receive email alerts when others reply to this comment.</div>";
 content += "<div style='text-align:right; padding-right:10px; padding-top:8px;'>";
 content += "<input class=bold type=button value='Add Reply' onclick='doRpy("+cid+");'>&nbsp;&nbsp;";
 content += "<input type=button value='Cancel' onclick='cancelRpy("+cid+");'></div>";
 EL("r"+cid).innerHTML = content;
 fixArcDesktopHt();
 EL("rpyTA").focus();
}

function doRpy(cid) {
 if(trim(EL("rpyTA").value) == "") {
  cancelRpy(cid);
  return;
 }
 goMsg(2,"Adding reply...",-1,"");
 EL("rpyTA").value = EL("rpyTA").value.replace(/([^ ]{25})/g,"$1 ");

 var parameters = "cid=" + cid + "&cmt=" + esc3(EL("rpyTA").value) + "&ea3=" + EL("ea3").checked + "&uid=" + loginId;
 doAjax("reply1",gDirPrefix+"/addreply.php",parameters,false);
}

function cancelRpy(cid) {
 var content = '[ <a class="small" href="javascript:makeRpy('+cid+');">reply</a> ]';
 EL("r"+cid).innerHTML = content;
}

function previewRtg(lvl) {
 var b = 1;
 while(b<=lvl) {
  EL("rtSr"+b).src = "images/star5.gif"
  b++;
 }
 while(b<=5) {
  EL("rtSr"+b).src = "images/star33.gif"
  b++;
 }
}

function reportAbuse(tbl,id) {
 var content = '<table cellpadding=0 class=fw><tr><td class=ctr style="font-size:16px;">';
 content += '<b>Report Abuse</b></td></tr>';
 content += '<tr><td style="padding-top:10px; padding-bottom:10px;">';
 content += 'Thank you for taking the time to report abuse.';
 content += '</td></tr><tr><td>';
 content += '<span class=smalltext>We have a high priority on keeping BibleArc.com a helpful and edifying website ';
 content += 'and so take abuse very seriously. Nonetheless, please only report <u>blatant</u> breaches to the guidelines:</span>';
 content += '</td></tr><tr><td style="padding-top:10px; padding-bottom:10px;" class=ctr><span class=smalltext><b>';
 content += 'Relevant, Edifying, Respectful, Clear and Humble.</b></span>'
 content += '</td></tr><tr><td>';
 content += 'Describe the abuse.';
 content += '</td></tr><tr><td>';
 content += '<textarea id=abusedesc style="width:100%; height:80px;"></textarea>';
 content += '</td></tr><tr><td><table cellpadding=0><tr><td class=em1>';
 content += '<input type=checkbox id=obscene></td><td class=em1>Obscene! Remove from site immediately!';
 content += '</td></tr></table></td></tr><tr><td style="padding-top:10px;" class=ctr>';
 content += '<span class=smalltext><b><u>Warning</u>: False reporting ';
 content += 'is grounds for account termination.</span>';
 content += '</td></tr><tr><td style="padding:5px; padding-top:15px;" class=ctr>';
 content += '<input class=bold value="Report" type=button onclick="doReport(\''+tbl+'\','+id+');"> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr>'; 
 content += '</table>';
 goPrmpt(3,content,400);
 EL("abusedesc").focus();
}

function doReport(tbl,id) {
 if(trim(EL("abusedesc").value) == "") { 
  alert("Please give a description of why this is abuse.");
  return;
 }
 goMsg(2,"Reporting abuse...",-1,"");
 var parameters = "tbl=" + tbl + "&id=" + id + "&obscene=" + EL("obscene").checked;
 parameters += "&desc=" + esc2(trim(EL("abusedesc").value)) + "&uid=" + loginId;
 doAjax("report1",gDirPrefix+"/reportabuse.php",parameters,false);
}

function doReport2(resp) {
 noMsg();
 noPrmpt();
 alert("Abuse reported successfully. Thank you!");
 if(resp.substring(0,4) == "arcs") {
  window.location = "myarcs.php";
 } else if(resp.substring(0,7) == "comment") {
  putInCmts1();
 }
}

function doAutoSave() {
 if(isSaved > 0) { return; }
 if(isBG()) { return; }
 ajaxSave((saveUserId==0),true);
}

function suggestSave() {
 if(isBG()) {
  sugSaveTimer = window.setTimeout("suggestSave();",1000);
  return;
 }
 var content = '<table cellpadding=0 class=fw><tr><td class=ctr style="font-size:16px;">';
 content += '<b>Begin Auto-Saving Your Arc</b></td></tr>';
 content += '<tr><td style="padding-top:10px; padding-bottom:10px;" class=ctr>';
 content += '<span class=smalltext><b><u>Warning</u>: This arc is unsaved and in danger of being lost!</b></span>';
 content += '</td></tr>';
 if(loginId == "") {
  content += '<tr><td>';
  content += 'Click below to begin saving automatically.';
  content += '</td></tr><tr><td style="padding-top:10px; padding-bottom:10px;" class=em1>';
  content += 'If you do not have an account at BibleArc.com and do not want to create one, ';
  content += 'you can still download your arc as a PDF file to (1) Save for future reference and ';
  content += '(2) Print from that PDF file. Nonetheless, be aware that it is dangerous to not save ';
  content += 'your arc as your work could easily be lost forever.';
  content += '</td></tr><tr><td class=ctr>';
 } else {
  content += '<tr><td class=ctr style="padding-top:10px;">';
 }
 content += '<input id=goAutoSave class=bold value="Begin Auto-Saving" type=button onclick="noPrmpt();beginAutoSave();ajaxSave(false,false);"> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr><tr><td style="padding-top:10px; padding-bottom:5px;"><hr>';
 content += '</td></tr><tr><td>';
 content += '<b>Note: do <u>not</u> try to print through your browser.</b>';
 content += '</td></tr><tr><td class=em1>';
 content += 'Rather, click the "Download" button on the rightbar, open the downloaded PDF file, and print through your PDF viewer.';
 content += '</td></tr>'; 
 content += '</table>';
 goPrmpt(3,content,400);
 EL("goAutoSave").focus();
}

function beginAutoSave() {
	saveUserId = loginId;
}

function stckyChkTggl() {
 if(EL("chkarc").checked) {
  EL("showstickies").disabled = "";
  EL("shrinktofit").disabled = "";
 } else {
  EL("showstickies").disabled = "true";
  EL("shrinktofit").disabled = "true";
 }
}

function togglePic(anch,div,pic) {
  if(anch.innerHTML == "Compare") {
    displayPic(div,pic);
    anch.innerHTML = "Hide";
  } else {
    hidePic(div,pic);
    anch.innerHTML = "Compare";
  }
  //fixBrowsDisp();
}

function displayPic(div,pic) {
  div.innerHTML = "<div style='padding-top:5px;'><img class=pic src='"+pic+"'></div>";
}

function hidePic(div,pic) {
  div.innerHTML = "";
}

function valPassRef() {
 var ref = trim(EL('passage').value);
 var bookref = ref.substring(0,ref.search(/ [0-9]/));
 var vsref = ref.substring(ref.search(/ [0-9]/)+1);
 var isOT = false;
 bookref = bookref.replace(/\./g,'')
 switch(bookref.toLowerCase()) {
  case "genesis":
  case "gen":
  case "gn":
  case "génesis":
    bookref = "Genesis";
    isOT = true;
    break;
  case "exodus":
  case "exod":
  case "exd":
  case "ex":
  case "éxodo":
    bookref = "Exodus";
    isOT = true;
    break;
  case "leviticus":
  case "lev":
  case "lv":
  case "levítico":
    bookref = "Leviticus";
    isOT = true;
    break; 
  case "numbers":
  case "number":
  case "num":
  case "nm":
  case "números":
    bookref = "Numbers";
    isOT = true;
    break;
  case "deuteronomy":
  case "deut":
  case "dtmy":
  case "dt":
  case "deuteronomio":
    bookref = "Deuteronomy";
    isOT = true;
    break;
  case "joshua":
  case "josh":
  case "jos":
  case "js":
  case "jsh":
  case "josué":
    bookref = "Joshua";
    isOT = true;
    break;
  case "judges":
  case "judg":
  case "jud":
  case "jdgs":
  case "jgs":
  case "jg":
  case "jueces":
    bookref = "Judges";
    isOT = true;
    break;
  case "ruth":
  case "rut":
  case "ru":
  case "rt":
    bookref = "Ruth";
    isOT = true;
    break;
  case "1 samuel":
  case "1 sam":
  case "1 sm":
  case "1samuel":
  case "1sam":
  case "1sm":
  case "i samuel":
  case "i sam":
  case "i sm":
  case "isamuel":
  case "isam":
  case "ism":
    bookref = "1 Samuel";
    isOT = true;
    break;
  case "2 samuel":
  case "2 sam":
  case "2 sm":
  case "2samuel":
  case "2sam":
  case "2sm":
  case "ii samuel":
  case "ii sam":
  case "ii sm":
  case "iisamuel":
  case "iisam":
  case "iism":
    bookref = "2 Samuel";
    isOT = true;
    break;
  case "1 kings":
  case "1 kng":
  case "1 kgs":
  case "1 kg":
  case "1kings":
  case "1kng":
  case "1kgs":
  case "1kg":
  case "i kings":
  case "i kng":
  case "i kgs":
  case "i kg":
  case "ikings":
  case "ikng":
  case "ikgs":
  case "ikg":
  case "1 reyes":
    bookref = "1 Kings";
    isOT = true;
    break;
  case "2 kings":
  case "2 kng":
  case "2 kgs":
  case "2 kg":
  case "2kings":
  case "2kng":
  case "2kgs":
  case "2kg":
  case "ii kings":
  case "ii kng":
  case "ii kgs":
  case "ii kg":
  case "iikings":
  case "iikng":
  case "iikgs":
  case "iikg":
  case "2 reyes":
    bookref = "2 Kings";
    isOT = true;
    break;
  case "1 chronicles":
  case "1 chron":
  case "1 chr":
  case "1chronicles":
  case "1chron":
  case "1chr":
  case "i chronicles":
  case "i chron":
  case "i chr":
  case "ichronicles":
  case "ichron":
  case "ichr":
  case "1 crónicas":
    bookref = "1 Chronicles";
    isOT = true;
    break;
  case "2 chronicles":
  case "2 chron":
  case "2 chr":
  case "2chronicles":
  case "2chron":
  case "2chr":
  case "ii chronicles":
  case "ii chron":
  case "ii chr":
  case "iichronicles":
  case "iichron":
  case "iichr":
  case "2 crónicas":
    bookref = "2 Chronicles";
    isOT = true;
    break;
  case "ezra":
  case "ezr":
  case "ez":
  case "esdras":
    bookref = "Ezra";
    isOT = true;
    break;
  case "nehemiah":
  case "neh":
  case "ne":
  case "nh":
  case "nehemías":
    bookref = "Nehemiah";
    isOT = true;
    break;
  case "esther":
  case "esth":
  case "est":
  case "ester":
    bookref = "Esther";
    isOT = true;
    break;
  case "job":
  case "jb":
    bookref = "Job";
    isOT = true;
    break;
  case "psalms":
  case "psalm":
  case "ps":
  case "salmos":
    bookref = "Psalms";
    isOT = true;
    break;
  case "proverbs":
  case "proverb":
  case "prov":
  case "prv":
  case "pr":
  case "proverbios":
    bookref = "Proverbs";
    isOT = true;
    break;
  case "ecclesiastes":
  case "eccls":
  case "eccl":
  case "ecl":
  case "eclesiastés":
    bookref = "Ecclesiastes";
    isOT = true;
    break;
  case "song of solomon":
  case "sng of sol":
  case "song of songs":
  case "sng of sngs":
  case "sngofsngs":
  case "sngofsol":
  case "sg":
  case "song":
  case "songs":
  case "cantares":
    bookref = "Song of Solomon";
    isOT = true;
    break;
  case "isaiah":
  case "is":
  case "isaías":
    bookref = "Isaiah";
    isOT = true;
    break;
  case "jeremiah":
  case "jer":
  case "jr":
  case "jeremías":
    bookref = "Jeremiah";
    isOT = true;
    break;
  case "lamentations":
  case "lam":
  case "lm":
  case "lamentaciones":
    bookref = "Lamentations";
    isOT = true;
    break;
  case "ezekiel":
  case "ezek":
  case "ezk":
  case "ez":
  case "ezequiel":
    bookref = "Ezekiel";
    isOT = true;
    break;
  case "daniel":
  case "dan":
  case "dn":
    bookref = "Daniel";
    isOT = true;
    break;
  case "hosea":
  case "hos":
  case "hs":
  case "oseas":
    bookref = "Hosea";
    isOT = true;
    break;
  case "joel":
  case "jl":
    bookref = "Joel";
    isOT = true;
    break;
  case "amos":
  case "am":
  case "amós":
    bookref = "Amos";
    isOT = true;
    break;
  case "obadiah":
  case "obad":
  case "obd":
  case "ob":
  case "abdías":
    bookref = "Obadiah";
    isOT = true;
    break;
  case "jonah":
  case "jon":
  case "jonás":
    bookref = "Jonah";
    isOT = true;
    break;
  case "micah":
  case "mic":
  case "mi":
  case "miqueas":
    bookref = "Micah";
    isOT = true;
    break;
  case "nahum":
  case "nah":
  case "na":
  case "nh":
  case "nahúm":
    bookref = "Nahum";
    isOT = true;
    break;
  case "habakkuk":
  case "habakuk": 
  case "hab":
  case "hb":
  case "habacuc":
    bookref = "Habakkuk";
    isOT = true;
    break;
  case "zephaniah":
  case "zeph":
  case "zep":
  case "zph":
  case "sofonías":
    bookref = "Zephaniah";
    isOT = true;
    break;
  case "haggai":
  case "hagai":
  case "hagg":
  case "hag":
  case "hg":
  case "hageo":
    bookref = "Haggai";
    isOT = true;
    break;
  case "zechariah":
  case "zech":
  case "zec":
  case "zch":
  case "zacarías":
    bookref = "Zechariah";
    isOT = true;
    break;
  case "malachi":
  case "mal":
  case "ml":
  case "malaquías":
    bookref = "Malachi";
    isOT = true;
    break;
  case "matthew":
  case "matt":
  case "mat":
  case "mt":
  case "mateo":
    bookref = "Matthew";
    break;
  case "mark":
  case "mar":
  case "mrk":
  case "mk":
  case "marcos":
    bookref = "Mark";
    break;
  case "luke":
  case "luk":
  case "lk":
  case "lucas":
    bookref = "Luke";
    break;
  case "john":
  case "joh":
  case "jn":
  case "juan":
    bookref = "John";
    break;
  case "acts":
  case "act":
  case "hechos":
    bookref = "Acts";
    break;
  case "romans":
  case "rom":
  case "rms":
  case "rm":
  case "romans":
    bookref = "Romans";
    break;
  case "1 corinthians":
  case "1 corinth":
  case "1 cor":
  case "1corinthians":
  case "1corinth":
  case "1cor":
  case "1co":
  case "i corinthians":
  case "first corinthians":
  case "1st corinthians":
  case "1 corintios":
    bookref = "1 Corinthians";
    break;
  case "2 corinthians":
  case "2 corinth":
  case "2 cor":
  case "2corinthians":
  case "2corinth":
  case "2cor":
  case "2co":
  case "ii corinthians":
  case "second corinthians":
  case "2nd corinthians":
  case "2 corintios":
    bookref = "2 Corinthians";
    break;
  case "galatians":
  case "gal":
  case "gálatas":
    bookref = "Galatians";
    break;
  case "ephesians":
  case "eph":
  case "efesios":
    bookref = "Ephesians";
    break;
  case "philippians":
  case "phillippians":
  case "phillipians":
  case "philipians":
  case "phil":
  case "phi":
  case "filipenses":
    bookref = "Philippians";
    break;
  case "colossians":
  case "col":
  case "colosenses":
    bookref = "Colossians";
    break;
  case "1 thessalonians":
  case "1 thess":
  case "1 thes":
  case "1 th":
  case "1thessalonians":
  case "1thess":
  case "1thes":
  case "1th":
  case "i thessalonians":
  case "first thessalonians":
  case "1st thessalonians":
  case "1 tesalonicenses":
    bookref = "1 Thessalonians";
    break;
  case "2 thessalonians":
  case "2 thes":
  case "2 th":
  case "2thessalonians":
  case "2thes":
  case "2th":
  case "ii thessalonians":
  case "second thessalonians":
  case "2nd thessalonians":
  case "2 tesalonicenses":
    bookref = "2 Thessalonians";
    break;
  case "1 timothy":
  case "1 tim":
  case "1 ti":
  case "1timothy":
  case "1tim":
  case "1ti":
  case "i timothy":
  case "first timothy":
  case "1st timothy":
  case "1 timoteo":
    bookref = "1 Timothy";
    break;
  case "2 timothy":
  case "2 tim":
  case "2 ti":
  case "2timothy":
  case "2tim":
  case "2ti":
  case "ii timothy":
  case "second timothy":
  case "2nd timothy":
  case "2 timoteo":
    bookref = "2 Timothy";
    break;
  case "titus":
  case "tit":
  case "ti":
  case "tito":
    bookref = "Titus";
    break;
  case "philemon":
  case "phm":
  case "filemón":
    bookref = "Philemon";
    break;
  case "hebrews":
  case "hebr":
  case "heb":
  case "hebreos":
    bookref = "Hebrews";
    break;
  case "james":
  case "jam":
  case "santiago":
    bookref = "James";
    break;
  case "1 peter":
  case "1 pet":
  case "1 pt":
  case "1 pe":
  case "1peter":
  case "1pet":
  case "1pt":
  case "1pe":
  case "i peter":
  case "first peter":
  case "1st peter":
  case "1 pedro":
    bookref = "1 Peter";
    break;
  case "2 peter":
  case "2 pet":
  case "2 pt":
  case "2 pe":
  case "2peter":
  case "2pet":
  case "2pt":
  case "2pe":
  case "ii peter":
  case "second peter":
  case "2nd peter":
  case "2 pedro":
    bookref = "2 Peter";
    break;
  case "1 john":
  case "1 joh":
  case "1 jo":
  case "1 jn":
  case "1john":
  case "1joh":
  case "1jo":
  case "1jn":
  case "i john":
  case "first john":
  case "1st john":
  case "1 juan":
    bookref = "1 John";
    break;
  case "2 john":
  case "2 joh":
  case "2 jo":
  case "2 jn":
  case "2john":
  case "2joh":
  case "2jo":
  case "2jn":
  case "ii john":
  case "second john":
  case "2nd john":
  case "2 juan":
    bookref = "2 John";
    break;
  case "3 john":
  case "3 joh":
  case "3 jo":
  case "3 jn":
  case "3john":
  case "3joh":
  case "3jo":
  case "3jn":
  case "iii john":
  case "third john":
  case "3rd john":
  case "3 juan":
    bookref = "3 John";
    break;
  case "jude":
  case "jud":
  case "ju":
  case "judas":
    bookref = "Jude";
    break;
  case "revelation":
  case "rev":
  case "rv":
  case "apocalipsis":
    bookref = "Revelation";
    break;
  default:
    alert("You have not entered a valid passage reference.");
    return false;
 }
 vsref = trim(vsref);
 vsref = vsref.replace(/\./g,':');
 vsref = vsref.replace(/( )+/g,' ');
 vsref = vsref.replace(/( )*-( )*/g,'-');
 vsref = vsref.replace(/ /g,':');
 //vsref = vsref.replace(/ /g,'');
 if(vsref.indexOf('-') != vsref.lastIndexOf('-') || vsref.indexOf(':') == -1) {
  alert("You have not entered a valid passage reference.");
  return false;
 }
 var numSemis = 0;
 for(var i=0; i<vsref.length; i++) {
  var thisChar = vsref.charCodeAt(i);
  if(thisChar != 45 && thisChar > 58 && thisChar < 48) {
   alert("You have not entered a valid passage reference.");
   return false;
  } 
  if(thisChar == 58) { numSemis++; }
 }
 if(numSemis > 2 || (numSemis == 2 && vsref.indexOf('-') == -1)) {
  alert("You have not entered a valid passage reference.");
  return false;
 }
 EL('passage').value = bookref + ' ' + vsref;
 if(isOT && EL("col1")[EL("col1").selectedIndex].id == "greek") {
  alert("Greek is currently only available for the New Testament.");
  return false;
 }
 return true;
}

function fillInPs(pas) {
 EL('passage').value = pas; 
 EL('passage').focus(); 
}

function findPos(obj) {
 var curleft = 0;
 var curtop = 0;
 if (obj.offsetParent) {
  curleft = obj.offsetLeft;
  curtop = obj.offsetTop;
  obj = obj.offsetParent;
  while (obj) {
   curleft += obj.offsetLeft;
   curtop += obj.offsetTop;
   obj = obj.offsetParent;
  }
 }
 return [curleft,curtop];
}

function trim(str) {
 return str.replace(/^\s+|\s+$/g,"");
}
function validUsername(uname) {
 if(uname.match(/[^A-Z0-9 \.\-]/i)) {
  alert("Your name contains invalid characters.\n\nValid characters are: A-Z 0-9 - .");
  return false;
 }
 return true;
}

function validEmail(addr,shAddr) {
 if(addr.indexOf('.') == -1 || addr.indexOf('@') == -1 || addr.match(/[\s'"]/i) || (addr.indexOf('@') != addr.lastIndexOf('@')) || (addr.lastIndexOf('.') < addr.lastIndexOf('@'))) {
  if(shAddr) {
   alert(addr+" is an invalid email address.");
  } else {
   alert("Invalid email address.");
  }
  return false;
 }
 return true;
}

function validArcName(aname) {
 if(aname.match(/[^A-Z0-9\-:\.\?\/\s!\(\)']/i)) {
  alert("Your arc name contains invalid characters.\n\nValid characters are: A-Z 0-9 - : . ? ! / ( ) '");
  return false;
 }
 if(trim(aname).length > 30) {
  alert("This arc name is too long.");
  return false;
 }
 return true;
}

function validPassword(pass) {
 if(pass == '') {
  alert("Please enter a password.");
  return false;
 }
 if(pass.match(/[^A-Z0-9]/i)) {
  alert("Your password contains invalid characters.\n\nValid characters are: A-Z 0-9.");
  return false;
 }
 return true;
}

function fixBrowsDisp() {
/*
 if(version < 3 && agent == "FIREFOX") {
  if(platform == "Mac") {
   window.resizeBy(0,-1);
   window.resizeBy(0,1);
  } else if(platform == "Win") {
   EL('myArcsTitle').innerHTML = EL('myArcsTitle').innerHTML;
  }
 }
*/
}

function donationPrmpt() {
	var content = '<div class=prmtHd>About Donations</div>';
	content += '<div class=prmtExplanation>Funding for BibleArc.com comes solely from registration fees and donations. Thus, your giving is a significant means that the Lord uses to allow us to make this site as professional and helpful as possible, while keeping the registration fee minimal and under the banner of a whatever-you-can-afford policy.</div>';
	content += '<div class=prmtExplanation><i>And my God will supply every need of yours according to his riches in glory in Christ Jesus. To our God and Father be glory forever and ever. (Phil 4:19-20)</i></div>';
 content += '<div class=ctr><input type=button value="Close" onclick="noPrmpt();"></div>';
 goPrmpt(3,content,370);
}

function doLdPrmpts(msg,num) {
 switch(msg) {
  case "renewdaysleft":
   var content = "<form method='POST' action='https://" + serverName + gDirPrefix + "/renew.php'>";
   content += "<div class=prmtHd>Please renew your registration.</div>";
   content += "<div class=ctr><i>Your current registration expires in "+num+" day(s).</i></div>";
   content += "<div class=ctrPd2><input type=submit value=Renew class=bold></div>";
   content += "</form>";
   goPrmpt(3,content,320);
   break;
  case "dayslefttoconfirm":
   var content = "<div class=prmtHd>Please confirm your email.</div>";
   content += "<div class=ctr><i>You have "+num+" day(s) left to access<br>your account without confirmation.</i></div>";  
   content += "<div class=ctrPd2>To confirm your email, simply click the<br>link in the email we just sent you.<br><i>(You may need to check your spam folder.)</i></div>";  
   content += "<div class=ctrPd2><input type=button value=Close onclick='noPrmpt();'></div>";
   goPrmpt(3,content,320);
   break;
  case "pagenotallowed":
   var content = "";
   content += "<div class=ctrPd>Requested page not allowed for this user.</div>";
   content += "<div style='height:15px;'>&nbsp;</div>";
   goPrmpt(3,content,320);
   break;
  case "alertupdateall":
   var content = "";
   content += "<div class=ctrPd>You have successfully unsubscribed<br>from all BibleArc.com email alerts.</div>";
   content += "<div style='height:15px;'>&nbsp;</div>";
   goPrmpt(3,content,320);
   break;
  case "alertupdatearc":
   var content = "";
   content += "<div class=ctrPd>You have successfully unsubscribed from<br>all email alerts for the given arc.</div>";
   content += "<div style='height:15px;'>&nbsp;</div>";
   goPrmpt(3,content,320);
   break;
  case "alertupdatecomment":
   var content = "";
   content += "<div class=ctrPd>You have successfully unsubscribed from<br>all email alerts for the given comment.</div>";
   content += "<div style='height:15px;'>&nbsp;</div>";
   goPrmpt(3,content,320);
   break;
  case "sampleacct":
   var content = "";
   content += "<div class=ctrPd>This function is not allowed for<br>the sample account. Please register.</div>";
   content += "<div style='height:15px;'>&nbsp;</div>";
   goPrmpt(3,content,320);
   break;
  case "forbiddendup":
   var content = "";
   content += "<div class=ctrPd>Duplicating one of these arcs is forbidden due to it being flagged for inappropriate content.<br><br>If you have questions about this, please use our <a href='"+gDirPrefix+"/feedback.php'>feedback</a> form.</div>";
   content += "<div style='height:15px;'>&nbsp;</div>";
   goPrmpt(3,content,320);
   break;
 }
}

function EL(elId) {
 return document.getElementById(elId);
}

function goBG(lvl) {
 EL("bgmask"+lvl).style.width = scrollWidth()+"px";
 EL("bgmask"+lvl).style.height = scrollHeight()+"px";
}

function noBG() {
 for(f=1; f<=3; f++) {
  EL("bgmask"+f).style.width = "0px";
  EL("bgmask"+f).style.height = "0px";
 }
}

function goBG2(lvl) {
 EL("bg2mask"+lvl).style.width = scrollWidth()+"px";
 EL("bg2mask"+lvl).style.height = scrollHeight()+"px";
}

function noBG2() {
 for(f=1; f<=3; f++) {
  EL("bg2mask"+f).style.width = "0px";
  EL("bg2mask"+f).style.height = "0px";
 }
}

function isBG() {
 for(h=1; h<=3; h++) {
  if(EL("bgmask"+h).offsetWidth > 0 || EL("bg2mask"+h).offsetWidth > 0) { return true; }
 }
 return false;
}

function resizeBG() {
 if(!EL("bgmask1") || !onloadsDone) { return; }
 for(t=1; t<=3; t++) {
  if(EL("bgmask"+t).offsetWidth != 0) {
   EL("bgmask"+t).style.width = "0px";
   EL("bgmask"+t).style.height = "0px";
   EL("bgmask"+t).style.width = scrollWidth()+"px";
   EL("bgmask"+t).style.height = scrollHeight()+"px";
  }
  if(EL("bg2mask"+t).offsetWidth != 0) {
   EL("bg2mask"+t).style.width = "0px";
   EL("bg2mask"+t).style.height = "0px";
   EL("bg2mask"+t).style.width = scrollWidth()+"px";
   EL("bg2mask"+t).style.height = scrollHeight()+"px";
  }
 }
}

function goPrmpt(bgLvl,cnt,wid) {
 goBG(bgLvl);
 EL("prmptSpot").innerHTML = cnt; 
 EL("prmptSpotCont").style.width = wid +"px"; 
 EL("prmptSpotCont").style.top = midFrTop("prmptSpotCont"); 
 EL("prmptSpotCont").style.left = parseInt(windowWidth()/2-wid/2)-7 + "px";
 EL("prmptSpotCont").style.visibility = "";
 EL("clsPrmpt").focus();
}

function noPrmpt() {
 noBG();
 EL("prmptSpotCont").style.visibility = "hidden";
 EL("prmptSpot").innerHTML = ""; 
 EL("prmptSpotCont").style.width = ""; 
 EL("prmptSpotCont").style.top = "0px"; 
 EL("prmptSpotCont").style.left = "0px";
 //postNoPrmpt();
}

function isPrmpt() {
 return (EL("prmptSpot").innerHTML != "");
}

//function postNoPrmpt() { }
function goMsg(bgLvl,msg,frTop,funcs) {
 if(bgLvl != -1) { goBG2(bgLvl); }
 EL("msgSpot").innerHTML = msg;
 if(frTop != -1) {
  EL("msgSpotCont").style.top = frTop + "px";
 } else {
  EL("msgSpotCont").style.top = midFrTop("msgSpot");
 }
 EL("msgSpot").style.visibility = "";
 if(funcs != "") {
  window.setTimeout(funcs + " noMsg();",1);
 }
}

function noMsg() {
 EL("msgSpot").style.visibility = "hidden";
 EL("msgSpotCont").style.top = "-100px";
 EL("msgSpot").innerHTML = "";
 noBG2();
}

function isMsg() {
 return (EL("msgSpot").innerHTML != "");
}

function midFrTop(el) {
 var calc = parseInt(windowHeight()/2 - EL(el).offsetHeight/2) + scrollTop();
 if(calc < 0) { calc = 0; }
 return calc + "px";
}

function getAjaxVar() {
 var ajVar;
 try {
  // Firefox, Opera 8.0+, Safari
  ajVar=new XMLHttpRequest();
 } catch (e) {
  // Internet Explorer
  try {
   ajVar=new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    ajVar=new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {
    return false;
   }
  }
 }
 return ajVar;
}

function doAjax(act,addr,param,sil) {
 if(ajaxActive) {
  var errMsg = "A request is already functioning. Please try again in 10 seconds.";
  if(!sil) { alert(errMsg); }
  ajaxFail(act,errMsg);
  return;
 }
 ajaxActive = true;
 var xmlHttp = getAjaxVar();
 if(!xmlHttp) {
  var errMsg = "Unable to perform task because your browser does not support AJAX or it is turned off.";
  if(!sil) { alert(errMsg); }
  ajaxFail(act,errMsg);
  return false;
 }
 xmlHttp.onreadystatechange=function() {
  if(xmlHttp.readyState==4) {
   window.clearTimeout(ajaxTOut);
   ajaxActive = false;
   if(xmlHttp.responseText.substring(0,8) == 'SUCCESS:') {
    ajaxSuccess(act,xmlHttp.responseText.substring(8));
   } else if(xmlHttp.responseText.substring(0,6) == "ERROR:") {
    var errMsg = xmlHttp.responseText.substring(6);
    if(!sil) { alert(errMsg); }
    ajaxFail(act,errMsg);
   } else {
    //alert(xmlHttp.responseText);
    var errMsg = "There was a problem connecting with BibleArc.com. Check your internet connection and try again.";
    if(!sil) { alert(errMsg); }
    ajaxFail(act,errMsg);
   }
  }
 }
 xmlHttp.open("POST",addr,true);
 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 xmlHttp.setRequestHeader("Content-length", param.length);
 xmlHttp.setRequestHeader("Connection", "close");
 xmlHttp.send(param);
 ajaxTOut = window.setTimeout(
  function() {
   if(ajaxActive) {
    xmlHttp.abort();
    ajaxActive = false;
    if(agent == "SAFARI") {
     var errMsg = "There was a problem connecting with BibleArc.com. Check your internet connection and try again.";
     if(!sil) { alert(errMsg); }
     ajaxFail(act,errMsg);
    }
   }
  },10000);
}

function esc1(str) {
 return str.replace(/</g,'&#60;').replace(/>/g,'&#62;'); 
}

function esc2(str) {
 return str.replace(/_/g,'_U').replace(/\+/g,'_P').replace(/&amp;|&/g,'_A').replace(/"/g,'_Q'); 
}

function esc3(str) {
 return esc2(esc1(str)); 
}

function guessFontAvailability(desiredFont) {
 // create an element with the desired font family
 var a = document.createElement ('span');
 a.appendChild (document.createTextNode ('AbCdEfGhIj'));
 a.style.fontFamily = desiredFont + ', monospace';
 a.style.fontSize = '100px';
 a.style.visibility = 'hidden';
 // create an element which will use the browser's default monospace font
 var b = document.createElement ('span');
 b.appendChild (document.createTextNode ('AbCdEfGhIj'));
 b.style.fontFamily = 'monospace';
 b.style.fontSize = '100px';
 b.style.visibility = 'hidden';
 // attach the elements to the body
 document.body.appendChild (a);
 document.body.appendChild (b);
 // check if the dimensions of the elements are similar
 var available = true;
 if (a.offsetWidth === b.offsetWidth &&
  a.offsetHeight === b.offsetHeight) {
  available = false;
 }
 // remove the elements and return the availability of the font
 a.parentNode.removeChild (a);
 b.parentNode.removeChild (b);
 return available;
}

function getStyleClass (className) {
 for (var s = 0; s < document.styleSheets.length; s++) {
  if(document.styleSheets[s].rules) {
   for (var r = 0; r < document.styleSheets[s].rules.length; r++) {
    if (document.styleSheets[s].rules[r].selectorText == className) {
     return document.styleSheets[s].rules[r];
    }
   }
  } else if(document.styleSheets[s].cssRules) {
   for (var r = 0; r < document.styleSheets[s].cssRules.length; r++) {
    if (document.styleSheets[s].cssRules[r].selectorText == className) {
     return document.styleSheets[s].cssRules[r];
    }
   }
  }
 }
 return null;
}

function gotoForgotPass1() {
 var emailaddr = trim(EL("emailaddr").value);
 if(!emailaddr) {
  alert("Please fill in an email address.");
 } else if(validEmail(emailaddr,false)) {
  window.location = "http://"+serverName+gDirPrefix+"/forgotpassword.php?email="+emailaddr;
 }
}

function validate4() {
 if(!validEmail(EL('email').value,false)) { return false; }
 if(!EL('password').value) { 
  alert("Please enter a password.");
  return false;
 }
}

function modify(info,button) {
 EL(info).disabled = "";
 button.style.visibility = "hidden";
 EL("submit").disabled = "";
 EL(info).focus();
}

function goChange() {
 EL("name").value = EL("nameSpot").value;
 EL("email").value = EL("emailSpot").value;
 EL("password").value = EL("passwordSpot").value;
 if(EL("ea1").checked) { EL("eas").value = "1"; } else { EL("eas").value = "0"; }
 if(EL("ea2").checked) { EL("eas").value += "1"; } else { EL("eas").value += "0"; } 
 if(EL("ea3").checked) { EL("eas").value += "1"; } else { EL("eas").value += "0"; }
 if(EL("applyall1").checked) { EL("applyall").value = "yes"; } else { EL("applyall").value = "no"; }
}

function checkPass() {
 if(EL("nameSpot").disabled=="" && !validUsername(EL("nameSpot").value)) { return; }
 if(EL("emailSpot").disabled=="" && !validEmail(EL("emailSpot").value)) { return; }
 if(EL("passwordSpot").disabled=="" && !validPassword(EL("passwordSpot").value)) { return; }
 var content = '<form method=post onsubmit="goChange();"><table cellpadding=4 class=fw>';
 content += '<tr><td align=center style="padding-top:0px;"><span><b>Please enter your current password.</b></span></td></tr>';
 content += '<tr><td align=center><input type=password id=oldpassword name=oldpassword style="width:200px;" maxlength=20></td></tr>';
 content += '<tr><td align=center>';
 content += '<input class=bold type=submit name=submit id=submit value=Save> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr></table>';
 content += '<input type=hidden id=name name=name>';
 content += '<input type=hidden id=email name=email>';
 content += '<input type=hidden id=password name=password>';
 content += '<input type=hidden id=eas name=eas>';
 content += '<input type=hidden id=applyall name=applyall></form>';
 goPrmpt(3,content,350);
 EL("oldpassword").focus();
}

function changeAmount() {
 var newAmt = EL("newcost").value;
 noPrmpt();
 if(newAmt.substring(0,1) == '$') { newAmt = trim(newAmt.substring(1)); }
 newAmt = parseInt(newAmt);
 if(newAmt != "NaN" && newAmt >= 0) {
  EL('regregcost').innerHTML = '$' + newAmt;
  EL('donation').value = '';
  calcTotal(true);
 } else {
  alert("Invalid amount.");
 }
}

function goRegist() {
	if(EL('name')) {
	 if(trim(EL('name').value) == '' || trim(EL('email').value) == '' || EL('password').value == '') {
	  alert("You must fill-in all fields.");
	  return false;
	 }
	}
 if(!EL('acceptterms').checked) {
  alert("You must check that you accept the Terms of Use.");
  return false;
 }
 if(!EL('name') || validUsername(EL('name').value)) {
  if(!EL('password') || validPassword(EL('password').value)) {
   if(!EL('email') || validEmail(EL('email').value,false)) {
   	if(EL('amount').value == 0 || (formatCardNum(true) && formatExpDate(true))) {
   		if(EL('donation').value == '' || donationAddrOk()) {
   			hideExpAddr();
						//next two lines seek to prevent double submission.
						goBG(1);
						EL('submit').blur();
						return true;  	  		
   		}
   	}
   }
  }
 }
 return false;
}

function donationAddrOk() {	
	if(isBlankRcptAddr() && EL('donation').value >= 25) {
		return confirm("Please confirm you do NOT wish to receive a tax-receipt.\n\n(If you would like a tax-receipt in January for your donation, please select CANCEL and fill in the pertinent field.)");
	} else if(!isBlankRcptAddr() && EL('donation').value < 25) {
		return confirm("Please note that you will only receive a tax-receipt in January for your donation(s) if you give a cumulative amount of $25 or more for a calendar year.");
	} else {
		return true;	
	}
}

function formatCardNum(doAlert) {
	frmtCardNum = EL('cardnum').value.replace(/ /g,'');
	if(frmtCardNum.match(/^[0-9]*$/) && frmtCardNum.length >= 13 && frmtCardNum.length <= 16) {
	 EL('cardnum').value = frmtCardNum;
	 return true;
	} else if(doAlert) {
		alert('Invalid credit card number.');
		EL('cardnum').focus();
		return false;
	}
}

function formatExpDate(doAlert) {
	var frmtExpDate = EL('expdate').value.replace(/[^0-9]/g,'');
	if(frmtExpDate.length == 5 || frmtExpDate.length == 3) { frmtExpDate = '0'+frmtExpDate; }
	var frmtMonth = parseInt(frmtExpDate.substr(0,2),10);
	var frmtYear = parseInt(frmtExpDate.substr(2),10);
	if(frmtYear < 100) { frmtYear += 2000; }
	if(frmtMonth > 0 && frmtMonth < 13 && frmtYear > 2008 && frmtYear < 2100) {
	 EL('expdate').value = ('0'+frmtMonth).replace(/^0(..)$/,'$1') + '/' + frmtYear;
	 return true;
	} else if(doAlert) {
		alert('Invalid credit card expiration date.');
		EL('expdate').focus();
		return false;
	}
}

function showWhatever() {
	EL("whateveramt").className = "whateverexpl";
	if(agent = 'IE' && version < 8) { EL("prmptSpot").innerHTML = EL("prmptSpot").innerHTML; }  //IE7 is dumb.
	EL("newcost").focus();
}

function showMoreInfo(action,type) {
 var content = '<form onsubmit="changeAmount(); return false;"><div class=prmtHd><i>Whatever-You-Can-Afford</i> Policy</div>';
 content += "<div class=prmtExplanation>Our "+type+" fees go to manage, maintain and further develop BibleArc.com. ";
 content += "<i>(We have lots of ideas of how to make this site better and are eager to integrate them!)</i> ";
 content += "Thus, we need this small "+type+" fee from everyone who is able to pay it.</div>";
 content += "<div class=prmtExplanation>But for those who are not able, we do not want this to stop you ";
 content += "from "+action+" and getting the most out of BibleArc.com. ";
 content += "Therefore, we hold to a whatever-you-can-afford policy.</div>";
 content += "<div class=prmtExplanation>So if $10/year is more than you can afford, ";
 content += "simply click <a href='javascript:showWhatever();'>here</a> ";
 content += "and pay what you are able.</div>";
 content += "<div class=hidden id=whateveramt><b>New amount:</b>&nbsp;&nbsp;";
 content += "<input type=text id=newcost name=newcost class=regdonation>&nbsp;&nbsp;<i>(Must be an even dollar amount)</i>&nbsp;&nbsp;";
 content += "<input class=bold type=submit value=Submit></div>";
 content += '<div class=prmtSubmitCancel><input type=button value="Close" onclick="noPrmpt();"></div>';
 content += '</form>';
 goPrmpt(3,content,480);
}

function showAboutShare() {
 var content = '<div class=prmtHd>Sharing on BibleArc.com</div>';
 content += "<div class=prmtExplanation>BibleArc.com allows you to compare your arcs with those done by others. Here is how:</div>";
 content += "<ol>";
 content += "<li><b>Create an arc.</b></li>";
 content += "<li><b>Share your arc.</b>&nbsp;&nbsp;Click the \"Share\" link next to the appropriate arc.</li>";
 content += "<li><b>Compare with others.</b>&nbsp;&nbsp;Click the \"Compare\" button next to any shared arc.</li>";
 content += "</ol>";
 content += "<hr>";
 content += "<div class=prmtExpSm><b>Why do we only allow you to view arcs of passages you have done yourself?</b></div>";
 content += "<div class=prmtExpSm>The aim of this section of the website is to engender a community in which we are able to wrestle with biblical texts through arcing together.</div>";
 content += "<div class=prmtExpSm>Originally, the idea was to simply create a public database of arcs that any user could access completely. Upon further discussion, however, we have deemed it to be more helpful to restrict you to only be able to view public arcs of passages that you have already made an arc of yourself.</div>";
 content += "<div class=prmtExpSm>The fact is that not having this restriction just makes it too easy to only view what others have done and not wrestle ourselves. And this, we think, would unravel some of the foremost aims of this tool--namely, that we would turn our brains on, ask tons of questions and slow down.</div>";
 content += "<div class=prmtExpSm><u>Note</u>: Do not feel like you must have a perfectly polished arc before you share. Do your best, share, view others' arcs, and then feel free to make changes to your own. Your changes will take effect immediately.</div>";
 content += '<div class=prmtSubmitCancel><input type=button value="Close" onclick="noPrmpt();"></div>';
 goPrmpt(3,content,650);
}

function copyArray(a) {
  var n = new Array(a.length);
  for(var i = 0; i < a.length; i++) {
    if(typeof a[i] == 'object') {
      n[i] = copyArray(a[i]);
    } else {
      n[i] = a[i];
    }
  }
  return n;
}

function initMyArcs() {
 numSorts = 3;
 results = allRes[0];
 compMode = 0;
 noSearchCurPage[0] = -1;
 noSearchCurSort[0] = -1;
 EL("search").value = curSearch[0] = "";
 EL("overlap").checked = "";
 detNumRowsPages();
 switchSort(0,1);
 EL("pageSpot1").innerHTML = beforeCompMsg;
 EL("search").focus();
 //fixBrowsDisp();
}

function detNumRowsPages() {
  var pgPrprtn = 0;
  if(numPages[compMode] && numPages[compMode] != 0) { pgPrprtn = (curPage[compMode]-1)/numPages[compMode]; }
  numRows = Math.ceil((windowHeight()-343)/rowHt) - 1;
  if(numRows < 5) { numRows = 5; }
  numPages[compMode] = Math.ceil(results[compMode].length/numRows);
  if(numPages[compMode] == 0) { numPages[compMode] = 1; }
  if(pgPrprtn != 0) {
    curPage[compMode] = parseInt(pgPrprtn*numPages[compMode] + 1);
  }
  if(curPage[compMode] > numPages[compMode]) {
    curPage[compMode] = numPages[compMode];
  }
}

function doWindowResize() {
		resizeBG();
		var oldNumRows = numRows;
		detNumRowsPages();
		if(oldNumRows != numRows) {
		  EL("pageSpot"+compMode).innerHTML = putInRows(-1,0,0,-1);
		  updatePageNums();
		}
}

function updatePageNums() {
  var oppCompMode = (compMode == 0) ? 1 : 0;
  EL('pageNumSpot'+oppCompMode).className = 'myarcspagenumshide';
  EL('pageNumSpot'+compMode).className = 'myarcspagenums';
  EL('curPageNum'+compMode).innerHTML = curPage[compMode];
  EL('pageCnt'+compMode).innerHTML = numPages[compMode];
}

function putInRows(id,doBlank,doSkip,sortUndln) {
  var arcList = copyArray(results[curSort[compMode]].slice(numRows*(curPage[compMode]-1),numRows*curPage[compMode]));  
  var content = "";
  var rowShade = "drk";
  var thisRow;
  var emptySet = true;
  for(var row=0; row<numRows; row++) {
    if(doSkip && ((!arcList[row] || arcList[row] == "") || id != arcList[row][4])) {
		  		thisRow = '';
    } else if((!arcList[row] || arcList[row] == "") || (doBlank && id != arcList[row][4])) {
      thisRow = "<div class=arclistshare"+rowShade+">&nbsp;</div><div class=arclistline"+rowShade+">";
      if(row == 0) { thisRow += "<!--FIRSTROWBLANK-->"; }
      thisRow += "&nbsp;</div>";
    } else {
						emptySet = false;

      //prep passage
      if(compMode == 1 && !doSkip) {
      		//we are doing the compare section
		    		thisRow = compListRow;
		    		if(EL('hideBMarks') == 'hidden') {
		      		arcList[row][1] = (EL('overlap').checked) ? arcList[row][1].substring(arcList[row][1].indexOf(' ',2)+1) : '';
		      }
      } else {
      		//we are doing the arc list section
		    		thisRow = arcListRow;
      }
      
      /*
      //put sorted field in red
      if(sortUndln == -1) { sortUndln = curSort[compMode]; }
      if(sortUndln != 4 && !(doSkip && sortUndln==3)) {
      		arcList[row][sortUndln] = "<span class=sortrow>"+arcList[row][sortUndln]+"</span>";
      }
      */

      if(doSkip) {
        thisRow = thisRow.replace(/CHECKORX/g,"<div class=xsymdwn onclick='hideComp();'></div>");
      } else {
      		thisRow = thisRow.replace(/CHECKORX/g,"<input type=checkbox value=ARCID id=chkbxLINENUM>");
      }
      if(arcList[row][5]) {
      		thisRow = thisRow.replace(/DISABLEDSPOT/g,'');
      		thisRow = thisRow.replace(/SHAREFUNC/g,'unshareArc(ARCID,UPONEWEEK)');
      } else {
      		thisRow = thisRow.replace(/DISABLEDSPOT/g," disabled='disabled'");
      		thisRow = thisRow.replace(/SHAREFUNC/g,'shareArc(ARCID,"PASSAGE","ESCAPENAME",TEXTSINDICATED,HASNOTES,MADEEFFORT)');
      }
      
      shareStatus = (arcList[row][5]) ? 'Shared' : 'Not Shared';
      shareAction = (shareStatus == 'Shared') ? 'Unshare' : 'Share';
      hasNotes = (arcList[row][3] != "") ? 1 : 0;
      arcBlogStatus = (arcList[row][11] == '') ? '' : '<span class=arclistblogstatus>[[ ArcBlog: <b>'+arcList[row][11]+'</b> ]]</span> ';
      
      thisRow = thisRow.replace(/USERID/g,loginId);      
      thisRow = thisRow.replace(/ROWCOLOR/g,rowShade);      
      thisRow = thisRow.replace(/LINENUM/g,row);
      thisRow = thisRow.replace(/SHARESTATUS/g,shareStatus);
      thisRow = thisRow.replace(/SHAREACTION/g,shareAction);
      thisRow = thisRow.replace(/HASNOTES/g,hasNotes);
      thisRow = thisRow.replace(/ARCBLOGSTATUS/g,arcBlogStatus);

      thisRow = thisRow.replace(/DATE/g,arcList[row][0]);
      thisRow = thisRow.replace(/PASSAGE/g,arcList[row][1]);
      thisRow = thisRow.replace(/ESCAPENAME/g,arcList[row][2].replace(/\'/g,'`'));
      thisRow = thisRow.replace(/NAME/g,arcList[row][2]);
      thisRow = thisRow.replace(/NOTE/g,arcList[row][3]);
      thisRow = thisRow.replace(/ARCID/g,arcList[row][4]);
      thisRow = thisRow.replace(/TEXTSINDICATED/g,arcList[row][6]);
      thisRow = thisRow.replace(/UPONEWEEK/g,arcList[row][7]);
      thisRow = thisRow.replace(/MADEEFFORT/g,arcList[row][8]);
      thisRow = thisRow.replace(/EALERT1/g,arcList[row][9]);
      thisRow = thisRow.replace(/EALERT2/g,arcList[row][10]);      
      thisRow = thisRow.replace(/AUTHOR/g,arcList[row][11]);

      if(arcList[row][12]) {
	      var bmNumO = (arcList[row][12].substring(0,1) == '!') ? parseInt(arcList[row][12].substring(1)) : parseInt(arcList[row][12]);
	      thisRow = thisRow.replace(/BOOKMARKS/g,getBMarksPart(arcList[row][4],arcList[row][12].substring(0,1)=='!',bmNumO));      
	     }
    }
    
    content += thisRow;
    rowShade = (rowShade == 'drk') ? 'lt' : 'drk';
  }

  if(emptySet) {
    if(curSearch[compMode] != "") {
      content = content.replace(/<!--FIRSTROWBLANK-->/,"<div class=arclistmsg>There are no arcs that match this search criteria.</div>");
    } else if(EL("viewBMarks").className != '') {
      content = content.replace(/<!--FIRSTROWBLANK-->/,"<div class=arclistmsg>You currently do not have any bookmarks.</div>");
    } else if(compMode == 1 && !EL("overlap").checked) {
      content = content.replace(/<!--FIRSTROWBLANK-->/,"<div class=arclistmsg>No arcs found. Would you like to <a href='javascript:checkOverlap();'>include overlapping passages</a>?</div>");
    } else if(compMode == 1) {
      content = content.replace(/<!--FIRSTROWBLANK-->/,"<div class=arclistmsg>Sorry, there are no arcs to compare with at this time. <a href='javascript:eAlerts();'>Receive email alerts</a>?</div>");
    } else if(!doBlank) {
      content = content.replace(/<!--FIRSTROWBLANK-->/,"<div class=arclistmsg>You currently do not have any saved arcs.</div>");
    }
  }
  return content;
}

function eAlerts() {
 if(ealert1 == -1) { return; }
 var content = '<table cellpadding=0 class=fw>'; 
 content += '<tr><td class=ctr style="font-size:16px;"><b>';
 content += 'Email Alerts Settings</b></td></tr>';
 content += '<tr><td style="padding:4px; padding-top:15px;">';
 content += '<i>For this arc, receive email alerts when...</i></td></tr><tr>';
 content += '<td style="padding-left:20px; padding-top:5px;"><span><input type=checkbox id=ea1';
 if(ealert1) { content += ' checked=checked'; }
 content += '> Others share arcs of this passage.</span></td></tr><tr>';
 content += '<td style="padding-left:20px; padding-bottom:10px;"><span><input type=checkbox id=ea2';
 if(ealert2) { content += ' checked=checked'; }
 content += '> This arc is commented on.</span></td></tr><tr>';
 content += '<td class=ctr style="padding:7px; padding-top:15px;">';
 content += '<input class=bold type=button value="Save" onclick="saveEAlerts1();"> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();"></td></tr></table>';
 goPrmpt(3,content,300);
}

function saveEAlerts1() {
 goMsg(2,"Saving alert settings...",-1,"");
 var arcIdToUse = (thisPage == 'myarcs.php') ? compId : arcId;
 var parameters = "arcid=" + arcIdToUse + "&ea1=" + EL("ea1").checked + "&ea2=" + EL("ea2").checked + "&uid=" + loginId;
 doAjax("ealerts1",gDirPrefix+"/saveealerts.php",parameters,false);
}

function saveEAlerts2(resp) {
 ealert1 = parseInt(resp.charAt(0));
 ealert2 = parseInt(resp.charAt(1));
 if(thisPage == 'myarcs.php') {
	 for(d=0; d<allRes[0].length; d++) {
	  for(g=0; g<allRes[0][d].length; g++) {
	   if(allRes[0][d][g][4] == compId) {
	    allRes[0][d][g][9] = ealert1;
	    allRes[0][d][g][10] = ealert2;
	   }
	  }
	 }
 }
 noMsg();
 noPrmpt();
}

function goComp(id,ea1,ea2) {
	if(compMode == 1) { hideComp(); return; }
 compId = id;
 EL("pageSpot1").innerHTML = "<div class=arclistsharedrk>&nbsp;</div><div class=arclistmsg>&nbsp;</div>";
 EL("pageNumSpot0").className = 'myarcspagenumshide';
 EL("actiondiv").className = 'myarcsactionhide';
 EL("allnonediv").className = 'myarcsallnonehide';
 EL("pageSpot0").innerHTML = putInRows(id,0,1,-1);
 //for(p=0; p<5; p++) { chsnPasSorts[p] = putInRows(id,0,1,p); }
 EL("pageSpot1").innerHTML = putInRows(-1,1,0,-1);
 curSearch[0] = EL("search").value;
 EL("search").value = "";
 EL("numResults").innerHTML = ""; 
 EL("myarcssort3_0").className = "tabtop";
 EL("myarcssort4_0").className = "tabtop";
 numSorts = 5;
 curSort[1] = curSort[0];
 bringInComp(id,1);
 ealert1 = ea1;
 ealert2 = ea2;
 EL("search").focus();
}

function goBMarks() {
	if(compMode == 1) { hideComp(); }
 EL("pageSpot1").innerHTML = "<div class=arclistsharedrk>&nbsp;</div><div class=arclistmsg>&nbsp;</div>";
 EL("pageNumSpot0").className = 'myarcspagenumshide';
 EL("actiondiv").className = 'myarcsactionhide';
 EL("allnonediv").className = 'myarcsallnonehide';
 EL("pageSpot0").innerHTML = "<div class=arclistsharedrk>&nbsp;</div><div class=arclistmsg><b>My bookmarks.</b> (<a href='javascript:hideComp();'>Hide</a>)</div>";
 EL("pageSpot1").innerHTML = putInRows(-1,1,0,-1);
 curSearch[0] = EL("search").value;
 EL("search").value = "";
 EL("numResults").innerHTML = ""; 
 EL("myarcssort3_0").className = "tabtop";
 EL("myarcssort4_0").className = "tabtop";
 numSorts = 5;
 curSort[1] = curSort[0];
 bringInBookmarks();
 EL("search").focus();
}

function hideComp() {
 EL("ealertsdiv").className = 'myarcsactionhide';
 EL("pageNumSpot1").className = 'myarcspagenumshide';
 EL("viewBMarks").className = '';
 EL("hideBMarks").className = 'hidden';
 ealert1 = -1;
 ealert2 = -1;
 compId = -1;
 switchSort(curSort[0],1);
 EL("myarcssort3_0").className = "tabunused";
 EL("myarcssort4_0").className = "tabunused";
 numSorts = 3;
 compMode = 0 ;
 EL("pageSpot1").innerHTML = beforeCompMsg;
 EL("search").value = curSearch[0];
 var goToPg = curPage[compMode];
 doInstSearch();
 if(goToPg != 1) { curPage[compMode] = goToPg-1; nextPage(); }
 EL("pageNumSpot0").className = 'myarcspagenums';
 EL("actiondiv").className = 'myarcsaction';
 EL("allnonediv").className = 'myarcsallnone';
 EL("search").focus();
}

function switchTab(tabBaseName,tabNum) {
	for(b=0; EL(tabBaseName+b+'_0'); b++) {
		for(c=0; EL(tabBaseName+b+'_'+c) && EL(tabBaseName+b+'_'+c).className != 'tabunused'; c++) {
			if(b == tabNum) {
				EL(tabBaseName+b+'_'+c).className = 'tabsel';
			} else if(c == 0) {
				EL(tabBaseName+b+'_'+c).className = 'tabtop';
			} else {
				EL(tabBaseName+b+'_'+c).className = 'tab';
			}
		}
	}
}

function switchSort(sortBase,force) {
	if(!force && sortBase == curSort[compMode]) { return; }
	switchTab("myarcssort",sortBase);
 curSort[compMode] = sortBase;
 curPage[compMode] = 1;
 EL("pageSpot"+compMode).innerHTML = putInRows(-1,0,0,-1);
 if(compMode == 1) {
  //EL("pageSpot0").innerHTML = chsnPasSorts[sortBase];
 }
 updatePageNums();
}

function previousPage() {
 if(curPage[compMode] > 1) {
  curPage[compMode]--;
  EL("pageSpot"+compMode).innerHTML = putInRows(-1,0,0,-1);
  updatePageNums();
 }
 EL('search').focus();
}

function nextPage() {
 if(curPage[compMode] < numPages[compMode]) {
  curPage[compMode]++;
  EL("pageSpot"+compMode).innerHTML = putInRows(-1,0,0,-1);
  updatePageNums();
 }
 EL('search').focus();
}

function doInstSearch() {
  curSearch[compMode] = EL("search").value;
  if(curSearch[compMode] == "") {
    results = allRes[compMode];
    if(noSearchCurPage[compMode] != -1 && noSearchCurSort[compMode] == curSort[compMode]) { curPage[compMode] = noSearchCurPage[compMode]; }
    noSearchCurPage[compMode] = -1;
    EL("numResults").innerHTML = ""; 
/*
  } else if(curSearch[compMode] == "") {
    results = new Array(numSorts);
    for(j=0; j<numSorts; j++) {
      results[j] = new Array();
      var l = 0;
      for(k=0; k<allRes[compMode][j].length; k++) {
        if(allRes[compMode][j][k][5]) {
          results[j][l] = allRes[compMode][j][k];    
          l++;
        }
      }
    }
    curPage[compMode] = 1; 
    if(noSearchCurPage[compMode] != -1 && noSearchCurSort[compMode] == curSort[compMode]) { curPage[compMode] = noSearchCurPage[compMode]; }
    noSearchCurPage[compMode] = -1;
    EL("numResults").innerHTML = ""; 
 */
  } else {
    var searchStrUp = curSearch[compMode].toUpperCase();
    results = new Array(numSorts);
    for(j=0; j<numSorts; j++) {
      results[j] = new Array();
      var l = 0;
      for(k=0; k<allRes[compMode][j].length && allRes[compMode][j][k][1]; k++) {
        if(allRes[compMode][j][k][0].toUpperCase().indexOf(searchStrUp) != -1 || allRes[compMode][j][k][1].toUpperCase().indexOf(searchStrUp) != -1 || allRes[compMode][j][k][2].toUpperCase().indexOf(searchStrUp) != -1 || (allRes[compMode][j][k][3] && allRes[compMode][j][k][3].toUpperCase().indexOf(searchStrUp) != -1)) {
          results[j][l] = allRes[compMode][j][k];    
          l++;
        }
      }
    }
    if(noSearchCurPage[compMode] == -1) { noSearchCurPage[compMode] = curPage[compMode]; noSearchCurSort[compMode] = curSort[compMode]; }
    curPage[compMode] = 1; 
    EL("numResults").innerHTML = "Found " + results[compMode].length + " arc(s).";
  }
  numPages[compMode] = Math.ceil(results[compMode].length/numRows);
  if(numPages[compMode] == 0) { numPages[compMode] = 1; }
  EL("pageSpot"+compMode).innerHTML = putInRows(-1,0,0,-1);
  updatePageNums();
}

function clearSearch() {
  EL('search').value = "";
  doInstSearch();
  EL('search').focus();
}

function bringInBookmarks() {
 goMsg(1,"Retrieving bookmarks...",320,"");
 var parameters = "bookmarks=true&uid=" + loginId;
 doAjax("bookmarks1",gDirPrefix+"/compare.php",parameters,false);
}

function bringInBookmarks2(resp) {
 allRes[1] = resp.split('<3');
 for(p=0; p<allRes[1].length; p++) {
   allRes[1][p] = allRes[1][p].split('<2');
   for(q=0; q<allRes[1][p].length; q++) {
     allRes[1][p][q] = allRes[1][p][q].split('<1');
   } 
 }
 compMode = 1;
 noSearchCurPage[1] = -1;
 noSearchCurSort[1] = -1;
 curSearch[1] = "";
 results = allRes[1];
 numPages[compMode] = Math.ceil(results[1].length/numRows);
 if(numPages[compMode] == 0) { numPages[compMode] = 1; }
 EL("viewBMarks").className = 'hidden';
 EL("hideBMarks").className = '';
 switchSort(1,1);
 EL("pageNumSpot1").className = 'myarcspagenums';
 noMsg();
}

function bringInComp(id,goOnNum) {
 goMsg(1,"Finding arcs...",320,"");
 var parameters = "id=" + id + "&overlap=" + EL("overlap").checked + "&uid=" + loginId;
 doAjax("compare"+goOnNum,gDirPrefix+"/compare.php",parameters,false);
}

function bringInComp2(resp) {
 allRes[1] = resp.split('<3');
 for(p=0; p<allRes[1].length; p++) {
   allRes[1][p] = allRes[1][p].split('<2');
   for(q=0; q<allRes[1][p].length; q++) {
     allRes[1][p][q] = allRes[1][p][q].split('<1');
   } 
 }
 compMode = 1;
 //curPage[1] = 1;
 noSearchCurPage[1] = -1;
 noSearchCurSort[1] = -1;
 curSearch[1] = "";
 results = allRes[1];
 numPages[compMode] = Math.ceil(results[1].length/numRows);
 if(numPages[compMode] == 0) { numPages[compMode] = 1; }
 switchSort(4,1);
 //updatePageNums(0);
 //EL("pageSpot1").innerHTML = putInRows(-1,0,0,-1);
 EL("ealertsdiv").className = 'myarcsaction';
 EL("pageNumSpot1").className = 'myarcspagenums';
 noMsg();
}

function updateOverlap() {
 if(compMode == 1 && EL("viewBMarks").className == '') {
  EL('search').value = "";
  EL("numResults").innerHTML = ""; 
  bringInComp(compId,1);
 }
}

function checkOverlap() {
 EL("overlap").checked = "checked";
 updateOverlap();
}


function shareArc(id,pas,nam,txts,not,eft) {
 var content = '<table cellpadding=0 class=fw>'; 
 content += '<tr><td class=ctr style="font-size:16px;"><b>';
 content += 'Make This Arc Public</b></td></tr>';
 content += '<tr><td style="padding:4px; padding-top:8px;">';
 content += 'There are ';
 if(txts == 0) { content += 'three'; } else { content += 'four'; }
 content += ' criteria an arc must meet to be made public.';
 content += '<br></td></tr><tr><td style="padding:4px;"><ol class=shr>';
 content += '<li class=shr><b>Thoughtful effort.</b><br><span class=smalltext>Before viewing others\' arcs, BibleArc.com requires ';
 content += 'that you put in some thoughtful effort of your own and <i>attempt</i> to arc the given passage.</span>';
 if(not && eft) { content += '<br><span class=bgray>If necessary, <input type=button value='; }
 if(not && eft) {
 	if(thisPage == 'myarcs.php') {
 		content += 'Open onclick="openArc('+id+',0);"> this arc';
 	} else {
 		content += 'Close onclick="noPrmpt();toggleTab(0);"> this prompt';
 	}
 }
 if(not && eft) { content += ' to continue work on this arc.</span>'; }
 content += '<br></li>';
 content += '<li class=shr><b>Descriptive name.</b><br><span class=smalltext>In order to help people browse through ';
 content += 'arcs in the share section, please choose a name that says something ';
 content += 'about what you are seeing in this passage.</span>';
 if(not && eft) { content += '<br><span class=bgray>If necessary, change the name here: </span><input id=anam type=text style="width:160px;" value="'+nam.replace(/`/g,"'")+'" maxlength=30>'; }
 content += '<br></li><li class=shr><b>Helpful notes.</b><br><span class=smalltext>Using the <i>notes</i> tab, tell us more about this arc. ';
 content += 'It could be a single sentence or an entire sermon. ';
 content += '(See the <i>Ideas</i> tab on the left-bar of the arcing widget.)</span>';
 if(not && eft) { content += '<br><span class=bgray>If necessary, <input type=button value='; }
 if(not && eft) {
 	if(thisPage == 'myarcs.php') {
 		content += 'Open onclick="openArc('+id+',0);"> this arc';
 	} else {
 		content += 'Close onclick="noPrmpt();toggleTab(1);';
   if(colVer[0] == 'greek') { content += 'toggleLeftTab(2);'; } else { content += 'toggleLeftTab(1);'; }
 		content += '"> this prompt';
 	}
 }
 if(not && eft) { content += ' to modify your notes.</span>'; }
 if(txts > 0) {  
  content += '<br></li><li class=shr><b>Original Texts.</b><br><span class=smalltext>For arcs begun before December 2008, please indicate which ';
  content += 'translation(s) you chose to use.</span>';
  if(not && eft) {
   content += '<br><span class=bgray>Choose here: ';
   content += '<select name="col1Ind" id="col1Ind"><option id="unselected" selected="selected"></option>';
   content += '<option id="greek">greek</option><option id="esv">esv</option><option id="nasb">nasb</option>';
   content += '<option id="kjv">kjv</option><option id="myown">my own</option></select>';
   if(txts == 2) {
    content += '&nbsp;&nbsp;<select name="col2Ind" id="col2Ind"><option id="unselected" selected="selected"></option>';
    content += '<option id="esv">esv</option><option id="nasb">nasb</option>';
    content += '<option id="kjv">kjv</option><option id="myown">my own</option></select>';
   }
   content += '<br>&nbsp;&nbsp;&nbsp;&nbsp;Or <input type=button value=Open onclick="openArc('+id+',0);"> this arc to remember. ';
   content += '(See the <i>notes</i> tab.)</span>';
  }
 }
 content += '<br></li></ol></td></tr><tr>';
 if(not && eft) {
  content += '<td style="padding-left:10px; padding-top:10px; background-color:white;"><span class=smalltext><i><b>Receive ';
  content += 'email alerts when...</b></i></span><br></td></tr><tr>';
  content += '<td style="padding-left:20px; padding-bottom:10px; background-color:white;"><span class=smalltext>';
  content += '<input id=ea1 type=checkbox';
  if(ead1) { content += " checked=checked"; }
  content += '>Others ';
  content += 'share arcs of this passage. <input id=ea2 type=checkbox';
  if(ead2) { content += " checked=checked"; }
  content += '>This arc is commented on.</span></td></tr><tr>';
  content += '<td class=ctr style="padding-top:10px;">';
  content += '<span class=smalltext><b><u>Warning</u>: Arcs must remain public for a minimum of one week.</b></span></td></tr><tr>';
  content += '<td class=ctr style="padding:7px; padding-top:15px;">';
  content += '<input class=bold type=button value="Go Public" onclick="doShare('+id+','+txts+',\''+pas+'\');"> ';
  content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 } else {
  content += '<td style="padding:4px; padding-bottom:10px; line-height:5pt;">';
  content += 'Thus, before you make this arc public, please <input type=button value=Open onclick="openArc('+id+',0);"> ';
  content += 'it, meet the given criteria, and save.<br>';
 } 
 content += '</td></tr></table>';
 goPrmpt(3,content,500)
}

function viewShare() {
 var content = '<table cellpadding=0 class=fw><tr><td colspan=2 class=ctr style="font-size:16px;">';
 content += '<b>Compare With Others</b></td></tr>';
 content += '<tr><td colspan=2 style="padding:4px; padding-top:8px;">';
 content += 'This arc is presently shared with the public. ';
 content += '(<a href="javascript:doShareArc();">Unshare</a>)</td></tr>';
 content += '<tr><td><table cellpadding=0><tr><td class=ovl1><input type=checkbox id=overlap onclick="bringInComp('+arcId+',2);"></td>';
 content += '<td class=ovl1>Include overlapping passages.</td></tr></table></td>';
 content += '<td style="text-align:right; padding-right:5px;"><span class=smalltext>';
 content += '(<a class=small href="javascript:eAlerts();">Email Alerts</a>)</span></td></tr>';
 content += '<tr><td colspan=2 style="padding:4px; padding-top:0px;">';
 content += '<div class=cmp id=cmpSpot></div>';
 content += '</td></tr><tr><td style="padding:4px;" class=em1>(Arcs open in a new window.)</td>';
 content += '<td class=done1><input type=button value=Done onclick="noPrmpt();"></td></tr></table>';
 goPrmpt(3,content,550);
 initCmp();
 bringInComp(arcId,2);
}

function doShare(id,txts,pas) {
 var re = new RegExp(pas.substring(pas.indexOf(' ',2)),'i');
 if(EL('anam').value.match(re) || trim(EL('anam').value) == "") {
  alert("You must choose a descriptive name that does not include the passage reference.");
  EL('anam').focus();
  return;
 }
 if(!validArcName(EL('anam').value)) { EL("anam").focus(); return false; }
 if((EL('col1Ind') && EL('col1Ind').value == "") || (EL('col2Ind') && EL('col2Ind').value == "")) {
  alert("You must indicate which translation(s) you used for this arc. (See \"Original Texts.\")");
  return;
 }
 goMsg(2,"Sharing...",-1,"");
 var parameters = "arcid=" + id + "&name=" + EL("anam").value;
 parameters += "&ea1=" + EL("ea1").checked + "&ea2=" + EL("ea2").checked;
 if(txts >= 1) {
  parameters += "&col1=" + EL("col1Ind").value;
  if(txts == 2) {
   parameters += "&col2=" + EL("col2Ind").value;
  } else {
   parameters += "&col2=none";
  }
 }
 parameters += "&uid="+loginId
 doAjax("share1",gDirPrefix+"/gopublic.php",parameters,false);
}

function doShare2(resp) {
 var res = resp.split('>');
 if(thisPage == 'myarcs.php') {
	 updArc(res[0],res[1].replace(/\\\'/g,"'"),1,parseInt(res[2]),parseInt(res[3]));
	 EL("pageSpot0").innerHTML = putInRows(-1,0,0,-1); 
	} else {
	 arcName = res[1];
	 EL("nametitle").innerHTML = arcName.replace(/\\\'/g,"'") + '&nbsp;';
	 EL("passagetitle").innerHTML = '(' + passage + ')';
	 ealert1 = parseInt(res[2]);
	 ealert2 = parseInt(res[3]);
	 isShared = 1;
	 EL("shareB").innerHTML = "Shared";
	 EL("toolsShare").innerHTML = 'Unshare this arc';
	 EL("toolsViewShare").className = 'toolitem';
	 EL("toolsViewShare").innerHTML = EL("toolsViewShare").innerHTML.replace(/ \([^)]*\)$/, '');
	 upOneWk = false;
	}
 noMsg();
 noPrmpt();
 if(thisPage == 'arc.php') { viewShare(); }
}

function updArc(id,nam,shar,ea1,ea2) {
 for(d=0; allRes[0][d]; d++) {
  for(f=0; allRes[0][d][f]; f++) {
   if(allRes[0][d][f][4] == id) {
    if(nam) { allRes[0][d][f][2] = nam; }
    allRes[0][d][f][5] = shar;
    allRes[0][d][f][7] = 0;
    if(ea1 != -1) { allRes[0][d][f][9] = ea1; allRes[0][d][f][10] = ea2; }
   }
  }
 }
}

function unshareArc(id,upWk) {
	if(thisPage == 'myarcs.php' && compMode == 1) { hideComp(); }
 if(!upWk) {
  alert('Arcs that are made public must remain so for at least one week.');
  return;
 }
 if(!confirm("Are you sure you want to remove this arc from the public listing?")) { return; }
	if(thisPage == 'arc.php') { noPrmpt(); }
 goMsg(2,"Unsharing...",-1,"");
 var parameters = "arcid=" + id + "&uid=" + loginId;
 doAjax("unshare1",gDirPrefix+"/unshare.php",parameters,false);
}

function unshareArc2(resp) {
	if(thisPage == 'myarcs.php') {
	 updArc(resp,'',0,-1,-1);
	 doInstSearch();
	} else {
	 isShared = 0;
	 EL("shareB").innerHTML = 'Not Shared';
	 EL("toolsShare").innerHTML = 'Share this arc';
	 EL("toolsViewShare").className = 'toolitemdisabled';
	 EL("toolsViewShare").innerHTML += ' (requires Share)';
	 upOneWk = false;	
	}
 noMsg();
}

function doShareArc() {
	if(isShared) {
		unshareArc(arcId,upOneWk);
	} else {
  if(mtsCrtria("share")) { shareArc(arcId,passage,arcName,0,1,1); }
	}
}

function doAction(action) {
 if(disableDoAction) return;
 var ids = '';
// for(var i=numRows*(curPage-1); EL("chkbx"+i); i++) {
 for(var i=0; EL("chkbx"+i); i++) {
  if(EL("chkbx"+i).checked) {
   ids += '+'+EL("chkbx"+i).value;
  }
 }
 ids = ids.substring(1);
 if(ids == "") {
  blankAction();
  alert("You must first select an arc by checking a checkbox.");
  return;
 }
 if(action == "delete" || action == "duplicate") {
  blankAction();
  if(action == "delete" && !confirm("Are you sure you want to delete the selected arcs?")) {
   return;
  }
  window.location = "updatemyarcs.php?action="+action+"&ids="+ids+"&base="+curSort[0]+"&page="+curPage[0]+"&search="+escape(EL("search").value);
 } else if(action == "rename") {
  blankAction();
  if(ids.indexOf('+') == -1) {
   if(!EL("newname")) {
    getRename();
   } else if(validArcName(EL("newname").value)) {
    window.location = "updatemyarcs.php?action="+action+"&id="+ids+"&newname="+escape(EL("newname").value)+"&base="+curSort[0]+"&page="+curPage[0]+"&search="+escape(EL("search").value);
   }
  } else {
   alert("You are only able to rename one arc at a time.");
  }
 } else if(action == "download") {
  blankAction();
  pdfArcs(ids);
 } else if(action == "email") {
  blankAction();
  var content = '<table cellpadding=0 class=fw><tr><td class=ctr style="font-size:16px;">';
  if(ids.indexOf("+")) {
   content += '<b>Email Selected Arcs To Friend(s)</b></td></tr>';
  } else {
   content += '<b>Email This Arc To Friend(s)</b></td></tr>';
  }
  content += '<tr><td style="padding-top:10px;">';
  content += 'Enter up to 10 email addresses, <i>separated by commas.</i>';
  content += '</td></tr><tr><td>';
  content += '<textarea id=eaddrs style="width:100%; height:50px;"></textarea>';
  content += '</td></tr><tr><td style="padding-top:8px;"><table cellpadding=0><tr><td class=em1>';
  content += 'Send to addresses:&nbsp;&nbsp;</td><td class=em1>';
  content += '<input type=radio id=grp name=mthd checked=checked></td><td class=em1>As a group&nbsp;&nbsp;</td><td class=em1>';
  content += '<input type=radio id=ind name=mthd></td><td class=em1>Individually';
  content += '</td></tr></table></td></tr><tr><td style="padding-top:8px;">';
  content += 'Enter a personal message. <span class=smallgray2><b>(Optional)</b></span>';
  content += '</td></tr><tr><td>';
  content += '<textarea id=pmsg style="width:100%; height:80px;"></textarea>';
  content += '</td></tr><tr><td style="padding:5px; padding-top:15px;" class=ctr>';
  content += '<input class=bold value="Send Email(s)" type=button onclick="doEmailArcPage(\''+ids+'\');"> ';
  content += '<input type=button value="Cancel" onclick="noPrmpt();">';
  content += '</td></tr>'; 
  content += '</table>';
  goPrmpt(3,content,400);
  EL("eaddrs").focus();
 }
}

function doEmail(ids) {
 if(trim(EL("eaddrs").value) == "") {
  alert("Please enter the email(s) you wish to send this arc to.");
  return;
 }
 var emls = EL("eaddrs").value.replace(/^\n+|\n+$/g,"").replace(/\n/g,",").split(',');
 if(emls.length > 10) {
  alert("You may only email up to 10 people at a time.");
  return;
 }
 for(w=0; w<emls.length; w++) {
  emls[w] = trim(emls[w]);
  if(!validEmail(emls[w],true)) { return false; }
 }
 goMsg(2,"Emailing...",-1,"");
 var parameters = "arcids=" + ids + "&toaddrs=" + emls.toString() + "&pmsg=" + esc2(trim(EL("pmsg").value)) + "&uid=" + loginId;
 if(EL("ind").checked) { parameters += "&method=ind"; } else { parameters += "&method=grp"; }
 doAjax("email2",gDirPrefix+"/emailarc.php",parameters,false);
}

function doEmail2(resp) {
 noMsg();
 noPrmpt();
 selNoChkBxs();
 //alert(resp);
 if(resp == "later") {
  alert("Email(s) successfully cued for sending.\n\n(Due to unusually high activity, there may be some delay.)");
 } else {
  alert("Email(s) sent successfully!");
 }
}

function selAllChkBxs() {
 for(var i=0; EL("chkbx"+i); i++) {
  EL("chkbx"+i).checked = "checked";
 }
 EL('search').focus();
}

function selNoChkBxs() {
 for(var i=0; EL("chkbx"+i); i++) {
  EL("chkbx"+i).checked = "";
 }
 EL('search').focus();
}

function blankAction() {
 disableDoAction = true;
 EL("actions").selectedIndex=0;
 EL("actions").blur();
 disableDoAction = false;
}

function getRename() {
 var content = '<form onsubmit="doAction(\'rename\');return false;"><table cellpadding=4 class=fw>';
 content += '<tr><td align=center style="padding-top:0px;"><span><b>Enter a new name.</b></span></td></tr>';
 content += '<tr><td align=center><input type=text id=newname name=newname style="width:200px;" maxlength=30></td></tr>';
 content += '<tr><td align=center>';
 content += '<input class=bold type=submit name=submit id=submit value=Rename> ';
 content += '<input type=button value="Cancel" onclick="noPrmpt();">';
 content += '</td></tr>';
 content += '<tr><td style="padding-top:10px; padding-bottom:5px;"><hr>';
 content += '</td></tr><tr><td class=em1>';
 content += '<b><u>Choosing a name</u>:</b> If you plan on sharing, you must choose a descriptive name. ';
 content += 'The name cannot contain the passage reference and should say something about what you have ';
 content += 'discovered through this arc. For example: <i>From Wrath to Kindness</i> or <i>Jesus is a Treasure.</i>';
 content += '</td></tr></table></form>';
 goPrmpt(3,content,350);
 EL("newname").focus();
}

function pdfArcs(aids) {
 if(thisPage == 'arc.php' && isSaved != 2) {
  if(saveUserId == 0) {
   goMsg(2,"Preparing arc...",-1,"");
	  ajaxSave(true,false);
  } else {
   goMsg(2,"Saving arc...",-1,"");
 	 ajaxSave(false,false);
  }
  postSaveAct = "pdf";
  return;
 }
 var xtraS = (aids.indexOf('+') != -1) ? 's' : '';

 var content = '<div class=prmtHd>Download Your Arc'+xtraS+'</div>';
 content += '<div class=prmtExplanation>Choose what to have included in your PDF'+xtraS+'.</div>';
 content += '<div class=prmtChkOpt><input type=checkbox id=chkarc checked=checked onchange="stckyChkTggl();">Arc</div>';
 content += '<div class=prmtChkSubOpt><input type=checkbox id=showstickies checked=checked>show sticky notes</div>';
 content += '<div class=prmtChkSubOpt><input type=checkbox id=shrinktofit>shrink-to-fit, if necessary</div>';
 content += '<div class=prmtChkOpt><input type=checkbox id=chknotes checked=checked>Notes</div>';
 content += '<div class=prmtSubmitCancel><input class=bold value="Download" type=button onclick="pdfArcs2(\''+aids+'\');">';
 content += '<input type=button value="Cancel" onclick="noPrmpt();"></div><hr>';
 content += '<div class=prmtEndNote><b><u>Printing</u>:</b> After downloading your arc'+xtraS+', you can open the downloaded PDF file'+xtraS;
 content += ' and print through your PDF viewer.</div>';
 goPrmpt(3,content,320);
}

function pdfArcs2(aids) {
// if(!EL("chkarc").checked && !EL("chknotes").checked && !EL("chkcomments").checked) {
 if(!EL("chkarc").checked && !EL("chknotes").checked) {
  alert("Please check which elements you would like to include in your PDF download.");
  return;
 }
 var pdfhref = 'http://'+serverName+gDirPrefix+'/pdf.php?';
 var userIdToUse = (typeof saveUserId == 'undefined') ? loginId : saveUserId;
 pdfhref += 'uid='+userIdToUse+'&';
 pdfhref += 'name='+escape(arcName)+'&';
 pdfhref += "chkarc="+EL("chkarc").checked+"&chknotes="+EL("chknotes").checked+"&"
// pdfhref += "chkcomments="+EL("chkcomments").checked+'&';
 pdfhref += "showstickies="+EL("showstickies").checked+'&';
 pdfhref += "shrinktofit="+EL("shrinktofit").checked+'&';
 var id_array = aids.split('+');
 for(var i=0; id_array[i]; i++) {
  window.open(pdfhref + "arcid="+id_array[i], '_blank', '');
 }
 if(thisPage == 'myarcs.php') {
	 selNoChkBxs();
	}
 noPrmpt();
}

function doDupAlt() {
 alert("Unable to duplicate (at least one arc) due to its being flagged for abuse."); 
}

function goTools() {
 window.clearTimeout(toolsTimer);
	if(EL('tools').className == 'tools') {
		noToolsNow();
	} else {
		var tbpos = findPos(EL('toolsButton'));
 	if(toolbarAutoScroll) { tbpos[1] += scrollTop(); }
		EL('tools').style.left = (tbpos[0]+EL('toolsButton').offsetWidth+5-EL('tools').offsetWidth) + 'px';
		if(windowHeight()-(tbpos[1]-scrollTop()+EL('toolsButton').offsetHeight+15) > EL('tools').offsetHeight) {
			EL('tools').style.top = (tbpos[1]+EL('toolsButton').offsetHeight+2) + 'px';
		} else {
			EL('tools').style.top = (tbpos[1]-EL('tools').offsetHeight-15) + 'px';
		}
		EL('tools').className = 'tools';
	}
}

function noTools() {
 window.clearTimeout(toolsTimer);
	if(EL('tools').className == 'tools') {
  toolsTimer = window.setTimeout('goTools();',400);
	}
}

function noToolsNow() {
	if(!EL('tools')) { return; }
 window.clearTimeout(toolsTimer);
	EL('tools').className = 'hidden';
	EL('tools').style.left = '';
	EL('tools').style.top = '';
}

function yesTools() {
 window.clearTimeout(toolsTimer);
}

function fixArcDesktopHt() {
 var minDeskHt = windowHeight() - 120;
 if(minDeskHt < 500) { minDeskHt = 500; }
	if(EL('arcDesktop').offsetHeight > minDeskHt) { minDeskHt = EL('arcDesktop').offsetHeight; }
	EL('arcDesktop').style.minHeight = minDeskHt + 'px';
	//EL('arcDesktop').style.height = '';
	//EL('arcDesktop').style.height = (minDeskHt > EL('arcDesktop').offsetHeight) ? minDeskHt + 'px' : EL('arcDesktop').offsetHeight + 'px';
}

function toggleVideo(objpref,objnum) {
 for(b=1; EL(objpref+b); b++) {
 	if(b == objnum) {
 		EL(objpref+b).className = "nolink";
			EL(objpref+'Obj'+b).className = "";
 	} else {
 		EL(objpref+b).className = "";	
			EL(objpref+'Obj'+b).className = "hidden";
 	}
 }
 EL(objpref+objnum).blur();
}

function prepToggledVideo(objpref,objtypes,namesorids) {
	var videosHidden = '';
 for(b=1; EL(objpref+b); b++) {
		videosHidden += vidimgobject[objtypes[b-1]].replace(/NAMEORID/g,namesorids[b-1]).replace(/OBJID/g,objpref+'Obj'+b);
 }
 EL('a101ContGraphic').innerHTML = videosHidden;
}

function showDistinct(dNum) {
	var vidPos = findPos(EL('a101ContGraphic'));
	if(platform == "Win") {
	 for(b=0; EL('a101ContGraphic').childNodes[b]; b++) {
	 	if(EL('a101ContGraphic').childNodes[b].className == '') {
	 		tmpHiddenObj = EL('a101ContGraphic').childNodes[b];
				tmpHiddenObj.className = 'hidden';
				break;
	 	}
	 }
 }
	EL('distinction'+dNum).style.left = vidPos[0] + 'px';
	EL('distinction'+dNum).style.top = vidPos[1] + 'px';
	EL('distinction'+dNum).className = 'a101Distinct';
}

function hideDistinct(dNum) {
	EL('distinction'+dNum).style.left = '';
	EL('distinction'+dNum).style.top = '';
	EL('distinction'+dNum).className = 'hidden';
	if(platform == "Win" && tmpHiddenObj) { tmpHiddenObj.className = ''; tmpHiddenObj = null; }
}

function showJumpToStep() {
	EL('jumpToStepStuff').className = '';
	EL('jumpStepNum').focus();
}

function jumpToStep() {
	var toNum = parseInt(trim(EL('jumpStepNum').value));
	if(toNum >= 1 && toNum <= numsteps) {
		window.location = 'step'+toNum+'.php';
	} else {
		alert('Please choose a number between 1 and '+numsteps);
		EL('jumpStepNum').focus();
	}
}

function calcTotal(formatDonations) {
	var donation = parseInt(EL('donation').value.replace(/\$/g,''));
	if(donation > 0) {
		if(formatDonations) {
			regamt = parseInt(EL('regregcost').innerHTML.substring(1));
			if(regamt < 10) {
				if(regamt + donation >= 10) {
					EL('regregcost').innerHTML = '$10';
					donation -= (10 - regamt);
				} else {
					EL('regregcost').innerHTML = '$' + (regamt + donation);
					donation = 0;
				}
			}
			EL('donation').value = donation;
			EL('receiptaddrdiv').className = 'regmainreceiptaddr';
			EL('receiptnotediv').className = 'regmainreceiptexpl';
			showExpAddr();
		}
  EL('amount').value = (donation + parseInt(EL('regregcost').innerHTML.substr(1)));
		EL('regtotalcost').innerHTML = '$' + EL('amount').value;

	} else {
		if(formatDonations) {
			EL('donation').value = '';
			EL('receiptaddrdiv').className = 'hidden';
			EL('receiptnotediv').className = 'hidden';
		}
  EL('amount').value = parseInt(EL('regregcost').innerHTML.substr(1));
		EL('regtotalcost').innerHTML = '$' + EL('amount').value;
	}
}

function showTerms() {
	var content = '<div class=regterms>Terms</div>';
 content += '<ul class=regtermslist>';
 content += '<li><span class=smalltext><b>Usage:</b></span><span class=reallysmalltext>&nbsp;&nbsp;You will not use this website to upload any content that is unlawful, defamatory, harassing, abusive, fraudulent, obscene, contains viruses, or is otherwise objectionable as reasonably determined by BibleArc.com.<br></span></li>';
 content += '<li><span class=smalltext><b>Disclaimer:</b></span><span class=reallysmalltext>&nbsp;&nbsp;You understand and agree that BibleArc.com is provided on an "as is" and "as available" basis. BibleArc.com disclaims all responsibility and liability for the availability, timeliness, security or reliability of this website.<br></span></li>';
 content += '<li><span class=smalltext><b>Termination:</b></span><span class=reallysmalltext>&nbsp;&nbsp;Violation of this agreement in any way is grounds for account termination without refund. BibleArc.com also reserves the right to modify, suspend or discountinue this website with or without notice at any time and without any liability to you (hold the following exception). Should BibleArc.com be discountinued, users with less than 6 months of usage since their registration (or re-registration) will be entitled to a partial refund.<br></span></li>';
 content += '<li><span class=smalltext><b>Refunds:</b></span><span class=reallysmalltext>&nbsp;&nbsp;Refunds are given at the sole discretion of BibleArc.com. Refund requests can be made via the feedback form.</span><br></li>';
 content += '<li><span class=smalltext><b>Property:</b></span><span class=reallysmalltext>&nbsp;&nbsp;You acknowledge that BibleArc.com owns all intellectual property rights of this website. Accordingly, you agree that you will not copy, reproduce, alter, modify, or create derivative works from BibleArc.com without prior consent.</span><br></li>';
 content += '<li><span class=smalltext><b>Thirteen+:</b></span><span class=reallysmalltext>&nbsp;&nbsp;Due to the <a class=footer href="http://www.ftc.gov/ogc/coppa1.htm" onclick="window.open(this.href,\'newwin\'); return false;" tabindex="-1">Children\'s Online Privacy Protection Act of 1998</a>, you must be at least thirteen (13) years of age to register.</span><br></li>';
 content += '</ul>';
 content += '<div class=prmtSubmitCancel><input type=button value="Close" onclick="noPrmpt();"></div>';
 goPrmpt(3,content,550);
}

function showExpAddr() {
	if(isBlankRcptAddr()) {
		EL('receiptaddr').value = exreceiptaddr;	
	}
}

function isBlankRcptAddr() {
	return (trim(EL('receiptaddr').value) == '' || EL('receiptaddr').value.replace(/[\n\r]*/g,' ') == exreceiptaddr.replace(/[\n\r]*/g,' '));
}

function hideExpAddr() {
 //replace functions there because of different endline chars between Macs & PCs
	if(isBlankRcptAddr()) {
		EL('receiptaddr').value = "";	
	}
}

function donationValidation() {
	if(!validEmail(EL('email').value,false)) { EL('email').focus(); return false; }
	var donation = parseInt(EL('donation').value.replace(/\$/g,''));
	if(donation > 0) {
		if(donation != EL('donation').value && '$'+donation != EL('donation').value) {
			if(!confirm('Please confirm donation amount of $'+donation+'.')) { EL('donation').focus(); return false; }
			EL('donation').value = donation;
		}
	} else {
		alert('Invalid donation amount.');
		EL('donation').focus();
		return false;
	}
	if(!formatCardNum(true) || !formatExpDate(true)) {
		return false;
	}
	if(!donationAddrOk()) {
		return false;
	}
	hideExpAddr();
	//next two lines seek to prevent double submission.
	goBG(1);
	EL('submit').blur();
	return true;
}

function doBMark() {
	window.clearTimeout(bookmarkAskTimer);
	doneWithBMAsk();
	if(EL("bmarklink").innerHTML.match(/Add/i)) {
	 goMsg(2,"Bookmarking arc...",-1,"");
	 var parameters = "arcid="+arcId+"&bookmark=yes&uid=" + loginId;
	 doAjax("bookmark2",gDirPrefix+"/bookmark.php",parameters,false);	
	} else {
	 goMsg(2,"Removing bookmark...",-1,"");
	 var parameters = "arcid="+arcId+"&bookmark=no&uid=" + loginId;
	 doAjax("bookmark3",gDirPrefix+"/bookmark.php",parameters,false);	
	}
	EL("bmarklink").blur();
}

function yesBMark2() {
	EL("bmarkdiv").innerHTML = "<img src='/images/checkmark.png' class=bmark>Bookmarked. (<a href='javascript:doBMark();' id=bmarklink>remove</a>)";
	EL("toolsBMark").innerHTML = 'Remove bookmark';
 noMsg();
}

function noBMark2() {
	EL("bmarkdiv").innerHTML = "<a href='javascript:doBMark();' id=bmarklink>&nbsp;Add bookmark</a>";
	EL("toolsBMark").innerHTML = 'Add a bookmark to this arc';
 noMsg();
}

function bMarkMyArcs(action,bmArcId) {
	if(action == 'yes') {
	 goMsg(2,"Bookmarking arc...",-1,"");
	} else {
	 goMsg(2,"Removing bookmark...",-1,"");	
	}
 var parameters = "arcid="+bmArcId+"&bookmark="+action+"&uid=" + loginId;
 doAjax("bookmark4",gDirPrefix+"/bookmark.php",parameters,false);	
}

function bMarkMyArcs2(res) {
	var bmArcId = res.substr(1);
	EL("bm"+bmArcId).innerHTML = getBMarksPart(bmArcId,res.substr(0,1)=='y',parseInt(EL("others"+bmArcId).innerHTML));
	for(a=0; allRes[1][a]; a++) {
		for(b=0; allRes[1][a][b]; b++) {
			if(allRes[1][a][b][4] == bmArcId) {
    var bmNumOthers = (allRes[1][a][b][12].substring(0,1) == '!') ? allRes[1][a][b][12].substring(1) : allRes[1][a][b][12];
    var bmNumMe = (res.substr(0,1) == 'y') ? '!' : '';
				allRes[1][a][b][12] = bmNumMe + bmNumOthers;
			}
		} 
	}
	noMsg();     
}

function getBMarksPart(bmArcId,bmYes,numOthers) {
	if(!numOthers) {numOthers = 0;}
	var bookmarks = '';
	var addOnTheS = (numOthers > 1) ? 's' : '';
	if(bmYes) {
 	bookmarks += "Bookmarked by <b><a href='javascript:if(confirm(\"Remove bookmark from this arc?\")) bMarkMyArcs(\"no\","+bmArcId+");'>You</a></b>";
  if(numOthers > 0) {
  	bookmarks += ', <span id=others'+bmArcId+'>' + numOthers + '</span> other'+addOnTheS+'.';
  } else {
  	bookmarks += '<span id=others'+bmArcId+'></span>.';
  }
 } else {
  if(numOthers > 0) {
  	bookmarks += 'Bookmarked by <span id=others'+bmArcId+'>'+numOthers+"</span> other"+addOnTheS+". <a href='javascript:bMarkMyArcs(\"yes\","+bmArcId+");'>Add</a>";
  } else {
   bookmarks += "<a href='javascript:bMarkMyArcs(\"yes\","+bmArcId+");'>Add bookmark<span id=others"+bmArcId+"></span></a>";
  }
 }
 return bookmarks;
}

function initBMarkAsk() {
	if(!anothersArc || loginId == '' || !EL("bmarklink").innerHTML.match(/Add/i)) { return; }
	bookmarkAskTimer = window.setTimeout('askBMarkDone=false; askToBMark();',15000);
}

function askToBMark() {
	if(!anothersArc || loginId == '' || askBMarkDone) { return; }
	if(toolbarAutoScroll == 0 && scrollTop() != 0) { doneWithBMAsk(); return; }
	EL('askBMarkCont').className = 'askToBMarkCont';
	EL('askBMarkCont').style.right = (parseInt(windowWidth()/2-492)+166) + 'px';
	EL('askBMarkCont').style.top = '73px';
}

function doneWithBMAsk() {
	EL('askBMarkCont').className = 'hidden';
	EL('askBMarkCont').innerHTML = '';
	askBMarkDone = true;
}

function doA101Feed() {
 return (trim(EL("feedback").value) != "");
}

function showStepName() {
	var intStepNum = parseInt(EL('jumpStepNum').value);
	if(intStepNum != EL('jumpStepNum').value || intStepNum < 1 || intStepNum > numsteps) {
		intStepNum = 0;
	}
	EL("jumpStepName").innerHTML = stepnames[intStepNum];
}


function goBigMap() {
	if(platform == "Win") {
	 for(b=0; EL('a101ContGraphic').childNodes[b]; b++) {
	 	if(EL('a101ContGraphic').childNodes[b].className == '') {
	 		tmpHiddenObj = EL('a101ContGraphic').childNodes[b];
				tmpHiddenObj.className = 'hidden';
				break;
	 	}
	 }
	}
 goBG(1);
 EL("relMapBigCont").className = 'relMapBigCont';
	EL("relMapBigCont").style.left = parseInt(windowWidth()/2-EL('relMapBigCont').offsetWidth/2)-7 + "px";
	EL("relMapBigCont").style.top = midFrTop("relMapBigCont");
 EL("relMapSm").blur();
}

function bigMapClose() {
 EL('relMapBigCont').className = 'hidden';
	EL("relMapBigCont").style.left = '';
	EL("relMapBigCont").style.top = '';
 noBG(1);
	if(platform == "Win" && tmpHiddenObj) { tmpHiddenObj.className = ''; tmpHiddenObj = null; }
}

function placeBreakEnds() {
	if(author) { return; }
	var breakends = '';
	var contpos = findPos(EL('breakends'));
	for(v=0; v<numProps+1; v++) {
		var xypos = findPos(EL('ydot'+v));
		breakends += breakEndTemplate.replace(/DOTNUM/g,v).replace(/XPOS/g,xypos[0]-contpos[0]).replace(/YPOS/g,xypos[1]-(contpos[1]+(17*v))-5);
		//17 from the previous line needs to match the height of the ydotcover class.
	}
	EL('breakends').innerHTML = breakends;
}

function clearBreakEnds() {
	EL('breakends').innerHTML = '';
}

function yDotHover(dotnum) {
	if(selectedPropBreak == dotnum) { return; }
	EL("ydot"+dotnum).className = 'ydot2';
}

function yDotOff(dotnum) {
	if(selectedPropBreak == dotnum) { return; }
	EL("ydot"+dotnum).className = 'ydot';
}

function saveBlogInfo() {
 var parameters = "arcid=" + arcId + "&passage=" + escape(passage);
	parameters += "&blogid="+EL('arcblogselect').value;
 for(b=1; EL('tweet'+b); b++) {
 	parameters += "&tweet"+b+"="+escape(EL('tweet'+b).value);
 }
 parameters += "&uid="+loginId;
 doAjax("savebloginfo1",gDirPrefix+"/submitblogentry.php",parameters,true);
}

function submitBlog() {
 if(colVer[0] == "unknown") {
  alert("Before you submit this arc as a blog entry, please indicate which translation(s) were used.\n\n(Do so on the right bar of the \"Notes\" tab.)");
  return false;
 }
 if(defaultArcsOnly || numProps<3 || EL("labels").innerHTML.length<500) {
  alert("You must complete your arc before you can submit it as a blog entry.");
  return false; 
 }
 var tNote = tinyMCE.get('notesTA');
 var isNotes = (trim(tNote.getContent()) != "");
 if(!isNotes) {
  alert("You must work on some thoughtful notes before you submit it as a blog entry.");
  return false;
 }
 var re = new RegExp(passage.substring(passage.indexOf(' ',2)),'i');
 if(arcName.match(re) || trim(arcName) == "") {
  alert("You must choose a descriptive name that does not include the passage reference before submitting this arc as a blog.");
  return false;
 }
 for(w=1; EL('tweet'+w); w++) { EL('tweet'+w).value = trim(EL('tweet'+w).value); }
 if(EL('tweet1').value=='' || EL('tweet2').value=='' || EL('tweet3').value=='') {
  alert("You must enter at least three tweets before submitting this arc as a blog.");
  return false;
 }
 if(saveUserId == 0) {
  alert("Before you submit this arc as a blog entry, you must save it.");
  return false;
 } else if(isSaved != 2) {
  goMsg(2,"Saving...",-1,"");
  ajaxSave(false,false);
  postSaveAct = 'submitblog';
  return false; 
 }
 
 if(!confirm('Are you sure you want to submit this arc as a blog entry?')) { return false; }
 
 goMsg(2,"Submitting blog entry...",-1,"");
 var parameters = "arcid=" + arcId + "&submitblog=true" + "&passage=" + escape(passage);
	parameters += "&blogid="+EL('arcblogselect').value;
 for(b=1; EL('tweet'+b); b++) {
 	parameters += "&tweet"+b+"="+escape(EL('tweet'+b).value);
 }
 parameters += "&uid="+loginId;
 doAjax("submitblog1",gDirPrefix+"/submitblogentry.php",parameters,false);
}

function submitBlog2() {
 for(b=1; EL('tweet'+b); b++) {
 	EL('tweetspan'+b).innerHTML = EL('tweet'+b).value;
 }
	EL('arcblogselect').disabled = true;
	EL('arcblogsubmitspot').innerHTML = 'This arc has already been submitted for approval, but is not yet approved. Thus, changes you make will be included in this arc when it is evaluated for approval.';
 noMsg();
}

function goBlogArchive(blogIdPlusDate) {
	if(blogIdPlusDate == 0) { return; }
	if(blogIdPlusDate == '-') { EL('archivelist').selectedIndex = 0; return; }
 window.location = "http://" + serverName + gDirPrefix + "/blogs/"+blogIdPlusDate;
}

function capTALength(maxLen,tArea,countSpot,charsToStrip) {
	if(charsToStrip != '') {
		tArea.value = tArea.value.replace(new RegExp("[\\"+charsToStrip+"]","g"),'');	
	} 
	tArea.value = tArea.value.substr(0,maxLen);
	countSpot.innerHTML = maxLen - tArea.value.length;
}
