
function ferma(a,b,c) {
inizio=a;
fine=b;
tempo.value=c;
clearTimeout('scrollIt(inizio,fine)', tempo.value);
runPage(inizio,fine,cc)
}

function runPage(a,b,c) {
if (a==b) {
img = 2;
} else {
img =1;
}
inizio=a;
fine=b;
cc=c;
interloop=true;
if (document.all) {
  ver5 = false;
  doc = "document.all";
  sty = ".style";
  htm = "";
} else {
  ver5 = false;
  doc = "document";
  sty = "";
  htm = ".document";
}

var scrollTimer = null;
var cT = 0; var cL = 0; var cB = 0; var cR = 0;

tempo.value=c;
SCROLL = 600;
CURTOP = 600;
FADE = (fine-inizio)*1;
SPEED = (fine-inizio)*1;

bWriting = false;
  scrollControl(inizio,fine);
}

function scrollControl(a,b) {
inizio=a;
fine=b;

  lyrSTY = eval(doc + '["newsLayer"]' + sty);lyrHTML = eval(doc + '["newsLayer"]' + htm);
  if (document.all) {
    lyrSTY.filter = "progid:DXImageTransform.Microsoft.Fade(FADE)";
    (newsLayer.filters[0]) ? ver5 = true : ver5 = false;
  }
  (interloop)? curArt=inizio-1:clearTimeout('scrollIt(inizio,fine)', tempo.value);
	interloop=false;
	scrollIt(inizio,fine);
}

function scrollIt(a,b) {
inizio=a;
fine=b;

  (document.all && ver5) ? newsLayer.filters[0].apply() : void(null);
  lyrSTY.visibility = 'hidden';
  (document.all && ver5) ? newsLayer.filters[0].play() : void(null);
  lyrSTY.top = (parseInt(lyrSTY.top) + CURTOP);
  if (document.all) {
    lyrHTML.innerHTML = writeArticle(curArt);
  } else {
    if(bWriting == true) {
      setTimeout('scrollIt(inizio,fine)', tempo.value);
    } else {
      lyrHTML.open();lyrHTML.write(writeArticle(curArt));lyrHTML.close();
    }
  }
  clipScroll(0, 0, 0, 1005);lyrSTY.visibility = 'visible';scroll(inizio,fine);
}

function scroll(a,b) {
inizio=a;
fine=b;
  if(scrollNews(cT, cL, cB, cR)) {
  setTimeout('scrollNew()', SPEED);
  } else {
  if(curArt < fine-1) {
  	curArt++;
  	setTimeout('scrollIt(inizio,fine)', tempo.value);
    } else {
    (interloop)? curArt=inizio-1:clearTimeout('scrollIt(inizio,fine)', tempo.value);
    }
    
}
}



function writeArticle(elt) {
var xText = "";
// write control buttons to play video
xText += '<center><table border="0" width="100%" height="100%"><tr width="100%"><td background="other/colorbkground.gif" width="100%" align="center" height="10" valign="top" >';
xText += '<img align="center" src="other/play' + img + '.gif">';
xText += '<a onclick="javascript:window.open(&#39presentation.htm&#39,&#39principale&#39)'+'"><img style=" CURSOR: hand" hspace=10 align="center" src="other/gohome.gif" alt="Home"></a>';
xText += '<a onclick="' + arrNews[elt].url + '"><img style=" CURSOR: hand" hspace=10 align="center" src="other/start.gif" alt="Play Album"></a>';
xText += '<a onclick="' + arrNews[elt].url1 + '"><img style=" CURSOR: hand" hspace=10 align="center" src="other/stop.gif" alt="Stop"></a>';
xText += '<a onclick="javascript:runPage(1,1,tempo.value)"><img  style=" CURSOR: hand"  hspace=10 align="center" src="other/gotofirst.gif" alt="Go to First"></a>';
xText += '<a onclick="' + arrNews[elt].url4 + '"><img style=" CURSOR: hand" hspace=10 align="center" src="other/back.gif" alt="Previous"></a>';
xText += '<a onclick="' + arrNews[elt].url5 + '"><img style=" CURSOR: hand" hspace=10 align="center" src="other/forward.gif" alt="Next"></a>';
xText += '<a onclick="' + arrNews[elt].url3 + '"><img style=" CURSOR: hand" hspace=10 align="center" src="other/gotoend.gif" alt="Go to Last"></a></td></tr>';
// set colors of tab
xText += '<tr align=center><td valign=middle><table cellpadding=2 border=0 ><tr>';
// write picture
xText += '<td align="center" valign="middle"><img align="center" src="' + arrNews[elt].img + '"><' + '/' + 'td><tr><td align="center" height="25" valign="top" >';
// write title
xText += '<p class=pictit><b>' + arrNews[elt].title + '</b></p><' + '/' + 'td><' + '/' + 'tr><' + '/' + 'table></td></tr></table></center>';
	  return xText;
}





function clipScroll(cTop, cLeft, cBottom, cRight) {
  if(document.all) {
    lyrSTY.clip = 'rect(' + cTop + ' ' + cRight + ' ' + cBottom + ' ' + cLeft + ')';
  } else {
    lyrSTY.clip.left = cLeft;lyrSTY.clip.right = cRight;lyrSTY.clip.top = cTop;lyrSTY.clip.bottom = cBottom;
  }
  cT = cTop; cL = cLeft;cB = cBottom; cR = cRight;
}

function scrollNews(oT, oL, oB, oR) {
  topY = parseInt(lyrSTY.top);
  if (oB >= CURTOP) {
    return true;
  } else {
    clipScroll(oT, oL, oB + SCROLL, oR);lyrSTY.top = topY - SCROLL;
    return false;
  }
}
function tmt_scrollLayerBy(bersaglio, dx, dy, vel,lung) {
if (document.layers) {
actual_layer = document.layers[bersaglio];
var cl = actual_layer.clip.left;
var ct = actual_layer.clip.top;
var cr = actual_layer.clip.right;
var cb = actual_layer.clip.bottom;
var l = actual_layer.left;
var t = actual_layer.top;
actual_layer.clip.left = cl + dx;
actual_layer.clip.top = ct + dy;
actual_layer.clip.right = cr + dx;
actual_layer.clip.bottom = cb + dy;
actual_layer.top = t - dy;
actual_layer.left = l - dx;
} else {
if (document.all) {
actual_layer = eval("document.all." + bersaglio + ".style");
if (actual_layer.clip) {
var clipv = actual_layer.clip.split("rect(")[1].split(")")[0].split("px");
var ct = Number(clipv[0]);
var cr = Number(clipv[1]);
var cb = Number(clipv[2]);
var cl = Number(clipv[3]);
var l = actual_layer.pixelLeft;
var t = actual_layer.pixelTop;
}
ncl = cl + dx;
nct = ct + dy;
ncr = cr + dx;
ncb = cb + dy;
actual_layer.pixelTop = t - dy;
actual_layer.pixelLeft = l - dx;
eval("actual_layer.clip = 'rect(' + nct + ' ' +  ncr + ' ' + ncb + ' ' + ncl +')'");
}
}
if (ncl ==lung ||ncl ==0) {
dx=-dx;
}
tmt_scrollalo = setTimeout("tmt_scrollLayerBy('" + bersaglio + "'," + dx + "," + dy + "," + vel + "," + lung + ")", vel);
}

function tmt_stopScroll() {
if (tmt_scrollalo) {
clearTimeout(tmt_scrollalo);
}
}
