//pre-load images

function makeNews(t,f,l,a,i,c,r){
	this.titulo = t;
	this.fecha = f;
	this.link = l;
	this.follow = a;
	this.img = i;
	this.cont = c;
	this.leer = r;
	this.write = writeNews;
}

function writeNews(){
	var str = '';
	
	   if (this.img == '')
	      {
		 //sin archivo
          str += '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
	      str += '<tr><td align="left"><div class="main"><b><a href="' + this.link + '">'+ this.titulo +'</b></div></a></td></tr><tr><td align="left"><div class="main"><b>'+ this.fecha +'</b></div></td>';
          str += '</tr><tr>';
          if (this.leer ==''){
	          str += '<td colspan="2"><div class="main">'+ this.cont +'</div></td>';
          }
          if (this.leer !=''){
	          str += '<td colspan="2"><div class="main">'+ this.cont +'<a href="' + this.link + '">'+ this.leer +'</a></div></td>';
          }
          str += '</tr></table>';
         }
         
         
         if (this.img != '')
	      {
		   //con archivo
		   str += '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
	       str += '<tr><a href="' + this.link + '"><img border="0" alt="'+ this.follow +'" src="' + this.img + '"></a>';                  
           str += '</tr><tr>';
           if (this.leer ==''){
	          str += '<td colspan="2"><div class="main">'+ this.cont +'</div></td>';
           }
           if (this.leer !=''){
	          str += '<td colspan="2"><div class="main">'+ this.cont +'<a href="' + this.link + '">'+ this.leer +'</a></div></td>';
           }
           str += '</tr></table>';
		      
	      }
   return str;
}

var nIndex = 0;
var timerID = null;
function rotateNews(newsArray){
	var len = newsArray.length;
	if(nIndex >= len)
		nIndex = 0;
	document.getElementById('stories').innerHTML = newsArray[nIndex];
	nIndex++;
	timerID = setTimeout('rotateNews(newsArray)',6000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function playNews() {
	if (timerID == null) {
		timerID = setTimeout('rotateNews(newsArray)', 1000);
	}
}
