allColors = new Array("#993300", "#CC6600", "#996633", "#663333", "#CC3300");

function nextImg() {
	curImg ++;
	if (curImg >= allImg.length) curImg = 0;
	newimg = "images/" + allImg[curImg];
	document.mainImg.src = newimg;
	newtxt = allTxt[curImg];
	document.getElementById("undertxt").innerHTML = newtxt;
}

function prevImg() {
	curImg --;
	if (curImg < 0) curImg = allImg.length - 1;
	newimg = "images/" + allImg[curImg];
	document.mainImg.src = newimg;
	newtxt = allTxt[curImg];
	document.getElementById("undertxt").innerHTML = newtxt;
}

function showImgLink(id) {
	divname = id + "div";
	document.getElementById(divname).style.visibility = "visible";
	// Place DIV
	checkScroll();
	mX = event.clientX + xscroll;
    mY = event.clientY + yscroll;
	newx = mX - 100;
	newy = mY - 100;
	if (id == "schoenr") {
		newx += 20;
	} else {
		newx -= 20;
	}
	if (newx < 0) newx = 0;
	document.getElementById(divname).style.left = newx;
	document.getElementById(divname).style.top = newy;
	// make small img invisible
	eval("document." + id + ".src = 'images/leeg.gif'");
		// new x and y for 2 Flies
	nextx1 = (Math.random() * 80 - 40);
	nexty1 = (Math.random() * 80 - 40);
	if (nextx1 >= 0) {
		nextx1 = mX + (nextx1 + 20);
	} else {
		nextx1 = mX + (nextx1 - 20);
	}
	if (nexty1 >= 0) {
		nexty1 = mY + (nexty1 + 20);
	} else {
		nexty1 = mY + (nexty1 - 30);
	}
	nextx2 = (Math.random() * 80 - 40);
	nexty2 = (Math.random() * 80 - 40);
	if (nextx2 >= 0) {
		nextx2 = mX + (nextx2 + 20);
	} else {
		nextx2 = mX + (nextx2 - 20);
	}
	if (nexty2 >= 0) {
		nexty2 = mY + (nexty2 + 20);
	} else {
		nexty2 = mY + (nexty2 - 30);
	}
	setFlyDest("vlieg1", nextx1, nexty1);
	setFlyDest("vlieg2", nextx2, nexty2);
}

function hideImgLink(id) {
		eval("document." + id + ".src = 'images/" + id + "klein.gif'");
		divname = id + "div";
		document.getElementById(divname).style.visibility = "hidden";
		document.getElementById(divname).style.visibility = "hidden";
	hitFly('vlieg1');
	hitFly('vlieg2');
}

function showLink(id, text, type) {
	// put text and link in DIV
	newcolor = allColors[Math.round(Math.random() * 4)];
	if (text == "020-6107962" || text == "020-6107962") {
		document.getElementById("grootDiv").innerHTML = "<a href='javaScript:void(0);' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else if (text == "English"){
		document.getElementById("grootDiv").innerHTML = "<a href='site_eng/index.html' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else if (text == "Terug") {
		document.getElementById("grootDiv").innerHTML = "<a href='javaScript:history.back();' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else if (text == "Home") {
		document.getElementById("grootDiv").innerHTML = "<a href='index.html' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else if (text == "post@sternnijland.nl") {
		document.getElementById("grootDiv").innerHTML = "<a href='mailto:post@sternnijland.nl' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else if (id == "download1") {
		document.getElementById("grootDiv").innerHTML = "<a href='images/mevrouw_dientje.pdf' target='_blank' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else if (id == "download2") {
		document.getElementById("grootDiv").innerHTML = "<a href='images/superliesje.pdf' target='_blank' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	} else {
		document.getElementById("grootDiv").innerHTML = "<a href='" + id + ".html' class='groot' onmouseover='this.style.visibility=\"visible\"'  onmouseout='hideLink(\"" + id + "\", \"" + type + "\");'><font color='" + newcolor + "'>"  + text + "</font></a>";
	}
	//showDiv("grootDiv");
	document.getElementById("grootDiv").style.visibility = "visible";
	// Place DIV
	checkScroll();
	mX = event.clientX + xscroll;
    mY = event.clientY + yscroll;
	newx = mX - text.length * 7.5;
	if (newx < 0) newx = 0;
	document.getElementById("grootDiv").style.left = newx;
	document.getElementById("grootDiv").style.top = mY - 25;
	// make text white/invisible
	document.getElementById(id).style.color = "#FFFFFF";
	// new x and y for 2 Flies
	nextx1 = (Math.random() * 80 - 40);
	nexty1 = (Math.random() * 80 - 40);
	if (nextx1 >= 0) {
		nextx1 = mX + (nextx1 + 20);
	} else {
		nextx1 = mX + (nextx1 - 20);
	}
	if (nexty1 >= 0) {
		nexty1 = mY + (nexty1 + 20);
	} else {
		nexty1 = mY + (nexty1 - 30);
	}
	nextx2 = (Math.random() * 80 - 40);
	nexty2 = (Math.random() * 80 - 40);
	if (nextx2 >= 0) {
		nextx2 = mX + (nextx2 + 20);
	} else {
		nextx2 = mX + (nextx2 - 20);
	}
	if (nexty2 >= 0) {
		nexty2 = mY + (nexty2 + 20);
	} else {
		nexty2 = mY + (nexty2 - 30);
	}
	setFlyDest("vlieg1", nextx1, nexty1);
	setFlyDest("vlieg2", nextx2, nexty2);
}

function hideLink(id, type) {
	if (type == "spot" || type == "nav") {
		newcolor = "#333333";
	} else {
		newcolor = allColors[Math.round(Math.random() * 4)];
	}
	document.getElementById("grootDiv").style.visibility = "hidden";
	document.getElementById(id).style.color = newcolor;
	hitFly('vlieg1');
	hitFly('vlieg2');
}

function changeColor(id) {
	newcolor = allColors[Math.round(Math.random() * 4)];
	document.getElementById(id).style.color = newcolor;
}
// algemene functies


var winx;
var winy;
function checkSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winx = window.innerWidth;
    winy = window.innerHeight;
  } else {
    if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      winx = document.documentElement.clientWidth;
      winy = document.documentElement.clientHeight;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        winx = document.body.clientWidth;
        winy = document.body.clientHeight;
      }
    }
  }
}

var xscroll;
var yscroll;
function checkScroll() {
	var x,y;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	xscroll = x;
	yscroll = y;
}

function showDiv(deDiv) {
  if (document.getElementById) { // IE5+/NS6
    document.getElementById(deDiv).style.visibility = "visible";
  } else if (document.layers) { // NS4
      document.layers[deDiv].visibilty = "show";
  } else if (document.all) { // IE4
      document.all[deDiv].style.visibilty = "visible";
  }
}
function hideDiv(deDiv) {
  if (document.getElementById) { // IE5+/NS6
    document.getElementById(deDiv).style.visibility = "hidden";
  } else if (document.layers) { // NS4
    document.layers[deDiv].visibilty = "hide";
  } else if (document.all) { // IE4
    document.all[deDiv].style.visibilty = "hidden";
  }
}