// JavaScript Document
function clip() {

 	var id1 = document.getElementById('slideA');
 	var width = id1.offsetWidth;

 	id1.style.left = parseInt(id1.style.left)-1 + 'px';

 	if(parseFloat(id1.style.left) == -(width/2)) {
  		id1.style.left = '0px';
 	}
 	setTimeout(clip,40)
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function writeClipImages(width,height,name,num) {
  document.write('<div id="slideCont" style="height:'+height+'px;position:relative;z-index:1;left:0px;overflow:hidden;">');
  document.write('<div id="slideA" style="position:absolute;z-index:1;top:0px;left:0px;width:'+(width*2)+'px;overflow:hidden;">');
    for (j=0; j<2; j++) { 
      for (i=0; i<num; i++) { 
        document.write('<img src="' + name + ''+(i+1)+'.jpg" alt="Immagini di repertorio" title="Immagini di repertorio">'); 
      }
    }
  document.write('</div>');
  document.write('</div>');
  
  addLoadEvent(function() {
    clip();
  });
}

