﻿﻿
// Ticker startup
function startTicker()
{
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {	
		    theAnchorObject     = document.getElementById("tickerAnchor");
			runTheTicker();
		 }
	else {
            document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
            return true;
	}
}
// Ticker main run loop
function runTheTicker()
{
	var myTimeout;
	// Go for the next story data block
	if(theCurrentLength == 0)
	{
		theCurrentStory++;
		theCurrentStory      = theCurrentStory % theItemCount;
		theStorySummary      = theSummaries[theCurrentStory].replace(/&quot;/g,'"').replace(/&ap;/g, '\'');
		theTargetLink        = theSiteLinks[theCurrentStory];
		theAnchorObject.href = theTargetLink;
		thePrefix 	     = "<span class=\"tickls\">" + theLeadString + "</span>";
	}
	// Stuff the current ticker text into the anchor
	theAnchorObject.innerHTML = thePrefix +
	theStorySummary.substring(0,theCurrentLength) + whatWidget();
	// Modify the length for the substring and define the timer
	if(theCurrentLength != theStorySummary.length)
	{
		theCurrentLength++;
		myTimeout = theCharacterTimeout;
	}
	else
	{
		theCurrentLength = 0;
		myTimeout = theStoryTimeout;
	}
	// Call up the next cycle of the ticker
	setTimeout("runTheTicker()", myTimeout);
}
// Widget generator
function whatWidget()
{
	if(theCurrentLength == theStorySummary.length)
	{
		return theWidgetNone;
	}

	if((theCurrentLength % 2) == 1)
	{
		return theWidgetOne;
	}
	else
	{
		return theWidgetTwo;
	}
}

	var theCharacterTimeout = 25;
	var theStoryTimeout     = 3000;
	var theWidgetOne        = "_";
	var theWidgetTwo        = "-";
	var theWidgetNone       = "";
	var theLeadString       = "";

	var theSummaries = new Array();
	var theSiteLinks = new Array();


	//var theItemCount =10;
var theItemCount =23;
theSummaries[0] = 'EXCLUSIVE: Intel Report Confirmed 18 Freed Gitmo Detainees Returned to Terror--Including in Afghanistan--Before Obama Ordered Closing of Prison';
theSiteLinks[0] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72090';
theSummaries[1] = 'For Arpaio, ?Fear Not, Sheriff Joe ? That the Sheriffs of America Stand by You,? Says Arizona Sheriff Babeu';
theSiteLinks[1] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72236';
theSummaries[2] = 'Laid-Off Temporary Census Workers Account for 43.6 Percent of Increase in Unemployed Americans';
theSiteLinks[2] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72206';
theSummaries[3] = 'Obama: New Jobs Numbers &ap;Positive&ap; but Not Good Enough';
theSiteLinks[3] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72203';
theSummaries[4] = 'Chief White House Economic Advisor Admits Her Forecast on Unemployment Was &ap;So Far Off&ap;';
theSiteLinks[4] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72147';
theSummaries[5] = 'American Academy of Pediatrics Says Media Portrayal of Sex ?Unhealthy&ap;';
theSiteLinks[5] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72167';
theSummaries[6] = 'Palestinian Leader Rebuffs Netanyahu?s Call for A ?Jewish State?';
theSiteLinks[6] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72176';
theSummaries[7] = 'Arizona Now Has ?Whopping 30? National Guard Troops and 15 Billboard Signs Warning Citizens About Drug Cartels Operating on Public Lands';
theSiteLinks[7] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72068';
theSummaries[8] = 'CNSNews.com Is Accepting Applications for Journalistic Interns';
theSiteLinks[8] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=71896';
theSummaries[9] = 'Roman Polanski Still on the Run ? U.S. Justice Department Not Releasing Documents in Ongoing Case';
theSiteLinks[9] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72170';
theSummaries[10] = 'White House Economic Advisor Claims Stimulus On Track To Create Or Save Over 3 Million Jobs';
theSiteLinks[10] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72218';
theSummaries[11] = 'HUD Offers Millions in Grants to Remove Lead-Based Paint in Lower-Income Homes';
theSiteLinks[11] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72199';
theSummaries[12] = 'CAIR Director: &ap;Tea Party and Republican Party Have Given the Green Light for These People to Defame and Stereotype Muslims&ap;';
theSiteLinks[12] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72126';
theSummaries[13] = 'Westerners Urged to Earmark Aid for Pakistan?s Marginalized Christians';
theSiteLinks[13] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72113';
theSummaries[14] = 'Feds Sue Arizona Sheriff in Civil Rights Probe';
theSiteLinks[14] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72138';
theSummaries[15] = 'David Limbaugh: Obama Is a Narcissist';
theSiteLinks[15] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72097';
theSummaries[16] = 'Defense Secretary Gates Says He?s ?Encouraged? by Progress in Afghanistan War';
theSiteLinks[16] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72193';
theSummaries[17] = '?Youth Promise Act? Would Funnel $1.6 Billion in Taxpayer Money to Anti-Gang Groups';
theSiteLinks[17] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72194';
theSummaries[18] = 'Arizona Governor Says She Was Wrong about Beheadings';
theSiteLinks[18] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72233';
theSummaries[19] = '9/11 Groups Split on Mosque Rallies on Anniversary';
theSiteLinks[19] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72211';
theSummaries[20] = 'Poll: NYers Conflicted on Mosque Near WTC';
theSiteLinks[20] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72228';
theSummaries[21] = 'BP: Failed Blowout Preventer Removed from Well';
theSiteLinks[21] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72234';
theSummaries[22] = 'Eugenics: The Real Reason for Legalized Abortion';
theSiteLinks[22] = 'http://www.cnsnews.com/public/checker.aspx?rsrcID=72220';
startTicker();
