﻿// JScript File
var newslist=new Array();

var cnt=0;			// current news item
var curr = "";
var i=-1;			// current letter being typed
var drpArticle="";
var mtxt="";
var check=0;
function newsticker(elementRef,spanRef,iCount)
{
    var str1;
    if (iCount==undefined)
    {
        iCount=-1;
    }
    if (mtxt=="")
    { 
        mtxt=spanRef;               
    }

    if (mtxt=="")
    { 
        mtxt=spanRef;               
    }
    
   if(drpArticle=="")
   {
   drpArticle= elementRef;
   }
   var count = drpArticle.options.length; 
  
   /*var j=0;
   for (j=0;j<count;j++)
   {
       newslist[j]=new Array(drpArticle.options[j].text,drpArticle.options[j].value);
   }*/
  //============================================
  function randOrd(){
    return (Math.round(Math.random())-0.5); } 

  //============================================
  //if Firefox or Netscape
  var browser=navigator.appName;
  if(browser=="Netscape")
  {
    if(check>=newslist.length)
    { check=0;}
    if (check==0)
    {
       var j=0;
       for (j=0;j<count;j++)
       {
           newslist[j]=new Array(drpArticle.options[j].text,drpArticle.options[j].value);
       }
       newslist.sort(randOrd); 
       //alert(newslist);
     }
      cursor="_";
      // next character of current item
      if (iCount < newslist[cnt][0].length - 1)
      {
        //i++;
        iCount++;
        temp1 = newslist[cnt][0];
        temp1 = temp1.split('');
        curr = curr+temp1[iCount];
        temp2 = newslist[cnt][1];
        check=1;
        if(iCount>=newslist[cnt][0].length-1)
        { cursor=" ";   }
        mtxt.innerHTML = "<span style='line-height:1.2;font-family:arial,helvetica,sans;font-size:11px;font-weight:bold;text-transform:uppercase;'><a style='text-decoration:none;color: #00008b; target='blank' href='http://www.rttnews.com/ArticleView.aspx?Id="+temp2+"'>"+curr+cursor+"</a></span>";
        setTimeout('newsticker(undefined,undefined,'+ iCount +')',30)
        return ;
      }
     // new item
      //i = -1; 
      curr = ""; iCount=-1;
      if (cnt<newslist.length-1)
        cnt++;
      else
        cnt=0;
        check++ ;
      setTimeout('newsticker(undefined,undefined,-1)',2000)
  }
  //If IE
  else
  {   
    if(check>=newslist.length)
    { check=0;}
    if (check==0)
    {
        var j=0;
        for (j=0;j<count;j++)
        {
           newslist[j]=new Array(drpArticle.options[j].text,drpArticle.options[j].value);
        }
        newslist.sort(randOrd); 
    }
      cursor="_";
      // next character of current item
      if (iCount < newslist[cnt][0].length - 1)
      {
        //i++;
        iCount++;
        temp1 = newslist[cnt][0];
        temp1 = temp1.split('');
        curr = curr+temp1[iCount];
        temp2 = newslist[cnt][1];
        check=1;
        if(iCount>=newslist[cnt][0].length-1)
        { cursor=" ";   }
        mtxt.innerHTML = "<span style='line-height:1.2;font-family:arial,helvetica,sans;font-size:11px;font-weight:bold;text-transform:uppercase;'><a style='text-decoration:none;color:#00008b;target='blank' href='http://www.rttnews.com/ArticleView.aspx?Id="+temp2+"'>"+curr+cursor+"</a></span>";
        str1='newsticker(undefined,undefined,'+ iCount +')'
        setTimeout(str1,10)
        return ;
      }
      // new item
      i = -1; curr = "";
      if (cnt<newslist.length-1)
        cnt++;
      else
        cnt=0;
        check++ ;
      setTimeout('newsticker(undefined,undefined,-1)',3000)
  }
}