
$(document).ready(function(){
	var s = e('slider');
	if(s != null)
	{
		$("#slider").easySlider({
			controlsBefore:	'<p id="controls">',
			controlsAfter:	'</p>',
			auto: true,
			continuous: true,
			speed: 1000,
			pause: 3000
		});
	}
});

function updateTotals(itemToUpdate)
{
	var quantObj = e('quantity');
	var postObj = e('PostageOptionID');

	var qURL = 'index.php?action=ajax-calculate-book-subtotal';
	var pURL = 'index.php?action=ajax-update-postage-cost';
	var gtURL = 'index.php?action=ajax-update-grand-total';

	switch (itemToUpdate)
	{
		case 'calculate-book-subtotal':
			$("#subTotal").html('<img src="images/spinner.gif">');
			$.ajax({
			  url: qURL,
			  data: 'module=books&PostageOptionID='+escape(postObj.options[postObj.selectedIndex].value)+'&quantity='+escape(quantObj.options[quantObj.selectedIndex].value),
			  success: function(html){
				$("#subTotal").html(html);
			  }
			});
		//always do the below case (i.e. no break here!)
		case 'update-postage-cost':
			$("#postageCostPrice").html('<img src="images/spinner.gif">');
			$.ajax({
			  url: pURL,
			  data: 'module=books&PostageOptionID='+escape(postObj.options[postObj.selectedIndex].value)+'&quantity='+escape(quantObj.options[quantObj.selectedIndex].value)+'&target=postageCostPrice',
			  success: function(html){
				$("#postageCostPrice").html(html);
			  }
			});
			$("#postageCostSubtotal").html('<img src="images/spinner.gif">');
			$.ajax({
			  url: pURL,
			  data: 'module=books&PostageOptionID='+escape(postObj.options[postObj.selectedIndex].value)+'&quantity='+escape(quantObj.options[quantObj.selectedIndex].value)+'&target=postageCostSubtotal',
			  success: function(html){
				$("#postageCostSubtotal").html(html);
			  }
			});
			$("#grandTotal").html('<img src="images/spinner.gif">');
			$.ajax({
			  url: gtURL,
			  data: 'module=books&PostageOptionID='+escape(postObj.options[postObj.selectedIndex].value)+'&quantity='+escape(quantObj.options[quantObj.selectedIndex].value),
			  success: function(html){
				$("#grandTotal").html(html);
			  }
			});
			break;
	}
	return false;
}
