// JavaScript Document

$(document).ready(function(){
		var inProgress = false; // Variable to check
		
		
		
		
		
		
		
		
		
		
		var page = "page1";
		var pageContainer = $('#pageContainer');
		var backgroundImage = $('.backgroundImage');
		
		var inProgressBackground = false; // Variable to check
		$('#page1Button').click(function(){
			if(page!=="page1")
			{
				if(inProgressBackground)
				{
					return;
				}
				else
				{
					inProgressBackground = true;
				}
				
				pageContainer.scrollTo('#page1',800);//all divs w/class pane
				
				backgroundImage.fadeOut();
				$('#homeBackgroundImage').fadeIn(function(){//set the in proggess to false so a new animation can begin when clicked.
							inProgressBackground = false;
				});
				
				//set page
				page = "page1";
			}//end if page
		});
		
		$('#page2Button').click(function(){
			if(page!=="page2")
			{
				if(inProgressBackground)
				{
					return;
				}
				else
				{
					inProgressBackground = true;
				}
				pageContainer.scrollTo('#page2',800);//all divs w/class pane
				backgroundImage.fadeOut();
				$('#aboutBackgroundImage').fadeIn(function(){//set the in proggess to false so a new animation can begin when clicked.
							inProgressBackground = false;
				});
				
				//set page
				page = "page2";
			}//end if page
		});
		
		$('#page3Button').click(function(){
			if(page!=="page3")
			{
				if(inProgressBackground)
				{
					return;
				}
				else
				{
					inProgressBackground = true;
				}
				pageContainer.scrollTo('#page3',800);//all divs w/class pane
				backgroundImage.fadeOut();
				$('#sponsorshipBackgroundImage').fadeIn(function(){//set the in proggess to false so a new animation can begin when clicked.
							inProgressBackground = false;
				});
				
				//set page
				page = "page3";
			}//end if page
		});
		
		$('#page4Button').click(function(){
			if(page!=="page4")
			{
				if(inProgressBackground)
				{
					return;
				}
				else
				{
					inProgressBackground = true;
				}
				pageContainer.scrollTo('#page4',800);//all divs w/class pane
				backgroundImage.fadeOut();
				$('#projectsBackgroundImage').fadeIn(function(){//set the in proggess to false so a new animation can begin when clicked.
							inProgressBackground = false;
				});
				
				//set page
				page = "page4";
			}//end if page
		});
		
		$('#page5Button').click(function(){
			if(page!=="page5")
			{
				if(inProgressBackground)
				{
					return;
				}
				else
				{
					inProgressBackground = true;
				}
				pageContainer.scrollTo('#page5',800);//all divs w/class pane
				backgroundImage.fadeOut();
				$('#helpBackgroundImage').fadeIn(function(){//set the in proggess to false so a new animation can begin when clicked.
							inProgressBackground = false;
				});
				
				//set page
				page = "page5";
			}//end if page
		});
		
		
		
		
		
		
		
		/*$('#page1Button,#page2Button,#page3Button,#page4Button,#page5Button').click(function() {
			
			//test if the animation is in the middle of a cycle.
			if(inProgress)
			{
        		return;
			}
			else
			{
				inProgress = true;
			}
			
			
			//here is where the background change will occur - it needs to fade to a new image via CSS
			//
			//
			
			
			var id = this.id;
			
			$('#page').stop().animate({
					opacity: 1,
					left: '-=1400',
				}, 500, function() {
				// Animation complete...
				//swap content
					var color = "";
					var url = "";
					switch(id)
					{
						case "page1Button":
						color = "#FC9";
						url = 'home.php';
						break;
						
						case "page2Button":
						color = "#6CF";
						url = 'about.php';
						break;
						
						case "page3Button":
						color = "#FFC";
						url = 'sponsorship.php';
						break;
						
						case "page4Button":
						color = "#F66";
						url = 'projects.php';
						break;
						
						case "page5Button":
						color = "#6F9";
						url = 'help.php';
						break;
					}
					
					//load the content file for the page clicked.
					$('#page').load(url);
				
					//change the background color to the page clicked
					//$('#page').css('backgroundColor', color);
					
					//Re-animate
					$('#page').animate({
							opacity: 1,
							left: '+=1400',
						}, 500, function() {
						// Animation complete.
						
						//set the in proggess to false so a new animation can begin when clicked.
						inProgress = false;
					});//end of #page animation
						
			  });// end of open animation
			  
		});//end of click function
		*/
		
		
		
		
		
		
	});//end of ready function
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
//-->
