$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow2();

});

function slideShow2() {

	//Set the opacity of all images to 0
	$('#nImg a').css({display:"none"});
	
	//Set the text  to 0
	$('#nTitle div.news-desc').css({display:"none"});
	
	//Get the first image and display it (set it to full opacity)
	$('#nImg a:first').css({opacity: 1.0,display:"block"});
	
	//Get the first text and display it (set it to full opacity)
	$('#nTitle div:first').css({opacity: 1.0,display:"block"});
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery2()',6000);
	
}

function gallery2() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#nImg .show')?  $('#nImg .show') : $('#nImg a:first'));
	var current1 = ($('#nTitle .show')?  $('#nTitle .show') : $('#nTitle div.news-desc: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() : $('#nImg a:first');
	var next1 = (current1.next().length) ? current1.next() : $('#nTitle div.news-desc:first');

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

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show')
	.css({display:"none"});

	current1.animate({opacity: 0.0}, 1000)
	.removeClass('show')
	.css({display:"none"});


	
	
}
