
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 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);
}
}
function ingrandisci(z,iniz,stop,start) {
newWindow = window.open( '','principale','width=100%');
newWindow.document.open();
newWindow.document.writeln('<html><head><title>Pictures Slide Show</title><LINK href=script/stile.css rel=stylesheet type=text/css>');
newWindow.document.writeln('<script type=text/javascript language=JavaScript src='+z+'></sc'+'ript>');
newWindow.document.writeln('<script type=text/javascript language=javascript src=script/video.js></sc'+'ript>');
newWindow.document.writeln('<bgsound src=' + start + ' loop=1>');
newWindow.document.writeln('</head><body link="#9AD2F1" vlink="#9AD2F1" alink="#9AD2F1" background="other/" leftmargin="0" topmargin="0"  onload=javascript:runPage('+iniz+','+stop+',6000)>');
var temp = "";
temp +='span style="position: absolute; top: 3px ; left: 10px; z-index: 6" class=TTempo><b> Time: </b><select name="tempo" size="1" style="font-family: Arial; font-size: 12 pt; background-color: #9AD2F1; color: #000000"> ><option value="3000">3 sec.</option>';
temp += '<option value="4000">4 sec.</option><option value="5000">5 sec.</option><option value="6000" selected>6 sec.</option>';
temp += '<option value="7000">7 sec.</option><option value="8000">8 sec.</option><option value="9000">9 sec.</option>';
temp += '<option value="10000">10 sec.</option><option value="11000">11 sec.</option>';
temp += '</select></span>';
newWindow.document.writeln('<' + temp + '<DIV id=newsLayer style="height: 100%; position: relative; top: 0px; visibility: hidden; width: 100%; z-index: 5"></div></body></html>');
newWindow.document.close();
newWindow.focus();
}
function writeArticle(elt) {
var max_PicW=640;
var max_PicH=340;
var max_PicW=640;
var ratioX=0;
var ratioY=0;
var xText = "";
xText += '  <center><table width="100%" height="100%" cellpadding=0 cellspacing=0 border="0"> ';
xText +='<tr><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="' + arrNews[elt].url + '"><img border="0" style=" CURSOR: hand" hspace=2 align="center" src="other/start.gif" alt="Play Album"></a>';
xText += '<a onclick="' + arrNews[elt].url1 + '"><img border="0" style=" CURSOR: hand" hspace=2 align="center" src="other/stop.gif" alt="Stop"></a>';
xText += '<a onclick="javascript:runPage(1,1,tempo.value)"><img border="0" style=" CURSOR: hand"  hspace=4 align="center" src="other/gotofirst.gif" alt="Go to First"></a>';
xText += '<a onclick="' + arrNews[elt].url4 + '"><img border="0" style=" CURSOR: hand" hspace=4 align="center" src="other/back.gif" alt="Previous"></a>';
xText += '<a onclick="' + arrNews[elt].url5 + '"><img border="0" style=" CURSOR: hand" hspace=4 align="center" src="other/forward.gif" alt="Next"></a>';
xText += '<a onclick="' + arrNews[elt].url3 + '"><img border="0" style=" CURSOR: hand" hspace=4 align="center" src="other/gotoend.gif" alt="Go to Last"></a>';
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 += '</td></tr>';
xText += '<tr><td width="100%" valign="middle" align="center" >';
xText += ' <table background="other/colorforeground.gif" width="100%" cellpadding=0 cellspacing=0 border="0" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#000000" >';
xText += '<tr><td width="100%" >';
xText += '</td></tr>';
xText += ' </table> ';
xText += '</td></tr>';
xText += '<tr><td width="100%" height=10 valign="middle" align="center" >';
xText += '</td></tr>';
xText += '<tr>';
xText += '<td width=100%  valign=middle>  ';
xText += '<center><table border="0" bordercolor="#9AD2F1" bordercolorlight="#9AD2F1" bordercolordark="#9AD2F1" cellpadding=0 cellspacing=0 >';
xText += '<tr><td align="center" valign="middle"><img  align="center" src="other/bar.gif"></td></tr>   ';
xText += '<tr><td valign="middle" align="center" height="16" ></td></tr>';
// write picture
xText += '<tr><td align="center" valign="middle"><img align="center" src="' + arrNews[elt].img + '"></td></tr>   ';
xText += '<tr><td valign="middle" align="center" height="16" ></td></tr>';
xText += '<tr><td align="center" valign="middle"><img  align="center" src="other/bar.gif"></td></tr>   ';
// write title
xText += '<tr><td valign="middle" align="center" height="25" >';
xText += '<p class=pictit><span style="background-color: #9AD2F1"><b>' + arrNews[elt].title + '</b></span></p>';
xText += ' </td></tr>';
xText += '</table></center></td></tr> ';
xText += ' </table></center> ';
return xText;
}

