(function ($) {
	$(document).ready(function () {
		// featured properties widget
		var $props = $('ul.featured-props > li');
		var $props_rand = $props.sort(function() { return (Math.round(Math.random())-0.5); });
		var props_count = $props.length;
		var cur_prop = 0;
		var interval_id;
		var props_delay = 10000;

		function nextProp() {
			$props_rand.eq(cur_prop).fadeOut('slow', function () {
				cur_prop += 1;

				if (cur_prop >= props_count) {
					cur_prop = 0;
				}

				$props_rand.eq(cur_prop).fadeIn('slow', function () {
					setTimeout(nextProp, props_delay);
				});
			});
		}

		function startProps() {
			if (props_count > 1) {
				nextProp();
			} else if (props_count == 1) {
				$props.eq(0).fadeIn('slow');
			}
		}

		startProps();
	});
})(jQuery);
