/* DOM check v1.0
 * Confirms that the browser is capable of utilizing most SI_functions
 * and hides unnecessary elements from these browsers. Apply the .non-dom class
 * to any element that is made redundant due to scripting.
 * ie. go buttons next to select menus with onchange event handlers
 *
 * Apply a class of .only-dom to elements that should only show up if JavaScript 
 * is available. Still some kinks to work out.
 * ie. FAQ toggle links/buttons that depend on JavaScript to perform their action
 */
if (SI_dom()) { document.write('<style type="text/css">.non-dom { display: none !important; } .only-dom {display: inherit !important; }<'+'/style>\n'); }

/* SI_dom() v1.0
 * Confirms that the browser is capable of 
 * getElementById and getElementsByTagName
 */
function SI_dom() { return new Boolean(document.getElementById && document.getElementsByTagName); };

/* SI_submitForm() v1.1
 * Usage: onchange/onclick="SI_submitForm(this.form);"
 */
function SI_submitForm(f) {
	if (!SI_dom()) return true;
	f.submit();
	}

/* SI_windowOpen() v1.0
 * Accessible pop-up windows that load the href in the current window
 * if JavaScript is disabled. 
 */
var SI_openWindow = new Object();
function SI_windowOpen(elem,center,w,h,opt) {
	if (!SI_dom()) return true;
	
	var src	= elem.href;
	var wnm	= (elem.target=='')?'SI_schoolSuite':((elem.target.indexOf('_')==0)?'SI'+elem.target:elem.target);
	var opt = (opt=='')?',scrollbars=yes,resizable=yes':((opt.indexOf(',')!=0)?','+opt:opt);
	var ctr	= (center)?',left='+((screen.availWidth-w)/2)+',top='+((screen.availHeight-h)/2):'';
	
	// A window has already been opened
	if (!SI_openWindow.closed && SI_openWindow.name==wnm && SI_openWindow.location) {
		SI_openWindow.location = src;
		}
	else {
		SI_openWindow = window.open(src,wnm,'width='+w+',height='+h+ctr+opt);
		if (!SI_openWindow.opener) SI_openWindow.opener = self;
		}
	if (window.focus) SI_openWindow.focus();
	return false;
	};

/* SI_clearFooter() v1.3c (Customized for Choate)
 * Use this function when absolutely positioning section navigation, 
 * primarary and secondary content and the footer falls below any one
 * of them. Absolute positioning avoids the unwanted wrapping that
 * sometimes occurs in IE PC when floats are used for layout.
 */
var SI_footer=new Object();
/* Configuration Defaults */
SI_footer.clear			= false;
SI_footer.container		= 'content';	// The inner container div
SI_footer.minHeight		= 410;	// Minimum page height in pixels
SI_footer.extendShallow = false;// Extends shallow children so that repeating backgrounds 
								// will repeat all the way to the footer - breaks print styles
SI_footer.bottomOut		= true;	// Whether the footer should just clear the contents of the 
								// inner-container div or snap to the bottom of the window 
								// when content is too short
function SI_clearFooter() {
	var d = document,w=window,dE=d.documentElement,dB=d.body,h;
	if (!SI_footer.clear || !d.getElementById || !dB.offsetHeight) return;
	
	var ic = d.getElementById(SI_footer.container); // The inner container div
	var ft = d.getElementById('footer');
	if (!ic||!ft||!window.loaded) return; // Added 04.08.23
	ic.style.height = '';		// Resets the height
	var oh = [];		// Holds the offset heights of each child div
	var icTop = ic.offsetTop;
	var winHeight	= (typeof(w.innerHeight)=='number')?w.innerHeight:(dE&&dE.clientHeight)?dE.clientHeight:(dB&&dB.clientHeight)?dB.clientHeight:0;
	var footHeight	= ft.offsetHeight;
	oh[0] = SI_footer.minHeight-icTop-footHeight;	// Minimum height of the inner-container div
	
	// Make an array of the rendered heights of the contained elements | #Customized for Choate's Back to Top button#
	for (i=0;i<ic.childNodes.length;i++) { c = ic.childNodes[i]; if (c.nodeName=='DIV' && c.id!='SI_topBtn') { c.style.height = ''; oh[oh.length] = parseInt(c.offsetHeight)+ parseInt(c.offsetTop); }}
	// Determine the max height
	h = 0; for (k=0;k<oh.length;k++) { h = (oh[k]>h)?oh[k]:h;}
	// Force footer to the bottom of the window 
	if (SI_footer.bottomOut) { h = ((icTop+h+footHeight) < winHeight)?winHeight-footHeight-icTop:h; }
	// Extend shorter elements
	if (SI_footer.extendShallow) { for (i=0;i<ic.childNodes.length;i++) { c = ic.childNodes[i]; if (c.nodeName=='DIV') { c.style.height = h+'px'; }}}
	/**/
	ic.style.height = h+'px';
	/**/
	};

/* SI_menu() v2.0
 * 
 * Holds IEs hand through what can be accomplished using only
 * CSS in other modern browsers. That's right, I said "modern."
 * In a medium that moves as fast the internet you didn't really
 * consider a 4 year old browser like IE modern did you? :P
 * 
 * Includes nodeName clarification which corrects
 * potential problems in IE 5.x (both platforms)
 * 
 * Now correctly applies the hover className to the li and not the link.
 * Removed RegExp from onmouseout by precaching the class names which speeds 
 * up the script phenomenally.
 */
function SI_menu() {
	var d = document;
	var isSafari 	= (navigator.userAgent.indexOf('Safari') != -1);
	var isIE 		= (navigator.appName == "Microsoft Internet Explorer");
	
	/* Safari doesn't need any help...
	 * Gecko needs a little help remembering which parent elements are currently :hover
	 * I have no idea what to do with Opera...
	 * IE needs the most help...
	 */
	if (!SI_dom() || window.opera || isSafari) return;
	
	var m=SI_menu.arguments;

	for(i=0; i<m.length; i++) {
		if (!d.getElementById(m[i])) continue; // Added 4.08.23
		for (var l=0; (lnk=d.getElementById(m[i]).getElementsByTagName("a")[l]); l++) {
			// If there are any nested menus...
			if (lnk.parentNode.childNodes.length > 1) {
				li = lnk.parentNode; // The containing <li>
				for (var n=0; n < li.childNodes.length; n++) {
					node = li.childNodes[n];
					if (node.nodeName=="UL") {
						li.ul = node; // The sibling <ul> (submenu)
						delete node;
						
						li.classDefault		= li.className;
						li.classHover		= li.className+((li.className=='')?'hover':' hover');
						
						li.isIE				= isIE;
						li.onmouseover		= SI_showMenu
						li.onmouseout		= SI_hideMenu
						//li.onclick			= SI_debug
						}
					}
				}
			}
		}
	}
function SI_showMenu() {
	this.className = this.classHover;
	if (this.isIE) {
		this.style.zIndex = 100;
		SI_toggleSelects('hidden'); 
		}
	}
function SI_hideMenu() {
	this.className = this.classDefault;
	if (this.isIE) {
		this.style.zIndex = 1;
		SI_toggleSelects('visible'); 
		}
	}
function SI_toggleSelects(state) {
	var d = document;
	var isWinIE		= (navigator.appName == "Microsoft Internet Explorer" && window.print);
	if (isWinIE) {
		for (var i=0; (sel=d.getElementsByTagName('select')[i]); i++) {
			sel.style.visibility = state;
			}
		}
	}
//function SI_debug() { alert(this.className) }

/* SI_initializeTabs()/SI_activateTab() v1.0
 * Accessible content tabbing that requires only one hit to the server
 * and degrades to simple HTML anchors when JavaScript is disabled.
 * Need to add: Support for multiple classes on ul.tabs li
 *
 * Changing `className` instead of `style.display` would allow for more 
 * control when dealing with print stylesheets.
 */
var SI_tabs=new Object();
function SI_initializeTabs() {
	for (var tab in SI_tabs) { 
		SI_activateTab(tab,SI_tabs[tab].active);
		}
	}
function SI_activateTab(tabGroup,activeTab) {
	var d = document;
	if (!d.getElementById) return;
	
	for (i=0; i<SI_tabs[tabGroup].tabs.length; i++) {
		//alert('tab-'+tabGroup+'-'+SI_tabs[tabGroup].tabs[i])
		tab = 'tab-'+tabGroup+'-'+SI_tabs[tabGroup].tabs[i];
		d.getElementById(tab).className = '';
		d.getElementById(tabGroup+'-'+SI_tabs[tabGroup].tabs[i]).style.display = 'none';
		}
	d.getElementById(tabGroup+'-'+activeTab).style.display = 'block';
	d.getElementById('tab-'+tabGroup+'-'+activeTab).className = 'active-tab';
	
	// Redraw the footer...
	SI_clearFooter();
	};

/* SI_initializeGroups()/SI_toggleGroups() v1.0
 * 
 */
var SI_groups=new Object();
function SI_initializeGroups() {
	var d = document;
	if (!d.getElementById) return;
	for (var group in SI_groups) {
		d.getElementById(group+'-toggle').style.display = 'inline';
		for (i=0; i<SI_groups[group].items.length; i++) {
			anItem = SI_groups[group].items[i];
			d.getElementById(anItem+'-toggle').style.display = 'inline';
			}
		SI_groups[group].expanded = SI_groups[group].items.length;
		SI_toggleGroups(group,'',d.getElementById(group+'-toggle'));
		}
	};
function SI_toggleGroups(group,item,toggle) {
	var d = document;
	if (!d.getElementById) return;
	
	var state = (toggle.innerHTML.toLowerCase().indexOf('hide ')!=-1);
	var display = (state)?'none':'block';
	var action = (state)?'Show ':'Hide ';
	if (item!='') {
		d.getElementById(item).style.display = display;
		toggle.innerHTML = action+SI_groups[group].label;
		SI_groups[group].expanded = (state)?SI_groups[group].expanded-1:SI_groups[group].expanded+1;
		d.getElementById(group+'-toggle').innerHTML = (SI_groups[group].expanded == SI_groups[group].items.length)?'Hide All':'Show All';
		}
	else {
		for (i=0; i<SI_groups[group].items.length; i++) {
			item = SI_groups[group].items[i];
			d.getElementById(item+'-toggle').innerHTML = ((state)?'Show ':'Hide ')+SI_groups[group].label;
			d.getElementById(item).style.display = display;
			SI_groups[group].expanded = (state)?0:SI_groups[group].items.length;
			}
		toggle.innerHTML = action+'All';
		}
	
	// Redraw the footer...
	SI_clearFooter();
	};

/* SI_initializeToggles()/SI_simpleToggle() v1.0
 * A simplified version of SI_toggleGroups() for toggling unrelated elements
 */
var SI_toggles = new Array();
function SI_initializeToggles() {
	var d = document;
	if (!d.getElementById) return;
	for (var toggle in SI_toggles) {
		SI_toggles[toggle][2] = (SI_toggles[toggle][2])?0:1;
		SI_simpleToggle(toggle);
		}
	}

function SI_simpleToggle(toggle) {
	var d = document;
	if (!d.getElementById) return;
	
	var div = d.getElementById(toggle);
	var lnk = d.getElementById(toggle+'-toggle');
	var state = SI_toggles[toggle][2];
	state = (state)?0:1;
	SI_toggles[toggle][2] = state;
	
	var display		= (state)?'block':'none';
	var className	= (state)?'toggle-min':'toggle-exp';
	
	lnk.innerHTML = SI_toggles[toggle][state];
	lnk.className = className;
	div.style.display = display;
	
	// Redraw the footer...
	SI_clearFooter();
	}

/* SI_galleryRedraw() and related v1.3
 * Client-side image gallery. An array of images and a configuration
 * object need to be defined in the HTML.
 */
var SI_gallery=new Object(); var SI_imgs=new Array(); SI_imgs[0]=null;
function SI_galleryRedraw() {
	if (!SI_dom()) return false;
	var d = document;
	var g = SI_gallery;
		
	// Update the image, caption, count and description
	imgSrc  = SI_imgs[g.imgActive][1]+'thumb/'+g.imgPrefix+SI_imgs[g.imgActive][0];
	imgLnk  = '/manager/PublicFileView.asp?myurl='+SI_imgs[g.imgActive][1]+SI_imgs[g.imgActive][0];
	imgLnk += '&Title='+SI_imgs[g.imgActive][2];
	imgLnk += '&Content='+SI_imgs[g.imgActive][3];
	
	img = d.getElementById('SI_galleryImg');
	img.onload = SI_clearFooter;
	img.src=imgSrc;
	// img.alt=SI_imgs[g.imgActive][3].replace(/(<[^>]*>)/g,'');
	img.parentNode.href=imgLnk;
	img.parentNode.onclick=function() {
		SI_windowOpen(this,true,SI_imgs[g.imgActive][4],SI_imgs[g.imgActive][5],'scrollbars=yes,resizable=yes'); return false;
		}
	d.getElementById('SI_galleryImgTitle').innerHTML=SI_imgs[g.imgActive][2]+' <span><em>'+g.imgActive+'<'+'/em> of '+g.imgTotal+'<'+'/span>';
	// Should alread be contained by a `<p>`
	d.getElementById('SI_galleryImgDesc').innerHTML=SI_imgs[g.imgActive][3];
	
	// Hide or show the previous/next buttons as appropriate
	d.getElementById('SI_galleryImgPrev').innerHTML=(g.imgActive==1)?'Previous Image':'<a href="#Previous Image" onclick="SI_galleryImgPrev(); return false;">Previous Image</a>';
	d.getElementById('SI_galleryImgNext').innerHTML=(g.imgActive==g.imgTotal)?'Next Image':'<a href="#Next Image" onclick="SI_galleryImgNext(); return false;">Next Image</a>';
	
	// Redraw with the current sets thumbnails 
	var t = d.getElementById('SI_galleryThumbs');
	t = '';
	for (i=g.setImg; i<g.setImg+g.thumbTotal;i++) {
		if (i<=g.imgTotal) {
			var className = (i==g.setImg)?'first-child':((i==g.setImg+g.thumbTotal)?'last-child':'');
			if (i==g.imgActive) { className += (className=='')?'active':' active'; }
			className = (className!='')?' class="'+className+'"':'';
			t += '<li'+className+'><a href="#image'+i+'" onclick="SI_galleryImgSelect('+i+'); return false;"><img src="'+SI_imgs[i][1]+'thumb/'+g.thumbPrefix+SI_imgs[i][0]+'" alt="'+SI_imgs[i][2]+'" border="0" /><'+'/a><'+'/li>\n';
			}
		}
	d.getElementById('SI_galleryThumbs').innerHTML = t;
	
	var sets = 'Set: ';
	for (i=1; i<=g.setTotal; i++) {
		if (i==g.setActive) {
			sets += i+' ';
			}
		else {
			sets += '<a href="#Load Set '+i+'" onclick="SI_gallerySetSelect('+i+'); return false;">'+i+'<'+'/a> ';
			}
		if (i!=g.setTotal) sets += '<i>|<'+'/i> ';
		}
	d.getElementById('SI_gallerySets').innerHTML = sets;
	}
// Displays the selected image
function SI_galleryImgSelect(imgNo) {
	if (SI_gallery.imgActive == imgNo) return;
	SI_gallery.imgActive = imgNo;
	SI_galleryRedraw();
	}
// Displays the next image
function SI_galleryImgNext() {
	var g = SI_gallery;
	if (g.imgActive<g.imgTotal) {
		g.imgActive++;
		if (g.imgActive >= g.setImg+g.thumbTotal) {
			g.setImg = g.imgActive;
			g.setActive++;
			}
		SI_galleryRedraw();
		}
	}
// Displays the previous image
function SI_galleryImgPrev() {
	var g = SI_gallery;
	if (g.imgActive>1) {
		g.imgActive--;
		if (g.imgActive < g.setImg) {
			g.setActive--;
			g.setImg = (g.setActive*g.thumbTotal)-(g.thumbTotal-1);
			}
		SI_galleryRedraw();
		}
	}
// Displays the selected set of images
function SI_gallerySetSelect(setNo) {
	var g = SI_gallery;
	g.setActive = setNo;
	g.setImg = (g.setActive*g.thumbTotal)-(g.thumbTotal-1);
	g.imgActive = g.setImg;
	SI_galleryRedraw();
	}
// Displays the previous set of images
function SI_gallerySetPrev() {
	var g = SI_gallery;
	if (g.setActive!=1) {
		g.setActive--;
		g.setImg = (g.setActive*g.thumbTotal)-(g.thumbTotal-1);
		g.imgActive = g.setImg;
		SI_galleryRedraw();
		}
	}
// Displays the next set of images
function SI_gallerySetNext() {
	var g = SI_gallery;
	if (g.setActive<g.setTotal) {
		g.setActive++;
		g.setImg = (g.setActive*g.thumbTotal)-(g.thumbTotal-1);
		g.imgActive = g.setImg;
		SI_galleryRedraw();
		}
	}
// v1.2
function SI_initializeSwapImg() {
	var d = document;
	var SI_preloadImgs = new Array();
	for (i=0;img=d.images[i];i++) {	
		if (img.src.indexOf('over=')!=-1) {
			img.defaultsrc	= img.src;
			img.oversrc		= img.src.replace(/^(.+)over=/i,'');
			img.onmouseover	= function () { this.src = this.oversrc; };
			img.onmouseout	= function () { this.src = this.defaultsrc; };
			
			SI_preloadImgs[i] = new Image();
			SI_preloadImgs[i].src = img.oversrc;
			}
		}
	}
/* SI_initializeFilters()/SI_activateFilter() v1.1
 * 
 * Notes:
 * The first filter should ALWAYS BE "all"
 *
 * Now works with definition lists (dd's only) AND an 
 * unordered list when SI_filters['filterGroup'].ul 
 * is set to true
 *
 * ClassNames used in the filter cannot contain on another
 * or the filter won't work properly
 */
var SI_filters=new Object();
function SI_initializeFilters() {
	for (var filter in SI_filters) {
		SI_activateFilter(filter,SI_filters[filter].active);
		}
	}
function SI_activateFilter(filterGroup,activeFilter) {
	var d = document;
	if (!d.getElementsByTagName) return;
	
	c = (SI_filters[filterGroup].ul)?'ul':'dl';
	r = (SI_filters[filterGroup].ul)?'li':'dd';
	
	var filterContent = d.getElementById('filter-'+filterGroup);
	
	/* Reset everything */
	for (i=0; i<SI_filters[filterGroup].filters.length; i++) {
		var f = d.getElementById('filter-'+filterGroup+'-'+SI_filters[filterGroup].filters[i]);
		f.className = f.className.removeClass('active-tab');
		}
	for (j=0; dl=filterContent.getElementsByTagName(c)[j]; j++) {
		dl.style.display='block';
		for (k=0;dd=dl.getElementsByTagName(r)[k]; k++) {
			dd.style.display='block';
			dd.className = dd.className.removeClass('alt','first-child','last-child');
			dd.style.marginTop='';
			}
		}
	/* Reset complete */
	
	// Activate appropriate filter tab
	var a = d.getElementById('filter-'+filterGroup+'-'+activeFilter);
	a.className = a.className.addClass('active-tab');
	
	/* Filter away */
	for (j=0; dl=filterContent.getElementsByTagName(c)[j]; j++) {
		var allHidden = true;
		var alt = false;
		var firstChild = 0;
		var lastChild = null;
		for (k=0;dd=dl.getElementsByTagName(r)[k]; k++) {
			if (dd.className.indexOf(activeFilter)==-1 && activeFilter!='all') {
				dd.style.display='none';
				}
			else {
				firstChild++;
				lastChild = dd;
				allHidden=false;
				if (alt) {
					dd.className = dd.className.addClass('alt');
					alt=false;
					}
				else { alt=true; }
				if (firstChild==1) {
					dd.className = dd.className.addClass('first-child');
					}
				}
			}
		if (lastChild!=null && firstChild>1) {
			lastChild.className = lastChild.className.addClass('last-child');
			}
		if (allHidden) { dl.style.display='none'; }
		}
	
	if (SI_filters[filterGroup].bin) { SI_filters[filterGroup].bin.value = activeFilter; }
	
	// Redraw the footer...
	SI_clearFooter();
	}

/* Gallery() Object v1.0
 * A new mini gallery object. Still finicky in IE Mac...
 */
function Gallery(imgId,titleId,captionId,prevId,nextId,imgs,loop) {
	var d = document;
	this.compatible = true;
	if (!d.getElementById || (d.all&&!window.print)) {
		this.compatible = false;
		return
		}
	this.aImg = 0;
	this.tImg = imgs.length;
	this.img = d.getElementById(imgId);
	this.title = d.getElementById(titleId);
	this.caption = d.getElementById(captionId);
	this.prevBtn = d.getElementById(prevId);
	this.nextBtn = d.getElementById(nextId);
	this.imgs = imgs;
	this.loop = loop;
	
	this.prevBtn.gallery = this;
	this.prevBtn.onclick = function () { this.gallery.prevImage(); return false; }
	this.nextBtn.gallery = this;
	this.nextBtn.onclick = function () { this.gallery.nextImage(); return false; }
	
	this.loadImage(null);
	}
Gallery.prototype.loadImage = function(i) {
	if (!this.compatible) return;
	if (i!=null) this.aImg = i-1;
	
	if (!this.loop) {
		this.prevBtn.style.display =  (this.aImg<=0)?'none':'block';
		this.nextBtn.style.display =  (this.aImg>=this.tImg-1)?'none':'block';
		}
	
	this.img.src = this.imgs[this.aImg][0];
	this.img.onload = SI_clearFooter;
	
	if (this.imgs[this.aImg][1]!= null) {
		this.title.style.display='block';
		this.title.innerHTML = this.imgs[this.aImg][1];
		}
	else { this.title.style.display='none'; }
	
	if (this.imgs[this.aImg][2]!= null) {
		this.caption.style.display='block';
		this.caption.innerHTML = this.imgs[this.aImg][2];
		}
	else { this.caption.style.display='none'; }
	
	if (this.imgs[this.aImg][3]!= null && this.img.parentNode.nodeName=="A") {
		this.img.parentNode.className = 'si-active-link';
		this.img.parentNode.onclick=this.imgs[this.aImg][3];
		}
	else {
		this.img.parentNode.className = 'si-inactive-link';
		this.img.parentNode.onclick=function() { return false; };
		}
	}
Gallery.prototype.prevImage = function() {
	if (!this.compatible) return;
	this.aImg--;
	this.aImg = (this.aImg<0)?this.tImg-1:this.aImg;
	this.loadImage(null);
	}
Gallery.prototype.nextImage = function() {
	if (!this.compatible) return;
	this.aImg++;
	this.aImg = (this.aImg>=this.tImg)?0:this.aImg;
	this.loadImage(null);
	}

/* SI_debug() v2.0
 * Sets the onmouseover event for all elements to display the 
 * current element's ancestor tree in the window status bar.
 */
function SI_debug() {
	var d = document;
	if (!d.getElementsByTagName) return;
	
	var all = (d.all)?d.all:d.getElementsByTagName('*');
	for (i=0; i<all.length;i++) {
		//var oldmouseover = (all[i].onmouseover)?all[i].onmouseover:function(){};
		all[i].onmouseover = function(e) {
			//oldmouseover();
			if (!e) var e = window.event;
			var status = '';
			var done = false;
			var ths = this;
			while (!done) {
				status = ths.nodeName.toLowerCase()+((ths.className!='')?'.'+ths.className.replace(/ /g,'.'):'')+((ths.id!='')?'#'+ths.id:'')+((status!='')?' > ':'')+status;
				done = (ths.nodeName=='HTML')?true:false;
				if (!done) ths=ths.parentNode;
				}
			
			this.status = status;
			window.status = ((this.status.length>128)?'...':'')+this.status.substr(this.status.length-124);
			e.cancelBubble = true;
			e.returnValue = false;
			if (e.stopPropagation) e.stopPropagation();
			return true;
			}
		}
	}

/* addClass()/removeClass() String Prototypes v1.0
 * Shortcut for the addition/removal of (multiple) classNames to HTML
 * objects. Takes care of adding spaces when a class is already assigned 
 * and cleaning up whitespace when removing a class.
 */
String.prototype.addClass = function() {
	var txt = this;
	for (var i=0; i<arguments.length; i++) { txt += ((txt=='')?'':' ')+arguments[i];}
	return txt;
	};
String.prototype.removeClass = function() {
	var txt = this;
	for (var i=0; i<arguments.length; i++) { 
		txt = txt.replace(new RegExp('( '+arguments[i]+'\\b|\\b'+arguments[i]+' |\\b'+arguments[i]+'\\b)'),'');
		}
	return txt;
	};

/* SI_initTopBtn() and related v1.0
 * Determines whether or not a "Back to Top" link is necessary
 * and moves it around the page as the user scrolls through the
 * document.
 */
var SI_topBtn = new Object();
function SI_initTopBtn() {
	var d = document,w=window,dE=d.documentElement,dB=d.body,h;
	if (!d.getElementById || !d.getElementsByTagName || !dB.offsetHeight) return;
	
	SI_topBtn.o = 8; // offset from the window top or nav-sub bottom
	SI_topBtn.t = d.getElementById('SI_topBtn');
	SI_topBtn.c = d.getElementById('contentTble');
	SI_topBtn.n = d.getElementById('nav');
	SI_topBtn.b = SI_topBtn.t.getElementsByTagName('img')[0];
	SI_topBtn.src = SI_topBtn.b.src;
	SI_topBtn.osrc = SI_topBtn.b.src.replace(/\.gif/,'_out.gif');
	
	SI_topBtn.nD = SI_topBtn.n.offsetHeight+SI_topBtn.c.offsetTop; // Depth of navigation
	SI_topBtn.cD = SI_topBtn.c.offsetHeight+SI_topBtn.c.offsetTop; // Depth of content
	SI_topBtn.wH	= (typeof(w.innerHeight)=='number')?w.innerHeight:(dE&&dE.clientHeight)?dE.clientHeight:(dB&&dB.clientHeight)?dB.clientHeight:0;
	//SI_topBtn.visible = false;
	SI_topBtn.timeout = 0;
	
	if (w.attachEvent) { w.attachEvent('onscroll',SI_hideTopBtn); } 
	else if (w.addEventListener) { w.addEventListener('scroll',SI_hideTopBtn,false); }
	else { w.onscroll = SI_hideTopBtn; };
	SI_displayTopBtn();
	};
// Returns the button's new top coordinate
function SI_newTopBtnPos() {
	scrollTop	= getScrollTop();
	tmpTop		= scrollTop+SI_topBtn.o;
	
	if (tmpTop>(SI_topBtn.nD+SI_topBtn.o)) { return tmpTop-SI_topBtn.c.offsetTop; }
	else { return SI_topBtn.n.offsetHeight + SI_topBtn.o; }
	};

// Positions and reloads the image
function SI_displayTopBtn() {
	// if the content is deeper than the window
	if (SI_topBtn.cD > SI_topBtn.wH && getScrollTop()!=0) {
		SI_topBtn.tT = SI_newTopBtnPos(); // top coordinate of the button
		SI_topBtn.tD = SI_topBtn.tT + SI_topBtn.t.offsetHeight; // bottom coordinate of the button
		
		SI_topBtn.b.style.display = 'block';
		SI_topBtn.b.src = ''; // unload image so that the animation will play when we reload it
		SI_topBtn.b.src = SI_topBtn.src; // force the animation to play
		SI_topBtn.t.style.top = SI_topBtn.tT+'px';
		// SI_topBtn.visible = true;
		}
	// no need to show anything
	else {
		SI_topBtn.b.style.display = 'none';
		// SI_topBtn.visible = false;
		};
	};
// Loads the fade-out graphic when appropriate
function SI_hideTopBtn() {
	if (SI_topBtn.timeout) {
		clearTimeout(SI_topBtn.timeout);
		};
	if (SI_newTopBtnPos()!=parseInt(SI_topBtn.t.style.top)) { // || (SI_newTopBtnPos()==parseInt(SI_topBtn.t.style.top) && !SI_topBtn.visible)) {
		// Hide button and reposition button
		SI_topBtn.b.src = SI_topBtn.osrc;
		SI_topBtn.timeout = setTimeout(SI_displayTopBtn,2000); // display again in 2 seconds
		};
	/*
	else if (getScrollTop()==0) {
		SI_topBtn.b.src = SI_topBtn.osrc;
		SI_topBtn.visible = false;
		};
	*/
	};
// Gets the viewport's current offset from the top of the document
function getScrollTop() {
	if (document.all) return (document.documentElement.scrollTop)?document.documentElement.scrollTop:document.body.scrollTop;
	else return window.pageYOffset;
	};

/* SI_deHTTPSLinks() v1.0
 * Changes all https links to http
 * Used when login must be secure but browsing 
 * of protected areas need not be.
 */
function SI_deHTTPSLinks() {
	if (!document.getElementsByTagName) return;
	var a = document.getElementsByTagName('a');
	for (var i=0;i<a.length;i++) {
		a[i].href = a[i].href.replace(/https/,'http');
		}
	}

var BackPack = new Object();
BackPack.remove	= function(id,e) {
	var dd =e.parentNode.parentNode;
	var tmpStore = [];
	
	for (var i=0; i<this.store.length; i++) {
		if (this.store[i]!=id) {
			tmpStore[tmpStore.length] = this.store[i];
			}
		}
	this.store	= tmpStore;
	this.cookie	= this.store.toString();
	
	e.parentNode.removeChild(e);
	this.save();
	};
BackPack.save = function() {
	setCookie('BackPack',this.cookie.toString(),SI_cookie.year,'/',SI_cookie.domain,false)
	};
BackPack.show = function() {
	if (!document.getElementById) return;
	document.getElementById('backpack').style.display = 'block';
	SI_toggleSelects('hidden'); 
	};
BackPack.hide = function() {
	if (!document.getElementById) return;
	document.getElementById('backpack').style.display = 'none';
	SI_toggleSelects('visible'); 
	};

/* SI_ApplyAltRows() v1.0
 * Automatically adds an "alt" class to every other row in any table with a 
 * class of "alt-table"
 */
function SI_ApplyAltRows() {
	if (!SI_dom()) { return; }
	var tables = document.getElementsByTagName('table');
	for (var i=0; i<tables.length; i++) {
		var table = tables[i];
		if (table.className=='alt-table') {
			var rows = table.getElementsByTagName('tr');
			var alt = false;
			for (var j=0; j<rows.length; j++) {
				var row = rows[j];
				if (alt) { row.className='alt' }
				alt = !alt;
				}
			}
		}
	}

var SI_cookie=new Object();
SI_cookie.domain = location.hostname.replace(/^www\./,'');
SI_cookie.year = new Date(); fixDate(SI_cookie.year); SI_cookie.year.setTime(SI_cookie.year.getTime() + 365 * 24 * 60 * 60 * 1000);
// Copyright (c) 1996-1997 Athenia Associates. http://www.webreference.com/js/ License is granted if and only if this entire copyright notice is included. By Tomer Shiran.
function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; }
function getCookie(name) { var prefix = name + '='; var c = document.cookie; var nullstring = ''; var cookieStartIndex = c.indexOf(prefix); if (cookieStartIndex == -1) { return nullstring; } var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); if (cookieEndIndex == -1) { cookieEndIndex = c.length; } return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); }
function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } }
function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); }

