currentSlide = 0;
slideDuration = 4000;
slideWidth = 365;
$(document).ready(function () {


	document.Slides = $("#capturi img");
	document.SlideControls = $("#capturiControls a");
	
	$(document.SlideControls).each(function () {
		$(this).click(function () {
			gotoSlide($(document.SlideControls).index(this));
			//$(SlideControls).index(this);
		})
	});
	$(document.SlideControls[currentSlide]).addClass("sel");
	slideShow_ID = setInterval("slideShow()", slideDuration);


/*
----------------------
 TABBED NAVIGATION
----------------------
*/
	$(".tab ul li a").click(function() {
		
		//alert($(this).parent().prevAll().length);
		myIndex = $(this).parent().prevAll().length;
		$(this).parent().parent().parent().children("div").slideUp();
		$(this).parent().parent().parent().children("div").eq(myIndex).slideDown();
		$(this)
		    .parents('ul:first') // find the first UL parent
		      .find('a') // find all the A elements
		        .removeClass('sel') // remove from all
		      .end() // go back to all A elements
		    .end() // go back to 'this' element
		    .addClass('sel');
	});
	

});

/*
----------------------
 SLIDE SHOW!
----------------------
*/
function slideShow () {
	//alert(document.SlideControls);
	gotoSlide(currentSlide+1);
}
function gotoSlide(nr) {
	nr= nr%document.Slides.size();
	destination = - (slideWidth * nr);
	$("#capturi").animate({ 
        left: destination
      }, 300 ,
      function () {
      	currentSlide = nr;
      	clearInterval(slideShow_ID);
      	slideShow_ID = setInterval("slideShow()", slideDuration);
      });
}





