
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
//
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- version date: 01/17/03 ---------------------------------------------------------

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Cross-Browser Functions

var dom = document.getElementById;
var iex = document.all;
var ns4 = document.layers;

function addEvent(event,method){
	this[event] = method;
	if(ns4) this.captureEvents(Event[event.substr(2,event.length).toUpperCase()]);
}
function removeEvent(event){
	this[event] = null;
	if(ns4) this.releaseEvents(Event[event.substr(2,event.length).toUpperCase()]);
}
function getElement(name,nest){
	nest = nest ? "document."+nest+"." : "";
	var el = dom ? document.getElementById(name) : iex ? document.all[name] : ns4 ? eval(nest+"document."+name) : false;
	el.css = ns4 ? el : el.style;
	el.hideVis = function(){el.css.visibility="hidden"};
	el.showVis = function(){el.css.visibility="visible"};
	el.changeCol = function(){el.css.color="#f0ad66"};
	el.getTop = function(){return parseInt(el.css.top) || 0};
	el.setTop = function(y){el.css.top = ns4 ? y: y+"px"};
	el.getHeight = function(){return ns4 ? el.document.height : el.offsetHeight};
	el.getClipHeight = function(){return ns4 ? el.clip.height : el.offsetHeight};
	el.addEvent = addEvent;
	el.removeEvent = removeEvent;
	return el;
}
function getMouse(e){
	return iex ? event.clientY : e.pageY;
}

document.addEvent = addEvent;
document.removeEvent = removeEvent;

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// ImageSwap Functions

function newImage(src){
	img = new Image();
	img.src = src;
	return img;
}
function imageSwap(img,obj,div){
	obj = eval(obj);
	if(document.layers && div != null){
		document.layers[div].document.images[img].src = obj.src;
	}else{
		document.images[img].src = obj.src;
	}
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Scroll Functions

var currentContent = null;
var docLoaded = false;

function initScroller(){
	scrollSpeed2 = 2; // scrolling speed
	scrollSpeed = 6; // scrolling speed

	trackHeight = 137; // Height of scrollbar track
	trackObj = getElement("track_wie"); // Reference to the scrollbar track div
	upObj = getElement("up_wie"); // Reference to the up arrow div
	downObj = getElement("down_wie"); // Reference to the down arrow div
	dragObj = getElement("drag_wie"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("contentMaskwie"); // Reference to the content mask div


	dragHeight = 22;


	trackTop = 232;
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmouseover", function(){scroll(scrollSpeed2);return false});
	upObj.addEvent("onmouseout", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmouseover", function(){scroll(-scrollSpeed2);return false});
	downObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("1");
}


function resizeDrag(){
	hoogte = contentObj.getHeight();
	schillie = 222 / hoogte;
	blok = Math.round(schillie * 137);
	dragObj.style.height = blok;
	return;
}


function currentText(aobject){
	oldObj = getElement("navbestuur");
	items = oldObj.getElementsByTagName("div");
	aantal = items.length;
	for(i = 0; i < aantal; i++) {
		items[i].className = "submenu";
		aobject.className = "huidigenaam"
	}
}
function loadContent(name){
	if(!docLoaded) return;
	if(currentContent!=null){
		contentObj.setTop(0);
		contentObj.hideVis();
	}

	currentContent = name;
	huidigObj = getElement("n" + name);
	currentText(huidigObj);
	contentObj = getElement("Content"+currentContent,"contentMaskwie");
	contentHeight = contentObj.getHeight(); // Height of the content div
	contentLength = contentHeight-contentMaskHeight; // Adjusted content height
	scrollLength = trackLength/contentLength; // Height difference between the scrollbar track and the content
	contentObj.showVis();
	dragObj.setTop(trackTop);
	if(contentHeight<=contentMaskHeight){
		trackObj.hideVis();
		upObj.hideVis();
		downObj.hideVis();
		dragObj.hideVis();
	}else{

		trackObj.showVis();
		upObj.showVis();
		downObj.showVis();
		dragObj.showVis();
	}
}
function startDrag(e){
	dragStartMouse = getMouse(e); // Holds the starting y mouse position
	dragStartOffset = dragObj.getTop(); // Holds the starting top position of the scrollbar drag
	document.addEvent("onmousemove", drag);
	document.addEvent("onmouseup", stopDrag);
	return false;
}
function stopDrag(){
	document.removeEvent("onmousemove");
	document.removeEvent("onmouseup");
}
function drag(e){
	var currentMouse = getMouse(e);
	var mouseDifference = currentMouse-dragStartMouse;
	var dragDistance = dragStartOffset+mouseDifference;
	var dragMovement = (dragDistance<trackTop) ? trackTop : (dragDistance>trackBottom) ? trackBottom : dragDistance;
	dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-trackTop)*(1/scrollLength);
	contentObj.setTop(contentMovement);
	return false;
}
function scroll(speed){
	var contentMovement = contentObj.getTop()+speed;
	var dragMovement = trackTop-Math.round(contentObj.getTop()*(trackLength/contentLength));
	if(contentMovement > 0){
		contentMovement = 0;
	}else if(contentMovement < -contentLength){
		contentMovement = -contentLength;
	}
	if(dragMovement < trackTop){
		dragMovement = trackTop;
	}else if(dragMovement > trackBottom){
		dragMovement = trackBottom;
	}
	contentObj.setTop(contentMovement);
	dragObj.setTop(dragMovement);
	scrollTimer = window.setTimeout("scroll("+speed+")",25);
}
function stopScroll(){
	if(scrollTimer){
		window.clearTimeout(scrollTimer);
		scrollTimer = null;
	}
}
function scrollJump(e){
	var currentMouse = getMouse(e);
	var dragDistance = currentMouse-(dragHeight/2);
	var dragMovement = (dragDistance<trackTop) ? trackTop : (dragDistance>trackBottom) ? trackBottom : dragDistance;
	dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-trackTop)*(1/scrollLength);
	contentObj.setTop(contentMovement);
	return false;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Utility Functions

function hideScrollbars(){
	if(document.getElementsByTagName){
		document.getElementsByTagName("body")[0].style.overflow = "hidden";
	}
}
function fixNetscape4(){
	if(ns4origWidth != window.innerWidth || ns4origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(document.layers){
	ns4origWidth = window.innerWidth;
	ns4origHeight = window.innerHeight;
	window.onresize = fixNetscape4;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||

window.onload = initScroller;

