//<!-- All JavaScript and HTML copyright The Library Corporation, Inwood, WV -->
	function addLoadEvent(func) { 
		var oldonload = window.onload; 
		if (typeof window.onload != 'function') { 
			window.onload = func; 
		} else { 
			window.onload = function() { 
				oldonload(); 
				func(); 
			} 
		} 
	}
	
	addLoadEvent(function(){
		addShadows();
		
		if(document.getElementById("clock"))startclock();
		
		if(document.AquaForm){
			setABfocus();
		}else if(document.SearchForm){
			setfocus();
		}
	});
	
	function setABfocus(){
		document.AquaForm.q.focus();
	}

	function setfocus(){
		document.SearchForm.SearchData.focus();
	}
	
//<!----- Image Rollover Script ----->
	if (document.images) {
  		var kidscaton = new Image();
  		kidscaton.src = "images/kidscaton.gif";
  		var kidscatoff = new Image();
  		kidscatoff.src = "images/kidscatoff.gif";
  		
  		var myhomepageon = new Image();
  		myhomepageon.src = "images/myhomepageon.gif";
  		var myhomepageoff = new Image();
  		myhomepageoff.src = "images/myhomepageoff.gif";
  		
  		var libhomeon = new Image();
  		libhomeon.src = "images/libhomeon.gif";
  		var libhomeoff = new Image();
  		libhomeoff.src = "images/libhomeoff.gif";
  		
  		var topofpageon = new Image();
  		topofpageon.src = "images/topofpageon.gif";
  		var topofpageoff = new Image();
  		topofpageoff.src = "images/topofpageoff.gif";
  		     
  		var searchon = new Image();
  		searchon.src = "images/searchon.gif";
  		var searchoff = new Image();
  		searchoff.src = "images/search.gif";
  		  
  		var browseon = new Image();
  		browseon.src = "images/browseon.gif";
  		var browseoff = new Image();
  		browseoff.src = "images/browse.gif"; 
		
  		var combinon = new Image();
  		combinon.src = "images/combinon.gif";
  		var combinoff = new Image();
  		combinoff.src = "images/combin.gif";  
		
  		var helpon = new Image();
  		helpon.src = "images/helpon.gif";
  		var helpoff = new Image();
  		helpoff.src = "images/help.gif"; 
	}

	function act(imgName) {
  		if (document.images) 
    		document[imgName].src = eval(imgName + "on.src");
	}

	function inact(imgName) {
  		if (document.images)
    		document[imgName].src = eval(imgName + "off.src");
	}
	
//<!----- Pop Up Window Script -----> itemgroup map popup page
	function ighelp (ig) {
		igwin = window.open(ig,"igpage","width=650,height=450,location=1,toolbar=yes,menubar=1,scrollbars=1,resizable=1,status=1,links=1");
		igwin.focus();
		if (!igwin.opener) {
        	igwin.opener = "self";
     	}
	}
	
//<!----- Open Window Script ----->
	function open_window(url) {
		mywin = window.open(url,"win",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,scrollable=yes,width=360,height=340');
	}
	
//<!----- Search Script ----->
	var QtSubmittedForm = false;
	var QsLastSearchData = "";

	function AllowSearch(){
		var s_thisSearchData = document.SearchForm.SearchData.value;

		if (QtSubmittedForm == true && s_thisSearchData == QsLastSearchData){
			return false;
		}else{
			QtSubmittedForm = true;
			QsLastSearchData = s_thisSearchData;
			return true;
		}
	}

	function SubmitSearch(){
		if (AllowSearch())
			document.SearchForm.submit();
	}

	function DataChange(){
		QtSubmittedForm = false;
	}
	
//<!----- Aquabrowser Script -----> builds keyword, title, subject and author searches for elementary schools
	function encodeit(searchstring){
   		var toreturn;
   		toreturn="";
   		temp=searchstring.split(" ");
    	for(x=0;x<temp.length;x++){
        	toreturn=toreturn+temp[x];
          	if(x!=temp.length-1){toreturn=toreturn+"+";}
     	} 
		return toreturn;
  	}
	
	var agt=navigator.userAgent.toLowerCase();
	var isOpera=agt.indexOf("opera");
	var isIE=agt.indexOf("msie");
	var isIE7=agt.indexOf("msie 7");
 	var is_nav  = ((agt.indexOf('firefox')==-1) && (agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	var needsIFrame=(isIE>0) && (isIE7==-1) && (isOpera==-1);
	//if(isIE>0 && isOpera<0){isIE=true}else{isIE=false}
	//alert(is_nav);
	var whoseOpen;
	function showMenu(num){
		whoseOpen=num;
		document.getElementById('menu'+num).style.visibility='visible';
		if(needsIFrame){
			document.getElementById('menu'+num).style.width='180px';
			document.getElementById('imenu'+num).style.display='block';
		}else if(is_nav){
			document.getElementById('menu'+num).style.width='180px';
		}
	}
	
	var whoseClosing;
	function hideMenu(num){
		whoseClosing=num;
		document.getElementById('menu'+num).style.visibility='hidden';
		if(needsIFrame){
			document.getElementById('imenu'+num).style.display='none';
		}
	}
	
	
	function startclock(){
		var thetime=new Date();

		var nhours=thetime.getHours();
		var nmins=thetime.getMinutes();
		var nsecn=thetime.getSeconds();
		var nday=thetime.getDay();
		var nmonth=thetime.getMonth();
		var ntoday=thetime.getDate();
		var nyear=thetime.getYear();
		var AorP=" ";

		if (nhours>=12)
    		AorP="P.M.";
		else
    		AorP="A.M.";
	
		if (nhours>=13)
    		nhours-=12;

		if (nhours==0)
   			nhours=12;
	
		if (nsecn<10)
 			nsecn="0"+nsecn;

		if (nmins<10)
		 	nmins="0"+nmins;

		switch(nday){
			case 0:
				nday="Sunday";
				break;
			case 1:
				nday="Monday";
				break;
			case 2:
				nday="Tuesday";
				break;
			case 3:
				nday="Wednesday";
				break;
			case 4:
				nday="Thursday";
				break;
			case 5:
				nday="Friday";
				break;
			case 6:
				nday="Saturday";
				break;
		}
	
		nmonth+=1;

		if (nyear<=99)
			nyear= "19"+nyear;

		if ((nyear>99) && (nyear<2000))
	 		nyear+=1900;

		document.getElementById("clock").innerHTML=nday+", "+nmonth+"/"+ntoday+"/"+nyear+"<br/>"+nhours+": "+nmins+": "+nsecn+" "+AorP;

		setTimeout('startclock()',1000);
	}
	
	
	
var SlideShow = {
	ID: null,
	Name: null,
	speed: 1,
	wait: 3000,
	imageNumber: 1,
	imageOpacity: 100,
	amount: 5,
	captions: true,
	
	myImages: [],
	myCaptions: [],
	
	Create: function(ID,Name,Speed,Delay,Cap){
		this.ID=ID;
		this.Name=Name;
		this.speed=Speed;
		this.wait=Delay;
		this.captions=Cap;
		
		var i1 = document.createElement("div");
		i1.id="imageone"+this.ID;
		i1.style.position="absolute";
		i1.style.height="100%";
		i1.style.width="100%";
		i1.style.zIndex=2;
		i1.style.top="0px";
		i1.style.left="0px";
		i1.style.background = "#000 center center no-repeat";
		document.getElementById(this.ID).appendChild(i1);
		
		var i2 = document.createElement("div");
		i2.id="imagetwo"+this.ID;
		i2.style.position="absolute";
		i2.style.height="100%";
		i2.style.width="100%";
		i2.style.zIndex=1;
		i2.style.top="0px";
		i2.style.left="0px";
		i2.style.background = "#000 center center no-repeat";
		document.getElementById(this.ID).appendChild(i2);
		
		if(this.captions){
			var c = document.createElement("div");
			c.id="captions";
			c.innerHTML = "<table id=\"captionwrapone\"><tr><td><span class=\"caption\" id=\"captionone"+this.ID+"\"></span></td></tr></table>"+
						  "<table id=\"captionwraptwo\"><tr><td><span class=\"caption\" id=\"captiontwo"+this.ID+"\" style=\"opacity:0; filter:alpha(opacity=0);\"></span></td></tr></table>"+
						  "<div id=\"shade\"></div>";
			document.getElementById(this.ID).appendChild(c);
		}
	},
	
	AddImage: function(Name,Caption){
		this.myImages[this.myImages.length] = new Image();
		this.myImages[this.myImages.length-1].src="uploads/"+Name;
		//if(this.captions) this.myCaptions[this.myCaptions.length]=Caption;
	},
	
	Start: function(){
		document.getElementById("imageone"+this.ID).style.backgroundImage="url('"+this.myImages[0].src+"')";
		if(this.myImages.length>1)
			document.getElementById("imagetwo"+this.ID).style.backgroundImage="url('"+this.myImages[1].src+"')";
		if(this.captions){
			document.getElementById("captions").style.display="block";
		//}else{
		 	document.getElementById("captionone"+this.ID).innerHTML=this.myCaptions[0];
			if(this.myImages.length>1)
				document.getElementById("captiontwo"+this.ID).innerHTML=this.myCaptions[1];
		}
		
		//eval('setTimeout("s'+this.ID+'.fadeout()",'+this.wait+')');
		if(this.myImages.length>1)
			setTimeout("SlideShow.fadeout()",this.wait);
	},
	
	fadeout: function(){
		this.imageOpacity=this.imageOpacity-this.amount;
		if(this.imageOpacity>0){
			this.myOpacity=this.imageOpacity/100;
		}else{
			this.imageOpacity=0;
			this.myOpacity=0;
		}
		if(document.all){
			document.getElementById("imageone"+this.ID).style.filter="alpha(opacity="+(this.myOpacity*100)+")";
			if(this.captions) document.getElementById("captionwrapone"+this.ID).style.filter="alpha(opacity="+(this.myOpacity*100)+")";
			if(this.captions) document.getElementById("captionwraptwo"+this.ID).style.filter="alpha(opacity="+(100-(this.myOpacity*100))+")";
		}else{
			document.getElementById("imageone"+this.ID).style.opacity=this.myOpacity;
			if(this.captions) document.getElementById("captionwrapone"+this.ID).style.opacity=this.myOpacity;
			if(this.captions) document.getElementById("captionwraptwo"+this.ID).style.opacity=1-this.myOpacity;
		}
		
		if(this.imageOpacity>0){
			//eval('setTimeout("s'+this.ID+'.fadeout()",'+this.speed+')');
			setTimeout("SlideShow.fadeout()",this.speed);
		}else{
			this.imageOpacity=100;
			document.getElementById("imageone"+this.ID).style.backgroundImage=document.getElementById("imagetwo"+this.ID).style.backgroundImage;
			if(this.captions) document.getElementById("captionone"+this.ID).innerHTML=document.getElementById("captiontwo"+this.ID).innerHTML;
			if(document.all){
				document.getElementById("imageone"+this.ID).style.filter="alpha(opacity="+(100)+")";
				if(this.captions) document.getElementById("captionwrapone"+this.ID).style.filter="alpha(opacity="+(100)+")";
				if(this.captions) document.getElementById("captionwraptwo"+this.ID).style.filter="alpha(opacity="+(0)+")";
			}else{
				document.getElementById("imageone"+this.ID).style.opacity=1;
				if(this.captions) document.getElementById("captionwrapone"+this.ID).style.opacity=1;
				if(this.captions) document.getElementById("captionwraptwo"+this.ID).style.opacity=0;
			}
			this.imageNumber++;
			if(this.imageNumber>=this.myImages.length){this.imageNumber=0;}
			document.getElementById("imagetwo"+this.ID).style.backgroundImage="url("+this.myImages[this.imageNumber].src+")";
			if(this.captions) document.getElementById("captiontwo"+this.ID).innerHTML=this.myCaptions[this.imageNumber]
			//eval('setTimeout("s'+this.ID+'.fadeout()",'+this.wait+')');
			setTimeout("SlideShow.fadeout()",this.wait);
		}
	},
	
	fadein: function(){
		this.imageOpacity=this.imageOpacity+this.amount;
		if(this.imageOpacity>0 && this.imageOpacity<100){
			this.myOpacity=this.imageOpacity/100;
		}else if(this.imageOpacity>=100){
			this.imageOpacity=100;
			this.myOpacity=1;
		}else{
			this.myOpacity=0
		}
		if(document.all){
			document.getElementById("imageone"+this.ID).style.filter="alpha(opacity="+(this.myOpacity*100)+")";
			if(this.captions) document.getElementById("caption"+this.ID).style.filter="alpha(opacity="+(this.myOpacity*100)+")";
		}else{
			document.getElementById("imageone"+this.ID).style.opacity=this.myOpacity;
			if(this.captions) document.getElementById("caption"+this.ID).style.opacity=this.myOpacity;
		}
		if(this.imageOpacity<100){
			//eval('setTimeout("s'+this.ID+'.fadein()",'+this.speed+')');
			setTimeout("SlideShow.fadein()",this.speed);
		}else{
			var i=this.imageNumber+1;
			if(i>=this.myImages.length){i=0;}
			document.getElementById("imagetwo"+this.ID).style.backgroundImage="url("+this.myImages[i].src+")";
			//setTimeout('fadeout()',wait);
			//eval('setTimeout("s'+this.ID+'.fadeout()",'+this.wait+')');
			setTimeout("SlideShow.fadeout()",this.wait);
		}
	}
}