/*
	Created by disjfa.
*/
	var slide;
	var from = 10;
	var speed = 0, maxSpeed = 100;
	var to = false, bet = false, mb = false, side;
	var who = 0;
	var tmpSpeed = false;
	var moveSpeed = 1;
	var stopSpeed = 2;
	var goUrl = false;
	var thisDoesNotWork = false;
	var side = false;
	var firstScroll = false;
	var timeList = false, slide = false;
	function doMoveHome(wich) {
		for(i = 0 ; i < imgs.length ; i++) {
			document.getElementById("image_" + i).style.display = "none";
		}

		if(!thisDoesNotWork) {
		}
		mb = document.getElementById("mb");
		
		tmp = document.getElementById("m_" + who);
		tmpList = tmp.getElementsByTagName("ul");
		if(tmpList.length > 0) {
			tmpList[0].style.display = "none";
		}
		who = wich;
		mb.style.display ="block";
		
		clearInterval(slide);
		if(mb) {
			to = 0 + (wich * 100);
			side = to > from ? "R" : "L";
			slide = setInterval("doScroll()", 1);
		}
	}

	
	function doMove(wich, tUrl) {
		
		if(who == wich) {
			document.location.replace(tUrl);
			return;
		}
		
		goUrl = tUrl;
		for(i = 0 ; i < imgs.length ; i++) {
			document.getElementById("image_" + i).style.display = "none";
		}
		
		if(!thisDoesNotWork) {
			document.getElementById("over_inhoud").style.display = "none";
			document.getElementById("updown").style.display = "none";
		}
		
		tmp = document.getElementById("m_" + who);
		tmpList = tmp.getElementsByTagName("ul");
		if(tmpList.length > 0) {
			tmpList[0].style.display = "none";
		}
		who = wich;
		clearInterval(slide);
		if(mb) {
			to = 0 + (wich * 100);
			side = to > from ? "R" : "L";
			slide = setInterval("doScroll()", 1);
		}
	}
	
	function doScroll() {
		if(side == "R") {
			from = from + speed;
			speed = (speed + moveSpeed) >= maxSpeed  ? maxSpeed : speed + moveSpeed;
			mb.style.marginLeft = from + "px";
			if(from >= to) {
				speed = Math.ceil(speed/3);
				if(speed <= stopSpeed || speed == -tmpSpeed) {
					clear();
				}
				tmpSpeed = speed;
				side = "L";
			}
		} else {
			from = from + speed;
			speed = (speed - moveSpeed) <= -maxSpeed  ? -maxSpeed : speed - moveSpeed;
			mb.style.marginLeft = from + "px";
			
			if(from <= to) {
				speed = Math.floor(speed/3);
				if(speed >= -stopSpeed || speed == -tmpSpeed) {
					clear();
				}
				tmpSpeed = speed;
				side = "R";
			}
		}
	}
	
	function clear() {
		if(to) {
			mb.style.marginLeft = to;
		}
		clearInterval(slide);
		speed = 0;
		tmpSpeed = false;
		
		tmp = document.getElementById("m_" + who);
		tmpList = tmp.getElementsByTagName("ul");
		if(tmpList.length > 0) {
			hideList(tmpList[0]);
			tmpList[0].style.display = "block";
		}
	}
	
	var listCount;
	var theList;
	function hideList(obj) {
		theList = obj.getElementsByTagName("LI");
		listCount = theList.length;
		if(listCount > 0) {
			for(i=0 ; i < listCount ; i++) {
				theList[i].style.visibility = "hidden"; 
			}
			timeList = setInterval("showList()", 100);
		}
	}
	
	function showList() {
		if(listCount > 0) {
			listCount = listCount - 1;
			theList[listCount].style.visibility = "visible";
		} else {
			clearInterval(timeList);
			if(goUrl != '') {
				document.location.replace(goUrl);
			} else {
				
      	tlogo = document.getElementById("logo");
  			tlogo.style.display = "block";
  		
			}
		}
	}

	var timeDown = false;
	function up() {
		clearInterval(timeDown);
		timeDown = setInterval("doDown(-1)", 5);
	}
	function down() {
		clearInterval(timeDown);
		timeDown = setInterval("doDown(1)", 5);
	}

	var mouseX, mouseY, dSpeed = 1;
	document.onmousemove = function(e){ 
	  if(!e){ 
	    mouseX = event.x;
	    mouseY = event.y;
	  }else{ 
	    mouseX = e.pageX;
	    mouseY = e.pageY;
	  }
	}	
	document.onmouseup = function(){ 
		clearInterval(timeDown);
	}
	
	function doDown(where) {
		if(where > 0) {
			dSpeed = Math.ceil((mouseY - 253) / 30);
		} else {
			dSpeed = Math.ceil((253 - mouseY) / 30);
		}
		
		inhoud.scrollTop += (where * dSpeed);
		if(imgDown.down != false && (inhoud.scrollHeight - inhoud.scrollTop - inhoudHeight) < 0) {
			imgDown.src = "/gfx/down.gif";
			imgDown.down = false;
		} else if (imgDown.down != true && (inhoud.scrollHeight - inhoud.scrollTop - inhoudHeight) > 0) {
			imgDown.src = "/gfx/downb.gif";
			imgDown.down = true;
		}
		if(inhoud.scrollTop <= 0) {
			imgUp.src = "/gfx/up.gif";
		} else {
			imgUp.src = "/gfx/upb.gif";
		}
	}
	var imgUp = false, imgDown = down, inhoud = false;
	var inhoudHeight = 350;
	
	window.onload = function() {

		mb = document.getElementById("mb");
		deb = document.getElementById("debug");
		
		if(firstScroll) {
			doScroll();
		}

		if(undefined == document.getElementById("inhoud") ) {
			thisDoesNotWork = true;
			return;
		}
		
		imgUp = document.getElementById("imgUp");
		imgDown = document.getElementById("imgDown");
		inhoud = document.getElementById("inhoud");
		
		if(inhoud.scrollHeight > inhoudHeight) {
			imgDown.src = "/gfx/downb.gif";
			imgDown.down = true;
		} else {
			document.getElementById("updown").style.display = "none";
			imgDown.down = false;
		}
		
	}

var deb;
function debug(what) {
	//deb.innerHTML = what;
	deb.innerHTML = what;
}

function wopen(wurl) {
	aa = "a_" + get_random();
	window.open(wurl, aa, "toolbar=no , location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=640, height=480");
	return false;
}
function get_random() {
	var ranNum= Math.floor(Math.random()*500);
	return ranNum;
}
function doSearch(who, onoff) {
	if(onoff) {
		who.style.backgroundImage = "url(/gfx/logindown.gif)";

		with(document.getElementById("ss").style) {
			lineHeight = "22px";
			paddingRight = "4px";
		}

	} else {
		who.style.backgroundImage = "";
		with(document.getElementById("ss").style) {
			lineHeight = "24px";
			paddingRight = "0px";
		}
		
	}
	
}

