var ListingsStart = -1;
var interval = 0;
var ForLease = 0;
var ForSale = 0;

function showListing(auto) {
	if (!auto)
		clearInterval(interval);

	new Request({
			url : "ajax_featured_listing.php?ForSale=" + ForSale + "&ForLease=" + ForLease + "&ListingsStart=" + ListingsStart,
			onSuccess : function (responseText, responseXML) {
					new Fx.Tween($('featured'), {
						onComplete : function (element) {
							$('featured').innerHTML = responseText;
							new Fx.Tween($('featured')).start('opacity', 1);
						}
					}).start('opacity', 0);
			}
		}).send();
}

function showNextListing(auto) {
	ListingsStart++;
	showListing(auto);
}

function showPrevListing(auto) {
	if (ListingsStart > 0) {
		ListingsStart--;
		showListing(auto);
	}
}

window.addEvent('domready', function(){
	showNextListing(true);
	interval = setInterval("showNextListing(true)", 8000);
});


