/********************************
jQuery Do when dom is ready!
*********************************/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

$(document).ready(function()
{
	// Switch Between Member Stories
	$('#carusel div ul li a').click(function() {
		var path = "../../portfolio/ajax.php";
		$(".wrap:visible").hide();
		$("div#loading_main").show();
		var SiteID = $(this).attr("id");
		if ($("#site_"+SiteID).length) {
			$("div#loading_main").hide();
			$("#site_"+SiteID).fadeIn();
		}else{
			$.get(path, {site: SiteID}, function(html) {
				$("div#loading_main").hide();
				$("div#main").append(html);
			});
		};
		return false;
	});

	// Scroll the site thumbnails
	$('#carusel div').serialScroll({
		items:'li',
		prev:'#carusel a.link-prev',
		next:'#carusel a.link-next',
		start:0, //as we are centering it, start at the 2nd
		duration:550,
		step:4,
		force:false,
		stop:false,
		lock:true,
		easing:'easeOutQuart',
		lazy:true,
		cycle:true, //don't pull back once you reach the end
		jump:false //click on the images to scroll to them
	});

	// image switching
	$('div.visual ul li:nth-child(1) a').livequery('click', function(event) {
		$('div.holder div:visible').hide();
		$('div.holder div:nth-child(1)').fadeIn();
		return false;
	});
	$('div.visual ul li:nth-child(2) a').livequery('click', function(event) {
		$('div.holder div:visible').hide();
		$('div.holder div:nth-child(2)').fadeIn();
		return false;
	});
	$('div.visual ul li:nth-child(3) a').livequery('click', function(event) {
		$('div.holder div:visible').hide();
		$('div.holder div:nth-child(3)').fadeIn();
		return false;
	});
	$('div.visual ul li:nth-child(4) a').livequery('click', function(event) {
		$('div.holder div:visible').hide();
		$('div.holder div:nth-child(4)').fadeIn();
		return false;
	});
});
