﻿var ShowNum2 = 4; //How many stories to show
var CycleInterval2 = 6000; //Number of milliseconds to hold story
var StopCycle2 = 10000; //number of additional milliseconds to hold story if mouseover
var StoryRollcounterx2=2; //do not change this unless you want to start with a different story. This is the counter for which story id being shown in the roll
//alert("loaing jacascript");
var StoryRollIntervalID2=0;
var AnchorsFixed2= false;

function StartTheStories2()
{
	if(!AnchorsFixed2)
	{
		//alert("Fixing anchors");
		for(var i=1;i<=ShowNum2;i++)
			{
	
				var ThisItem = document.getElementById("StoryRollItem2_"+i);
				//alert(ThisItem.id);
				var anchors = ThisItem.getElementsByTagName("a");
				//alert(anchors.length);
				for (var j=0;j<anchors.length;j++)
				{			
					anchors[j].onmouseover=function(){StopStoryRoll2();};
				}
			}
			
		var RollWrap = document.getElementById("botRoll2");
		//alert(RollWrap.id);
		var NumWrap = document.createElement("div");
		NumWrap.id = "StoryRollNumWrap";
		for(var k=1;k<=ShowNum2;k++)
		{
			//alert(k);
			var ThisNumRoll = document.createElement("div");
			ThisNumRoll.id = "StoryRollNum2_" + k;
			if(k==1)
			{	ThisNumRoll.className = "StoryNumRollin";
			
			}
			else
			{
				ThisNumRoll.className = "StoryNumRollout";
			}
			
			var ThisNumRollAnchor = document.createElement("a");
			ThisNumRollAnchor.href = "javascript:FocusStory2("+k+");";
			var blankimg = document.createElement("img");
			blankimg.src="/_layouts/images/blank.gif";
			ThisNumRollAnchor.appendChild(blankimg);
			
			ThisNumRoll.appendChild(ThisNumRollAnchor);
			
			NumWrap.appendChild(ThisNumRoll);
		}
		
		RollWrap.appendChild(NumWrap);	
		
		AnchorsFixed2=true;
	}
	//alert("StartingStories");
	var intervalcode = 'RollTheStories2()';
	StoryRollIntervalID2= setInterval(intervalcode,CycleInterval2);

}

function FocusStory2(StoryNum)
{
	StopStoryRoll2();
	hideAllStories2();
	showThisStory2(StoryNum);


}


function showThisStory2(storyNum)
{
	document.getElementById("StoryRollItem2_"+storyNum).className="StoryRollItemWrap";

	document.getElementById("StoryRollNum2_"+storyNum).className="StoryNumRollin";

}

function hideAllStories2()
{

	for(var i=1;i<=ShowNum2;i++)
	{
		document.getElementById("StoryRollItem2_"+i).className="HideMe StoryRollItemWrap";
		document.getElementById("StoryRollNum2_"+i).className="StoryNumRollout";

	}
	
}

function RollTheStories2()
{
	hideAllStories2();
		
	//alert(StoryRollcounterx);
	showThisStory2(StoryRollcounterx2);
	
	if(StoryRollcounterx2==ShowNum2)
	{
		StoryRollcounterx2=1;
	}
	else
	{
		StoryRollcounterx2++;
	}
}

function StopStoryRoll2()
{
	//alert("stopstories");
	clearInterval(StoryRollIntervalID2);
}