function frontPage() {
	slideShow();
	middleHovers();
	wide_gallery_info();
}

function slideShow() {

	//Set the opacity of all images to 0
	$('#mainfeature a').css({opacity: 0.0});
	$('#rightfeature a').css({opacity: 0.0});
	$('#widefeature a.feature').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#mainfeature a:first').css({opacity: 1.0});
	$('#rightfeature a:first').css({opacity: 1.0});
	$('#widefeature a.feature:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#mainfeature .caption').css({opacity: 0.7});
	$('#rightfeature .caption').css({opacity: 0.7});
	$('#widefeature .caption').css({opacity: 0.7});
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('main_gallery()',8000);
	setInterval('right_gallery()',6000);
	setInterval('wide_gallery()',8000);
}

function main_gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#mainfeature a.show')?  $('#mainfeature a.show') : $('#mainfeature 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('caption'))? $('#mainfeature a:first') :current.next()) : $('#mainfeature 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}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0
	$('#mainfeature .caption').animate({opacity: 0.0}, 500);	
	
	//Animate the caption, opacity to 0.7
	$('#mainfeature .caption').animate({opacity: 0.7}, 1000 );
}

function right_gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#rightfeature a.show')?  $('#rightfeature a.show') : $('#rightfeature 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('caption'))? $('#rightfeature a:first') :current.next()) : $('#rightfeature 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}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#rightfeature .caption').animate({opacity: 0.0}, 500);	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#rightfeature .caption').animate({opacity: 0.7}, 1000 );
}

function wide_gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#widefeature a.show')?  $('#widefeature a.show') : $('#widefeature a.feature: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('caption'))? $('#widefeature a.feature:first') :current.next()) : $('#widefeature a.feature: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}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');  
	
	//Set the opacity to 0 and height to 1px
	$('#widefeature .caption').animate({opacity: 0.0}, 500 );	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#widefeature .caption').animate({opacity: 0.7}, 1000 );
}

function wide_gallery_info() {
	//When user hovers over info icon display the whole div
	$('#widefeature .info').hover(
		function() { $(this).addClass("show"); },  
   		function() { $(this).removeClass("show"); }
	); 
}

function middleHovers() {
	var bgl = $('#middlefeatures .left .fill').css("background-color");
	var bgm = $('#middlefeatures .middle .fill').css("background-color");
	var bgr = $('#middlefeatures .right .fill').css("background-color");

	$('#middlefeatures .feature').hover(function() {
		$(this).find('.fill').animate({backgroundColor: '#fff'}, 100);
		$(this).find('.hover').animate({opacity: 1.0}, 100);
		if ( $(this).hasClass('left') ) {
			$(this).find('.title').css({'color': bgl});
		} else if ( $(this).hasClass('middle') ) {
			$(this).find('.title').css({'color': bgm});
		} else if ( $(this).hasClass('right') ) {
			$(this).find('.title').css({'color': bgr});
		}
		return false;
	}, function() {
		if ( $(this).hasClass('left') ) {
			$(this).find('.fill').animate({backgroundColor: bgl}, 100);
			$(this).find('.hover').animate({opacity: 0.0}, 100);
			$(this).find('.title').css({'color': '#fff'});
			return false;
		} else if ( $(this).hasClass('middle') ) {
			$(this).find('.fill').animate({backgroundColor: bgm}, 100);
			$(this).find('.hover').animate({opacity: 0.0}, 100);
			$(this).find('.title').css({'color': '#fff'});
			return false;
		} else if ( $(this).hasClass('right') ) {
			$(this).find('.fill').animate({backgroundColor: bgr}, 100);
			$(this).find('.hover').animate({opacity: 0.0}, 100);
			$(this).find('.title').css({'color': '#fff'});
			return false;
		}
	});
}

function loginSlide() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});			
}