var footer_slide_width = null;
var footer_slide_height = null;

$(document).ready(function() {
	$("a.iframe").fancybox({ width: 640, height: 352, scrolling: 'no' });

	$(".footer .nav a").click(function(e) {
		e.preventDefault();
		if ($(this).hasClass("disabled"))
			return false;
		else
			$(".footer .nav a").addClass("disabled");
		if (typeof footer_slideshow != "undefined")
		{
			clearInterval(footer_slideshow);
		}
		
		if ($(this).hasClass("prev"))
		{
			change_footer_slide("prev");
		}
		else if ($(this).hasClass("next"))
		{
			change_footer_slide("next");
		}
	});
	
	footer_slide_width = $(".footer .footer-slideshow").width();
	footer_slide_height = $(".footer .footer-slideshow").height();
	
	footer_slideshow = setInterval("change_footer_slide()", 4000);
});

function change_footer_slide(direction)
{
	var wrapper = $(".footer-carousel .wrapper");
	if (direction === "prev")
	{
		wrapper.css("margin-left", "-300px").children().last().prependTo(wrapper);
		wrapper.animate({"margin-left" : "+=300"}, function() {
			$(".footer .nav a").removeClass("disabled");
		});
	}
	else
	{
		wrapper.animate({"margin-left" : "-=300"}, function() {
			wrapper.children().first().appendTo(wrapper);
			wrapper.css("margin-left", 0);
			$(".footer .nav a").removeClass("disabled");
		});
	}
}

