$(document).ready(
	function() {
	
	// Motion Image Cycle
		
		// Show slides ul
			$("#motion ul#slides").show();
		
		// Change background image to blank slate
			$("#motion").css({"background":"url(../../images/spartan6/home/motion_js_bg.png) no-repeat 9px 0"});
		
		// Initiate image cycle
			$('#motion ul#slides').cycle();
	 	
	
	// Top Bar current states
		
		// School list current state
			$("#top_bar li.school_list a.control").toggle(
				function () {
					$(this).parent("li.school_list").css({"background":"url(../../images/spartan6/topBar/hover.png) repeat-x 0 0"});
	      		},
	      		function () {
	        		$(this).parent("li.school_list").css({"background":"none"});
	      		}
	    		);
	
	
		// Search current state
			$("li.search a").toggle(
      			function () {
        			$(this).parent("li.search").css({"background":"url(../../images/spartan6/topBar/hover.png) repeat-x 0 0"});
      			},
      			function () {
        			$(this).parent("li.search").css({"background":"none"});
      			}
    		);

	
	
	// School Slider
		
		// Initiate slider
			$('div.slider').anythingSlider({
	   			easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
	   			autoPlay: false,                // This turns off the entire FUNCTIONALITY, not just if it starts running or not
	   			startStopped: false,            // If autoPlay is on, this can force it to start stopped
	   			delay: 4000,                    // How long between slide transitions in AutoPlay mode
	   			animationTime: 800,             // How long the slide transition takes
	   			hashTags: false,                 // Should links change the hashtag in the URL?
	   			buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
	   			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
	   			startText: "",             // Start text
	   			stopText: "",               // Stop text
	   			navigationFormatter: null      // Advanced Use: details below
			});
	
		// Anchor Nav for slider
			$(".anchor_nav .elementary a").click(function(){
	     		$('.slider').anythingSlider(1);
	
				return false;
			});
	
			$(".anchor_nav .middle a").click(function(){
	     		$('.slider').anythingSlider(12);
	
				return false;
			});
	
			$(".anchor_nav .high a").click(function(){
	     		$('.slider').anythingSlider(16);
	
				return false;
			});
			
			// Jump to School pop up and anchors
				
				// Toggle school list pop up
				$(".school_nav .top_controls .school_list li a.control").click(function() {
					$(this).next("ul").toggle();

					return false;
				});
				
				// Hide school list after a school is clicked
				$(".school_nav .top_controls .school_list li ul li a").click(function() {
				  $(".school_nav .top_controls .school_list ul.main").fadeOut();
				});
				
				// School list anchors
				$(".school_nav .top_controls .school_list li ul li.school_two").click(function(){
		     		$('.slider').anythingSlider(1);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_three").click(function(){
		     		$('.slider').anythingSlider(2);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_four").click(function(){
		     		$('.slider').anythingSlider(3);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_five").click(function(){
		     		$('.slider').anythingSlider(4);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_six").click(function(){
		     		$('.slider').anythingSlider(5);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_seven").click(function(){
		     		$('.slider').anythingSlider(6);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_eight").click(function(){
		     		$('.slider').anythingSlider(7);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_nine").click(function(){
		     		$('.slider').anythingSlider(8);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_ten").click(function(){
		     		$('.slider').anythingSlider(9);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_eleven").click(function(){
		     		$('.slider').anythingSlider(10);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_twelve").click(function(){
		     		$('.slider').anythingSlider(11);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_thirteen").click(function(){
		     		$('.slider').anythingSlider(12);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_fourteen").click(function(){
		     		$('.slider').anythingSlider(13);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_fifteen").click(function(){
		     		$('.slider').anythingSlider(14);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_sixteen").click(function(){
		     		$('.slider').anythingSlider(15);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_seventeen").click(function(){
		     		$('.slider').anythingSlider(16);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_eighteen").click(function(){
		     		$('.slider').anythingSlider(17);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_nineteen").click(function(){
		     		$('.slider').anythingSlider(18);

					return false;
				});
				
				$(".school_nav .top_controls .school_list li ul li.school_twenty").click(function(){
		     		$('.slider').anythingSlider(19);

					return false;
				});
				
			
		// Change "Browse your schools" to "Elementary" on click of any slider control				
			
			// If an arrow is clicked
				$(".slider a.arrow").click(function(){
					$(".slider li.browse h2").fadeOut();
					$(".slider li.browse").hide();
					$(".slider li.elementary").show();
					$(".slider li.elementary h3").hide();
					$(".slider li.elementary h3").fadeIn();
				});
			
			// If an anchor link is clicked
				$("ul.anchor_nav li a").click(function(){
					$(".slider li.browse h2").fadeOut();
					$(".slider li.browse").hide();
					$(".slider li.elementary").show();
					$(".slider li.elementary h3").hide();
					$(".slider li.elementary h3").fadeIn();
				});			
			
	}
);
	


