/**
 * Project: Nto Annang Foundation- Atlanta Chapter Homepage v2
 * File: index_ui.js (javascript dom manipulation for org page)
 * Author: Basil Udoudoh
 * Revision: v1
 * Last edited: 5/22/2010
 * Description: All of the DOM Manipulation for the Home page. Makes divs disappear and reappear.
 */
 
var currentStory = 1;
var storyCount = 1;
 
function resetPage()
{
	var divs = true;
	storyCount = 1;
	while(divs)
	{
		if($('#news_div' + storyCount).length > 0)
		{
			$('#news_div' + storyCount).hide();
			storyCount = storyCount + 1;
		}
		else
		{
			divs = false;
		}
	}
	if(storyCount - 1 >= 0)
	{
		$('#news_div1').show();
		$('#news_nav').css("visibility", "visible");
		$('#pre_story').hide();
		currentStory = 1;
	}	
	
}
 
 function showPreviousStory()
 {
	if(currentStory > 1)
	{
		$('#news_div' + currentStory).hide();
		currentStory = currentStory - 1;
		if(currentStory == 1)
		{
			$('#pre_story').hide();
		}
		else
		{
			$('#next_story').show();
		}
		$('#news_div' + currentStory).show("slide", { direction: "left" }, 500);
		
	}
 }

 function showNextStory()
 {
 	if(currentStory < (storyCount-1))
	{
		$('#news_div' + currentStory).hide();
		currentStory = currentStory + 1;
		if(currentStory > 1)
		{
			$('#pre_story').show();
		}
		if(currentStory == (storyCount-1))
		{
			$('#next_story').hide();
		}
		$('#news_div' + currentStory).show("slide", { direction: "left" }, 500);
		
	}
 
 } 
 $(document).ready
			 (
			 	function()
				{
					resetPage();
						
					$('a#pre_story').click(function() {
						showPreviousStory()
    						return false;
  					});
					
					$('a#next_story').click(function() {
						showNextStory();
	    					return false;
  					});						
				}
			 );
