ie = document.all && navigator.userAgent.indexOf("Opera") == -1;
to = new Array("", "", "", "", "", "", "", "", "", "", "");
dropto = "";
dodrag = false;
parenttop = 0;
var x = "1";
var isBack;

function backbutton(){
	isBack = (x != document._mine._a1.value);
	document._mine._a1.value = 2;
	document._mine._a1.defaultValue = 2;
	return isBack;
}
function alltris() {
	movetri(4, 16);
	movetri(3, 13);
	movetri(2, 10);
	movetri(1, 7);
}

function movetri(num,s) {
	if (document.all) {
		x = event.x-document.getElementById("tricontdiv").offsetLeft-2;
		if (to[num] != "") window.clearTimeout(to[num]);
		gotri(x, num, s);
	}
}

function gotri(x,num,s) {
	n = document.getElementById("tridiv"+num).offsetLeft;
	if (n != x) {
		step = x - n;
		add = step / s;
		if (add > -1 && add < 0) add = -1;
		if (add < 1 && add > 0) add = 1;
		document.getElementById("tridiv" + num).style.left = n + add;
		to[num] = window.setTimeout("gotri(" + x + ", " + num + ", " + s + ")", 20);
	} else to[num] = "";
}

function fadeIn(whatdiv,speed) {
	if (ie) {
		document.getElementById(whatdiv).style.filter = "blendTrans(duration=" + speed + ")";
		    if (document.getElementById(whatdiv).filters.blendTrans.status != 2) {
		        document.getElementById(whatdiv).filters.blendTrans.apply();
		        document.getElementById(whatdiv).style.visibility = "visible";
		        document.getElementById(whatdiv).filters.blendTrans.play();
		    }
	} else {
	        document.getElementById(whatdiv).style.visibility = "visible";
	}
}

function fadeall() {
	l1 = document.getElementById("scrolldiv");
	l2 = document.getElementById("scrollcontent");
	if (l1.offsetHeight > l2.offsetHeight) {
		document.getElementById("scrollbardiv").style.visibility = "hidden";
	}

	w = 0;
	e = document.location.href.split("/");
	f = e[e.length-1];
	if (f == "" || f == "index.php") {
		window.setTimeout("fadeIn('logo', 1.2)", w + 0);
		window.setTimeout("fadeIn('nav', 1)", w + 1000);
		window.setTimeout("fadeIn('nav2', 1)", w + 1500);
		window.setTimeout("fadeIn('tricontdiv', 1)", w+ 1000);
		window.setTimeout("fadeIn('bow', 1)", w + 1000); 
		window.setTimeout("loadingdone()", w + 0);
	} else {
		window.setTimeout("fadeIn('logo', 0.2)", w + 0);
		window.setTimeout("fadeIn('nav', 0.2)", w + 0);
		window.setTimeout("fadeIn('nav2', 0.2)", w + 0);
		window.setTimeout("fadeIn('tricontdiv', 0.2)", w + 0);
		window.setTimeout("fadeIn('bow', 0.2)", w + 0);
		window.setTimeout("loadingdone()", w + 0);
	}
	window.setTimeout("newheight('bs3', 298)", w + 0);
	window.setTimeout("newheight('bs2', 298)", w + 300);
	window.setTimeout("newheight('bs1', 298)", w + 600);
	window.setTimeout("fadeIn('topline', 1)", w + 500);
	window.setTimeout("fadeIn('sl1', 1)", w + 1000);
	window.setTimeout("fadeIn('sl2', 1)", w + 1000);
	window.setTimeout("swoosh(4, 1)", w + 1000);

	r = document.referrer;
	if (r.substring(r.length-1, r.length) == "/") r+= "index.php";
	d = document.location.href;
	if (backbutton() || (d.indexOf("detail") != -1 && r.indexOf("keukens/") != -1 && r.indexOf("keukens/detail") == "-1" && r.indexOf("keukens/index") == "-1")) window.setTimeout('drop()', w+600);
}

function loadingdone() {
	document.getElementById("innertable").style.backgroundImage="url(/dummy.gif)";
}

function swoosh(n,f) {
	if (ie) {
		if (document["movie" + n].CurrentFrame() >= f || document["movie" + n].CurrentFrame() == 0) {
			document["movie" + n].GotoFrame(2);
			document["movie" + n].Play();
		}
	}
}

function newheight(div,h) {
	d = document.getElementById(div);
	d.style.visibility = "visible";
	if (d.offsetHeight != h) {
		step = Math.round((h - d.offsetHeight) / 7);
		if (step < 4) step = 4;
		nh = d.offsetHeight + step;
		if (nh > h) nh = h;
		d.style.height = nh;
		window.setTimeout("newheight('" + div + "', " + h + ")", 25);
	}
}

function togglephototext() {
	t = document.getElementById("footertext").offsetTop;
	h = document.getElementById("footertext").offsetHeight;
	if (t == (296 - h)) {
		for (i = 0; i < 18; i++) window.setTimeout("movetogglediv(" + h + ", " + t + ", " + (i + 1) + ", 18, 1, '<IMG SRC=/images/triup.gif WIDTH=13 HEIGHT=13 BORDER=0>')", i * i);
	} else if (t == 296) {
		for (i = 17; i >= 0; i--) window.setTimeout("movetogglediv(" + h + ", " + t + "," + (i + 1) + ", 18, -1, '<IMG SRC=/images/tridown.gif WIDTH=13 HEIGHT=13 BORDER=0>')", i * i);
	}
}

function fixphototext() {
	t = document.getElementById("footertext").offsetTop;
	h = document.getElementById("footertext").offsetHeight;
	if (h % 18 != 0) h+= (18 - (h % 18));
	document.getElementById("footertext").style.top = 296 - h;
	document.getElementById("footerline").style.top = 295 - h;
	document.getElementById("footerbg").style.top = 296 - h;
	document.getElementById("footertext").style.height = h;
	document.getElementById("footerbg").style.height = h;
}

function movetogglediv(h,t,step,steps,dir,txt) {
	if (step == steps) document.getElementById("togglelink").innerHTML = txt;
	document.getElementById("footerline").style.top = t + (h / steps * step) * dir + 1 * dir;
	document.getElementById("footerbg").style.top = t + (h / steps * step) * dir;
	document.getElementById("footertext").style.top = t + (h / steps * step) * dir;
}

function drop() {
	newheight('dd1', 197);
	fadeIn('dd1a', 0.4);
	renewdrop();
}

function renewdrop() {
	if (dropto) window.clearTimeout(dropto);
	dropto = window.setTimeout("nodrop()", 5000);
}

function nodrop() {
	document.getElementById("dd1").style.height = 1;
	document.getElementById("dd1a").style.visibility = "hidden";
}

function photopop(s, f, w, h) {
	f = f.replace("index.php/", "");
	
	f = "";	// nieuw toegevoegd sinds de fotos in /includes/ zitten, anders werkt het niet
	
	sx = Math.floor(screen.width-w) / 2;
	sy = Math.floor(screen.height-h) / 2;
	window.open("/bigpic.php?s=" + f + escape(s) + "&w=" + w + "&h=" + h, "pic", "width=" + w + ", height=" + h + ", left=" + sx + ", top=" + sy);
}

canscroll = false;
scrolldir = 0;
step = 5;
lsto = false;

function largescroll(d) {
	if (canscroll) {
		nh = "no";
		scrolldir = d;
		l1 = document.getElementById("scrolldiv");
		l2 = document.getElementById("scrollcontent");

		if (scrolldir > 0) {
			if (l2.offsetTop < 0) {
				nh = l2.offsetTop + step * scrolldir;
				if (nh > 0) nh = 0;
			}
		} else {
			if (l2.offsetTop > 0 - (l2.offsetHeight - l1.offsetHeight)) {
				nh = l2.offsetTop + step * scrolldir;
				if (nh < (0 - (l2.offsetHeight - l1.offsetHeight))) nh = 0 - (l2.offsetHeight - l1.offsetHeight);
			}
		}
		if (nh != "no") {
			l2.style.top = nh;

			dif = l1.offsetHeight - l2.offsetHeight;

			pos = Math.floor(nh / dif * 241);
			if (pos > 241) pos = 241;
			document.getElementById("scrolldrag").style.top = 13 + pos;

			if (lsto) window.clearTimeout(lsto);
			if (scrolldir * scrolldir == 1) {
				lsto = window.setTimeout("largescroll(" + d + ")", 20);
			}
		}
	}
}

popcount = 0;

function popit(t, w, h, code, naam) {
	difx = (popcount % 2) * (w + 10) - Math.floor(w / 2);
	dify = (popcount % 4 > 1 ? 1 : 0) * (h + 30) - Math.floor(h / 2);
	sx = Math.floor((screen.width - w) / 2) + difx;
	sy = Math.floor((screen.height - h) / 2) + dify;
	window.open(t + "&code=" + code + "&naam=" + escape(naam), "popup" + popcount, "width=" + w + ", height=" + h + ", left=" + sx + ", top=" + sy);
	popcount++;
}

function jumpto(n) {
	h = document.getElementById("bigtitle" + n).offsetTop;
	document.getElementById("scrollcontent").style.top = 0 - h;

	l1 = document.getElementById("scrolldiv");
	l2 = document.getElementById("scrollcontent");
	dif = l1.offsetHeight - l2.offsetHeight;
	pos = Math.floor(l2.offsetTop / dif * 241);
	if (pos > 241) pos = 241;
	document.getElementById("scrolldrag").style.top = 13 + pos;

}
function getdragy() {
	parenttop = document.getElementById("scrollcontent").offsetParent.offsetParent.offsetTop;
}
function dragfunc() {
	if (dodrag) {
		my = event.clientY - parenttop - 16;
		if (my < 13) my = 13;
		if (my > 254) my = 254;
		document.getElementById("scrolldrag").style.top = my;

		l1 = document.getElementById("scrolldiv");
		l2 = document.getElementById("scrollcontent");
		dif = l1.offsetHeight - l2.offsetHeight;
		pro = (my - 13) / 241;
		l2.style.top = Math.floor(pro * dif);
	}
}

function mwheel() {
	d = event.wheelDelta;
	if (d == -120 || d == 120) {
		canscroll = true;
		largescroll(d / 12);
	}
}

function printscroll(basedir) {
	html = document.getElementById("scrollcontent").innerHTML;
	window.open("/print.php?basedir=" + basedir, "print", "width=600,height=400,scrollbars=yes");
}

onresize = new Function("document.location.reload()");
document.onmousemove = dragfunc;
document.onmouseup = new Function("dodrag=false");
document.write('<SCR' + 'IPT SRC="http://stats.spiritus.be/stat.js" LANGUAGE="javascript"></SC' + 'RIPT>');
