var handlerFunc = function(t) {
    //alert(t.responseText);
	elem = document.getElementById('booktitle');
	elem.innerHTML = t.responseText;
}

var errFunc = function(t) {
	elem = document.getElementById('booktitle');
	elem.innerHTML = '<div align="center">Error: We were not able to retrieve information about this book.</div>';
}

var handlerFunc2 = function(t) {
    //alert(t.responseText);
	elem = document.getElementById('bookbrowse');
	elem.innerHTML = t.responseText;
}

var errFunc2 = function(t) {
	elem = document.getElementById('bookbrowse');
	elem.innerHTML = '<div align="center">Error: We were not able to retrieve any more books.</div>';
}

var display_title = function(id) {	
	new Ajax.Request('bookdetails.php?id='+id, {asynchronous:true, onSuccess:handlerFunc, onFailure:errFunc});
}

var hide_title = function() {
	elem = document.getElementById('booktitle');
	elem.innerHTML = '<div align="center">&lt;mouse over a photo above to see more info&gt;</div>';
}

var browse_books = function(id,sid) {
	//+'&prev'+prev
	new Ajax.Request('bookbrowse.php?set='+id+'&sid='+sid, {asynchronous:true, onSuccess:handlerFunc2, onFailure:errFunc2});
}

function openDetails(id,sid) {
	//Dialog.info({url: 'details.php?id='+id, options: {method: 'get'}}, {className: "alphacube",  width:500, height:500});
    Dialog.alert({url: 'details.php?id='+id+'&sid='+sid, options: {method: 'get'}}, {className: "alphacube",  width:500, height:500});
}

var handlerFunc3 = function(t) {
	alert(t.responseText);
	Dialog.okCallback();
	return true;
}

var closeInfo = function() {
	Dialog.okCallback();
	return true;
}

var errFunc3 = function(t) {
	alert('There was a problem adding the book to your shopping cart.');
	Dialog.okCallback();
	return true;
}

var add_to_cart = function(sid,id) {
	new Ajax.Request('cart.php?id='+id+'&shoppingcart='+sid+'&action=add', {asynchronous:false, onSuccess:handlerFunc3, onFailure:errFunc3});
}
