
var numFeatureImages = 0;
var currentFeature = 0;
var nextFeature = 1;

jQuery(document).ready(function(){
								
	jQuery("#search .tabs a").click(function(){
		jQuery("#search .search-form").hide();
		if(jQuery(this).parent().attr("id") == "buying-tab"){
			jQuery("#buying-form").show();
		}else{
			jQuery("#renting-form").show();
		}
		return false;
	});
	
	numFeatureImages = jQuery("#featured .image-block li").length;
	
	if(numFeatureImages > 1){
		showNext();
	}
	
	
});

function showNext(){
	
	nextFeature = currentFeature + 1;
	if(nextFeature >= numFeatureImages){
		nextFeature = 0;
	}
	
	var delay = 1000;
	var transition = 1500;
	
	jQuery("#featured .image-block li").css("z-index", 0);
	jQuery("#featured .image-block li").eq(currentFeature).css("z-index", 1);
	jQuery("#featured .image-block li").eq(nextFeature).delay(delay + transition).css("z-index", 2);
	jQuery("#featured .image-block li").eq(nextFeature).css("right", -260);
	jQuery("#featured .image-block li").eq(nextFeature).delay(delay + transition).animate({right: 0}, transition, showNext);
	currentFeature = nextFeature;
}
