//=======================This opening is not a function. It happens with every page 
hotID="a"
bgScheme=getCookie("ColorScheme","Tan")
algScheme=getCookie("AlignmentScheme","justify")
Ref=getCookie("Ref","OWD")
switch(bgScheme){	//pbgc=page background color, bbgc=body background color, fgc=foreground color(i.e.text color)
	case "Tan"	:pbgc="#edc";bbgc="#fed";fgc="#000";break	//e2d6c0
	case "Green"	:pbgc="#dfb";bbgc="#be8";fgc="#000";break	//baf190
	case "Red"	:pbgc="#fde";bbgc="#fef";fgc="#000";break 	//fcb7e4
	case "White"	:pbgc="#fff";bbgc="#ddd";fgc="#000";break	//e3e3e3
	case "Black"	:pbgc="#000";bbgc="#555";fgc="#fff";break
	case "Blood"	:pbgc="#000";bbgc="#666";fgc="#f00";break
	default		:pbgc="#bdf";bbgc="#cef";fgc="#000";bgScheme="Blue";break	//aad1fc
}

document.ondblclick = goPage;		/*this calls the dictionary lookup routines*/

document.writeln('<style>'
+'	body {'
+'		background-color:'+bbgc+';'
+'		background-image:url(bg'+bgScheme+'.gif);'
+'	}'
+'	p,p.note,dl,dd,dt,li,h1,h2,h3,h4,td,table,ul,ol,blockquote {'
+'		background-color:'+pbgc+';'
+'		color:'+fgc+';'
+'	}'
+'	dl,.end{'
+'		text-align:'+algScheme+';'
+'	}'
+'	</style>'
)
if (!gebi('icon')){				/*if there's not an icon already specified, then set it here*/
	document.writeln('<link rel="icon" href="favicon.ico" type="image/x-icon">'
	+'<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">'
	)}
document.writeln(''
+'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
+'<body onkeyup="hotkey(event);">'
)

//===============================================================================

function subBox(num){
document.writeln(
'	<form name="signup" action="http://groups.google.com/group/mpoets/boxsubscribe" method="get">'
+'		<img id=logo'+num+' src=MPS200x200.gif height=100 style="float:left" onmouseover="exchng(this.id);">'
+'		<a rel=license href="http://creativecommons.org/licenses/by-nc-sa/3.0/">'
+'			<img alt="Creative Commons License" border=0 src=somerights20.png style="float:right"></a>'
+'		<table border="0" cellspacing="0" cellpadding="5" width="200" style="margin-bottom:0;">'
+'			<tr><td align=center nowrap style="text-align:center;font-family:arial,helvetica;font-size:small;color:#000000;background-color:#cf0">'
+'				<a href="http://groups.google.com/group/mpoets" target="google">Information</a>'
+'				or free subscription to our MPoets Newsletter<br>'
+'				<div style="text-align:left;font-family:arial,helvetica;font-size:x-small;color:#000000">'
+'				Enter your email address:</div>'
+'				<input name="email" type="text" size=30>&nbsp;'
+'				<input name="joingroup" type="image" align="absmiddle" alt="Click Here To Join!" src="SubButton.gif" border="0" height="32" >'
+'				<input type="hidden" name="sub" value="Subscribe"><br><br>'
+'			</td></tr>'
+'		</table>'
+'	</form>'
)}

function navBar(){
document.writeln('<br>'
+'		<button title="Authors"	 	onclick=window.location="AuthorIndex.htm" style=width:32%>Index of Authors</button>&nbsp;'
+'		<button title="First Lines" 	onclick=window.location="FirstIndex.htm" style=width:32%>Index of First Lines</button>&nbsp;'
+'		<button title="Titles" 		onclick=window.location="TitleIndex.htm" style=width:32%>Index of Titles</button>&nbsp;'
+'		<hr 	onclick=window.location="http://mpoets.org">'
+'		<button title="Back" 		onclick=history.back()>Press to Return from Whence You Came ...</button>&nbsp;'
+'		<button title="Home Page" 	onclick=window.location="index.html">Press for More Light</button>&nbsp;'
+'		<button title="Customize this site\'s appearance" onclick=window.open("Customization.htm","custom",'
+'"directories=no,location=no,menubar=no,status=no,toolbar=no,width=600,scrollbars=yes,resizable=yes")>'
+'Customize</button><br><br>'
)}

function aalphabet(file){			/*authors--used only on index pages*/
if(file==undefined)file=""
document.writeln(
'<p class=c style="padding:5px;background-color:#cf0;"><a'
+' href='+file+'#top	title="Table of Contents">Authors</a><a'
+' href=AuthorIndex.htm		title="Authors Index"><b>.</b></a><a'
+' href=FirstIndex.htm	title="First Lines Index">·</a><a'
+' href=TitleIndex.htm	title="Titles Index"><b>.</b></a>|<a'
+' href='+file+'#aa>A</a>|<a'
+' href='+file+'#ab>B</a>|<a'
+' href='+file+'#ac>C</a>|<a'
+' href='+file+'#ad>D</a>|<a'
+' href='+file+'#ae>E</a>|<a'
+' href='+file+'#af>F</a>|<a'
+' href='+file+'#ag>G</a>|<a'
+' href='+file+'#ah>H</a>|<a'
+' href='+file+'#ai>I</a>|<a'
+' href='+file+'#aj>J</a>|<a'
+' href='+file+'#ak>K</a>|<a'
+' href='+file+'#al>L</a>|<a'
+' href='+file+'#am>M</a>|<a'
+' href='+file+'#an>N</a>|<a'
+' href='+file+'#ao>O</a>|<a'
+' href='+file+'#ap>P</a>|Q|<a'
+' href='+file+'#ar>R</a>|<a'
+' href='+file+'#as>S</a>|<a'
+' href='+file+'#at>T</a>|U|<a'
+' href='+file+'#av>V</a>|<a'
+' href='+file+'#aw>W</a>|X|Y|Z|'
+'</p>')
}

function falphabet(file){			/*First Lines--used only on index pages*/
if(file==undefined)file=""
document.writeln(
'<p class=c style="padding:5px;background-color:#cf0;"><a'
+' href='+file+'#top	title="Table of Contents">First Lines</a><a'
+' href=AuthorIndex.htm		title="Authors Index"><b>.</b></a><a'
+' href=FirstIndex.htm	title="First Lines Index">·</a><a'
+' href=TitleIndex.htm	title="Titles Index"><b>.</b></a>|<a'
+' href='+file+'#fa>A</a>|<a'
+' href='+file+'#fb>B</a>|<a'
+' href='+file+'#fc>C</a>|<a'
+' href='+file+'#fd>D</a>|<a'
+' href='+file+'#fe>E</a>|<a'
+' href='+file+'#ff>F</a>|<a'
+' href='+file+'#fg>G</a>|<a'
+' href='+file+'#fh>H</a>|<a'
+' href='+file+'#fi>I</a>|<a'
+' href='+file+'#fj>J</a>|<a'
+' href='+file+'#fk>K</a>|<a'
+' href='+file+'#fl>L</a>|<a'
+' href='+file+'#fm>M</a>|<a'
+' href='+file+'#fn>N</a>|<a'
+' href='+file+'#fo>O</a>|<a'
+' href='+file+'#fp>P</a>|Q|<a'
+' href='+file+'#fr>R</a>|<a'
+' href='+file+'#fs>S</a>|<a'
+' href='+file+'#ft>T</a>|<a'
+' href='+file+'#fu>U</a>|<a'
+' href='+file+'#fv>V</a>|<a'
+' href='+file+'#fw>W</a>|X|<a'
+' href='+file+'#fy>Y</a>|Z|'
+'</p><p class=l style=\'margin:0 "";\'>')
}

function talphabet(file){			/*titles--used only on index pages*/
if(file==undefined)file=""
document.writeln(
'<p class=c style="padding:5px;background-color:#cf0;"><a'
+' href='+file+'#top	title="Table of Contents">Titles</a><a'
+' href=AuthorIndex.htm		title="Authors Index"><b>.</b></a><a'
+' href=FirstIndex.htm	title="First Lines Index">·</a><a'
+' href=TitleIndex.htm	title="Titles Index"><b>.</b></a>|<a'
+' href='+file+'#ta>A</a>|<a'
+' href='+file+'#tb>B</a>|<a'
+' href='+file+'#tc>C</a>|<a'
+' href='+file+'#td>D</a>|<a'
+' href='+file+'#te>E</a>|<a'
+' href='+file+'#tf>F</a>|<a'
+' href='+file+'#tg>G</a>|<a'
+' href='+file+'#th>H</a>|<a'
+' href='+file+'#ti>I</a>|<a'
+' href='+file+'#tj>J</a>|<a'
+' href='+file+'#tk>K</a>|<a'
+' href='+file+'#tl>L</a>|<a'
+' href='+file+'#tm>M</a>|<a'
+' href='+file+'#tn>N</a>|<a'
+' href='+file+'#to>O</a>|<a'
+' href='+file+'#tp>P</a>|<a'
+' href='+file+'#tq>Q</a>|<a'
+' href='+file+'#tr>R</a>|<a'
+' href='+file+'#ts>S</a>|<a'
+' href='+file+'#tt>T</a>|<a'
+' href='+file+'#tu>U</a>|<a'
+' href='+file+'#tv>V</a>|<a'
+' href='+file+'#tw>W</a>|X|<a'
+' href='+file+'#tx>Y</a>|Z|'
+'</p><p class=l style=\'margin:0 "";\'>')
}

function footer(){
	document.writeln("<h6 align=right>End of file <span style='color:blue'>",
	document.URL+"</span>, last Updated:",document.lastModified,"</h6>")
	}

function gebi(objID){		     	     /* gebi */
	//getElementById for various browsers
	return document.getElementById ? document.getElementById(objID) : document.all ? document.all[objID] : "";
}

function setCookie(name,value,dte){		/* setCookie */
	//Third parameter is optional. dte=days till expiration; defaults to 90 days
	expires=new Date()
	expires.setTime(expires.getTime()+ 86400000*(dte ? dte : 90))	//86400000=milliseconds in 1 day
	document.cookie=name+"="+escape(value)+"; expires="+expires.toUTCString()
}

function getCookie(name,defalt) {			/* getCookie */
	//optional second argument will return if not found, otherwise return string contains null if cookie doesn't exist
	dc=document.cookie
	prefix=name+"="
	begin=dc.indexOf("; "+prefix)				//find exact match
	if(begin==-1){								//if not found
		begin=dc.indexOf(prefix)				//check first item
		if(begin != 0){	return defalt }			//if not there either return default or null
	}else{begin+=2}								//skip "; " (unless it was first cookie)
	end=dc.indexOf(";", begin);					//end at start of next cookie
	if(end==-1){ end=dc.length }				//...unless this is the final cookie
	return unescape(dc.substring(begin+prefix.length, end));	//return string contains value of cookie
}

function exchng(tid){
	if(gebi(tid).src.slice(-14)!="MPS200x200.gif"){
	gebi(tid).src="MPS200x200.gif"
	}else{
	gebi(tid).src="MPS212x200.gif"
	}
}

function exchang(thisID,thatID){
	if(gebi(thisID).style.display=="none"){
		gebi(thisID).style.display="inline"
		gebi(thatID).style.display="none"
	}else{
		gebi(thisID).style.display="none"
		gebi(thatID).style.display="inline"
	}
}

function schemeSelect(color){
	bgScheme=color
	setCookie("ColorScheme",color,370)
	history.go(0)
}
function alignSelect(algn){
	algScheme=algn
	setCookie("AlignmentScheme",algn,370)
	history.go(0)
}

function refSelect(ref){
	Ref=ref
	setCookie("Ref",ref,370)
	history.go(0)
}

function hotkey(event){
	if(event.altKey){
	key=event.keyCode
	if(key==65 || key==97 || key==76 || key==108){	//A or a or L or l (A is already pre-empted in IE)
		if(algScheme=="center")alignSelect("left")
		else alignSelect("center")
	}
	else if(key==67 || key==99){	//C or c
		switch(bgScheme){
			case "White"	:schemeSelect("Black");break
			case "Black"	:schemeSelect("Blood");break
			case "Blood"	:schemeSelect("Tan");break
			case "Tan"	:schemeSelect("Green");break
			case "Green"	:schemeSelect("Red");break
			case "Red"	:schemeSelect("Blue");break
			default		:schemeSelect("White");
		}
	}
	else if(key==87 || key==119){	//W or w
		schemeSelect("White")
	}
	}
}
	
function CDetect(content){document.writeln(''
+'<table style="width:150px;margin:auto 0 auto 0">'
+'	<tr><td class="s c" style="background-color:#999;color:white;">'
+'		Notify me when '+content+' is added'
+'	<tr><td class="xs r" valign=top>'
+'		<form action="http://www.ChangeDetection.com/detect.html" method="get" target=custom>'
+'		<input style="width:100%;" type="text" name="email"  value="enter email">'
+'	<tr><td class=r>'
+'		<input type="submit" name="enter" value=" OK " onclick="somewin=window.open("http://www.ChangeDetection.com/page.html", "CD","resizable=yes,scrollbars=yes,width=624,height=460");somewin.focus()">'
+'		</form>'
+'	<tr><td class="xs c">'
+'	powered by<br><a  href="http://www.ChangeDetection.com/" target=custom>ChangeDetection</a>'
+'</table>')
}

function XSearch(){
document.writeln(''
+'	<div style="border:2px outset;width:100%;margin:0 auto;padding:2px 2px 2px 2px;">'
+'	<div class="s c" style="background-color:#999;color:white;text-align:left;padding:.5em 10px; ">'
+'		Search for this word or phrase:</div>'
+'		<div style="padding:0 10px 0 0;zoom:1;">'
+'		<input type=text id=phrase'
+'			style="margin:1px 0;width:100%;border:1px solid #7E9DB9;color:#666;height:18px;padding:0px 3px; background:#fff;">'
+'		</div>'

+'		<input type=radio name=srch id=web style="margin-right:5px;">'
+'		<label for=srch1 style="display:inline;padding-top:2px;"> Entire Web</label>'
+'		<input type=radio name=srch id=mps style="margin-right:5px;" checked="checked">'
+'		<label for=srch1 style="display:inline;padding-top:2px;margin-right:15px;"> Masonic Poets Society site</label>'
+'<br>'

+'		<input type=radio name=engine id=google style="margin-right:5px;" 	checked="checked">'
+'		<label for=google style="display:inline;padding-top:2px;"> Google</label>'
+'		<input type=radio name=engine id=yahoo style="margin-right:5px;">'
+'		<label for=yahoo style="display:inline;padding-top:2px;"> Yahoo</label>'

+'		<button id=SearchButton style="margin-left:25px;" onclick=window.open(readRadios(),"custom",'
+'"directories=no,location=no,menubar=no,status=no,toolbar=no,width=600,scrollbars=yes,resizable=yes")>'
+'Search</button><br><br>'
+'		</ul></div>')
}

function readRadios(){
	if (gebi("yahoo").checked && gebi("web").checked) return "http://search.yahoo.com/search?p="+gebi("phrase").value
	if (gebi("yahoo").checked && gebi("mps").checked) return "http://search.yahoo.com/search?p="+gebi("phrase").value+"&vs=mpoets.org"
	if (gebi("google").checked && gebi("web").checked) return "http://www.google.com/search?q="+gebi("phrase").value
	/*default*/ return "http://www.google.com/search?as_q="+gebi("phrase").value+"+site:mpoets.org"
}



//=======================This section is the dictionary lookup routines, from http://www.websters-online-dictionary.org/js/define.js

function findSelection(){
	if (document.getSelection){ txt = document.getSelection();}
	else if (document.selection){ txt = document.selection.createRange().text;}
	else {return "";}
	return txt;
}


function goPage(){
	if (Ref=="TFD")RefURL="http://www.thefreedictionary.com/"
	else if (Ref=="Google")RefURL="http://www.google.com/search?q=define:"
	else if (Ref=="Wikipedia")RefURL="http://en.wikipedia.org/wiki/"
	else if (Ref=="Wiktionary")RefURL="http://en.wiktionary.org/wiki/"
	else {Ref="OWD"; RefURL="http://www.websters-online-dictionary.org/search/?s="}
	var result = findSelection();
	if (result != "") {
		var toast = window.open(RefURL+encodeUTF(result),'custom','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=510');
	}
}
function keyhandler(e) {
    if (window.event) { Key = window.event.keyCode; }
    else { Key = e.which;}
    if (Key == 100) { 
	goPage();
    }
}
function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeUTF(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}
//===============================================================================
/*function navBarOld(){
document.writeln(
'	<hr size=12 color=tan onclick=window.location="index.html">'
+'	<form style="margin-top:0;" >'
+'		<input type=button value="Press to Return from Whence You Came ..." onclick=history.back()'
+'			 title="Press to Return from Whence You Came" alt="Press to Return from Whence You Came"> '
+'		<input value="Press for More Light" onclick=window.location="http://masonic-poets-society.com/index.html" type=button'
+'			 title="Press for More Masonic Poets" alt="Press for More Masonic Poets">'
+'		<input value="Customize" onclick=window.open("Customization.htm","custom",'
+'"directories=no,location=no,menubar=no,status=no,toolbar=no,width=600,scrollbars=yes,resizable=yes")'
+'			type=button title="Customize this site\'s appearance" alt="Customize this site\'s appearance">'
+'	</form><br>'
)}
//+'	<hr class=navBar style=float:left title="Authors Index" onclick=window.location="AuthorIndex.htm">'
//+'	<hr class=navBar style=float:right title="First Lines Index" onclick=window.location="FirstIndex.htm">'
//+'	<hr class=navBar style=float:none title="Titles Index" onclick=window.location="TitleIndex.htm">'
*/
/*function GSearch(){
document.writeln(''
+'<script src="http://gmodules.com/ig/ifr?url=http://www.google.com/coop/api/003788866548731145772/cse/omynh6cfcd4/gadget&amp;synd=open&amp;w=600&amp;h=75&amp;title=Masonic+Poetry+Search+Engine&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script><h2>Special Sections</h2>'
)}*/

/*function YSearch(){
document.writeln('<!-- START CODE -->'
+'	<div id="ysrchForm" style="border:2px outset ;		'
+'						 width:100%;				'
+'						 margin:0 auto;			'
+'						 padding:2px 2px 20px 2px; 	'
+'						 position:relative;">		'
+'	<div class="s c" style="background-color:#999;color:white;text-align:left;padding:1em 0 1em 10px;vertical-align:middle">	'
+'		Search for this word or phrase:</div>'
+'	<form id="searchBoxForm_U0bf6114900df5653af61" style="padding:0;" action="http://builder.search.yahoo.com/a/bouncer">		'
+'		<input type="hidden" name="mobid"	value="U0bf6114900df5653af61">'
+'		<input type="hidden" name="ei" 	value="UTF-8">	'
+'		<input type="hidden" name="fr" 	value="ystg-c">'
+'		<div style="padding:0 10px 0 0;zoom:1;">		'
+'			<input type="text" name="p" id="searchTerm"'
+'					onFocus="this.style.background=\'#fff\';"'
+'					onBlur="if(this.value==\'\')this.style.background=\'#fff url(http://us.i1.yimg.com/us.yimg.com/i/us/sch/gr/horiz_pwrlogo_red2.gif) 3px center no-repeat\'"'
+'					style="margin:1px 0;width:100%;border:1px solid #7E9DB9; color:#666666;height:18px;padding:0px 3px; background:#fff 3px center no-repeat url(http://us.i1.yimg.com/us.yimg.com/i/us/sch/gr/horiz_pwrlogo_red2.gif); position:relative;">'
+'		</div>'
+'		<ul style="color:#666666;'
+'			font:11px/11px normal Arial, Helvetica, sans-serif;'
+'			margin:0;padding:0;		'
+'			text-align:left;		'
+'			list-style-type:none;">	'
+'		<li style="display:inline;padding-right:10px;">'
+'		<input name="mobvs" id="web_U0bf6114900df5653af61" value="0" onclick=\'displayPopSearch("web","U0bf6114900df5653af61");\'	type="radio" style="vertical-align:middle;margin-right:5px; ">'
+'		<label for="web_U0bf6114900df5653af61" style="display:inline;vertical-align:middle; padding-top:2px;">'
+'			Web</label>'
+'		<li style="display:inline;padding-right:10px;">'
+'		<input name="mobvs" id="site_U0bf6114900df5653af61" value="1" onclick=\'displayPopSearch("site","U0bf6114900df5653af61");\'	checked="checked" type="radio" style="vertical-align:middle;margin-right:5px; ">'
+'		<label for="site_U0bf6114900df5653af61" style="display:inline;vertical-align:middle; padding-top:2px;">'
+'			Masonic Poets Society site</label>'
+'		<li style="display:inline;padding-right:10px;">'
+'		<input type="submit" id="btn_U0bf6114900df5653af61" value="Search" '
+'			style="padding-bottom:2px;margin:0px;height:22px;width:65px;">'
+'		</ul></form></div>'
+'<!-- END CODE --> ')
}*/




