﻿var theSummaries = new Array("لینک و لوگوی ما را در سایت خود قرار دهید و برای تبادل لینک و لوگوی سایت یا وبلاگ خود با ما تماس بگیرید.",
				 "عضو هیأت نظارت بر صدا و سیما : فرزاد حسنی از كوله پشتي اخراج شده است/ برکناری 4 نفر دیگر.",
				 "کار مشترک آریان و کریس‌دی‌برگ و برخورد سرد رسانه‌ها!",
				 "نام خود را به زبان پارسي باستان ببینید!",
				 "كنفرانس خبري كريس دي برگ",
				 "20 وب سایت ایده آل برای آپلود فایل!",
				 "هم اکنون میتوانید در این سایت فال خود را نیز بگیرید : به منوهای سمت چپ مراجعه کنید.",
				 "لینک و لوگوی ما را در سایت خود قرار دهید و برای تبادل لینک و لوگوی سایت یا وبلاگ خود با ما تماس بگیرید.",
				 "لینک و لوگوی ما را در سایت خود قرار دهید و برای تبادل لینک و لوگوی سایت یا وبلاگ خود با ما تماس بگیرید.");
						
var theSiteLinks = new Array("",
			"http://asriran.com/view.php?id=23057",
			"http://bamdadi.com/2008/05/29/chris-de-burge-and-arian-album/",
			"http://www.iranview.ir/index.aspx?tm=2&cat=1&subcat=20&book=pars",
			"http://www.farsnews.com/plarg.php?nn=M330904.jpg",
			"http://digitdreams.blogfa.com/post-65.aspx",
			"",
			"",
			"");

// Control parameters
	var theCharacterTimeout = 40;
	var theStoryTimeout     = 3000;
	var theWidgetOne        = "_";
	var theWidgetTwo        = "-";
	var theWidgetNone       = "";
    var theItemCount = theSummaries.length;
	var NS6=(document.getElementById && !document.all) ? true : false;
	
// Ticker startup

function startTicker()
{

	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {	
			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];
		theTargetLink = theSiteLinks[theCurrentStory];
	}
	
	var textTitle = theStorySummary.substring(0,theCurrentLength) + whatWidget();
	
	if (theTargetLink ) {
	
		if (NS6) {
	document.getElementById("theTicker").innerHTML  = '<a  class=jstop  target="_blank" href="'+ theTargetLink +'" target="_top">'+textTitle+'</a>';
				 }
		else {
	document.all.theTicker.innerHTML = '<a  class=jstop  target="_blank" href="'+ theTargetLink +'" target="_top">'+textTitle+'</a>';
				}
						} 	
	else {
		if (NS6) {
	document.getElementById("theTicker").innerHTML = '<span>'+textTitle+'</span>';
				}
		else {
	document.all.theTicker.innerHTML = '<span>'+textTitle+'</span>';
				}
	}
	
	// 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;
	}
}