<!--
/* set initial values here */
// set up nav right routine
var itp = -44			// initial top position 
// var ftp = 50			// final top position
var ftp = 30			// gewijzigd door hoang (wens van klant)
var bn = "block"			// base name
var bi = 1				// iterator
var br				// block ref
var ttp = itp			// temp top pos
var st				// timeout
var done				// flag to see if routine is done
var navStep = 10
var navSpeed = 0
var nrOfBlocks = 0

// set up scroll
var step = 10		// scroll step
var speed = document.all?50:20		// scroll speed
var topPos			// content top
var minPos			// max scroll up
var maxPos = 0		// max scroll down
var sign			// up or down
var to			// timeout

// nav right arrays of "out" images (over images in separate file, see (fr/en/nl/) blocks.js)
var blocksOut = new Array()

blocksOut[1] = new Image(43,44)
blocksOut[1].src = "images/shared/blocks/chateau_f2.gif"
blocksOut[2] = new Image(43,44)
blocksOut[2].src = "images/shared/blocks/wijnen_f2.gif"
blocksOut[3] = new Image(43,44)
blocksOut[3].src = "images/shared/blocks/wijngebied_f2.gif"
blocksOut[4] = new Image(43,44)
blocksOut[4].src = "images/shared/blocks/druif_f2.gif"
blocksOut[5] = new Image(43,44)
blocksOut[5].src = "images/shared/blocks/streek_f2.gif"

// reference to content layer
var ref = document.all?document.all:document

// variables for keeping a reference to the visited pages. to emulate browsers back button.
var vp = new Array()	// visited pages
vp[0] = "3.php"	// start page
var vpi = 0			// iterator
var vpi2 = 0		// iterator 2

// variables that hold name/value pairs from forms
var nameValuePairs = new Array()	// will hold any number of form values
var nvpi = 0				// nameValuePairs iterator

// flags first page visited, second page visited
var firstTime
var secondTime

/* functions */

// functions for nav right animation ******************************************************

function setRoutine(nr){
	clearTimeout(st)
	// ftp = 50
	ftp = 30 // gewijzig door hoang (wens van klant)
	bi = 1
	ttp = itp
	done = true
	nrOfBlocks = nr
	doRoutine()	// start right nav animation. 
}

function doRoutine() {
	if ((document.all && document.all['block1'] != null) || (document.layers && document.content.document.layers['block1'] != null)){
		if (ttp == itp){		// starting with new block
			br = bn + bi	// construct name of block to move
			document.all?document.all[br].style.visibility = "visible":document.content.document.layers[br].visibility = "show"
		}
		if (ttp < ftp){		// if temp top pos < final top pos: move down
			document.all?document.all[br].style.top = ttp:document.content.document.layers[br].top = ttp
			ttp+=navStep
			st = setTimeout("doRoutine()", navSpeed)
		} else if (bi < nrOfBlocks) {
			// set variables for next block
			var theImg = "navr" + bi
			var theLayer = "block" + bi
			theImg = document.all?document.images[theImg]:document.content.document.layers[theLayer].document.images[theImg]
			theImg.src = blocksOut[bi].src
			ttp=itp
			bi++
			ftp+= 60	// hard coded. horizontal distance between (top of) blocks will be 60.
			st = setTimeout("doRoutine()", navSpeed)
		} else {
			// change block picture
			var theImg = "navr" + bi
			var theLayer = "block" + bi
			theImg = document.all?document.images[theImg]:document.content.document.layers[theLayer].document.images[theImg]
			theImg.src = blocksOut[bi].src
		}
	}
}


// scroll functions ******************************************************

function setScroll(){
	var pch // page content height
	topPos = 0
	if (document.layers){
		pch = document.content.document.layers.pagecontent.clip.height
		minPos = (pch * -1) + ch
	} else {
		pch = document.all.pagecontent.offsetHeight
		minPos = (pch * -1) + parent.ch
	}

}

function genScroll(dir){	// triggered by mouseOver (arrow)

	if(dir)
		sign = dir;

	topPos-= (step * sign)

	if (topPos >= minPos - step && topPos <= maxPos){

		if (document.all)
			pagecontent.style.pixelTop=topPos;
		else
			layers.pagecontent.top = topPos;
		
		to = setTimeout("genScroll()",speed);
	
	} else 
		clearTimeout(to);
}

function stopScroll(){	// triggered by mouseOut
	clearTimeout(to)
}


// control (called onLoad)

function init(pageID, nr){
	// set up scroll functions
	setScroll()
	// set up right nav animation
	if (pageID)
		setRoutine(nr)
}

// functions for loading content into "content" iframe/layer *************************

function changeContent(page){
	if (page != "#"){
		vp[++vpi] = page;
		if(secondTime){	// not on first page: language selection off
			hideLangBox();
			secondTime = false
		}
		ref.content.src=page;
	}
}

function Page(url){	// this function is only used once... (onLoad first page)
	if (document.layers)
	changeContent(url)
}


// history back: ******************************************************


function pageBack(){
		if (vpi>1)				
			ref.content.src = vp[--vpi]
}

/* change content passing form variables */
// collect variables
function collect(thisName, thisValue){
	nameValuePairs[++nvpi] = thisName
	nameValuePairs[++nvpi] = thisValue
}
// ** test

function collectHidden(thisForm){
	var i=1
	while(thisForm.elements[i].type == "hidden"){
		collect(thisForm.elements[i].name, thisForm.elements[i].value)
		i++
	}
}
	
// ** eind test

// construct url + query
function process(thisForm){
	var us = thisForm.url.value + "?"
	if(thisForm.ID)
		us+="ID=" + thisForm.ID.value + "&";
	// collectHidden(thisForm) (not used because of netscape bug)
	for(i=1;i<nvpi;i+=2){
		us+=nameValuePairs[i] + "=" + escape(nameValuePairs[i+1]) + "&"
	}

	us = us.substring(0,us.length-1)
	changeContent(us)

	nvpi = 0
	return false 	// stop form from submitting
}



/* ****************************** test zone ************************ */

function process_test(thisForm){
	alert(thisForm.elements.length)
}


var color = '';

function over(id) {
    if (document.layers) {
        color = document.content.document.layers.select.document.layers[id].bgColor;
        document.content.document.layers.select.document.layers[id].bgColor = '#000000';
    }
    else if (document.all) {
        color = document.content.document.all[id].style.background;
        document.content.document.all[id].style.background = '#000000';
        document.content.document.all[id].style.cursor = 'hand';
    }
}

function out(id) {
    if (document.layers)
        document.content.document.layers.select.document.layers[id].bgColor = color;
    else if (document.all)
        document.content.document.all[id].style.background = color;
}

// call from page/t 1/3:
function setLangBox(){
	if(firstTime){
		if (document.layers) {
			LBheight = document.content.document.layers.select.clip.height;
			document.content.document.layers.select.top = ch - LBheight;
			document.layers.langs.visibility = "show"
		}
		else if (document.all) {
			LBheight = document.content.document.all.select.offsetHeight;
			document.content.document.all.select.style.top = ch - LBheight
			document.all.langs.style.visibility = "visible"
		}
		firstTime = false
		secondTime = true
	}
}

function showLangBox(){
	if (document.layers) {
		document.content.document.layers.select.visibility = "show"
	}
	else if (document.all) {
		document.content.document.all.select.style.visibility = "visible"
	}
}

function hideLangBox(){
	if (document.layers) {
		document.layers.langs.visibility = "hide"
	}
	else if (document.all) {
		document.all.langs.style.visibility = "hidden"
	}
}

// function checkCollection(){
// 	if (nvpi > 0){
// 		for (){
// 
// 		}
// 	}
// }

function checkCollection_v1(){
	for(i=0;i<nvpi-1;i++){
		for(j=i+1;j<nvpi;j++){
			if (nameValuePairs[i]==nameValuePairs[j]){
				nameValuePairs[i]= ""
			}
		}
	}
}



// just for testing correct passing of variables
// used in test page (page1_select.htm)
function showLocation(){
	if (document.layers)
		ref.content.document.layers.pagecontent.document.form5.loc.value=ref.content.src
	else
		parent.content.document.form5.loc.value=ref.content.src
}

// resize fix? doesn't seem to work for NN
function startAgain(page, baseloc){
	lePage = page
	var base
	if(baseloc)
		base = (baseloc.indexOf("?page=")>0)? baseloc.substring(0, baseloc.indexOf("?")):baseloc;
	else
		base = "base.htm";

	setTimeout('location.href="' + base + '?page=" + lePage', 1000); // pause before reload
}


function checkHistory(template){
	if(template == 't1.php' || template == 't3.php') {
		firstTime = true;
		secondTime = false;
	}
	else {
		firstTime = false;
		secondTime = true;
	}
		
	a = location.href.indexOf('page=')

	if(a>0){
		b = location.href.length
		contentURL = location.href.substring(a+5,b)
		// alert(contentURL);
		changeContent(contentURL)
	}else {					// first content load
		// contentURL = "t3.php"
		contentURL = template;
		changeContent(contentURL)
		// firstTime = true
	}
}
// nav right mouseOvers
function changePics(nr, action){
	if (done){
		var theImg = "navr" + nr
		var theLayer = "block" + nr
		theImg = document.all?document.images[theImg]:document.content.document.layers[theLayer].document.images[theImg]
		if (action == "over"){
			theImg.src = blocksOver[nr].src
		} else if (action == "out"){
			theImg.src = blocksOut[nr].src
		}
	}
}
// -->
