var storyLoaded = false;

function showStory(panel) {
	//alert("This is a story!");
	var panelId = panel;
	//alert(panelId);
	var content = document.getElementById("content");
	
	if (storyLoaded){
		var oldTitle = document.getElementById('title');
		content.removeChild(oldTitle);

		var oldAuthor = document.getElementById('author');
		content.removeChild(oldAuthor);

		var oldDate = document.getElementById('date');
		content.removeChild(oldDate);

		var oldStory = document.getElementById('story');
		content.removeChild(oldStory);
	}
	
	var titleHeader = document.createElement("h2");
	var authorHeader = document.createElement("p");
	var dateHeader = document.createElement("p");
	var paragraph = document.createElement("p");
	
	
	titleHeader.setAttribute('id', 'title');
	authorHeader.setAttribute('id', 'author');
	dateHeader.setAttribute('id', 'date');
	paragraph.setAttribute('id', 'story');
	
	var title = null;
	var author = null;
	var date = null;
	
	if(panelId == 'Panel 1'){
		title = document.createTextNode("Fiji Recieves Charter");
		author = document.createTextNode("UNK Antelope");
		date = document.createTextNode("4/4/2009");
		var story = document.createTextNode('Kearney, Neb. - The 41-member social fraternity Phi Gamma Delta has received its official charter at the University of Nebraska at Kearney.  "This past weekend was a culmination of our hard work over the past year," Scotty Seeba, president of Phi Gamma Delta said. "It is believed to be one of the fastest chartering from a colony to a chapter in Phi Gamma Delta history."  During the spring 2009 semester, the group volunteered more than 700 community service hours. Since colonization in April 2008, Phi Gamma Delta has contributed more than 1,500 community service hours, according to Seeba. Phi Gamma Delta began as a colony on the UNK campus in early 2008. "Two representatives from Phi Gamma Delta international headquarters, Jesse Hitt and Marcus Hitt, came to see the UNK campus and see the viability of adding another fraternity," Seeba said. The two men recruited 26 others in March 2008 and initiated them as a colony in April 2008.  "This class which is collectively referred to as the alpha class, then was charged with the recruitment of the beta and gamma class," Seeba said. "Once we felt that we were ready for chartering, we officially filed a petition to become a chartered chapter instead of a colony," he said. "Our international fraternity of Phi Gamma Delta took a vote of their undergraduate members and governing body to see if we were fit to become a chapter." After voting, the international fraternity agreed and officially named the fraternity the Nu Kappa chapter of Phi Gamma Delta at UNK.  UNK has seven social fraternities and five social sororities.');
	}
	else if(panelId == 'Panel 2'){
		title = document.createTextNode("Test");
		author = document.createTextNode("Author");
		date = document.createTextNode("10/10/1000");
		var story = document.createTextNode("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent pellentesque eros in tellus tincidunt id feugiat lorem feugiat. Mauris vitae lacinia ante. Nam euismod elit vel nunc ultricies semper. Ut sed placerat enim. Vivamus eget diam consectetur urna ullamcorper porta. Morbi nec magna et lorem consequat interdum quis vitae augue. Nunc auctor, mauris nec sagittis mollis, purus est porta ante, non dictum ante leo et tellus. Integer pulvinar egestas pretium. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse potenti. Aenean rhoncus, metus id imperdiet adipiscing, ligula urna tempor urna, non auctor lacus lorem viverra tortor. Vestibulum scelerisque elementum erat, a hendrerit eros porta eget.");
	}
	else if(panelId == 'Panel 3'){
		title = document.createTextNode("Test");
		author = document.createTextNode("Author");
		date = document.createTextNode("10/10/1000");
		var story = document.createTextNode("lkjdfjdkslajsadiojl jeroijflwj wekl jflkjweio wkljlfkjsklj lk wewij");
	}
	else if(panelId == 'Panel 4'){
		title = document.createTextNode("Test");
		author = document.createTextNode("Author");
		date = document.createTextNode("10/10/1000");
		var story = document.createTextNode("Looky some text");
	}
	else if(panelId == 'Panel 5'){
		title = document.createTextNode("Test");
		author = document.createTextNode("Author");
		date = document.createTextNode("10/10/1000");
		var story = document.createTextNode("I could say something funny here...");
	}
	else if(panelId == 'Panel 6'){
		title = document.createTextNode("Test");
		author = document.createTextNode("Author");
		date = document.createTextNode("10/10/1000");
 		var story = document.createTextNode("...but I wont");
	}
	else 
		alert("error: panel format is not correct");
	
	titleHeader.appendChild(title);
	authorHeader.appendChild(author);
	dateHeader.appendChild(date);
	paragraph.appendChild(story);


	var bottomNode = document.getElementById('bottomContent');	

	content.insertBefore(titleHeader, bottomNode);
	content.insertBefore(authorHeader, bottomNode);
	content.insertBefore(dateHeader, bottomNode);
	content.insertBefore(paragraph, bottomNode);


	storyLoaded = true;
	//alert("reached end");
}
