// JavaScript Document





$(document).ready(function() {	
						   
	var thisPageURL		=	window.location.href;
	var thisPageParts	=	thisPageURL.split('/');
	var thisPage		=	thisPageParts[thisPageParts.length - 1];
	var thisDir			=	thisPageParts[thisPageParts.length - 2];
	
	
	
	if(thisDir == 'it'){
		
		$("#view_it").css('opacity', 0.2);
	/*
	$("#view_uk").click(function(){
									 window.location.href = "../" + thisPage;
									 });
		
	*/	
	} else {
		
		$("#view_uk").css('opacity', 0.2);
		/*
		$("#view_it").click(function(){
									 document.location.href = "it/" + thisPage;
									 });
		*/
	}
	// end if this dir
	
	
	
	
	//Execute the slideShow
	slideShow();

						   
				   
});

				function slideShow() {

					//Set the opacity of all images to 0
					$('#carousel a').css({opacity: 0.0});

					//Get the first image and display it (set it to full opacity)
					$('#carousel a:first').css({opacity: 1.0});
					$('#carousel a:first').addClass('show');

					//Call the gallery function to run the slideshow, 5000 = change to next image after 5 seconds
					setInterval('gallery()',5000);

				}

				function gallery() {

					//if no IMGs have the show class, grab the first image
					var current = ($('#carousel a.show')?  $('#carousel a.show') : $('#carousel a:first'));

					//Get next image, if it reached the end of the slideshow, rotate it back to the first image
					var next = ((current.next().length) ? ((current.next().hasClass('carousel_end'))? $('#carousel a:first') :current.next()) : $('#carousel a:first'));	


					//Set the fade in effect for the next image, show class has higher z-index
					next.css({opacity: 0.0})
					.addClass('show')
					.animate({opacity: 1.0}, 500);

					//Hide the current image
					current.animate({opacity: 0.0}, 500)
					.removeClass('show');
					

				}
