/*Copyright Trinity Innovations LTD 2011. All rights reserved*/
/*
# Project [iPad 3D]
# Version: [activeproject_activever]  Alan Ryan www.codecrunchers.ie
#-------------------------------------------------------------------------
*/
var PRELOAD = 4; // number of images to preload Landsacpe
var PRELOAD_P = 3; // number of images to preload portrait
var consoleLog = false; //TODO: Turn Off!
var imgPreLoadCounter = 0;
var thumbNavUp = false;
var activeCPControl = false;
//var COLSINTHUMBROW = 4; //TODO: Not needed
var SCROLLROWS = 1;
var curPage = -1;
var leftStart = 0, rightStart = 1;

if(consoleLog)
	console.log("Log Init");

$.imgpreload('images/loading.gif',function(){ });


$(document).ready(function(){	
	
// preload images
if($('#myBook img').size()){
	//$('#imgLoadScreen').show();
	$('#myBook img').imgpreload
	({
		each: function()
		{				
		},
		all: function()
		{
			//$('#imgLoadScreen').hide();
			
		}
	});
	
	//$('#ff_panel').hide();
	
}

Shadowbox.init({
	modal:false,
	animate:false,
});//Pop Ups


//search 
$("#do_search").click(function(){	
    $("#searchresults").load("lib/do_search.php?keyword="+encodeURIComponent($("#search_keyword").val()));
}); 

});

//This is double tap/zoom script
function getCurPage(){
		return curPage;
}
/**
 * When Div is touched we trigger this, not indicative of pages loaded
 * 
 * @param _curPage
 * @return
 */
function setCurPage(_curPage){
	if(consoleLog){
		console.log("Cur Page At Flip:" + $('#gotoFlip').attr('value') + " Setting to" + _curPage);		
	}		
	curPage = _curPage;
}


function incCurPage(){
	setCurPage(curPage+1);
}


function decCurPage(){
	setCurPage(curPage-1);
}


function _dtZoom(index){	
	if(consoleLog)
		console.log("zoom index="+index+1);
	newLoc = "php/zoom.php?or=0&page="+(index+1);
	$(window.location).attr('href', newLoc);
}