$(function()
{
	($("#content #homepage").length == 1) ? $("#content").hide() : $(".scrollable").jScrollPane({showArrows:true,topCapHeight:20,bottomCapHeight:20});
	$("#slides a").click(function()
	{
		$("#slides").cycle('pause');
		$("#content").fadeIn(800);
		$(".scrollable").jScrollPane({showArrows:true});
		return false;
	});
	$("#content a.btn_close").click(function()
	{
		$("#content").fadeOut(800);
		$("#slides").cycle('resume');
		return false;
	});
	$("#btn_testimonials").click(function()
	{
		if ($("#testimonials").length == 0)
		{
			$("#sitewrapper").append('<div id="testimonials"></div>').find("#testimonials").load("/layout/set/modal/testimonials", function()
			{
				$ss = $("#testimonial-slides");
				$ss.before('<div id="slide-pager">').cycle(
				{
					fx: "fade",
					speed: 800,
					timeout: 5000,
					pager: "#slide-pager",
					cleartype: false
				});
				$("#slide-pager a:last").css("border", "none");
				$(this).fadeIn(800);
			});
		}
		else if ($("#testimonials:visible").length == 1)
		{
			$("#testimonials").fadeOut(800);
			$("#testimonial-slides").cycle("pause");
		}
		else
		{
			$("#testimonials").fadeIn(800, function()
			{
				$("#testimonial-slides").cycle("resume");
			});
		}
		return false;
	});
	$("#testimonials a.btn_close").live("click", function()
	{
		$("#testimonials").fadeOut(800);
		$("#testimonial-slides").cycle("pause");
		return false;
	});
	if ($("#slides .slide").length > 1)
	{
		$("#slides").cycle(
		{
			fx: "fade",
			speed: 1000,
			timeout: 5000
		});
	}
});