// opening windows fuctions 

	function openWin(page) {
		 window.location = page;
	}

	function newWindow(url,wid,ht) {
		var param = "directories=yes,scrollbars=yes,resizable=yes,status=yes,menubar=yes,location=yes,toolbar=yes";
		if (wid) { param = param + ",width=" + wid; } 
			else { param = param + ",width=500"; }
		if (ht) { param = param + ",height=" + ht ; } 
			else { param = param + ",height=500"; }
		smallWindow = window.open(url,'smallWin',param);
		smallWindow.focus();
	}

// open page in parent window and close self

	function closeandLink(page) {
		window.parent.opener.location = page;
		window.parent.close();
	}
	
// translate page 

	function translateURL(page) {
		var transURL = "http://translate.google.com/translate?u=" + page + "&langpair=en%7Ces&hl=en&ie=UTF-8&oe=UTF-8";
		window.location = transURL;
	}
// del.icio.us link 

	function socialBookmarking() {
		document.write('<a href=http://del.icio.us/post?&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+' target="blank">Add to my del.icio.us!</a>');
	}	
	
// header search function
		
	function jplSearch(terms) {
		var searchURL = "http://www.google.com/search?q=site%3Ajpl.coj.net " + terms;
		window.location = searchURL;
	}
	function jplsiteSearch(terms) {
		var searchURL = "http://www.google.com/search?q=site%3Ajpl.coj.net " + terms;
		window.location = searchURL;
	}

// Languages 
	
	function jaxcatSearch(syn1,val1,bool1,syn2,val2,bool2,syn3,val3,bool3,syn4,val4,boolvid,vid) {
		var caturl = "/web2/tramp2.exe/do_keyword_search/guest?setting_key=english&servers=1home&query=" + syn1 + "+[" + val1 + "]";
		if (bool1)   
			{ caturl = caturl + "+" + bool1   + "+" + syn2 + "+[" + val2 + "]"; }
		if (bool2)   
			{ caturl = caturl + "+" + bool2   + "+" + syn3 + "+[" + val3 + "]"; } 
		if (bool3) 
			{ caturl = caturl + "+" + bool3   + "+" + syn4 + "+[" + val4 + "]"; } 
		if (boolvid=="yes" || boolvid=="and")
				{ caturl = caturl + "+and+(videorecording)"; }
			else 
				{ caturl = caturl + "+not+(videorecording)";}		
		window.location = caturl;
	}
	
	function jaxcatBasic(searchterms) {
		var searchURL = "/web2/tramp2.exe/do_keyword_search/guest?SETTING_KEY=English&servers=1home&index=default&screen=hitlist.html&query=";
		searchURL = searchURL + searchterms;
		window.location = searchURL;
	}	

// Page last updated function

	function writeDateModified(time) {
	
		var days = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");                    
		var months = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")
		
		// Assign date variables with document.lastModified 
		var modDate = new Date(Date.parse(document.lastModified));
		
		// If we have a valid date reformat it.
		if (modDate != 0) {
			var day = days[modDate.getDay()];
			var ndate = modDate.getDate();
			var month = months[modDate.getMonth()];
			var year = modDate.getYear();
			if (year < 1000) year = year + 1900;
			if (time) {
				var hour = modDate.getHours().toString();
				if (hour.length == 1) hour = "0" + hour; 
				var minute = modDate.getMinutes().toString();
				if (minute.length == 1) minute = "0" + minute;
				var second = modDate.getSeconds().toString();
				if (second.length == 1) second = "0" + second;
			}
			
			// Display date and time document was last updated.
			document.write(month + " "  + ndate + ", " + year+ "  ");
			if (time) {	document.write(hour + ":" + minute + ":" + second);	}	
		}
	}
	
// Timestamp 

	function display_todays_date() {
		var today = new Date();
		var num_day=today.getDay();
		var num_month=today.getMonth();
		var date=today.getDate();
		var year=today.getFullYear();
	
		dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
		monName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
	
		document.write('<strong>' + dayName[num_day] +', '+ monName[num_month] +' '+ date +', '+ year + '</strong>');
	}

// calendar menu 

	function calendarOpen(year,month,branch) {
		if (branch != " ")  {
			var calURL = '/lib/branches/' + branch + '.html'; 
			window.location = calURL;
		}
		else if ((branch == " ") && (month == " ") && (year == " ")) {
			alert('Please make a valid selection.');
		}
		else if ((branch == " ") && (((month != " ") && (year == " ")) || ((month == " ") && (year != " ")))) {
			alert('Please make a valid selection.');
		}
		else {
			var calURL = '/program.calendar/' + year + '/' + month + '.html'; 
			window.location = calURL;
		}
	}

/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

	//Specify affected tags. Add or remove from list:
	var tgs = new Array('td','tr','select','input','span','p','dt','dd','li','div','a');
	
	//Specify spectrum of different font sizes:
	var szs = new Array('13px','15px','17px');
	var fcnt = -1;
	var maxfont = szs.length - 1;
	
	function ifont() { //v3.0
		if(fcnt < maxfont) {
			fcnt = fcnt + 1;
		}else if(fcnt == maxfont) {
			location.reload();
		}else {
			fcnt = maxfont;
		}
		ts('body');
	}
	
	function ts( trgt ) {
		if (!document.getElementById) return
		var d = document,cEl = null,i,j,cTags;
			
		if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
		cEl.style.fontSize = szs[ fcnt ];
	
		for ( i = 0 ; i < tgs.length ; i++ ) {
			cTags = cEl.getElementsByTagName( tgs[ i ] );
			for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ fcnt ];
		}
	}
	
	function changeFont(NewFont) {
		if (!document.getElementById) return
		var tags = new Array('td','tr','select','input','span','p','dt','dd','li','div','a');
		var cEl = null;
		var i,j,changedTags;
			
		if (!( cEl = document.getElementById('center_panel'))) 
			 cEl = document.getElementsByTagName('center_panel')[0]; 
		
		cEl.style.fontSize = NewFont;
	
		for ( i = 0 ; i < tags.length ; i++ ) {
			changedTags = cEl.getElementsByTagName( tags[ i ] );
			for ( j = 0 ; j < changedTags.length ; j++ ) 
				 changedTags[j].style.fontSize = NewFont; 
		}
	}

// popup windows written by Ed

	function popUp(evt,currElem) {	
		stdBrowser=(document.getElementById)?true:false
		popUpWin = (stdBrowser)?document.getElementById(currElem).style : eval("document." + currElem);
		popUpWin.visibility = "visible";
		popUpWin.display = "block";
		popUpWin.focus();
	}
	
	function popDown(currElem) {	
		stdBrowser=(document.getElementById)?true:false
		popUpWin = (stdBrowser)?document.getElementById(currElem).style : eval("document." + currElem);
		popUpWin.visibility = "hidden";
		popUpWin.display = "none";
	}

// rotating images functions

	function get_random(num)
	{
		var ranNum= Math.floor(Math.random()*num);
		return ranNum;
	}
	
	function hdrimgld() {
		imgNum = get_random(16);
		if (imgNum == 0) {imgNum = imgNum + 1;}
		imgSrc = "http://jaxpubliclibrary.org/pics/nav/top_bar/top_img_" + imgNum + ".jpg";
		imgAtt = 'width="225" height="85" align="right" alt="Rotating Image"';
		document.write('<img src="' + imgSrc + '" ' + imgAtt + ' />');
	}
		
	function mainImgLoad() {
		var imgNum = get_random(6);
		var imgSrc = "http://jaxpubliclibrary.org/pics/nav/home/main_image" + imgNum + ".jpg";
		var imgAtt = 'width="60%" height="312" class="right" alt="Rotating Image"';
		document.write('<img src="' + imgSrc + '" ' + imgAtt + ' />');
	}
	
	function kidsimgld() {
		var choice = get_random(9);
		if (choice <=4 ) {		
			imgType = "Children&rsquo;s Department @ Main";
			imgNum = get_random(5);
			if (imgNum == 0) {imgNum = imgNum + 1;}
			imgSrc = "http://jaxpubliclibrary.org/pics/kids/kidslib_" + imgNum + ".gif";
			imgAtt = 'width="250" height="188" alt="Rotating Image" border="1"';
		}
		else {
			imgType = "Storytime Thru the Ages";
			imgNum = get_random(4) ;
			if (imgNum == 0) {imgNum = imgNum + 1;}
			imgSrc = "http://jaxpubliclibrary.org/pics/kids/storytime_" + imgNum + ".gif";
			imgAtt = 'width="250" height="188" alt="Rotating Image" border="1"';
		}
		document.write('<div align="center"><img src="' + imgSrc + '" ' + imgAtt + ' /><br /><p class="small">' + imgType + '</p></div>');
	}
	
	function teenimgld() {
		var choice = get_random(3);
		if (choice == 1 ) {		
			imgType = "Teen Department @ Main";
			imgNum = get_random(3);
			imgNum = imgNum + 1;
			if (imgNum >= 3) {imgNum = 0;}
			imgSrc = "http://jaxpubliclibrary.org/pics/teens/teens_img_" + imgNum + ".jpg";
			imgAtt = 'width="250" height="188" alt="Rotating Image" border="1"';
			}
		else {
			imgType = "Teens In JPL Programs";
			imgNum = get_random(6);
			imgNum = imgNum + 1;
			if (imgNum >= 6) {imgNum = 0;}
			imgSrc = "http://jaxpubliclibrary.org/pics/teens/teenprog_img_" + imgNum + ".jpg";
			imgAtt = 'width="250" height="188" alt="Rotating Image" border="1"';
		}
		document.write('<div align="center"><img src="' + imgSrc + '" ' + imgAtt + ' /><br /><p class="small">' + imgType + '</p></div>');
	}
		
	function updateMonth() {
		var monName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")
		var now = new Date
		var monFLURL = "http://www.flahistory.net/" + monName[now.getMonth()] + ".htm";
		newWindow = window.open(monFLURL);
		newWindow.focus();
		return false;
	}
	// enlarge image function
	
	function enlargeImage(image,wid,ht,info,title) {
		
		var imgURL = "/" + image;		
		if (wid < 200) {var newWid = wid + 200;}
		else {var newWid = wid + 150;}		
		var newHt = ht + 150;
		var param = "width=" + newWid + ",height=" + newHt + ",scrollbars=yes,resizable=yes";			
		var imgWin = window.open('','OpenWin',param);
		
		var winContent = '<HTML><head><title>' + title + '</title>';
		winContent = winContent + '<link rel="stylesheet" TYPE="text/css" href="/common/styles/layout.css">';
		winContent = winContent + '<script TYPE="text/javascript" src="/common/javascripts/scripts.js"></script>';
		winContent = winContent + '</head>';
		winContent = winContent + '<body>'; 
		winContent = winContent + '<div align="center" style="background-color:#ffffff; color:#000000;">'; 
		winContent = winContent + '<div class="left"><IMG SRC="/pics/jplsmall.jpg" ALT="Library home page" border="0" align="left" hspace="18"></div>';
		winContent = winContent + '<div class="right"><a class="small" href="javascript:void(0);" onClick="window.print(self)">[Print this window]</a>&nbsp;<a class="small" href="javascript:void(0);" onClick="window.close(self)">[Close this window]</a></div>';
		winContent = winContent + '<div class="spacer">&nbsp;</div>';
		winContent = winContent + '<div style="clear:both"></div>';
		winContent = winContent + '<hr>';
		winContent = winContent + '<br>';
		winContent = winContent + '<div align="center">';
		winContent = winContent + '<img src="' + imgURL + '" alt="' + info + '" height="' + ht + '" width="' + wid + '"border="1">';
		winContent = winContent + '<br><br>';
		winContent = winContent + '<p class="spacer">' + info + '</p>';
		winContent = winContent + '</div>';
		winContent = winContent + '<hr>';
		winContent = winContent + '<div class="left">&copy; Jacksonville Public Library, City of Jacksonville.</div>';
		winContent = winContent + '<div class="right">&nbsp;&nbsp;</div>';
		winContent = winContent + '</div>';
		winContent = winContent + '</body>';
		winContent = winContent + '</html>';
	
		imgWin.document.write(winContent);
		imgWin.focus();
	 }
	 
	 function updateMonth() {
		monName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")
		var now = new Date
		var monFLURL = "http://www.flahistory.net/" + monName[now.getMonth()] + ".htm";
		newWindow = window.open(monFLURL);
		newWindow.focus();
		return false;
	}
	 
	function randomPopupWindow(page,wid,ht) {
		var param = "directories=no,scrollbars=no,resizable=no,status=no,menubar=no,location=no,toolbar=no";
		if (wid) { param = param + ",width=" + wid; } 
			else { param = param + ",width=500"; }
		if (ht) { param = param + ",height=" + ht ; } 
			else { param = param + ",height=500"; }
		smallWindow = window.open(page,'smallWin',param); 
			smallWindow.focus();
	}
	