
			var oldBox = 1; //set the deafault featured post
			var stopAnimation = "false";

			

			$(document).ready(function(){
					
				  $("#new2").slideUp(1);
				  $("#new3").slideUp(1);
				  $("#new4").slideUp(1);
				  $("#new5").slideUp(1);
				  
				document.getElementById("box"+oldBox).style.backgroundColor = "#424242";
				automate();

			});

			

			// function for changing the featured post on the home page
				function fade(newBox, stopMotion){
					// when nav is clicked the varibale stop motion is set to true. This perminantly stops all animations
					if (stopMotion == "true"){
						window.clearTimeout(animationTimer);
						stopAnimation = "clicked";
					}
					//alert("oldBox = "+oldBox+" newBox ="+newBox);

					if ((newBox) != oldBox){
						var postIn = ('#new'+newBox); //set div id to a string for animation
						var postOut = ('#new'+oldBox);

						

						// animate the old box out and the new box in
						//$(postOut).slideUp("slow");
						//$(postIn).slideDown("slow");
						$(postOut).slideUp("slow", function() {
							$(postIn).slideDown("slow");
						});
						
						//$(postIn).show("fast");
						//$(postOut).animate( {opacity: 0}, 500, function() {
						//	$(postIn).animate( {opacity: 1.0}, 500, function() {$(postOut).hide("fast");});
						//});

						var activeNav = ("box"+newBox); //set nav div id to a string for animation
						var oldNav = ("box"+oldBox);


						//set the nav to an active color then resets to old one to default color
						document.getElementById(activeNav).style.backgroundColor = "#424242";
						document.getElementById(oldNav).style.backgroundColor = "#dedede";


						oldBox = newBox; //set newBox as the oldBox so we now what to fade out next time
						automate();

					}
   				}; //close fade


				// function to set automation timer
				var animationTimer = '';
				function automate(change){
						if (stopAnimation == "false"){
							animationTimer = window.setTimeout(function() { setBox(); }, 7000); // set time
						}
				};

				

				//sets which box to load and to fade
				function setBox(){
					newBox = (oldBox+1); // adds 1 to the current box
					if (newBox >= 6){									   
						newBox = 1;
					} 
					fade(newBox); // starts the function fade as if it was clicked with a newBox to load
				};

				

				// pauses animation on mouse over

				function mouseOver(){ 
					if (stopAnimation != "clicked"){
						stopAnimation = "true";
						window.clearTimeout(animationTimer);
					}
				};

				

				// unpauses animation on mouse out

				function mouseOut(){ 
					if (stopAnimation != "clicked"){
						stopAnimation = "false";
						automate();
					}
				};


