// ---- On Page Load ---- //
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(initNewsTicker);


var state = 'none'; 

function showhide(layer_ref) 
{ 

	if (state == 'block') 
	{ 
		state = 'none'; 
	} 
	else 
	{ 
		state = 'block'; 
	} 
	
	if (document.all) { //IS IE 4 or 5 (or 6 beta) 
		eval( "document.all." + layer_ref + ".style.display = state"); 
	} 
	
	if (document.layers) 
	{ //IS NETSCAPE 4 or below 
		document.layers[layer_ref].display = state; 
	} 
	
	if (document.getElementById &&!document.all) 
	{ 
		hza = document.getElementById(layer_ref); 
		hza.style.display = state; 
	} 
}


//--- Dicky Ticker
var items, currentitem, currentindex, currentopacity=0, currentposition, newswidth;
 
function initNewsTicker() 
{
  var news = document.getElementById("newsticker");
  if (news != null) 
  {
    items = news.getElementsByTagName("li");
    if (items != null) 
	{
      for (i=0; i<items.length; i++) 
	  {
        items[i].style.opacity = 0;
        items[i].style.filter = "alpha(opacity=0)";
        items[i].style.display = "none";
      }
      currentindex = 0;
      currentopacity = 1;
      currentposition = 0;
      currentitem = items[currentindex];
      currentitem.style.opacity = 1;
      currentitem.style.filter = "alpha(opacity=100)";
      currentitem.style.display = "block";
      window.setTimeout(fadeout, 3000);
    }
  }
}
 
function next() 
{
  currentindex = ++currentindex % items.length;
  currentitem = items[currentindex];
  currentitem.style.display = "block";
  currentitem.style.opacity = 1;
  currentitem.style.filter = "alpha(opacity=100)";
  currentopacity = 1;
  fadein();
}
 
function fadein() 
{
  if(currentposition > 0) 
  {
    currentposition -= 2;
    currentitem.style.margin = "0 0 0 "+currentposition+"px";
    window.setTimeout(fadein, 8);
  } else {
    currentposion = 0;
    currentitem.style.margin = "0 0 0 0";
    window.setTimeout(fadeout, 5000);
  }
}
 
function fadeout() 
{
  currentopacity -= 0.02;
  currentopacity = parseInt(currentopacity*100)/100;
  if (currentopacity > 0) 
  {
    currentitem.style.opacity = currentopacity;
    currentitem.style.filter = "alpha(opacity="+(currentopacity*100)+")";
    window.setTimeout(fadeout, 20);
  }
  else 
  {
    currentitem.style.opacity = 0;
    currentitem.style.filter = "alpha(opacity=0)";
	currentitem.style.display = "none";
	currentposition = 250;
	currentopacity = 0;
    next();
  }
}