// jslong.js - init thing
	
d=document;l=(d.layers)?1:0;op=navigator.userAgent.toLowerCase().indexOf('opera')!=-1;
	var myIndent=0;

// init thing
var stat="sliding"
var engine=0;
var curimg=0;
var curwork=0
var pad, naam, delay, wid, hei, swf;
var cnt=2;
var NS;
var IE, isMac, isWin;
var winX=0;var winY=0;
if(navigator.appName == "Netscape") {
	NS=true;
	IE=false;
	winX = window.innerWidth;
	winY = window.innerHeight;
} else {
	IE=true; 
//	winX = document.body.width;
//	winY = document.body.height;
	}

var resX=winX/2
var resY=winY/2

// 
if (NS) {document.captureEvents(Event.MOUSEMOVE);}
//// stuur het plaatje
document.onmousemove = printEvent;
//if (NS) {
// window.addEventListener (MOUSEMOVE,printEvent,true)
//}



// janr
function showSize() {
  var myWidth = 0, myHeight = 0; myIndent = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  // nu de indent uitrekenen
  // 820 is de breedte van de container
  myIndent = (myWidth - 760)/2;
	// window.alert( 'myIndent = ' + myIndent );
  // window.alert( 'Width = ' + myWidth );
  // window.alert( 'Height = ' + myHeight );
 document.writeln('<div>Width = ' + myWidth+ 'Indent = ' + myIndent + '</div>');
  return myIndent;
}


	
// 1k DHTML API	
// get element
function gE(e,f){
	if(l){f=(f)?f:self;
	var V=f.document.layers;if(V[e])return V[e];
	for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}
	if(d.all)return d.all[e];return d.getElementById(e);}
// show
function sE(e){if(l)e.visibility='show';else e.style.visibility='visible';}
// hide
function hE(e){if(l)e.visibility='hide';else e.style.visibility='hidden';}
// z-index
function sZ(e,z){if(l)e.zIndex=z;else e.style.zIndex=z;}
// position x
function sX(e,x){
	if(l)e.left=x;else
	if(op)e.style.pixelLeft=x;
	else e.style.left=x;}

// position x janr variant - de indent van de container moet erbij
function sX1(e,x){
	showSize(); // haalt window.myWidth
	if(l)e.left=x;else
	if(op)e.style.pixelLeft=x;
	else e.style.left=x-(myIndent+10);}

// position y
function sY(e,y){
	if(l)e.top=y;else
	if(op)e.style.pixelTop=y;else
	e.style.top=y;}
// position y 	
function sY1(e,y){
	if(l)e.top=y;else
	if(op)e.style.pixelTop=y;
	else e.style.top=y-10;}
function sW(e,w){if(l)e.clip.width=w;else if(op)e.style.pixelWidth=w;else e.style.width=w;}
function sH(e,h){if(l)e.clip.height=h;else if(op)e.style.pixelHeight=h;else e.style.height=h;}
function sC(e,t,r,b,x){if(l){X=e.clip;X.top=t;X.right=r;X.bottom=b;X.left=x;}else e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
function wH(e,h){if(l){Y=e.document;Y.write(h);Y.close();}if(e.innerHTML)e.innerHTML=h;}


//// end 1k DHTML API
// www.quirksmode.org/js/findpos.html
function findPosX(obj){var curleft = 0; if (obj.offsetParent){while (obj.offsetParent){curleft += obj.offsetLeft;obj = obj.offsetParent;}} else if (obj.x){curleft += obj.x;}; return curleft;}

function findPosY(obj){var curtop = 0;if (obj.offsetParent){while (obj.offsetParent){curtop += obj.offsetTop;obj = obj.offsetParent;}}else if (obj.y){curtop += obj.y;}; return curtop;}

function findWidth(obj) {if(obj.offsetWidth || navigator.appVersion.toLowerCase().indexOf('safari')!=-1){return obj.offsetWidth}else{return obj.clip.width}};

function findHeight(obj) {if(obj.offsetHeight || navigator.appVersion.toLowerCase().indexOf('safari')!=-1){return obj.offsetHeight}else{return obj.clip.height}};

function rRand(send){return(Math.ceil(Math.random()*send))};

function printEvent(e) {
   if (IE){
    resX = event.clientX;
    resY = event.clientY;
  } else {
    resX = e.pageX;
    resY = e.pageY;
  }
window.status='mouse at '+resX+'  '+resY+'  '+myIndent;
}

function resizeme() {
	if (NS) {document.location.href = document.location.href;}
}



function choose(i) {
	n=i-1; curwork=i;
	writeimage(folders[n]+'/images/'+srcs[n],ws[n],hs[n],titels[n])
}

function writeimage(fil,wid,hei,tit) {
	curW=wid; curH=hei;
	z=gE('content');
	sX(z,-1000); sY(z,-1000);
	txt='<a href="javascript:hideimg()"><img onload="center()" src="../js/'+fil+'" wid='+wid+' hei='+hei+' border=0><\/a>';
	txt+='<br>'+tit
	txt+='<br><a href="javascript:next()">next<\/a>'
	wH(z,txt); //sZ(z,oldz); oldz++


	sW(z,wid);
	z=gE("loader"); //sE(z);
	sX(z,0); sY(z,0);
	//center();
}

function center() {
	z=gE('content');
	hh=findHeight(z);
	sX(z,(winX-curW)/2); sY(z,(winY-hh)/2);
	z=gE("loader"); //hE(z);
	sX(z,-1000); sY(z,-1000);
}
// janr
function hideelement(myelement) {
	var myelement;
	z=gE(myelement); hE(z);
}

function hideimg() {
	z=gE('content'); sX(z,-1000); sY(z,-1000);
}

function next() {
	curkind=folders[curwork-1]; curwork++
	if (folders[curwork-1]!=curkind) {curwork=findfirst(curkind)}
	choose(curwork);
}



function findfirst(which) {
	for (i=0;i<srcs.length;i++) {
		if (folders[i]==which) {return i+1}
	}
}

function init() {motor();
	engine=setTimeout("motor()",delay);
}
// de motor stuur de slideshows, het pad hier is kwetsbaar
function motor() {
	window.status=new Date();
	clearTimeout(engine);
	curimg+=1;
	if (curimg>cnt) {curimg=1};
	//
//	if (document.getElementById)
//		alert ("1 "+document.getElementById("debeeld").src);
//	else if (document.all)
//		alert ("2 "+document.all.debeeld.src);
//	if (document.getElementById)
//		alert ("3 "+document.getElementById("beeld").src);
//	else if (document.all)
//		alert ("4 "+document.all.beeld.src);
	//
// 	document.debeeld.src = pad+naam+curimg+'.jpg';
// ivm met new
//	if typeof(document.debeeld.src)=='undefined')	{
//	document.debeeld.src = '/slides/hoogspanning/hoog36.jpg';
// 	alert ("my "+document.debeeld.src); // ie not defined
//	} else
document.debeeld.src = '../'+pad+naam+curimg+'.jpg';
// document.debeeld.src = +pad+naam+curimg+'.jpg';

	engine=setTimeout("motor()",delay)
}

function slideshow(path, basename, count, del, thewid, thehei,fla) {
	mypath="slides/";
	if (path!="") {path+="/"};
	mypath+=path;
	// document.writeln(mypath,basename, count, del, thewid, thehei,fla+"<br>");
	pad=mypath; naam=basename; cnt=count; delay=del*1000;
	wid=thewid; hei=thehei; swf=fla;
// hier override van width en height
//	wid=480;hei=288;
wid=508;hei=305;



}

// makepage schrijft de basis voor de slideshow, het pad hier is kwetsbaar

function makepage() {
	beeldnaam=pad+naam+'1.jpg';
//	document.writeln(beeldnaam);
// testing: 	txt='../'+beeldnaam+' =test<br><DIV ID="imagearea"><DIV ID="beeld"><IMG WIDTH="'+wid+'" HEIGHT="'+hei+'" NAME="debeeld" SRC="../'+beeldnaam+'"><\/DIV>';
	txt='<DIV ID="imagearea"><DIV id="beeld" ID="debeeld"><IMG WIDTH="'+wid+'" HEIGHT="'+hei+'" name="debeeld"  SRC="../'+beeldnaam+'"><\/DIV>';
	txt+='<DIV ID="flash"><\/DIV><\/DIV>';
	document.writeln(txt);
}
// paden kwetsbaar, let op pado
function showmovie() {
		z=gE("flash");
		if (stat!="video") { 
			pado="movies/"+swf;
			// alert (pado);
			y=gE("beeld"); // alert (y); //alert (z);
			txt='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+wid+'" HEIGHT="'+hei+'" id="tom3" ALIGN=""><PARAM NAME=movie VALUE="../'+pado+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=exactfit> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="../'+pado+'" quality=high bgcolor=#FFFFFF  SCALE="exactfit" WIDTH="'+wid+'" HEIGHT="'+hei+'" NAME="tom3" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"><\/EMBED><\/OBJECT>';
			xx=findPosX(y);
			yy=findPosY(y);
			wH(y,txt); //schrijf naar y of naar z ??
			clearTimeout(engine);
			stat="video1"
	 } else {
			wH(z," "); sX(z,-1000); stat="sliding"; motor();
	 }
}
// init thing
var themovie="";
function showmovienew(themovie) {
		z=gE("flash");
		if (stat!="video") {
			pado="movies/"+themovie;
// alert (pado);
			y=gE("beeld");
			txt='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+wid+'" HEIGHT="'+hei+'" id="tom3" ALIGN=""><PARAM NAME=movie VALUE="../'+pado+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=exactfit> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="../'+pado+'" quality=high bgcolor=#FFFFFF  SCALE="exactfit" WIDTH="'+wid+'" HEIGHT="'+hei+'" NAME="tom3" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"><\/EMBED><\/OBJECT>';
			xx=findPosX(y);
			yy=findPosY(y);
			wH(y,txt); //schrijf deze swf-start-txt naar de 'flash' id, vorige 'flash' stopt dus.

			clearTimeout(engine);
			stat="video2"
	 } else {
			wH(z," "); sX(z,-1000); stat="sliding"; motor();
	 }
}

function writetxt(dezetxt) {
	z=gE("flash");
	wH(z,dezetxt);
	z=gE("beeld");
	wH(z,dezetxt);
}
function showyt(ytmovie) {
	z=gE("flash");
	wH(z,ytmovie);
	z=gE("beeld");
	wH(z,ytmovie);
}

function over(which) {

//	out(0);
	//z=gE("d"+which); // 

	// alert ("d"+which); //GOED
// resY=resY-40;
// resX=resX-100;
// if (resY> 249){resY=249;} //overgrens
// if (resX> 420){resX=420;}

  if (window.event) {
    resX = window.event.clientX + document.documentElement.scrollLeft
                             + document.body.scrollLeft;
    resY = window.event.clientY + document.documentElement.scrollTop +
                             + document.body.scrollTop;
  }
  else {
    resX = event.clientX + window.scrollX;
    resY = event.clientY + window.scrollY;
  }
  resX -= 20; resY -= 75;
// test


		document.getElementById("d"+which).style.left=resX+"px";
		document.getElementById("d"+which).style.top=resY+"px";
		document.getElementById("d"+which).style.width="100px";
	document.getElementById("d"+which).style.display="block";
// alert ("x "+resX		+" y "+resY);
// showSize(); //groote van viewport
}

function out(which) {
	for (i=0;i<icons.length;i++) {
	
	document.getElementById("d"+i).style.display="none";

	}
}


function go(which) {
	alert(which);
}

// get url parameter
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

// Replaces all instances of the given substring.
// Wordt gebruikt om %20 te vervangen door " "
String.prototype.replaceAll = function(
	strTarget, // The substring you want to replace
	strSubString // The string you want to replace in.
	){
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );

	// Keep looping while an instance of the target string
	// still exists in the string.
	while (intIndexOfMatch != -1){
		// Relace out the current instance.
		strText = strText.replace( strTarget, strSubString )

		// Get the index of any next matching substring.
		intIndexOfMatch = strText.indexOf( strTarget );
	}

	// Return the updated string with ALL the target strings
	// replaced out with the new substring.
	return( strText );
}
function changeTitle(title) { document.title = title; }

// http://www.javascriptjedi.com/getElementById/

function ShowElementInfo( iElementId )
{
  if( typeof(iElementId) == "string" && iElementId.length > 0 )
  {
    var element = document.getElementById(iElementId);
    if( element )
      alert("name=" + element.name + " - id=" + element.id );
    else
      alert("ERROR: could not find the requested element");
  }
}
function toggleItem(strElementID) {
  if (document.getElementById("div" + strElementID).style.display == "none") { 
      expandItem(strElementID);
  } else { 
//      collapseItem(strElementID);
  }
}

function expandItem(strElementID) {
    document.getElementById("div" + strElementID).style.display = "block"; 
    document.getElementById("image" + strElementID).src = "images/min.gif"; 
}
function collapseItem(strElementID) {
     document.getElementById("div" + strElementID).style.display = "none";
     document.getElementById("image" + strElementID).src = "images/plus.gif"; 
}
function makecolright( )
{

// testarea    
// alert ("ii: "+ii+" links: "+links[ii]+" urlin: "+urlin+" slidemap "+slidemap[ii]); // good testing
// document.writeln ("ii: "+ii+" links: "+links[ii]+" urlin: "+urlin+" slidemap "+slidemap[ii]); // good testing
// ii 
if (ii==undefined)
{
// force forward to error !!
// janr uitgezet ivm FLAT window.location.href = 'http://www.eyethink.nl?lang=nl&url=404/index.html'
}
else  { 
	slideshow (slidemap[ii],slidebasisnaam[ii],slideaantal[ii],slideseconds[ii],508,305, flash[ii]) ;
	makepage ();
}
	
// de bio etc. pags hebben geen buttons bij movie
// uitsturen buttons onder diashow en movie
if (ii<=catcollast[2] ){
	// ii is nr van item, begrens de prev en next link per kolom
	// hier wordt de next en prev kolom grensen uitgerekend.
		var previ=links[ii-1];var prevtitel= titels[ii-1];
		var nexti=links[ii+1];var nexttitel= titels[ii+1];
		var colnummer=0;
		for (colnummer=0;colnummer<=2;colnummer=colnummer+1) {
				if ( (ii<=catcollast[colnummer]) && (ii>=catcolfirst[colnummer]) ) { //colom 1
					if (ii==catcollast[colnummer]) {
						var nexti=links[catcolfirst[colnummer]];var nexttitel= titels[catcolfirst[colnummer]];
					}
					if (ii==catcolfirst[colnummer]){//grens kolom bereikt prev veranderd;}
						var previ=links[catcollast[colnummer]];var prevtitel= titels[catcollast[colnummer]];
					}
				}
		}	// einde next en prev uitrekenen, nu create string		
						//document.write(document.readyState);
                        var prev='<a href="http://www.eyethink.nl?lang='+jtaal+'&url='+previ+'">prev</a>';
						var next='<a href="http://www.eyethink.nl?lang='+jtaal+'&url='+nexti+'">next</a>';
						var incat='in '+cat[ii]+' ';
						var catnr=catcol[ii]
						// buttonstring is videolinks, leeg of niet
						if (buttonsstring[ii]=='') {
						txt='<div class="buttons"><span style="color:white">video | </span>'+prev+' &lt;&gt; '+next+' '+incat+' |  '+reag+'</div>';
						} else {
// met toggle voor play video
						txt='<div class="buttons"><a href="javascript:void(0);" onMouseover="toggleItem(1)">video</a> | '+prev+' &lt;&gt; '+next+' '+incat+' | '+reag+'<span style="color:white"> | '+ii+'</span></div>';
// de videostring
						txt+='<div style="display: none;" id="div1">'+buttonsstring[ii]+'</a></div>';
						}
						document.writeln(txt);
						// kolom change
	// testarea
	// document.writeln ('<BR>'+ii+' |- '+catcolfirst[0]+' '+catcollast[0]+' - '+catcolfirst[1]+' '+catcollast[1]+' - '+catcolfirst[2]+' '+catcollast[2]);
	//			}
	//		}
}
}


