$(document).ready(function() {

	// variables
	var slideshow = $('#box4').find('.images');
	var info = $('#info');
	//var link = window.location.href;
	//var title = "Tyler Meyer: " + escape($("#text h1").html());
	//$("#social a.facebook").attr("href", "http://www.facebook.com/sharer.php?u="+link+"&t="+title);
	//$("#social a.twitter").attr("href", "http://twitter.com/share?url="+link);
	
	var property_info = [];
	function createInfo(){
		slideshow.find("img").each(function(){
			var data = $(this).data("property");
			property_info.push(data.address);
			//console.log(data.address);
		});
	};
	createInfo(); // initialize
	info.html(property_info[0]);

	function onAfter(){
		var id = this.getAttribute('rel')-1;
		info.html(property_info[id]);
	};

	slideshow.cycle({ // initialize
		timeout: 5000,
		speed: 1000,
		pause: 1,
		after: onAfter,
		prev: '.prev',
		next: '.next'
	});	
	
	$("#box1").find(".images").cycle({
		timeout: 10000,
		speed: 1000,
		pause: 1,
		random: 1
	});
	
	$(".property_image").cycle({
		timeout: 8000,
		speed: 1000,
		pause: 1,
		prev: '.prev',
		next: '.next',
		pager: '.pager',
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<img class="thumbnail" src="' + slide.src + '" />'; 
		} 
	});

});
