var isFlat = false;
function Is() {
 var agent = navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.minor = parseFloat(navigator.appVersion);
 this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
 this.ns2 = (this.ns && (this.major == 2));
 this.ns3 = (this.ns && (this.major == 3));
 this.ns4 = (this.ns && (this.major == 4));
 this.ns5 = (this.ns && (this.major > 4));
 this.ie = (agent.indexOf("msie") != -1);
 this.ie3 = (this.ie && (this.major == 2));
 this.ie4 = (this.ie && (this.major >= 4));
 this.op3 = (agent.indexOf("opera") != -1);
 this.pc  = (agent.indexOf("win") != -1);

 if (!(this.ie4 || this.ns5)) {
  isFlat = true;
 }
}

var is = new Is()

if (is.ie)
 if (is.pc)
  document.write("<link rel='stylesheet' href='http://www.astrobio.net/news/themes/Red-White-Blue/style/tonr_pc_ie.css' type='text/css'>");
 else
  document.write("<link rel='stylesheet' href='http://www.astrobio.net/news/themes/Red-White-Blue/style/tonr_mac_ie.css' type='text/css'>");
if (is.ns4) { 
 if (is.pc) {
  document.write("<link rel='stylesheet' href='http://www.astrobio.net/news/themes/Red-White-Blue/style/netscape_tonr_pc_ns4.css' type='text/css'>");
  document.write("<link rel='stylesheet' href='http://www.astrobio.net/news/themes/Red-White-Blue/style/tonr_pc_ns4.css' type='text/css'>");
 } else { 
  document.write("<link rel='stylesheet' href='http://www.astrobio.net/news/themes/Red-White-Blue/style/tonr_pc_ns4.css' type='text/css'>");
 }
}
if (is.ns5) 
 document.write("<link rel='stylesheet' href='http://www.astrobio.net/news/themes/Red-White-Blue/style/tonr_pc_ns5.css' type='text/css'>");

var _js12 = false;


/*
Methods
=======
Ticker.start()
       starts the animation of the ticker
       
Ticker.stop()
       stops the animation of the ticker
       
Ticker.changeInterval(newinterval)
       changes the shifting interval to newinterval

Properties
==========
Ticker.name
	String : name of global variable containing reference to the ticker object

Ticker.id
	String : id of the DIV containing the Ticker data

Ticker.shiftBy
	Number : Number of pixels to shift the Ticker each time it fires.
	
Ticker.interval
    Number : Number of millisecond intervals between times Ticker fires
    
Ticker.runId
    Number : Value returned from setTimeout or null if the Ticker is not 
             running
             
Ticker.div
    HTMLElement : Reference to DIV containing the Ticker data.
  
*/












function Ticker(name, id, shiftBy, interval)
{
  this.name     = name;
  this.id       = id;
  this.shiftBy  = shiftBy ? shiftBy : 1;
  this.interval = interval ? interval : 100;
  this.runId	= null;

  this.div = document.getElementById(id);

  // remove extra textnodes that may separate the child nodes
  // of the ticker div

  var node = this.div.firstChild;
  var next;

  while (node)
  {
    next = node.nextSibling;
    if (node.nodeType == 3)
      this.div.removeChild(node);
    node = next;
  }

  //end of extra textnodes removal
 
  this.left = 0;
  this.shiftLeftAt = this.div.firstChild.offsetWidth;
  this.div.style.height	= this.div.firstChild.offsetHeight;
  this.div.style.width = 2 * screen.availWidth;
  this.div.style.visibility = 'visible';
}

function startTicker()
{
  this.stop();
  this.left -= this.shiftBy;
  if (this.left <= -this.shiftLeftAt)
  {
    this.left = 0;
    this.div.appendChild(this.div.firstChild);  
    this.shiftLeftAt = this.div.firstChild.offsetWidth;
  }

  this.div.style.left = (this.left + 'px');
  this.runId = setTimeout(this.name + '.start()', this.interval);
}

function stopTicker()
{
  if (this.runId)
    clearTimeout(this.runId);
    
  this.runId = null;
}

function changeTickerInterval(newinterval)
{

  if (typeof(newinterval) == 'string')
    newinterval =  parseInt('0' + newinterval, 10); 
	
  if (typeof(newinterval) == 'number' && newinterval > 0)
    this.interval = newinterval;
    
    this.stop();
    this.start();
}

/* Prototypes for Ticker */
Ticker.prototype.start = startTicker;
Ticker.prototype.stop = stopTicker;
Ticker.prototype.changeInterval = changeTickerInterval;

isFlat = false

Is();


var ticker = null; /* ticker object */

function init() {
  if (isFlat) {
    return;
  }
  tickerRef = document.getElementById("tickerwindow").firstChild.firstChild;
  for(i=0;(i<valArray.length && i<10);i++) {
    document.getElementById("item"+i).innerHTML = valArray[i];
  }
  ticker = new Ticker('ticker', 'tickerID', 1, 45);
  ticker.start();
}

window.onload=init;
