
$(document).ready(function(){

	var tab_a1 = true;
	var tab_b1 = false;
	var tab_c1 = false;
	var tab_d1 = false;
	var tab_e1 = false;
	var tab_f1 = false;
	var api;
 
/*====================================================*/ 
	$("#BookcaseLBox_scrollable_a1").scrollable({circular:true}).navigator();

	api = $("#BookcaseLBox_scrollable_a1").data("scrollable");

	display_div_listi = api.getItems();	
	
	load_item_list_all(0,3,7,display_div_listi,'list_type.asp?book_class=a1&num=7&index=0',96,144);
	
  	$('#IndexBookCaseBList ul li').hover(function()
  	{  		
 				var id = $(this).attr('id');
				id = id.substr(5);

    		$('#'+id).show().siblings('.IndexBookCaseBInfo').hide();
    		
				$(this).addClass('ListVisible').siblings().removeClass('ListVisible');
		  			  		
	  		var update = false;
	  		switch(id)
	  		{
	  			case "a1":
	  					if ( tab_a1 == false )
	  					{
								update = true;
								tab_a1 = true;
	  					}
	  					break;
	  			case "b1":
	  					if ( tab_b1 == false )
	  					{
	  						update = true;
								tab_b1 = true;
	  					}
	  					break;
	  			case "c1":
	  					if ( tab_c1 == false )
	  					{
								update = true;
								tab_c1 = true;
	  					}

	  					break;
	  			case "d1":
	  					if ( tab_d1 == false )
	  					{
								update = true;
								tab_d1 = true;
	  					}
	  					break;
	  			case "e1":
	   					$.getJSON('list_type.asp',{book_class:"e1"},function(data)
	   					{
//	   						$("#" + id).empty();
	   							content_html = "";
	     						for( var i = 0; i < 7; ++i )
	     						{
	     							if ( data.books[i].book_id != "" )
	     							{
	     								content_html = content_html + '<div class="IndexBookCaseBBox"><a href="' + data.books[i].book_link + '"><img src="' + data.books[i].book_cover + '" width="96" height="144" class="img" /></a><br/>';
	     								if( data.books[i].price != "NO DATA")
	     								{
	     									content_html = content_html + '$' + data.books[i].price;
	     								}
	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].book_name + '" name="book_title">';
	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].author + '" name="book_author">';
	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].price + '" name="book_price">';
	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].book_id + '" name="book_id">';
	     								content_html = content_html + '<input type="hidden" value="' + id + '" name="div_id"></div>';	     								
	     							}else
	     							{
	     								content_html = content_html + '<div class="IndexBookCaseBBox" style="background:none;visibility:hidden"><span><img src="' + data.books[i].book_cover + '" width="96" height="144" class="img" /></span>';
	     								content_html = content_html + '<input type="hidden" value="" name="book_id"></div>';	     		
	     							}
		 					}

		 					$("#" + id).html(content_html);
		 					show_tooltip_list($("#e1").children("div").children().children("img"));
		 					
		 				});
		 				break;
	  		}
	  		if ( update == true )
	  		{
	  		    if( id != 'c1' )
	  		    {

						$("#BookcaseLBox_scrollable_" + id ).scrollable({circular:true}).navigator();
	  				    api = $("#BookcaseLBox_scrollable_" + id ).data("scrollable");

						display_div_listi = api.getItems();	

						load_item_list_all(0,3,7,display_div_listi,'list_type.asp?book_class=' + id + '&num=7&index=0',96,144);
						
						$("#BookcaseLBox_scrollable_" + id).data("scrollable").onBeforeSeek(function()  {
						}).onSeek(function() {
								item_offset = this.getIndex();
								item_num	= this.getSize();
								image_num	= 7;
								width		= 96;
								height		= 144;
								display_div_list = this.getItems();
								var first_div_length = display_div_list.eq(item_offset).children().eq(0).children().length;
								if (first_div_length == "0")
								{
									load_item_list_all(item_offset,item_num,image_num,display_div_list,'list_type.asp?book_class=' + id + '&num=7&index=' + item_offset,width,height);
								}		
						});	 
				}else
				{
	   					$.getJSON('list_type.asp',{book_class:"c1",num:"21"},function(data)
	   					{
	   					    content_html = "";
//	   						$("#" + id).empty();
	   					    if( data.books[7].book_id == "" )
	   					    {
    	   							content_html = "";
    	     						for( var i = 0; i < 7; ++i )
    	     						{
    	     							if ( data.books[i].book_id != "" )
    	     							{
    	     								content_html = content_html + '<div class="IndexBookCaseBBox"><a href="' + data.books[i].book_link + '"><img src="' + data.books[i].book_cover + '" width="96" height="144" class="img" /></a><br/>';
    	     								if( data.books[i].price != "NO DATA")
    	     								{
    	     									content_html = content_html + '$' + data.books[i].price;
    	     								}
    	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].book_name + '" name="book_title">';
    	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].author + '" name="book_author">';
    	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].price + '" name="book_price">';
    	     								content_html = content_html + '<input type="hidden" value="' + data.books[i].book_id + '" name="book_id">';
    	     								content_html = content_html + '<input type="hidden" value="' + id + '" name="div_id"></div>';	     								
    	     							}else
    	     							{
    	     								content_html = content_html + '<div class="IndexBookCaseBBox" style="background:none;visibility:hidden"><span><img src="' + data.books[i].book_cover + '" width="96" height="144" class="img" /></span>';
    	     								content_html = content_html + '<input type="hidden" value="" name="book_id"></div>';	     		
    	     							}
    		 					    }
    
    		 					    $("#c1" ).html(content_html);
//    		 					    show_tooltip_list($("#c1").children("div").children().children("img"));	   					        
    		 					    show_tooltip_list($("#c1").children("div").children("div").children(".items").children("div").children().children().children("img"));
	   					    }else
	   					    {
	   					        //alert("this");
	   					        //more than one page..
	   					        var total_page = ( data.books[14].book_id == "" ) ? 2 : 3;
	   					        content_html = '<div class="IndexBookcaseLInfo"><div class="scrollable_list scrollable" id="BookcaseLBox_scrollable_c1"><div class="items">';
	   					        
    	   						for( var j = 0; j < total_page; ++j )
    	   						{
    	   							    content_html = content_html + '<div>';
    	     						    for( var i = j * 7; i < ( ( j * 7 ) + 7 ); ++i )
    	     						    {
    	     							    if ( data.books[i].book_id != "" )
    	     							    {
    	     								    content_html = content_html + '<div class="IndexBookCaseBBox"><a href="' + data.books[i].book_link + '"><img src="' + data.books[i].book_cover + '" width="96" height="144" class="img" /></a><br/>';
    	     								    if( data.books[i].price != "NO DATA")
    	     								    {
    	     									    content_html = content_html + '$' + data.books[i].price;
    	     								    }
    	     								    content_html = content_html + '<input type="hidden" value="' + data.books[i].book_name + '" name="book_title">';
    	     								    content_html = content_html + '<input type="hidden" value="' + data.books[i].author + '" name="book_author">';
    	     								    content_html = content_html + '<input type="hidden" value="' + data.books[i].price + '" name="book_price">';
    	     								    content_html = content_html + '<input type="hidden" value="' + data.books[i].book_id + '" name="book_id">';
    	     								    content_html = content_html + '<input type="hidden" value="' + id + '" name="div_id"></div>';	     								
    	     							    }else
    	     							    {
    	     								    content_html = content_html + '<div class="IndexBookCaseBBox" style="background:none;visibility:hidden"><span><img src="' + data.books[i].book_cover + '" width="96" height="144" class="img" /></span>';
    	     								    content_html = content_html + '<input type="hidden" value="" name="book_id"></div>';	     		
    	     							    }
    	     							}
    	     							content_html = content_html + '</div>';
    	     					}
    		 					content_html = content_html + '</div></div>';
    		 					if( total_page == 2 )
    		 					{
    		 					        content_html = content_html + '<div class="apdivp prev" style="cursor:pointer"><img src="images/btn_arrow_l.png" width="33" height="33" alt="#" class="img" /></div><div class="apdivn next" style="cursor:pointer"><img src="images/btn_arrow_r.png" width="33" height="33" alt="#" class="img" /></div><div class="Colorbar" style="padding-left:30px;"><div class="navi"><div class="ColorbarSizeList-2b Colorbar-a active"></div><div class="ColorbarSizeList-2b Colorbar-a"></div></div><div style="float:left;"><a href="list.asp?type=c1"><span class="textGreen2">see all</span></a> >></div></div>';
    		 					}else
    		 					{
    		 					        content_html = content_html + '<div class="apdivp prev" style="cursor:pointer"><img src="images/btn_arrow_l.png" width="33" height="33" alt="#" class="img" /></div><div class="apdivn next" style="cursor:pointer"><img src="images/btn_arrow_r.png" width="33" height="33" alt="#" class="img" /></div><div class="Colorbar" style="padding-left:30px;"><div class="navi"><div class="ColorbarSizeList-b Colorbar-a active"></div><div class="ColorbarSizeList-b Colorbar-a"></div><div class="ColorbarSizeList-b Colorbar-a"></div></div><div style="float:left;"><a href="list.asp?type=c1"><span class="textGreen2">see all</span></a> >></div></div>';
    		 					}
    		 					content_html = content_html + '</div>';
//    		 					alert( content_html);
    		 					$("#c1").html(content_html);
    		 					show_tooltip_list($("#c1").children("div").children("div").children(".items").children("div").children().children().children("img"));
    		 				}
    		 				$("#BookcaseLBox_scrollable_c1" ).scrollable({circular:true}).navigator();

		 				});	  					
				    
				    
				}
			}
								
				

		});
		
/*====================================================*/	

	$("#BookcaseLBox_scrollable_a1").data("scrollable").onBeforeSeek(function()  {
	}).onSeek(function() {
		item_offset = this.getIndex();
		item_num	= this.getSize();
		image_num	= 7;
		width		= 96;
		height		= 144;
		display_div_list = this.getItems();
		var first_div_length = display_div_list.eq(item_offset).children().eq(0).children().length;
		if (first_div_length == "0")
		{
			load_item_list_all(item_offset,item_num,image_num,display_div_list,'list_type.asp?book_class=a1&num=7&index=' + item_offset,width,height);
		}		
	});	 
 		
});


$(document).ready(function(){
	

	$("#BookcaseLDblBox_scrollable2").scrollable({circular:true}).navigator();
	
	api = $("#BookcaseLDblBox_scrollable2").data("scrollable");
	


	display_div_listi = api.getItems();	

	isize = api.getSize();
	load_item_list_all(0,isize,10,display_div_listi,'list_type.asp?book_class=inde&num=10&index=0',96,144);
	

	$("#BookcaseLDblBox_scrollable2").data("scrollable").onBeforeSeek(function()  {


	}).onSeek(function() {
		item_offset = this.getIndex();
		item_num	= this.getSize();
		image_num	= 10;
		width		= 96;
		height		= 144;
		display_div_list = this.getItems();
		var first_div_length = display_div_list.eq(item_offset).children().eq(0).children().length;
		if (first_div_length == "0")
		{
			load_item_list_all(item_offset,item_num,image_num,display_div_list,'list_type.asp?book_class=inde&num=10&index=' + item_offset,width,height);
		}		
	});	
	
	
	


	$("#BookcaseLBox_scrollable_2").scrollable({circular:true}).navigator();
	
	api = $("#BookcaseLBox_scrollable_2").data("scrollable");

	display_div_listi = api.getItems();	
	
	load_item_list_all(0,5,5,display_div_listi,'list_type.asp?book_class=view&num=5&index=0',96,144);
	
	

	$("#BookcaseLBox_scrollable_2").data("scrollable").onBeforeSeek(function()  {


	}).onSeek(function() {

		item_offset = this.getIndex();

		item_num	= this.getSize();

		image_num	= 5;
		width		= 96;
		height		= 144;

		display_div_list = this.getItems();

		var first_div_length = display_div_list.eq(item_offset).children().eq(0).children().length;
		if (first_div_length == "0")
		{
			load_item_list_all(item_offset,item_num,image_num,display_div_list,'list_type.asp?book_class=view&num=5&index=' + item_offset,width,height);
		}		
	});
	



	$("#BookcaseLDblBox_scrollable").scrollable({circular:true}).navigator();


	api = $("#BookcaseLDblBox_scrollable").data("scrollable");

	display_div_listi = api.getItems();	
	load_item_list_all(0,3,10,display_div_listi,'list_type.asp?book_class=NY&num=10&index=0',96,144);

	

	$("#BookcaseLDblBox_scrollable").data("scrollable").onBeforeSeek(function()  {


	}).onSeek(function() {

		item_offset = this.getIndex();

		item_num	= this.getSize();

		image_num	= 10;
		width		= 96;
		height		= 144;

		display_div_list = this.getItems();

		var first_div_length = display_div_list.eq(item_offset).children().eq(0).children().length;
		if (first_div_length == "0")
		{

			load_item_list_all(item_offset,item_num,image_num,display_div_list,'list_type.asp?book_class=NY&num=10&index=' + item_offset,width,height);

		}		
	});

	var oScrollStaff;

	$.post("list_total.asp",{type:"staff"},function(data_string)
	{

		if( data_string.substring(0,7) == "success" )
		{
			var count = data_string.substr(7);
			var page_html = $("#BookcaseBoxS_scrollable_1").children(".items").children().first().html();
			var page_list = $("#BookcaseBoxS_scrollable_1").children(".items");
			var prev_button = $("#apDiv9");
			var next_button = $("#apDiv10");
			
//			load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=staff&num=1&index=0&count=" + count,152,227);
			load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=staff&num=1&index=0",152,227);	


			oScrollStaff = new ScrollObject(page_list,prev_button,next_button,false,152,250,page_html,count,true,"","",function()
			{
				var PageIndex = oScrollStaff.GetIndex();

//				load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=staff&num=1&index=" + PageIndex + "&count=" + count,152,227);
				load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=staff&num=1&index=" + PageIndex,152,227);
			});
		}
	});

	var oScrollHot;

	$.post("list_total.asp",{type:"hot"},function(data_string)
	{

		if( data_string.substring(0,7) == "success" )
		{
			var count = data_string.substr(7);
			var page_html = $("#BookcaseBoxS_scrollable_2").children(".items").children().first().html();
			var page_list = $("#BookcaseBoxS_scrollable_2").children(".items");
			var prev_button = $("#apDiv11");
			var next_button = $("#apDiv12");
			
//			load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=hot&num=1&index=0&count=" + count,152,227);
			load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=hot&num=1&index=0",152,227);			
			
			oScrollHot = new ScrollObject(page_list,prev_button,next_button,false,152,250,page_html,count,true,"","",function()
			{
				var PageIndex = oScrollHot.GetIndex();

//				load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=hot&num=1&index=" + PageIndex,152,227);
				load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=hot&num=1&index=" + PageIndex,152,227);
			}
			);
		}
	});

	var oScrollLove;

	$.post("list_total.asp",{type:"love"},function(data_string)
	{

		if( data_string.substring(0,7) == "success" )
		{
			var count = data_string.substr(7);
			var page_html = $("#BookcaseBoxS_scrollable_3").children(".items").children().first().html();
			var page_list = $("#BookcaseBoxS_scrollable_3").children(".items");
			var prev_button = $("#apDiv13");
			var next_button = $("#apDiv14");
			
//			load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=love&num=1&index=0&count=" + count,152,227);
			load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=love&num=1&index=0",152,227);
			
			oScrollLove = new ScrollObject(page_list,prev_button,next_button,false,152,250,page_html,count,true,"","",function()
			{
				var PageIndex = oScrollLove.GetIndex();

//				load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=love&num=1&index=" + PageIndex + "&count=" + count,152,227);
				load_item_list_all_detail(0,count,1,page_list,"list_type2.asp?book_class=love&num=1&index=" + PageIndex,152,227);
				
			}
			);
		}
	});

	

});


function show_tooltip (trigger) {
	trigger.tooltip({opacity: 0.9,
	   position: "bottom center",
	   delay:10,
	   tip:'#apDiv16',
	   // tweak the position
			offset:[5,0],
	   // use the "slide" effect
	   effect: 'slide'}).dynamic({ top: { direction: 'up', bounce: true , offset: [-20, 0]} });
	   	
	trigger.data("tooltip").onBeforeShow(function()  {

		tip		= this.getTip();
		trigger = this.getTrigger();
		attr_div_parent = trigger.parent().parent();
		
		var position = 	trigger.offset()
		
		
		current_size	= attr_div_parent.parent().children().length;
		current_offset	= attr_div_parent.parent().children().index(attr_div_parent);
		
		
		var book_id  = attr_div_parent.find("[name=book_id]").val();
		
		

		if( book_id == "" )
		{
			tip.empty();	
		}else
		{
			var book_title  = attr_div_parent.find("[name=book_title]").val();
			var book_author = attr_div_parent.find("[name=book_author]").val();
			var book_price  = attr_div_parent.find("[name=book_price]").val();			
			var div_id  = attr_div_parent.find("[name=div_id]").val();

			var book_link = trigger.parent().attr("href");

			if ( tip.attr("class") == "tooltip" )
			{
/*				if ( div_id == "c1" )
				{

						tip_content = '<div style="background:url(images/tip_bottom_part_1.png);height:25px"></div><div style="background:url(images/tip_bottom_part_2.png);height:162px">';
				
						tip_content += '<table style="padding:0px 20px 0px 20px"><tr><td style="overflow:hidden;"><h3 class="textGreen" style="max-height:30px">'+book_title+'</h3></td></tr><tr><td><div style="overflow:hidden;max-height:17px">by <span class="textGreen">'+book_author+
													'</span></div></td></tr><tr><td><p class="textGreen textPrizeMid"><input name="input3" type="button" class="TyprBotton" value="DOWNLOAD" onclick="javscipt: return window.open(\'' + book_link + '\',\'_blank\');"/></p></td></tr></table>';				

						tip_content += '</div><div style="background:url(images/tip_bottom_part_3.png);height:13px"></div>';
				}else
				{
*/
						tip_content = '<div style="background:url(images/tip_bottom_part_1.png);height:25px"></div><div style="background:url(images/tip_bottom_part_2.png);height:162px">';
			
						tip_content += '<table style="padding:0px 20px 0px 20px"><tr><td style="overflow:hidden;"><h3 class="textGreen" style="max-height:30px">'+book_title+'</h3></td></tr><tr><td><div style="overflow:hidden;max-height:17px">by <span class="textGreen">'+book_author+
														'</span></div></td></tr><tr><td><p class="textGreen textPrizeMid">$' + book_price + '<br /><input name="input3" type="button" class="TyprBotton" value="BUYNOW" onclick="javscipt: return location.assign(\'cart.asp?act=add&EAN=' + book_id + '\&type=' + div_id + '\');"/></p></td></tr></table>';
					

						tip_content += '</div><div style="background:url(images/tip_bottom_part_3.png);height:13px"></div>';
//				}
			}else
			{
/*				if ( div_id == "c1" )
				{
						tip_content = '<div style="background:url(images/tip_top_part_3.png);height:13px"></div><div style="background:url(images/tip_top_part_2.png);height:162px">';
				
						tip_content += '<table style="padding:0px 20px 0px 20px"><tr><td style="overflow:hidden;"><h3 class="textGreen" style="max-height:30px">'+book_title+'</h3></td></tr><tr><td><div style="overflow:hidden;max-height:17px">by <span class="textGreen">'+book_author+
													'</span></div></td></tr><tr><td><p class="textGreen textPrizeMid"><input name="input3" type="button" class="TyprBotton" value="DOWNLOAD" onclick="javscipt: return window.open(\'' + book_link + '\',\'_blank\');"/></p></td></tr></table>';				

						tip_content += '</div><div style="background:url(images/tip_top_part_1.png);height:24px"></div>';
				}else
				{
*/						tip_content = '<div style="background:url(images/tip_top_part_3.png);height:13px"></div><div style="background:url(images/tip_top_part_2.png);height:162px">';
						
						tip_content += '<table style="padding:0px 20px 0px 20px"><tr><td style="overflow:hidden;"><h3 class="textGreen" style="max-height:30px">'+book_title+'</h3></td></tr><tr><td><div style="overflow:hidden;max-height:17px">by <span class="textGreen">'+book_author+
														'</span></div></td></tr><tr><td><p class="textGreen textPrizeMid">$' + book_price + '<br /><input name="input3" type="button" class="TyprBotton" value="BUYNOW" onclick="javscipt: return location.assign(\'cart.asp?act=add&EAN=' + book_id + '\&type=' + div_id + '\');"/></p></td></tr></table>';
						
						tip_content += '</div><div style="background:url(images/tip_top_part_1.png);height:24px"></div>';
//				}				
			}
			

			tip.html(tip_content);
		}
	});
}


function show_tooltip_list(triggers) {

	for (var n = 0 ; n < triggers.length ; n++ )
	{
		show_tooltip(triggers.eq(n));
	}
}


function load_item_list_all(item_offset,item_num,image_num,display_div_list,hander_php,width,height) {
	var start_offset = item_offset*image_num;
	display_div_list.eq(item_offset).children().html('<img src="images/bookcase/loading.gif" width="'+width+'" height="'+height+'" class="img" />');

	$.getJSON(hander_php,
		{
		  "start_offset": start_offset,
		  "image_num": image_num
		},
		function(data){

			for (var n = 0 ; n < image_num ; n++ )
			{		
				var div_block = display_div_list.eq(item_offset).children().eq(n);

				display_book_div(div_block,data.books[n],width,height);
				show_tooltip(div_block.find("img"));

			}	
		}
	);
}


function display_book_div(div_block,data_info,width,height) {

	if ( data_info.book_id != "" )
	{

		div_content_html = '<a href="' + data_info.book_link + '"';
//		if( data_info.div_id == "c1" )
//		{
//			if( data_info.price == "y")//google books
//			{
//				div_content_html = '<a href="book2.asp?id=' + data_info.book_id + '"><img src="' + data_info.book_cover+'" width="'+width+'" height="'+height+'" class="img" /></a><br /><input type="hidden" name="book_price" value="NO DATA"/>';
//			}else
//			{
//				div_content_html = '<a href="' + data_info.book_link + '" target="_blank"><img src="' + data_info.book_cover+'" width="'+width+'" height="'+height+'" class="img" /></a><br /><input type="hidden" name="book_price" value="NO DATA"/>';
//			}
//		}else
//		{
			div_content_html = '<a href="' + data_info.book_link + '"><img src="' + data_info.book_cover+'" width="'+width+'" height="'+height+'" class="img" /></a><br />$' + data_info.price;
			div_content_html += '<input type="hidden" name="book_price" value="'+data_info.price+'" />';
//		}
		
		div_content_html += '<input type="hidden" name="book_title" value="'+data_info.book_name+'" />';
		div_content_html += '<input type="hidden" name="book_author" value="'+data_info.author+'" />';
		div_content_html += '<input type="hidden" name="book_id" value="'+data_info.book_id+'" />';
		div_content_html += '<input type="hidden" name="div_id" value="'+data_info.div_id+'" />';
	}else
	{	//tip function will find trigger's grandparent,so you need two level,we change the <a> to <span>
		div_block.css("background","none");
		div_block.css("visibility","hidden");
		div_content_html = '<span><img src="' + data_info.book_cover+'" width="'+width+'" height="'+height+'" class="img" /></span>';
		div_content_html += '<input type="hidden" name="book_id" value="" />';
	}

	div_block.html(div_content_html);
}


/*
single slot book
*/
function load_item_list_all_detail(item_offset,item_num,image_num,display_div_list,hander_php,width,height) {
	var start_offset = item_offset*image_num;
	display_div_list.eq(item_offset).children().html('<img src="images/bookcase/loading.gif" width="'+width+'" height="'+height+'" class="img" />');
	$.getJSON(hander_php,
		{
		  "start_offset": start_offset,
		  "image_num": image_num
		},
		function(data){
			for (var n = 0 ; n < image_num ; n++ )
			{		
				var div_block = display_div_list.eq(item_offset).children().eq(n);

				display_book_div_detail(div_block,data.books[n],width,height);
				show_tooltip(div_block.find("img"));
			}	
		}
	);
}


function display_book_div_detail(div_block,data_info,width,height) {

	if ( data_info.book_id != "" )
	{		
		div_content_html = '<a href="' + data_info.book_link + '"><img src="'+data_info.book_cover+'" width="'+width+'" height="'+height+'" class="img" /></a><br />';
		div_content_html += '$'+data_info.price;
		div_content_html += '<input type="hidden" name="book_price" value="'+data_info.price+'" />';
		div_content_html += '<input type="hidden" name="book_title" value="'+data_info.book_name+'" />';
		div_content_html += '<input type="hidden" name="book_author" value="'+data_info.author+'" />';
		div_content_html += '<input type="hidden" name="book_id" value="'+data_info.book_id+'" />';		
		div_content_html += '<input type="hidden" name="div_id" value="'+data_info.div_id+'" />';		
	}else
	{
		div_block.css("background","none");
		div_block.css("visibility","hidden");
		div_content_html = '<span><img src="" width="'+width+'" height="'+height+'" class="img" /></span><br />';
		div_content_html += '<input type="hidden" name="book_id" value="" />';
	}

	div_block.html(div_content_html);
}
