// JavaScript Document
var gallery;
var photoWidth;
var currPhoto = 0;

function changeEvent(EID) {
	$("#right-slide img").css("display","block");
	$("#left-slide img").fadeOut(400);
	$("#photo-container").html($("#eveniment-" + EID).html());
	$("#photo-container").find("ul").css("left","0px");
	currPhoto = 0;
	gallery = $("#photo-container ul").find("li");
}

$(document).ready(function(){
	photoWidth = $("#photo-container li").width();
	gallery = $("#photo-container ul").find("li");
	
	$("#right-slide img").live("click",function(){
		if(currPhoto + 1 < gallery.size()) {
			$("#photo-container").find("ul").animate({left:-photoWidth*(currPhoto+1) + "px"},700,function(){
				currPhoto++;
			
				if(currPhoto + 1 == gallery.size()) {
					$("#right-slide img").fadeOut(400);
				}
				if(currPhoto > 0) {
					$("#left-slide img").fadeIn(400);
				}
			});
		}								
	});
	
	$("#left-slide img").live("click",function(){
		if(currPhoto - 1 >= 0) {
			$("#photo-container").find("ul").animate({left:-photoWidth*(currPhoto-1) + "px"},700,function(){
				currPhoto--;
				if(currPhoto + 1 < gallery.size()) {
					$("#right-slide img").fadeIn(400);
				}
				if(currPhoto == 0) {
					$("#left-slide img").fadeOut(400);
				}
			});
		}								
	});
	
	$('.tabs > ul').tabs();
	
	$('#video_gallery_links a').each(function() {
		$(this).click(function() {
			$("#video_gallery_display").html($("#video-" + $(this).attr("rel")).html());
			
			$("#video_gallery_links a[class=selected]").removeClass("selected");
			$(this).addClass("selected");
		});
	});
});
