var targetCustomerQuoteNodeId = '';
var lastCustomerQuoteCategoryName = '';

function beginRotateCustomerQuote(nodeId, categoryName) {
	targetCustomerQuoteNodeId = nodeId;
	lastCustomerQuoteCategoryName = categoryName;
	
	var xhr = new Request.HTML(
		{
			url:
				"api/get/customerQuote.php" +
				"?CategoryName=" + categoryName
			,
			method: 'get',
			async: true,
			autoCancel: true,
			//update: $(nodeId)
			onComplete: endRotateCustomerQuote
		}
	);
	
	xhr.send();
}

function endRotateCustomerQuote(tree, elements, html, js) {
	var node = $(targetCustomerQuoteNodeId);
	
	var fadeIn = new Fx.Tween(
		node,
		{
			duration: 250,
			property: "opacity",
			onComplete: function() {
				setTimeout(
					"beginRotateCustomerQuote('" + targetCustomerQuoteNodeId + "', '" +
					lastCustomerQuoteCategoryName + "');",
					10000
				);
				
				targetCustomerQuoteNodeId = '';
			}
		}
	);
	
	var fadeOut = new Fx.Tween(
		node,
		{
			duration: 250,
			property: "opacity",
			onComplete: function() {
				$(targetCustomerQuoteNodeId).innerHTML = html;
				fadeIn.start(0.0, 1.0);
			}
		}
	);
	
	fadeOut.start(1.0, 0.0);
}
