var title = new Array();//DYNAMIC 
var text = new Array();//DYNAMIC 
var newsimg = new Array();//DYNAMIC 
var widtharr = new Array();
var heightarr = new Array();
var NewsItems=0; //DYNAMIC 

var inoout=false;
var tmpv="100%";
var cvar=0,say=0,tpos=0,enson=0,hidsay=0,hidson=0;

var psy = new Array();
divtextb =	"<div id=newshead";
divtev1=	" onClick=\"showNews(";
divtev2=	");\" onmouseover=\"ItemHover(";
divtev3=	")\" onmouseout =\"PauseTime(";
divtev4=	")\" ";
divtexts = 	" style=\"position:absolute;visibility:hidden;width:"+tmpv+"; left:0; top:0; margin:0px; height:25px; overflow:inherit; cursor:'default';\">";
ie6span= 	" style=\"position:relative; width:"+tmpv+"; padding:0px;\"";
ScrollPan=	"<div id=\"newsscroll\" style=\"position:relative;left:0;top:0;width:100%;height:25px; \">";
var uzunobj=null;
var itemtop=0;
var playon=0;
var ScrollElemNo=0;
var TimeOut;
var FirstTime=true;
var Direction='Top';
function showNews(id)
{
    //location.assign("News.aspx?NewsID="+id);
}
function ItemHover(gnum)
{
	inoout=true;
	if (TimeOut!=null)
	    clearTimeout(TimeOut);
}

function PauseTime(gnum2)
{
	inoout=false;
	objd=document.getElementById("newshead"+gnum2);
	objd2=document.getElementById("newstext"+gnum2);
	 
//	objd.style.textDecoration='none';
//	objd2.style.textDecoration='none';

	Move();
}

function Move()
{
  if(Direction=='Left')
     MoveLeft();
  else if(Direction=='Right')
  	 MoveRight();
  else if(Direction=='Top')
  	 MoveTop();
  else if(Direction=='Bottom')
  	 MoveBottom();
}

function MoveLeft()
{ 
	if(inoout==false)
	{
		itemtop--;
		if(itemtop<(-1*playon))
		{	itemtop=0;
			ScrollElemNo=0;
			InitScroll(); //InitScroll2();
			FirstTime=true;
		}
		else
			elem.style.left=""+itemtop+"px";
	
	
		if(psy[(itemtop*(-1))]==3)
		{	
			LastElemNo=ScrollElemNo-1;
			if(ScrollElemNo==0)
				LastElemNo=NewsItems-1;
			objs=document.getElementById("newshead"+LastElemNo);
			objd=document.getElementById("newshead"+ScrollElemNo);
			objstop=objs.style.left;
			PosTop=parseInt(objstop.substr(0,objstop.length-2))+widtharr[LastElemNo]+10;
			objd.style.left=PosTop+"px";
			ScrollElemNo++;
			if(ScrollElemNo>=NewsItems)
				ScrollElemNo=0;
				
			if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('Move()',35);
		}
		else if(FirstTime==true)
		{
			if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('Move()',35);
			FirstTime=false;
		}
		else
		{	
			if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('Move()',35);
		}
	}
}

function MoveTop()
{ 
	if(inoout==false)
	{
		itemtop--;
		if(itemtop<(-1*playon))
		{	itemtop=0;
			ScrollElemNo=0;
			InitScrollTop();//InitScroll();//InitScroll2();
			FirstTime=true;
		}
		else
			elem.style.top=""+itemtop+"px";
		
		if(psy[(itemtop*(-1))]==3)
		{	
			LastElemNo=ScrollElemNo-1;
			if(ScrollElemNo==0)
			    LastElemNo=NewsItems-1;
				
			objs=document.getElementById("newshead"+LastElemNo);
			objd=document.getElementById("newshead"+ScrollElemNo);
			objstop=objs.style.top;
			PosTop=parseInt(objstop.substr(0,objstop.length-2))+heightarr[LastElemNo]+10;
			objd.style.top=PosTop+"px";
			ScrollElemNo++;
			if(ScrollElemNo>=NewsItems)
				ScrollElemNo=0;
				
			if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('Move()',2000+35);
		}
		else if(FirstTime==true)
		{
			if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('Move()',2000+35);
			FirstTime=false;
		}
		else
		{	
			if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('Move()',35);
		}
	}
}

function InitScrollLeft()
{	
	for(i=0;i<NewsItems;i++)
	{
		objd=document.getElementById("newshead"+i);
		if(parseInt(objd.offsetHeight)<=0)
		{	if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('InitScrollLeft()',1000);
			return;
		}
	}
	i=0;
	for(i=0;i<NewsItems;i++)
	{
		objd=document.getElementById("newshead"+i);
		widtharr[i]=parseInt(objd.offsetWidth); 
	}

	playon=0;//8
	for(i=0;i<NewsItems;i++)
	{
		objd=document.getElementById("newshead"+i);
		objd.style.visibility="visible";
		objd.style.left=""+playon+"px";
		
		psy[playon]=3;
		playon=playon+widtharr[i]+10;
	}
	elem=document.getElementById("newsscroll");
	elem.style.left=playon+"px"; // **************
    itemtop=0;
	
	Move();
}

function InitScrollTop()
{	
	for(i=0;i<NewsItems;i++)
	{
		objd=document.getElementById("newshead"+i);
		if(parseInt(objd.offsetHeight)<=0)
		{	if (TimeOut!=null)
				clearTimeout(TimeOut);
			TimeOut=setTimeout('InitScrollTop()',1000);
			return;
		}
	}
	i=0;
	for(i=0;i<NewsItems;i++)
	{
		objd=document.getElementById("newshead"+i);
		heightarr[i]=parseInt(objd.offsetHeight); 
	}

	playon=0;//8
	for(i=0;i<NewsItems;i++)
	{
		objd=document.getElementById("newshead"+i);
		objd.style.visibility="visible";
		objd.style.top=""+playon+"px";
		
		psy[playon]=3;
		playon=playon+heightarr[i]+10;
	}
	elem=document.getElementById("newsscroll");
	elem.style.top=playon+"px"; // **************
    itemtop=0;
	Move();
}

function InitScroll()
{ 
	i=0;
	bgColor = "#fdfdfd";
	innertxt="";
	for(i=0;i<NewsItems;i++) {
	    if(i%2==0)
	    {bgColor = "#fdfdfd";}
	    else
	    {bgColor = "#f7eff3";}
	    innertxt = innertxt + "" + divtextb + "" + i + "" + divtev1 + NewsIds[i] + divtev2 + NewsIds[i] + divtev3 + i + divtev4 + divtexts + "<div id=\"newstext" + i + "\"" + ie6span + "><table width=\"100%\" bgcolor=\"" + bgColor + "\"><tr><td valign=\"top\" align=\"left\"><div class=\"tdgrey\"><table cellpadding=\"3\" cellspacing=\"1\" border=\"0\"><tr><td><font class=\"newscontent_main\"><a href=\"News.aspx?lang=" + lang + "&NewsID=" + NewsIds[i] + "\"><span><b>" + title[i] + "</b></span></a></font></td></tr></table></div></td></tr></table></div></div>"; //Changed By Sanjay 22-12-2010
    //innertxt = innertxt + "" + divtextb + "" + i + "" + divtev1 + NewsIds[i] + divtev2 + NewsIds[i] + divtev3 + i + divtev4 + divtexts + "<div  class=\"newsHead\" id=\"newstext" + i + "\"" + ie6span + "><table width=\"100%\" bgcolor=\"" + bgColor + "\"><tr><td valign=\"top\" align=\"justify\"><div class=\"tdgrey\"><table cellpadding=\"3\" cellspacing=\"1\" class=\"newsContent\" border=\"0\"><tr><td><span><font class=\"newscontent_main\">" + title[i] + "</font></span></td></tr></table></div></td></tr></table></div></div>";
 }
	innertxt=ScrollPan+innertxt+"</div>";
	document.getElementById("newsticker").innerHTML=""+innertxt;
	if (TimeOut!=null)
		clearTimeout(TimeOut);
		
  if(Direction=='Left')
     TimeOut=setTimeout('InitScrollLeft()',500);
  else if(Direction=='Right')
  	 TimeOut=setTimeout('InitScroll()',500); //TimeOut=setTimeout('InitScroll2()',500);
  else if(Direction=='Top')
  	 TimeOut=setTimeout('InitScrollTop()',500);
  else if(Direction=='Bottom')
  	 TimeOut=setTimeout('InitScroll()',500); //TimeOut=setTimeout('InitScroll2()',500);
	
}
