function setupBookReader( pages, baseimageurl, title) {
		
	window.baseimageurl = baseimageurl;
	// 
	// This file shows the minimum you need to provide to BookReader to display a book
	//
	// Copyright(c)2008-2009 Internet Archive. Software license AGPL version 3.
	
	// Create the BookReader object
	//$('#BookReader').html('');
	if(window.br == null){
		br = new BookReader();
	
	
		// Return the width of a given page.  Here we assume all images are 800 pixels wide
		br.getPageWidth = function(index) {
		    return 292;
		}
		
		// Return the height of a given page.  Here we assume all images are 1200 pixels high
		br.getPageHeight = function(index) {
		    return 413;
		}
		
		// We load the images from archive.org -- you can modify this function to retrieve images
		// using a different URL structure
		br.getPageURI = function(index) {
			var url;
			if(this.reduce == 1){
				if( index == 0 )
					url = window.baseimageurl+'-50-front.jpg';
				else if( index == 1 )
					url = '/site_media/images/br-50-blank.jpg';
				else if( index == this.numLeafs-2 )
					url = '/site_media/images/br-50-blank.jpg';
				else if( index == this.numLeafs-3 ) {
					if( window.br_iseven )
						url = window.baseimageurl+'-50-'+ (index.toString()-2) + '.jpg';		
					else					
						url = '/site_media/images/br-50-blank.jpg';	
				}
				else if( index == this.numLeafs-1 )
					url = window.baseimageurl+'-50-back.jpg';			
				else
					url = window.baseimageurl+'-50-'+ (index.toString()-2) + '.jpg';
			}
			else if(this.reduce == .5){
				if( index == 0 )
					url = window.baseimageurl+'-100-front.jpg';
				else if( index == 1 )
					url = '/site_media/images/br-100-blank.jpg';
				else if( index == this.numLeafs-2 )
					url = '/site_media/images/br-100-blank.jpg';
				else if( index == this.numLeafs-3 ) {
					if( window.br_iseven )
						url = window.baseimageurl+'-100-'+ (index.toString()-2) + '.jpg';			
					else
						url = '/site_media/images/br-100-blank.jpg';
				}
				else if( index == this.numLeafs-1 )
					url = window.baseimageurl+'-100-back.jpg';			
				else
					url = window.baseimageurl+'-100-'+ (index.toString()-2) + '.jpg';			
			}
		    return url;
		}
		
		// Return which side, left or right, that a given page should be displayed on
		br.getPageSide = function(index) {
			if( index % 2 )
		        return 'L';
		    else
		        return 'R';
		}
		
		// This function returns the left and right indices for the user-visible
		// spread that contains the given index.  The return values may be
		// null if there is no facing page or the index is invalid.
		br.getSpreadIndices = function(pindex) {   
		    var spreadIndices = [null, null]; 
		    if ('rl' == this.pageProgression) {
		        // Right to Left
		        if (this.getPageSide(pindex) == 'R') {
		            spreadIndices[1] = pindex;
		            spreadIndices[0] = pindex + 1;
		        } else {
		            // Given index was LHS
		            spreadIndices[0] = pindex;
		            spreadIndices[1] = pindex - 1;
		        }
		    } else {
		        // Left to right
		        if (this.getPageSide(pindex) == 'L') {
		            spreadIndices[0] = pindex;
		            spreadIndices[1] = pindex + 1;
		        } else {
		            // Given index was RHS
		            spreadIndices[1] = pindex;
		            spreadIndices[0] = pindex - 1;
		        }
		    }	    
		    return spreadIndices;
		}
		
		// For a given "accessible page index" return the page number in the book.
		//
		// For example, index 5 might correspond to "Page 1" if there is front matter such
		// as a title page and table of contents.
		br.getPageNum = function(index) {
			return index;
		}
		
		// Total number of leafs
		if( pages % 2 ) {
			br.numLeafs = parseInt(pages) + 5;
			window.br_iseven = false;
		}
		else {
			br.numLeafs = parseInt(pages) + 4;
			window.br_iseven = true;
		}
		
		// Starting zoom at 100%
		br.reduce = 1;
		// start with 2 up mode
		br.mode = 2;
		// pothi logo
		br.logoURL = 'http://pothi.com/pothi/files/logo.png';
		// No autofit
		br.twoPage.autofit = false;
		// We have only 2 zoom levels
	    br.reductionFactors = [0.5, 1];
	    
		// Book title and the URL used for the book title link
		br.bookTitle= title;
		br.bookUrl  = 'bookurl_downloadlink';
		
		// Let's go!
		br.init();
		
		$('[id="#BRbooktitle"]').hide();
		$('#BRtoolbarbuttons').children('.embed,.print,.play').hide()
	}
	else{
		// Total number of leafs
		if( pages % 2 ) {
			br.numLeafs = parseInt(pages) + 5;
			window.br_iseven = false;
		}
		else {
			br.numLeafs = parseInt(pages) + 4;
			window.br_iseven = true;
		}
		
		// Book title and the URL used for the book title link
		br.bookTitle= title;
		br.prepareTwoPageView();
	}
}

