﻿   
   var news = new Array();
   
   function newsArray(newsItems){
		this.newsItems = newsItems;
		for (p=0;p<newsItems.length;p++){
			news[p] = new makeNews(newsItems[p][0], newsItems[p][1], newsItems[p][2], newsItems[p][3]).write();
		}
		rotateNews();
   }
   
   function makeNews(i,l,t,c){
	  var photo = new Image();
	  photo.src = i;
      this.img = photo;
      this.link = l;
      this.title = t;
      this.caption = c;
      this.write = writeNews;
   }
   
   function writeNews(){
      var str = '';
      str += '<a href="' + this.link + '">';
      str += '<img border="0" src="' + 
         this.img.src + '"></a><br/>';
      str += '<div class="NewsTitle">' + this.title + '</div>';
      str += '<div class="NewsCaption">' + this.caption + ' <a href="' + this.link + '">more</a></div>';
      return str;
   }

   var nIndex = 0;
   var timerID = null;

//var item1 = new Array();

//item1 [0] = ['/uploadedImages/Default/GraveDigger.jpg', 'http://www.gravedigger.com',"Grave Digger ","What a way to kick off the 2010 Advance Auto Parts Monster Jam" +
//"than to have it here at the Blue Cross Arena in Rochester New York.Happy New Year everyone and welcome to the first show."];

//item1 [1] = ['/uploadedImages/Default/player.jpg', 'http://www.youtube.com',"Player","Player Caption"];
   
   function rotateNews(){
      var len = news.length;
      if(nIndex >= len)
         nIndex = 0;
       
      document.getElementById('stories').innerHTML = news[nIndex];
      nIndex++;
      timerID = setTimeout('rotateNews()',6000);
   }
   
   function pauseNews() {
      if (timerID != null) {
         clearTimeout(timerID);
         timerID = null;
      }
   }
   
   function playNews() {
      if (timerID == null) {
         timerID = setTimeout('rotateNews()', 1000);
      }
   }
