//////////////////////////////////////////////
// c  Zeezeilen - www.zzln.nl - Amsteradm
// script written by Egbert Bleyenburg 
// gpu gl 2008 march 
// 
// version 1.7
// Filmmuseum Amsterdam
//////////////////////////////////////////////

// ===================== touch this =========================
    var nowOnload = window.onload; // Let's save the existing assignment, if any
    window.onload = function () {
        // Here is your precious function
        // You can call as many functions as you want here;
        startticker();
     //

        // Now we call old function which was assigned to onLoad, thus playing nice
        if(nowOnload != null && typeof(nowOnload) == 'function') {
            nowOnload();
        }
    }





var scrollTime=30;// 1-infinite : the higher this value, the slower the movement
var htmlblock_doubling=30;// this is how often the content of the span htmlblock is multiplied
var pixelspeed=2;// this is the distance teh layer is moved every time the layer scrolls, the higer this value the faster the scrolling, but also the bumpier
var balkwidth=0;
// =================== don't touch this ======================
// get the arguments


var move=true;

function startticker(){
testDomVersion();
balkwidth=1-(5*askwidth());
if (Math.abs(balkwidth)<1000){balkwidth=-1200}
ZZLN_multiplyHTMLContent();
ZZLN_moveLichtkrant();
}


function askwidth(){
	x = document.getElementById('container');
	return parseInt(x.offsetWidth);
}

function ZZLN_multiplyHTMLContent(){
  qq = document.getElementById("htmlblock"); 
  yy = document.getElementById("container");
  currenthtml=qq.innerHTML; 
  var new_htmlblock="";
  for (var i=0;i<=htmlblock_doubling;i++) {
    new_htmlblock+=qq.innerHTML;
  }
  qq.innerHTML=new_htmlblock;
}


function ZZLN_moveLichtkrant(){
  if (move){
//    alert(getLayerProperty("lichtkrant","width"));
    var left=getLayerProperty("container", "left");
   // if (left <  getLayerProperty("lichtkrant","width")){alert(getLayerProperty("lichtkrant","width"));}	
    var new_left=parseInt(left)-pixelspeed;
    if (new_left<balkwidth) {new_left=0;}	
    setLayerProperty("container", "left", new_left);

  }
  setTimeout("ZZLN_moveLichtkrant()",scrollTime);
}

var domversion = null; 
var domtest = false; 

function testDomVersion() { 
  if (document.layers) { 
    layerRef="document.layers"; 
    styleSwitch=""; 
    argVisibility="show"; 
    screenSize = window.innerWidth; 
    domversion ="ns4"; 
  } 
  else if(document.all) { 
    layerRef="document.all"; 
    styleSwitch=".style"; 
    argVisibility="visible"; 
    screenSize = document.body.clientWidth + 18; 
    domversion ="ie4"; 
  } 
  else if(document.getElementById) { 
    layerRef="document.getElementByID"; 
    styleSwitch=".style"; 
    argVisibility="visible"; 
    domversion="dom1"; 
  } 
  else { 
    domversion="none"; 
  } 
  domtest = true; 
} 

function setLayerProperty(layerName, property, value) { 
  if (layerName =='' ){return;}
//  alert(value);
  if(domtest) { 
    if (domversion =="none") { 
      return; 
    } 
    else if (domversion == "dom1") { 
    	//alert("oud:"+eval('document.getElementById("'+layerName+'").style.'+property));
	// mozilla bug: je moet px achte de value zetten anders verplaatst ie het layer niet echt
	var px=((property=='left') || (property=='top'))?"px":"";
      eval('document.getElementById("'+layerName+'").style.'+property+'="'+value+px+'"'); 
	//alert("nieuw:"+eval('document.getElementById("'+layerName+'").style.'+property));
    } 
    else { 
	//alert(layerName);alert(property);alert(value);
	// wanneer je de div via het css positioneer leest de getproperty een NaN in voor left 
      eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.'+property+'="'+value+'"'); 
    } 
  } 
  else { 
    return; 
  } 
} 

function getLayerProperty(layerName, property) { 
  if (layerName =='' ){return;}
  if(domtest) { 

    if (domversion =="none") { 

      return; 
    } 
    else if (domversion == "dom1") { 

      return eval('document.getElementById("'+layerName+'").style.'+property); 
    } 
    else { 
// wanneer je de left zet via het css, leest ie de property hier blijkbnaar niet is 
// zet je d epos in de html, ziet ie hem wel, heel irritant
      return eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.'+property);
    } 
  } 
  else { 
    return; 
  } 
} 


function stop_layer(){
  move=false;
}

function resume_layer(){
  move=true;
}

