tools = {
	options : {
		readerBaseUrl : '/reader/index'
	}
};

tools.readBook = function(docID, searchString) {
	winH = screen.height;
	winW = screen.width;

	var url = tools.options.readerBaseUrl + '/docid/' + docID;
	if (searchString)
		url = url + '/searchterm/' + searchString;

	mywin = window.open(url, 'ComReader', 'status=yes,top=0,left=0,width='
			+ (winW - 10) + ',height=' + (winH - 80)
			+ ',toolbar=no,menubar=no,location=no,scollbars=yes,resizable=yes');

	mywin.focus();
}

tools.updateSubjects = function(docid, container) {
	this.debugMsg(docid);
	$.ajax({
		url : '/tag/ajaxsubjects/docid/' + docid,
		success : function(data) {
			$('#' + container).html(data);
		}
	});
}

tools.isIpad = function() {
	return (navigator.userAgent.indexOf("iPad") > 0);
}
tools.showBooksOfSubject = function(subject) {
	if (tools.isIpad()) {
		winH = screen.height;
		winW = screen.width;
	} else {
		winH = screen.height / 2;
		winW = 800; //screen.width /2;
	}

	var url = '/tag/subject/id/' + subject;

	mywin = window.open(url, 'BooksSubject', 'status=yes,top=0,left=0,width='
			+ (winW) + ',height=' + (winH)
			+ ',toolbar=no,menubar=no,location=no,scollbars=yes,resizable=no');

	mywin.focus();
}
tools.showBooksOfTag = function(subject) {
	if (tools.isIpad()) {
		winH = screen.height;
		winW = screen.width;
	} else {
		winH = screen.height / 2;
		winW = 800; //screen.width /2;
	}

	var url = '/tag/tagbooks/id/' + subject;

	mywin = window.open(url, 'BooksTag', 'status=yes,top=0,left=0,width='
			+ (winW) + ',height=' + (winH)
			+ ',toolbar=no,menubar=no,location=no,scollbars=yes,resizable=no');

	mywin.focus();
}

tools.debugMsg = function(msg) {
	try {
		console.log(msg);
	} catch (ee) {
	}
}

var readBook = tools.readBook;

