$(document).ready(function() {




		
		
		/*
		--------------------------------------------------------------
		Setup faqs
		--------------------------------------------------------------
		*/
		
		// Create lists
		var home_list = $("#home_content").children("#home_text");
		var num_list = $("#home_numbers").children("p");
		var num_home_images = $("#home_content").children("#home_text").size();	
		var curr_home_image = 0;
	
		// Hide all of the answers
		$("#home_content").children("#home_text").hide();
		
		// Show the first answer
		$(home_list[0]).show();
		
		// Set the new number color
		$(num_list[0]).css("color","#ff0000");
		$(num_list[0]).css("cursor","auto");
		
		// Start the loop
		startGalleryLoop();

		
		/*
		--------------------------------------------------------------
		Setup faq answers
		--------------------------------------------------------------
		*/
		
		
		
		
		
		function startGalleryLoop() {
			
			$(this).everyTime(5000, "gallery_loop", function() {
															 
					
				// Create a variable to save the new position
				var newPos = curr_home_image + 1;
				
				// Check the new number and set back to zero
				// if it's greater than the number of images
				if (newPos == num_home_images) newPos = 0;
	
				// Swap out the projects			
				swapProjects(newPos);
			});
		}
		
		function stopGalleryLoop() {
			
			// Stop the timer
			$(this).stopTime("gallery_loop");
		}
		
		
		
		// Function used to swap projects
		function swapProjects(pos) {

			if (pos != curr_home_image) {
				
				// Stop the timer
				$(this).stopTime("gallery_loop");
			
				// Reset the number colors & pointer
				$("#home_numbers").children("p").css("color","#000000");
				$("#home_numbers").children("p").css("cursor","pointer");
				
				// Set the new number color & pointer
				$(num_list[pos]).css("color","#ff0000");
				$(num_list[pos]).css("cursor","auto");
				
				// Fade out the current image
				$(home_list[curr_home_image]).fadeOut("slow");
				
				// Fade in the new image
				$(home_list[pos]).fadeIn("slow");
				
				// Save the new position
				curr_home_image = pos;
				
				// Start the loop
				startGalleryLoop();
			}
		}

		
		
		
	
		
		
		
		/*
		--------------------------------------------------------------
		Mouse Event Functions
		--------------------------------------------------------------
		*/
		
		// Home number click
		$("#home_numbers").children("p").click(function() {
													 
			// Find the position of the nav
			var pos = Number($("#home_numbers").children("p").index($(this)));	

			// Swap out the projects			
			swapProjects(pos);		
			
		});

		
		// FAQ question click event
		$("#faq_col_1").children("p").click(function() {
													 
			// Hide all of the answers
			$("#faq_col_2").children("p").hide();
			
			// Find the position of the question
			var pos = $("#faq_col_1").children("p").index($(this));
			
			// Fade in the new image
			$(answer_list[pos]).fadeIn("slow");
			
			// Set the css of the questions
			$("#faq_col_1").children("p").css("background-color","#e6e7e8");
			$("#faq_col_1").children("p").css("background-image","");
			$("#faq_col_1").children("p").css("color","#231F20");
			
			
			// Set the css of the questions
			$(this).css("background-color","#ec1c24");
			$(this).css("background-image","url(files/images/arrow.jpg)");
			$(this).css("color","#FFFFFF");
			
		});
		
		
		/*
		--------------------------------------------------------------
		Mouse Event Functions
		--------------------------------------------------------------
		*/
		
	});
