


// --- Global variable stuff here
       var theItemCount;
       var theCurrentStory;
       var theCurrentLength;
       var theStorySummary;
       var theTargetLink;
       var theCharacterTimeout;
       var theStoryTimeout;
       var theBrowserVersion;
       var theWidgetOne;
       var theWidgetTwo;
       var theSpaceFiller;
       var theLeadString;
       var theStoryState;
       var url;

// --- Check for old browser and force applet
       theBrowserVersion = parseInt(navigator.appVersion);

       if (theBrowserVersion < 4)
       {
          location.href = "/ticker/ticker_applet.252.htm";
       }



// --- Only run for V4 browsers (check browser again here - some old browsers won't do this inline)
       function startTicker()
       {
          theBrowserVersion = parseInt(navigator.appVersion);

          if (theBrowserVersion < 4)
          {
             location.href = "/ticker/ticker_applet.252.htm";
             return;
          }



// ------ Check and fixup incoming data block
          if(!document.body.children.incoming.children.properties)
          {
             document.all.incoming.innerHTML = "<DIV ID=\"properties\"><DIV ID=\"itemcount\">1</DIV></DIV><DIV ID=\"stories\"><DIV ID=\"1\"><DIV ID=\"Summary\">UK news stories online.</DIV><DIV ID=\"SiteLink\">http://news.bbc.co.uk/hi/english/uk/default.htm</DIV><DIV ID=\"UrlLink\"></DIV></DIV></DIV>";
          }



// ------ Set up initial values
          theCharacterTimeout =   50;
          theStoryTimeout     = 5000;
          theWidgetOne        =  "_";
          theWidgetTwo        =  "-";



// ------ Set up initial values
          theStoryState       = 1;
          theItemCount        = document.body.children.incoming.children.properties.children.itemcount.innerText;
          theCurrentStory     = -1;
          theCurrentLength    = 0;
          theLeadString       = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
          theSpaceFiller      = " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<BR><BR><BR>";
// ------ Begin the ticker       
          runTheTicker();
       }



// --- The basic rotate function
       function runTheTicker()
       {
          if(theStoryState == 1)
          {
             setupNextStory();
          }

          if(theCurrentLength != theStorySummary.length)
          {
             drawStory();
          }
          else
          {
             closeOutStory();
          }
       }



// --- Index to next story
       function setupNextStory()
       {
          theStoryState = 0;

          theCurrentStory++;

          theCurrentStory = theCurrentStory % theItemCount;
          
          theStorySummary = document.body.children.incoming.children.stories.children[theCurrentStory].children.Summary.innerText;

          theTargetLink   = document.body.children.incoming.children.stories.children[theCurrentStory].children.SiteLink.innerText;

          if(theTargetLink == "")
          {
             theTargetLink = document.body.children.incoming.children.stories.children[theCurrentStory].children.UrlLink.innerText;
          }
   
          theCurrentLength = 0;

          document.all.hottext.href = theTargetLink;
       }



// --- Draw a teletype line
       function drawStory()
       {
          var myWidget;
          
          if((theCurrentLength % 2) == 1)
          {
             myWidget = theWidgetOne;
          }
          else
          {
             myWidget = theWidgetTwo;
          }
          document.all.hottext.innerHTML = theLeadString + theStorySummary.substring(0,theCurrentLength) + myWidget + theSpaceFiller;
          theCurrentLength++;
          setTimeout("runTheTicker()", theCharacterTimeout);
       }



// --- Finalise the item
       function closeOutStory()
       {
          document.all.hottext.innerHTML = theLeadString + theStorySummary + theSpaceFiller;
          theStoryState = 1;
          setTimeout("runTheTicker()", theStoryTimeout);
       }
       
       
	function PopoffWindow(url)
	{
		window.open(url,"_blank","height=460,width=440,menubar=no,scrollbars=auto,resizable=yes,copyhistory=yes,toolbar=no");
	}
	

 

function WriteDate(){


var dayNames = new Array(7);

dayNames[0] = "Sunday";

dayNames[1] = "Monday";

dayNames[2] = "Tuesday";

dayNames[3] = "Wednesday";

dayNames[4] = "Thursday";

dayNames[5] = "Friday";

dayNames[6] = "Saturday";



var monthNames = new Array(12);

monthNames[0] = "January";

monthNames[1] = "February";

monthNames[2] = "March";

monthNames[3] = "April";

monthNames[4] = "May";

monthNames[5] = "June";

monthNames[6] = "July";

monthNames[7] = "August";

monthNames[8] = "September";

monthNames[9] = "October";

monthNames[10] = "November";

monthNames[11] = "December";



var now = new Date();

var day = now.getDay();

var month = now.getMonth();

var year = now.getFullYear();

var date = now.getDate();



   if (year < 100){



      // Fix two digit year codes up to 2036

      if (year <= 36){



            // Add three digits to the year displayed for years up to 2009

            if (year < 10){

                     document.write(dayNames[day] + ", " + monthNames[month] + "  " + date + ", 200" + year);

            }

            else{

                     document.write(dayNames[day] + ", " + monthNames[month] + "  " + date + ", 20" + year);

            }

      }



      else{

            document.write(dayNames[day] + ", " + monthNames[month] + "  " + date + ", 19" + year);

      }

   }

   else if (year >= 2000){

      document.write(dayNames[day] + ", " + monthNames[month] + "  " + date + ", " + year);

   }

   else{

      document.write(dayNames[day] + ", " + monthNames[month] + "  " + date + ", *** DATE INVALID ***");

   }

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}


          
