//set links to all point to correct FP
function setLinks(currentProperty) {
	var link_to_fp = "";
	if (typeof currentProperty.firstChild.href != "undefined") {
		link_to_fp = currentProperty.firstChild.href;
	} else {
		link_to_fp = currentProperty.childNodes[1].href;
	}
	
	var fp_links = document.getElementsByClassName('fp_link');
	for (var i=0; i<fp_links.length; i++) {
		fp_links[i].href = link_to_fp;
	}
}

var properties = Spry.$$(".quote")

function fadeInNextProperty() {
	if (!properties || properties.length < 1) {
		return;
	}
	
	if (typeof properties.curIndex == "undefined") {
		properties.curIndex = 0;
	}
	
	var currentProperty = properties[properties.curIndex];
	properties.curIndex = (properties.curIndex+1)%properties.length;
	var nextProperty = properties[properties.curIndex];
	
	Spry.Effect.DoFade(currentProperty, {
		duration: 2000, 
		from: 100, 
		to: 0, 
		finish:function() {currentProperty.style.display="none";}
	});
	
	Spry.Effect.DoFade(nextProperty, { 
		duration: 2000,
		to: 100,
		setup: function() {nextProperty.style.display="block"; setLinks(nextProperty);},
		finish: function() {setTimeout(function(){ fadeInNextProperty(); }, 4000); }
	});
}

window.onload = fadeInNextProperty;
