function ProcessGBSBookInfo(booksInfo) 
{ 
	for (isbn in booksInfo) 
	{ 
		var url_elem = document.getElementById(isbn); 
		var pic_elem = document.getElementById("slide_1"); 
		var bookInfo = booksInfo[isbn]; 
		if (bookInfo) 
		{ 
			url_elem.href = bookInfo.info_url; 
			url_elem.style.display = ''; 
			if (bookInfo.thumbnail_url) 
			{ 
				pic_elem.src = bookInfo.thumbnail_url; 
				pic_elem.style.display = ''; 
			} 
		} 
	} 
} 

function SlideShow(objNameParam, slideShowIDParam, slideWidthParams, slideHeightParams) {

	var slideShowID = slideShowIDParam;
	var arrSlide;
	var arrSlidePaging;
	var arrCounter;
	var currItem;
	var slideShowPlay;
	var objName = objNameParam;
	var slideWidth = 0;
	var slideHeight = 0;
	var slideTimer = 9000;
	var mouseBehavior = 'click';
	
	if (typeof slideWidthParams != "undefined")
		slideWidth = slideWidthParams.replace('px','');
	if (typeof slideHeightParams != "undefined")
		slideHeight = slideHeightParams.replace('px','');
	
	this.getSlideShow = function(start, play) { /* Sets up the configuration and environment */
		arrSlide = new Array();
		arrSlidePaging = new Array();
		arrCounter = 0;
		
		if (start == 'random')
			start = Math.floor(Math.random() * $('#'+slideShowID+' div#'+slideShowID+'Data>div').length);
		else
			start = start - 1;
		
		$('#'+slideShowID+' div#'+slideShowID+'Data>div').each( function() { /* Grabs data from the divs and insert in the array */
			$(this).css('zIndex',1);
			$(this).css('position','absolute');
			if (arrCounter != start)
				$(this).css('display','none');
			arrSlide[arrCounter++] = $(this);
		});

		if (play) {
			currItem = start-1;
			if (currItem < 0)
				currItem = arrSlide.length-1;
		} else
			currItem = start
	
		arrCounter = 0;
		
		if (arrSlide.length > 1) { /* Only show paging if more than 1 image */
			$('#'+slideShowID).append("<div id='"+slideShowID+"Paging'><ul></ul></div>");/* Creates the paging */
			for (i=0;i<arrSlide.length;i++) {
				if (mouseBehavior == 'click')
					$('#'+slideShowID+' #'+slideShowID+'Paging ul').append("<li id='"+slideShowID+"Item"+i+"'><a href='javascript:;' onclick='"+objName+".slideSwitch("+i+");return false;'>&nbsp;</a></li>");
				else
					$('#'+slideShowID+' #'+slideShowID+'Paging ul').append("<li id='"+slideShowID+"Item"+i+"'><a href='javascript:;' onMouseOver='"+objName+".slideSwitch("+i+");return false;'>&nbsp;</a></li>");
			}
			$('#'+slideShowID+' #'+slideShowID+'Paging li').each( function() {  
				arrSlidePaging[arrCounter++] = $(this);
			});
		}
		
		$('#'+slideShowID).css("width", slideWidth+"px");
		if (slideWidth > 0)
			$('#'+slideShowID+'>div:first-child').css("width", slideWidth+"px");
		if (slideHeight > 0)
			$('#'+slideShowID+'>div:first-child').css("height", slideHeight+"px");
		
		$('#'+slideShowID+'>div:first-child').css("position", "relative");
		
		if (arrSlide.length > 1) /* Only executes if more than 1 image */
			arrSlidePaging[currItem].addClass('slideSelected'); /* Highlights the paging box according to the start */

		if (arrSlide.length == 1) {
			arrSlide[0].show();
		} else {
			if (play) { 
				slideShowPlay = true; 
				this.slideSwitch('play');
			} else
				this.slideSwitch(currItem);
		}
	}
	
	 this.slideSwitch = function(position) {
		var oldItem = currItem;
		
		if (position=='play' && !slideShowPlay)
			return;
		
		if (position == 'play') {
			currItem = currItem + 1;
			if (currItem > arrSlide.length-1)
				currItem = 0;
		} else { 
			slideShowPlay = false;
			currItem = position;
		}

		if (oldItem != currItem || slideShowPlay == false) {
			arrSlide[oldItem].fadeOut('slow');
			arrSlidePaging[oldItem].removeClass('slideSelected');
			arrSlide[currItem].fadeIn('slow');
			arrSlidePaging[currItem].addClass('slideSelected');
			/*onSlideChangeFn();*/
		}
		if ((position == 'play') && (slideShowPlay)) {
			setTimeout(""+objName+".slideSwitch('play');",slideTimer);
		}
	}
	
	this.setTimer = function(timerParam) {
		slideTimer = timerParam;	
	}
	
	this.setMouseBehavior = function(type) { /* mouseOver, click */
		mouseBehavior = type;	
	}
}
