
// functions for eManga
function openPlayerWin(url){
	w=(screen.width*1);
	h=(screen.height*1)-20;
	wleft=(screen.width-w)/2;
	wtop=0; //(screen.height-h)/2;
	bookUrl="http://www.emanga.com/app/reader/?b="+url;
	wName="eMangaReader";
	props='width='+w+',height='+h+','+'left='+wleft+',top='+wtop+','+'location=no,menubar=no,statusbar=no,status=no,toolbar=no,scrollbars=no,resizable=yes';
	var rWin=window.open(bookUrl,wName,props);
	// Just in case width and height are ignored
	rWin.resizeTo(w, h);
	// Just in case left and top are ignored
	rWin.moveTo(wleft, wtop);
	rWin.focus();
}

function addToCart(pc,obj){
	if (hasAccess) {
		$.ajax({
			type:'POST',
			url:'books.php',
			data:'action=cart&p=add&code='+pc,
			success:function(data){
				if (data==1) {
					alert('The book has been added to your list!');
					var unread=parseInt($('#list-unread').html());
					unread++;
					$('#list-unread').html(unread.toString());
				}
				else if (data==-1) alert('The book is already on your list.');
				else if (data==-2) alert('That book is already available to you now.');
			
				if (typeof obj != 'undefined' && data!=0) {
					var tmp=$(obj).attr('href','https://secure.emanga.com/my/');
					if (tmp.find('img').attr('src')=='images/book_add.jpg')
						tmp.html('<img src="images/book_added.jpg" alt="View" title="View My List" />');
					else
						tmp.html('<img src="images/book_added_sm.jpg" alt="View" title="View My List" />');
				}
			}
		});
	}
	else
		alert('You must be logged in first.');
}

function rentBook(bktitle,bkprice) {
	if (hasAccess) {
		return confirm("Rent "+bktitle+" for "+bkprice+" points?");
	}
	else {
		alert('You must be logged in first.');
		return false;
	}
}
