<!--
		//GLOBALS
		var cur_last_mult = new Array();
		var current_page = 0;
		var current_num = 0;
		var cur_total_mult = 0;
		var real_page_tally = 0;
		var reached_end = false;
		var has_enlarge = false;
		var is_multiple = 0;
		var multiple_ar = new Array();
		//FUNCTION: init() Initializes page to current page (1 by default) and letter (A by default)
		function init(page) {	
			current_page = (page && page < 1) ? nextNotBlank(page) : 1;
			setSelect(current_alpha);
			goImageAndProgress(false);
		}

		//FUNCTION: getCurTotalMult() creates total pages array for each volume if there are multiple
		function getCurTotalMult() {
			var tmp = 0;
			for (var i = 1; i < multiple_ar.length; i++) {
					tmp += parseInt(multiple_ar[i]);
			}
			return tmp;
		}

		//FUNCTION: getCurLastMult() creates total pages array for each volume if there are multiple in to the viewers page numbers
		function getCurLastMult() {
			if (is_multiple) {
			cur_last_mult[1] = multiple_ar[1];
			for (var i = 2; i < multiple_ar.length; i++) {
				cur_last_mult[i] = parseInt(parseInt(cur_last_mult[i - 1]) + parseInt(multiple_ar[i]));
			}
			} else {
				current_num = 0;
			}
		}
						
		//FUNCTION: setEnlargementImg() Sets navigation enlargement image if enlargement exists
		function setEnlargementImg() {
			MM_findObj("enlargeImage").src = (has_enlarge) ? off_enl : off_no_enl;
		}

		//FUNCTION: swapEnlargementImg() Mouseover for navigation enlargement image
		function swapEnlargementImg() {
			var img = (has_enlarge) ? on_enl : on_no_enl;
			MM_swapImage("enlargeImage","", img, 0);			
		}

		//FUNCTION: swapEnlargeRestore() Restores mouseoff state to original depending on if there is an enlargement
		function swapEnlargeRestore() {
			if (has_enlarge) MM_swapImage("enlargeImage","", off_enl, 0);			
			else MM_swapImage("enlargeImage","", off_no_enl, 0);			
		}
		//FUNCTION: pageNumber(int) Returns string of 4 digit representation of page number given integer
		function pageNumber(num) {
		var str;
			switch (num.toString().length) {
				case(0) : break; 
				case(1) : str = "000" + num; break;
				case(2) : str = "00" + num; break;
				case(3) : str = "0" + num; break;
				case(4) : str = num; break;
				default : break; 
			}

			return str;		
		}

		//----- Multiple Viewer Functions
		//FUNCTION: nextMultiple() triggers the process to find the next page
		function nextMultiple(page) {	
			return getMultipleNum(page);
		}

		//FUNCTION: getMultipleNum using the main page tallies, finds out which volume the page is from
		function getMultipleNum(page) {
				if (parseInt(page) > 0 && parseInt(page) <= parseInt(multiple_ar[1])) current_num = 1;
				else {
					for (var i = 2; i < multiple_ar.length; i++) {
						if ((parseInt(page) >  parseInt(cur_last_mult[i - 1])) && (parseInt(page) <= parseInt(cur_last_mult[i])))
							current_num = i;
					}
				}
		}	

		//FUNCTION: getRealPage() after finding out the volume, this function returns the page the image on the server is
		function getRealPage(num, page) {
			if (num == 1) return page;
			else if (num <= is_multiple) {
				real_page_tally = parseInt((current_page) - parseInt(totalLastMult()));
				return real_page_tally;
			}
		}
		
		//FUNCTION totalLastMult() Figures out the end page number of each volume as the viewer sees is as one book
		function totalLastMult() {
			var tmp = 0;
			for (var i = 1; i < multiple_ar.length; i++) {
				if (i < current_num) {
					tmp += parseInt(multiple_ar[i]);
				}
			}
			return tmp;
		}
		
		//FUNCTION: goBack50() Adjusts current page number - 50 and executes change to image window/progress bar
		function goBack50() {
			current_page = (current_page >= 51) ? (current_page -= 50) : 1;
			current_page = previousNotBlank(current_page);			
			goImageAndProgress();
		}

		//FUNCTION: goBack10() Adjusts current page number - 10 and executes change to image window/progress bar
		function goBack10() {			
			current_page = (current_page >= 11) ? (current_page -= 10) : 1;
			current_page = previousNotBlank(current_page);			
			goImageAndProgress();
		}
		
		//FUNCTION: goPrevious() Sets current page number - 1 and executes change to image window/progress bar
		function goPrevious() {
			prev_page = previousNotBlank((current_page >= 2) ? (current_page - 1) : 1);
			if (prev_page > 0 && current_page != prev_page) {
				current_page = prev_page;
				goImageAndProgress();
			}
		}

		//FUNCTION: goNext() Sets current page number + 1 and executes change to image window/progress bar
		function goNext() {
			next_page = nextNotBlank((current_page < total_pages) ? (current_page + 1) : total_pages);			
			if (current_page < total_pages) {
				current_page = next_page;
				goImageAndProgress();
			}
		}

		//FUNCTION: goAdvance10() Sets current page number + 10 and executes change to image window/progress bar
		function goAdvance10() {
			current_page = (current_page < (total_pages - 10)) ? (current_page += 10) : total_pages;
			current_page = nextNotBlank(current_page);			
			if (current_page <= total_pages) goImageAndProgress();
		}

		//FUNCTION: goAdvance50() Sets current page number + 50 and executes change to image window/progress bar
		function goAdvance50() {
			current_page = (current_page < (total_pages - 50)) ? (current_page += 50) : total_pages;
			current_page = nextNotBlank(current_page);			
			if (current_page <= total_pages) goImageAndProgress();
		}
		
		//FUNCTION: go() triggers page number change for select menu and input box
		function go(page, noload) {
			current_page = parseInt(page);
			if (is_multiple > 0) nextMultiple(page);
			if (!noload) noload = false; 
			goImageAndProgress(noload);
		}
		
		//FUNCTION: goImageNumber() error checking routine for the input box, checks for integer
		function goImageNumber(frm) {
			if (!parseInt(frm.text_image_number.value) || frm.text_image_number.value > total_pages)
				alert("Please enter a number from \n 1 to " + total_pages + "\n for this book");
			else 
				go(frm.text_image_number.value);

			frm.text_image_number.value = "";
			frm.text_image_number.blur();
			return false;
		}
		
		//FUNCTION: goImageAndProgress(reload) Executes image url page swap and executes progress bar change
		function goImageAndProgress(noload) {

				if (is_multiple > 1) {
					text_page = parseInt(getRealPage(current_num, current_page));
				} else {
					text_page = parseInt(current_page);
				}

			page = pageNumber(text_page);

			if (window.frames) {
				if (!noload) window.frames["imageFrame"].location.href='image.php?id=' + id + '&page=' + page + "&num=" + current_num;
			} else {
				if (!noload) document.frames["imageFrame"].document.location.href='image.php?id=' + id + '&page=' + page + "&num=" + current_num;
			}

			newImageSelect();
			newTownName();	
			document.forms["frm_sel_image"].elements[0].selectedIndex = 0;
			document.forms["frm_sel_image"].elements[0].options[0].text = "Image " + current_page + " of " + total_pages;
			//goProgress();
			return true;
		}

		//FUNCTION: goProgress() Executes change to progress bar based on function percentPage();
		function goProgress() {
			//MM_findObj("progress_bar").style.width = percentPage() + "px";
			return true;
		}
	

		//FUNCTION: goEnlarge() Spawns enlargement window;
		function goEnlargement() {
			var x = eval(screen.width/2-(780/2));			
			var y = eval(screen.height/2-(740/2));		
			page = (is_multiple > 1) ? pageNumber(getRealPage(current_num, current_page)) : pageNumber(current_page);
			var sid = sid_path + "/" + catnyp_id  + "/" + page + ".sid";
			if (has_enlarge) {
				MM_openBrWindow(sid,'enlarge','resizeable=yes,width=780,height=740,screenX=' + x + ',screenY=' + y + ',top=' + y + ',left=' + x);				
			}
		}

		function goBiblio() {
			MM_openBrWindow("http://catnyp.nypl.org/record=" + catnyp_id, "", "");
		}

		function goBuyBook() {
			MM_openBrWindow("http://catnyp.nypl.org/record=" + catnyp_id, "", "");
		}

		//FUNCTION: goCommunity() Executes communities iframe change based on user specified letter in alphabetical index;
		function goCommunity(value, letter) {
			if (value != "null") {
				//MM_findObj("letter").innerHTML = letter;
				if (window.frames)
					window.frames["communitiesFrame"].location.href="communities.php?sort=" + letter;
				else
					document.frames["communitiesFrame"].location.href="communities.php?sort=" + letter;
			
			}
		}

		//FUNCTION: goCommunityPreview() Executes communities iframe change based on user specified letter in alphabetical index; This one is for preview mode which shows all towns
		function goCommunityPreview(value, letter) {
			if (value != "null") {
				//MM_findObj("letter").innerHTML = letter;
				if (window.frames)
					window.frames["communitiesFrame"].location.href="communities_preview.php?sort=" + letter + "&" + "id=<?php echo $id ?>";
				else
					document.frames["communitiesFrame"].location.href="communities_preview.php?sort=" + letter + "&" + "id=<?php echo $id ?>";
			
			}
		}
		
		//FUNCTION: setSelect() Executes change to alphabetical index to current alphabetical user choice;
		function setSelect(letter) {
			for (var i = 0; i < document.forms["alpha_form"].alpha.options.length; i++)
				if (letter == document.forms["alpha_form"].alpha.options[i].value) {
					document.forms["alpha_form"].alpha.selectedIndex = i;
				}
		}		

		//FUNCTION: nextNotBlank() Sees if page is blank and returns the next not blank if checkbox toggle is not selected
		function nextNotBlank(page) {	
			tmp = blank_pages.split(",");				
			if (!show_blank && tmp.length) {			
				if (hasElement(tmp, pageNumber(page)))
					if (page < (total_pages - 1)) 
						return nextNotBlank(page + 1);
			}
			if (is_multiple > 0) nextMultiple(page);
			return page;

		}

		//FUNCTION: previousNotBlank() Sees if page is blank and returns the previous not blank if checkbox toggle is not selected
		function previousNotBlank(page) {		
		tmp = blank_pages.split(",");					
			if (!show_blank && tmp.length) {
				if (hasElement(tmp, pageNumber(page))) {					
					return previousNotBlank(page - 1);				
				}
			}
			if (is_multiple > 0) nextMultiple(page);
			return page;
		}				

		//FUNCTION: setBlank() sets global blank pages variable
		function setBlank(elem) {		
			show_blank = (elem.checked) ? true : false;
		}
	
		//FUNCTION: hasElement() searches array for value
		function hasElement(array, value) {
			for (var i=0; i < array.length; i++) 				
				if (array[i] == value) 
					return true;			
				return false;		
			}
		//Key stroke handler for keyboard browsing		
		document.onkeypress = keyhandler;

		//FUNCTION keyhandler() Captures key strokes and triggers change of town		
		function keyhandler(e) {
		    //if (document.layers)
		      // Key = e.which;
		    //else
		       //Key = window.event.keyCode;
		    
		    //if (Key != 0 && (Key > 96 && Key < 123))
		      //  change(Key)
		}

		//FUNCTION change() changes town given letter		
		function change(key) {
		var letter = returnLetter(key);
		setSelect(letter);
		frm = document.forms["alpha_form"].alpha;
		goCommunity(frm.options[frm.selectedIndex].value, frm.options[frm.selectedIndex].text);
		}

		//FUNCTION returnLetter() Returns ASCII code of letter		
		function returnLetter(key) {
		var ar1 = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
		var ar2 = new Array();
		for (i=0, j = 97; i < ar1.length; i++,j++)
			ar2[j] = ar1[i];
			return ar2[key];
		}
		
		//FUNCTION printPop() spawns pop window for printing		
		function printPop(id, page) {			
		var x = eval(screen.width/2-(547/2));			
		var y = eval(screen.height/2-(760/2));			
		cnum = (is_multiple == 0) ? 0 : current_num;
		page = (is_multiple > 1) ? pageNumber(getRealPage(current_num, current_page)) : pageNumber(current_page);

			win = MM_openBrWindow("print_page.php?id=" + id + "&page=" + page + "&num=" + cnum,"enlarge","scrollbars=auto,resizeable=no,width=547,height=760,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
		}

		//FUNCTION newTownName() replaces main town title on front page when a different book is selected
		function newTownName() {
			if (MM_findObj("h2_town_name").innerHTML != town_name) {
				MM_findObj("h2_town_name").innerHTML = "";
				MM_findObj("h2_town_name").innerHTML = town_name;
			}
		}

		//FUNCTION newImageSelect() replaces main select menu on the front page when a different book is selected
		function newImageSelect() {
			if (MM_findObj("h2_town_name").innerHTML != town_name) {
				str = "";			
				str += "<select name=\"" + sel_image_name + "\" style=\"width: 140px;\" onchange=\"go(this.options[this.selectedIndex].value)\">";
				str += "<option value=\"null\" selected=\"selected\">Image 1 of total_pages</option>";
				for (i = 1; i <= total_pages; i++) {
					str += "<option value=\"" + i + "\">" + i + "</option>";
				}
				str += "</select>";
				MM_findObj("div_sel_image").innerHTML = "";
				MM_findObj("div_sel_image").innerHTML = str;
			}
	
		}


		//FUNCTION: percentPage() Returns percent of current page over total pages by width of progress bar (172);
		function percentPage() {
			if (current_page == 1) return 1;
			if (current_page == total_pages) return 172;
			temp = (current_page/total_pages * 172);
			return Math.round(temp);
		}

-->