
/* =================================================================================================== */
/* target windows */
/* =================================================================================================== */

window.onerror = HandleError;
function HandleError() {return true}

function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
      var anchor = anchors[i];
      if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "externallink") {
          anchor.target = "_blank";
          if (anchor.title) anchor.title += " [Il link apre una nuova finestra]";
          if (!anchor.title) anchor.title = "Il link apre una nuova finestra";
      }
  }
}



/* =================================================================================================== */
/* BoDbMarque.js */
/* =================================================================================================== */

var scrollspeed=cache=1;
var scrolltop=150;
var scrolldirection="Up";
var scrollstart = 150;


function iniBoDbMarque(){
   	
   thelength = 150;
   dataobj = document.all? document.all.marque : document.getElementById("marque");

   if (dataobj != undefined) {
       dataobj.style.top = thelength;
       scrolltest();
   }    
}

function scrolltest(){
	
    dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed;
    scrTop    = parseInt(dataobj.style.top);
    scrHeight = parseInt(dataobj.offsetHeight);
    blnReset  = false;

    if (scrolldirection=="Up") {
        blnReset  = ((scrTop + scrHeight) <= 0);
        scrollstart = 150;
    } else {
        blnReset = (scrTop > scrolltop);
        scrollstart = - scrHeight;
    }    
    if (blnReset) {
         dataobj.style.top=scrollstart;
    }
    
    setTimeout("scrolltest()",50)    
}

function direction(strDirection){
	
	if (strDirection == "Up") {
        scrolldirection = "Up";
        scrollspeed=cache=1;
    } else {	
        scrolldirection = "Down";	
        scrollspeed=cache=-1;
    }    
}

function speed(intDelta){
	
	if (scrolldirection == "Up") {
        scrollspeed += intDelta; 
        if (scrollspeed > 5) {
            scrollspeed=5;
        }    
        if (scrollspeed < 0) {
            scrollspeed=1;
        }    
        
    } else {	
        scrollspeed -= intDelta; 
        if (scrollspeed < -5) {
            scrollspeed=-5;
        }    
        if (scrollspeed > 0) {
            scrollspeed=-1;
        }    
    }    
}

/* =================================================================================================== */


function initialize(){

	externalLinks();
	iniBoDbMarque();
		
}	
	
window.onload=initialize

