$(document).ready(function() {
  $('a.lightbox').lightbox();
});

$(document).ready (function () {

      
    imgCount = $('#Slideshow1 div').length;

    $('#Slideshow1 div').css ("position", "absolute");
    $('#Slideshow1 div').css ({opacity: 0.0});
    $('#Slideshow1 div.active').css ({opacity: 1.0});
    last_slide_href1 = $('#Slideshow1 div a.current').attr('href');
   
    $('#Slideshow2 div').css ("position", "absolute");
    $('#Slideshow2 div').css ({opacity: 0.0});
    $('#Slideshow2 div.active').css ({opacity: 1.0});
    last_slide_href2 = $('#Slideshow2 div a.current').attr('href');
 
    $('#Slideshow3 div').css ("position", "absolute");
    $('#Slideshow3 div').css ({opacity: 0.0});
    $('#Slideshow3 div.active').css ({opacity: 1.0});
    last_slide_href3 = $('#Slideshow3 div a.current').attr('href');
    
	window.setInterval("slideSwitchNext();",5000);
})




function slideSwitchNext(slideshow) {

	console.log('Lefut');
	if ($('#navigateNext').hasClass("active")) {
		
		$('#navigateNext').removeClass('active');
		
		

		var $active1 = $('#Slideshow1 div.active');
	
		if ( $active1.length == 0 ) $active1 = $('#Slideshow1 div:last');
		
		var href = $active1.next().length ? $active1.next().children('a').attr('href') : last_slide_href1;
		$('#Slideshow1 div a.current').attr('href',href);
		
		var $next1 =  $active1.next().length ? $active1.next()
							: $('#Slideshow1 div:first');
		
		$active1.addClass('last-active');
		//$active1.css({opacity: 0.0});
		$next1.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active1.css({opacity: 0.0});
				$active1.removeClass('active last-active');
			});
		
		

		var $active2 = $('#Slideshow2 div.active');
	
		if ( $active2.length == 0 ) $active2 = $('#Slideshow2 div:last');
		
		var href = $active2.next().length ? $active2.next().children('a').attr('href') : last_slide_href2;
		$('#Slideshow2 div a.current').attr('href',href);
		
		var $next2 =  $active2.next().length ? $active2.next()
							: $('#Slideshow2 div:first');
		
		$active2.addClass('last-active');
		//$active2.css({opacity: 0.0});
		$next2.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active2.css({opacity: 0.0});
				$active2.removeClass('active last-active');
			});
		
		

		var $active3 = $('#Slideshow3 div.active');
	
		if ( $active3.length == 0 ) $active3 = $('#Slideshow3 div:last');
		
		var href = $active3.next().length ? $active3.next().children('a').attr('href') : last_slide_href3;
		$('#Slideshow3 div a.current').attr('href',href);
		
		var $next3 =  $active3.next().length ? $active3.next()
							: $('#Slideshow3 div:first');
		
		$active3.addClass('last-active');
		//$active3.css({opacity: 0.0});
		$next3.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active3.css({opacity: 0.0});
				$active3.removeClass('active last-active');

			});
		
		$('#navigateNext').addClass('active');
	}
}

