// GALLERY ONE
function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0}).addClass('show');
			
	$("#gallery").click(function () {        	
	    	gallery();
	});

	$("#gallery").hover(function () {        	
		$("p", this).animate({
		    top: 270,
		    opacity: 0.7
		},
		"slow")
	},
	function () {
		$("p", this).animate({
		    top: 335,
		    opacity: 0.7
		},
		"slow").dequeue();
		return false
	});
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery 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() : $('#gallery a:first'));		
	var total = $('#gallery a').length;	

	if(total > 1){
		//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}, 1000);
		
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');			
	}
}

// GALLERY TWO
function slideShow2() {

	//Set the opacity of all images to 0
	$('#gallery2 a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery2 a:first').css({opacity: 1.0}).addClass('show');	

	$("#gallery2").click(function () {        	
		gallery2();
	});
	
	
	$("#gallery2").hover(function () {        	
		$("p", this).animate({
		    top: 270,
		    opacity: 0.7
		},
		"slow")
	},
	function () {
		$("p", this).animate({
		    top: 335,
		    opacity: 0.7
		},
		"slow").dequeue();
		return false
	});
	setInterval('gallery2()',6000);
}

function gallery2() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery2 a.show')?  $('#gallery2 a.show') : $('#gallery2 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() : $('#gallery2 a:first'));			
	var total = $('#gallery2 a').length;
	
	if(total > 1){
		
		//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}, 1000);
		
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');		
	}
	
}

// GALLERY THREE
function slideShow3() {

	//Set the opacity of all images to 0
	$('#gallery3 a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery3 a:first').css({opacity: 1.0}).addClass('show');
	
	$("#gallery3").click(function () {        	
		gallery3();
	});	
	
	$("#gallery3").hover(function () {        	
		$("p", this).animate({
		    top: 270,
		    opacity: 0.7
		},
		"slow")
	},
	function () {
		$("p", this).animate({
		    top: 335,
		    opacity: 0.7
		},
		"slow").dequeue();
		return false
	});
	setInterval('gallery3()',6000);
}

function gallery3() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery3 a.show')?  $('#gallery3 a.show') : $('#gallery3 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() : $('#gallery3 a:first'));			
	var total = $('#gallery3 a').length;

	if(total > 1){
		
		//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}, 1000);
		
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
	}
}

// GALLERY TWO
function slideShow4() {

	//Set the opacity of all images to 0
	$('#gallery4 a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery4 a:first').css({opacity: 1.0}).addClass('show');
	
	$("#gallery4").click(function () {        	
		gallery4();
	});
	
	$("#gallery4").hover(function () {        	
		$("p", this).animate({
		    top: 270,
		    opacity: 0.7
		},
		"slow")
	},
	function () {
		$("p", this).animate({
		    top: 335,
		    opacity: 0.7
		},
		"slow").dequeue();
		return false
	});
	
	setInterval('gallery4()',6000);
}

function gallery4() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery4 a.show')?  $('#gallery4 a.show') : $('#gallery4 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() : $('#gallery4 a:first'));			
	var total = $('#gallery4 a').length;
		
	if(total > 1){
		
		//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}, 1000);
		
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
	}	
}
