/* access.js: Search routines, search boxes, and cookie read/write and
 CSS\DOM alter only. Also Buttons and complex WAI switching.
 For easy expansion/revert, some functions here available as void in
 Acssub. Textsize switches classes instead of styles, as style.float has a
 reserved word. */

d_=document;
ackts=' accesskey="+"';
acknv=' accesskey="@"';
buttxtact=false;//Have active links following buttons or just plain text.

txtsz=false;nvad=txtsz;//Set default values.

function CookieObey(){//onload Wedge.
u=d_.cookie;if(u.indexOf("TextSize=Large")>-1)tst();
if(u.indexOf("NavAids=Hide")>-1)togglenv()}

function togglenv(){if(!d_.getElementsByTagName)return;
var L,LL,i;
u=d_.getElementsByTagName("input");
if(nvad){m="visible";n="inherit";L="Hide";LL="Show"}
 else{m="hidden";n="none";L="Show";LL="Hide"}
nvad=(!nvad);
for(i=0;u.length>i;i++)
 if(u[i].getAttribute("className")=="but")u[i].value=L
s("a");s("p");//Add further tags as/if ness.
createCookie("NavAids",LL);
function s(t){u=d_.getElementsByTagName(t);
for(i=0;u.length>i;i++){if(u[i].getAttribute("className")=="nav")
 {u[i].style.visibility=m;u[i].style.speak=n}}}}

function tst(){if(!d_.getElementsByTagName)return;
var m,L,LL,CSa,CSb,CSc,CSd;
if(txtsz){m="12pt";L="Large";LL="Normal";CSa="co2l";CSb="coll";CSc="co2r";
CSd="colr"}else{m="24pt";L="Normal";LL="Large";CSa="coll";CSb="co2l";
CSc="colr";CSd="co2r"}
txtsz=(!txtsz);
u=d_.getElementsByTagName("input");for(i=0;u.length>i;i++)
 {if(u[i].getAttribute("className")=="tsb")u[i].value=L}
u=d_.getElementsByTagName("div");
for(i=0;u.length>i;i++){var uu=u[i],un=uu.getAttribute("className");
 if(un==CSa)uu.className=CSb;if(un==CSc)uu.className=CSd}
d_.getElementsByTagName("body")[0].style.fontSize=m;
createCookie("TextSize",LL)}


// Buttons and complex WAI switching:

function navaid2(){//Don't offer to switch off Navigation if you can't.
if(d_.getElementsByTagName){//Normal behaviour:
d_.write('So you can turn them off (and back on again) in this document.\n'
 +'Also, text hidden in this manner will not be spoken by an Aural'
 +' Browser.\nIn all cases, they will not show when the document is'
 +' printed.\x3cBR\x3eTo\n\x3cINPUT class=but type=button value="Hide"'
 +' onclick="togglenv()"\n onkeypress="togglenv()"\x3e them, activate the'
 +' button.\n')
}else{//Can't handle; simulate NOSCRIPT ("enable js" bits amended):
d_.write('Because \x3cB\x3ejavascript is non-standard on\nthis machine'
 +'\x3c/B\x3e, you cannot easily turn off navigation aids. You can'
 +' remedy\nthis by altering the CSS in the source of this document.'
 +' Search for\n&quot;ACCESS!&quot; when editing the page for'
 +' instructions on what to alter.\n')}}

function navbut(){//Don't offer Buttons if they won't work:
if(!d_.getElementsByTagName) return;//Can't handle; simulate NOSCRIPT.
d_.write('\x3cP\x3e\x3cINPUT class=but type=button value="Hide"\n'
 +' onclick="togglenv()" onkeypress="togglenv()"'+acknv+'\x3e\n');
if(buttxtact)d_.write('\x3cA href="#navaid"\x3e');
d_.write('Navigation Aids');
if(buttxtact)d_.write('\x3c/A\x3e');
d_.write('.\n');acknv=""}

function textaid2(){//Don't offer to switch off Navigation if you can't.
if(d_.getElementsByTagName){//Normal behaviour:
d_.write('You can change the text size in this document. (This change'
 +' \x3cI\x3ewill\x3c/I\x3e\naffect printing.)\x3cBR\x3eTo change to'
 +' \x3cINPUT class=tsb type=button value="Large"\n onclick="tst()"'
 +' onkeypress="tst()"\x3e text, activate the button.\n')
}else{//Can't handle; simulate NOSCRIPT ("enable js" bits amended):
d_.write('\nBecause javascript is non-standard on this machine, you'
 +' cannot easily change\nthe text size, unless there is a function for'
 +' this in your Browser (please\nconsult your mannual). You can remedy'
 +' this by either enabling javascript, or\naltering the CSS in the'
 +' source of this document. Search for &quot;BODY{&quot;\nwhen editing'
 +' the page, and change &quot;12pt&quot; to &quot;24pt&quot;, or\n'
 +'whatever base size you like for that matter. Columns will be hard to'
 +' switch\nunless experienced users of CSS can copy the definitions of'
 +' double across to\nsingle. This is a non-essential feature, so no'
 +' extra help has been provided.\n')}}

function sizebutb(sfx){//Don't offer Buttons if they won't work:
if(!d_.getElementsByTagName) return;//Can't handle; simulate NOSCRIPT.
d_.write(sfx+'Switch to \x3cINPUT class=tsb type=button value="Large"'
 +' onclick="tst()"\n onkeypress="tst()"'+ackts+'\x3e ');
if(buttxtact)d_.write('\x3cA href="#textsize"\x3e');
d_.write('text size');
if(buttxtact)d_.write('\x3c/A\x3e');
d_.write('.\n');ackts=""}

function sizebut(){
if(!d_.getElementsByTagName) return;
sizebutb('\x3cP\x3e')}

function bothbut(){//Compact display.
if(!d_.getElementsByTagName) return;
navbut();sizebutb(' ')}


// Search box support:

function seartb(){d_.write('\x3cINPUT type=button value='
+'" this Page "\n title="Search and highlight in this page only:\naccesskey'
+' %" accesskey="%" class=searpage onclick="search(d_.searbx)"\x3e')}
// No newline on end.

function searthis(){if(incompat) return;//No option if not possible.
d_.write('\x3cBR\x3e');seartb()}

// Similar; whole FORM in js:
function searthisonly(){if(incompat) //No option if not possible.
d_.write('\x3cDIV id=searalt\x3eUse your Browser\'s search facility to '
+'search text in this\npage, or export content to a Text&nbsp;Editor.\x3c'
+'/DIV\x3e\n'); else{
d_.write('\x3cFORM name=searbx id=searbx action="" style="width:9em"\x3e\n'
+'\x3cLABEL title="Type your query here"\x3eFind\n\x3cINPUT '
+'name=query size=10\x3e\x3c/LABEL\x3e\x3cBR\x3e\nin ');
seartb();
d_.write('\x3cBR\x3e\x3cA class=fffont href="/find.php"\x3eAdvanced find'
+'\x3c/A\x3e\n');
d_.write('\x3c/FORM\x3e\n')}}


// Third party code:

// Cookie functions crunched from tutorial by Peter-Paul Koch
// in http://www.quirksmode.org/js/cookies.html

function createCookie(name,value){//Expiry date is always 5 years ahead.
var date=new Date();date.setTime(date.getTime()+157680000000);
d_.cookie=name+"="+value+"; expires="+date.toGMTString()+"; path=/"}

// Find In Page Script by Alan Koontz alankoontz@REMOVETHISyahoo.com
// Via http://www.dynamicdrive.com/ (Crunched)

var tRg=null,dupeRange=null,TstRg=null;
var agt=navigator.userAgent.toLowerCase();
var is_major=parseInt(navigator.appVersion);
var is_minor=parseFloat(navigator.appVersion);
var is_ie4up=((agt.indexOf("msie")!=-1)&&(is_major>=4));
var is_not_moz=(agt.indexOf('netscape')!=-1);
var is_nav4=(((navigator.appName.toLowerCase()).indexOf('netscape')!=-1)&&(is_major==4));
var is_gecko=(agt.indexOf('gecko')!=-1);
var is_rev=0;if(is_gecko){temp=agt.split("rv:");is_rev=parseFloat(temp[1])}
var incompat=((is_ie4up&(agt.indexOf("mac")!=-1))|(is_gecko&(1>is_rev))|(agt.indexOf("opera")!=-1));

function search(){wfm=d_.searbx.query;
if(wfm.value!=null&&wfm.value!='')str=wfm.value; else return;
if(is_nav4&&(5>is_minor))sF=self.find(str);if(is_gecko&&(is_rev>=1))
{sF=self.find(str,false,false,true);if(is_not_moz)wfm.focus()}
if(is_ie4up){if(tRg!=null){TstRg=d_.body.createTextRange();
if(dupeRange.inRange(TstRg)){tRg.collapse(false);sF=tRg.findText(str);
if(sF){d_.body.scrollTop=d_.body.scrollTop+tRg.offsetTop;tRg.select()}}
else{tRg=d_.body.createTextRange();tRg.collapse(false);subr()}}
if(tRg==null||sF==0){tRg=d_.body.createTextRange();
dupeRange=tRg.duplicate();subr()}}if(!sF)alert("'"+str+"' not there.")}
function subr(){sF=tRg.findText(str);
if(sF){d_.body.scrollTop=tRg.offsetTop;tRg.select()}}

