function addLoadEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
	var oldonload = window.onload
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload()
			func()
		}
	}
}


	var speed=60 ;  // speed of scroller pių č bassso il numero pių č veloce
	var step=1  ;   // smoothness of movement
	var y, scroll, hb, hs, h,tp ;		
	
	function initScroller(){
	  if (document.getElementById && document.createElement && document.body.appendChild) {
		document.getElementById('board').style.height=70+'px';
		document.getElementById('news').style.position='absolute';
		//document.getElementById('newsNascondi').style.display='none';
		
	    document.getElementById('control').style.display='block';
	    hb=document.getElementById('board').offsetHeight;
	    hc=document.getElementById('control').offsetHeight;
	    hs=hb-hc+6; 			
	    document.getElementById('scrollcontent').style.height=hs+'px';
		document.getElementById('scrollcontent').onmouseover=function(){
			stopScroller();
		}
		document.getElementById('scrollcontent').onmouseout=function(){
			startScroller();
		}
	    tp=hs-(hs/3);
	    document.getElementById('news').style.top=tp+'px';
	    y=tp;
	    scroll=setTimeout('startScroller()',speed);
	  }
	}
	
	function startScroller(){
	  //document.getElementById('newsVia').style.display='none';
	  //document.getElementById('newsStop').style.display='block';
	  h=document.getElementById('news').offsetHeight;
	  //crea il loop
	  if (-h == parseInt(document.getElementById('news').style.top)){
	  	  clearTimeout(scroll);
		  initScroller();
	  }else{
			y-=step;
			if (y<-h) {y=hs};
			document.getElementById('news').style.top=y+'px';
			scroll=setTimeout('startScroller()',speed);
	  }
	}
	
	function stopScroller(){
		clearTimeout(scroll);
		//document.getElementById('newsStop').style.display='none';
		//document.getElementById('newsVia').style.display='block';
	}
	
	function showAll(){
	//document.getElementById('newsTutto').style.display='none';
	//document.getElementById('newsNascondi').style.display='block';
		  if (document.getElementById) {
		    stopScroller();
		    document.getElementById('news').style.position='relative';
		    document.getElementById('board').style.height='auto';
		    document.getElementById('scrollcontent').style.height='auto';
		    document.getElementById('news').style.top='0px';
		  }
	}
	
	function hideAll(){
	//document.getElementById('newsNascondi').style.display='none';
	document.getElementById('newsTutto').style.display='block';
		  if (document.getElementById) {
		    document.getElementById('news').style.position='absolute';
		    document.getElementById('board').style.height=hb+'px';
		    initScroller();
		  }
	}
	
	function scrollUp(){
	  if (document.getElementById) {
	    y-=step*20;
	    if (y<-h) {y=hs};
	    document.getElementById('news').style.top=y+'px';
	  }
	}
	
	function scrollDown(){
	  if (document.getElementById) {
	    y+=step*50;
	    if (y>h) {y=h};
	    document.getElementById('news').style.top=y+'px';
	  }
	}
			
	addLoadEvent(initScroller);









// Style sheet switcher //
/*
function setActiveStyleSheet(title) {
  if (!document.getElementsByTagName) return
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function getCookie(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);





addLoadEvent(getCookie)

*/


