// JavaScript Document

$(document).ready(function() { 
 		
		// initialize scrollable 
		if ($(".scrollable .items img").size()>1) {
			//$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true, autopause: true, interval: 4000, steps: 1 }).navigator();
		} else { $(".scrollable").find(".prev, .next").remove(); }
		// facebox
		$("body").append("<div id='facebox' class='facebox'><div class='faceboxwrap'><h2 class='title'></h2><div class='content'></div></div></div>");
		$("#facebox").overlay({
				top: 25, mask: { color: '#000', loadSpeed: 200, opacity: 0.5 },
				load: false
			});
		
		
		$("a.fbx").click(function() {
				var ttitle = this.title;
				$.ajax({ async: true, type: "GET", url: this.href,
							error: function (XMLHttpRequest, textStatus, errorThrown) {
								$("#facebox").addClass("facebox-error")
									.find(".content").html("<p>Erreur "+ XMLHttpRequest.status +"</p>").end();
							},
							success: function(data) {
								$("#facebox").removeClass("facebox-error")
									.find(".title").html(ttitle).end()
									.find(".content").html(data).find("h1").hide().end()
								.end();
							}
						});
					$("#facebox").data("overlay").load();
					return false;
			});
	}); 

$(window).load(function() {
	if ($(".scrollable .items img").size()>1) {
			$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true, autopause: true, interval: 4000, steps: 1 }).navigator();
		}
});
