<!--

//====================== Functions that are triggered onload are collected in the init() function:
init = function(){
	stickyFooter();
	var myClassName = document.getElementsByTagName("body")[0].className;
	if(myClassName=="parkeren" || myClassName=="werken" || myClassName=="wonen" || myClassName=="leren" || myClassName=="overige" || myClassName == "home" || myClassName == "basisfonds" || myClassName == "gebouwen" || myClassName == "terreinen"){ // 23 juni 2006 , 29 juni 2006
		rolloverBanners();
	}
	if(myClassName=="home"){
		initPreloadHome("projecten");
	}
	if(myClassName=="parkeren-regio"){
		parkingSpaces("free-parking");
		parkingSpaces("paid-parking");
	}
	if(myClassName=="project") {
		showPhotos();
	}
	submitRollovers();
}
//======================

//====================== Call functions at Onload-event:
window.onload = function() {
	init();	
}
//====================== Call functions at Onresize-event:
window.onresize = function() {
	stickyFooter();
}

//====================== this function preloads images required for rollovers
//====================== note: this is only required for the 'banner' visuals that are 
//====================== hidden by default and then displayed on rollover
function initPreloadHome(page){
	if (page == "projecten") {
		preloadImages("/nsvastgoed_sites/objects/3a2fa0d4f9562a62b812df316ebfbbcb/projecten_home_werken.jpg", 
					"/nsvastgoed_sites/objects/514f4f34c730441af62bcf74a84f6af9/projecten_home_leren.jpg", 
					"/nsvastgoed_sites/objects/c725b14cf29e3f2e43e2c947c02d0d9e/projecten_home_overige.jpg", 
					"/nsvastgoed_sites/objects/bb217c964e3b3bff5ce841df37a91875/projecten_home_wonen.jpg", 
					"/nsvastgoed_sites/objects/355273c9574c81db5e7adf62d22a825a/projecten_home_parkeren.jpg");
	}
	if (page == "overOns") {
		preloadImages("/nsvastgoed_sites/objects/dc39f64d4d247438200b9b67312b75e5/overons_home_visie.jpg", 
					"/nsvastgoed_sites/objects/bd91ba07aa559a0a580248af96d8cfe3/overons_home_organisatie.jpg", 
					"/nsvastgoed_sites/objects/d232e9587a8d0cdc9d107f27b2b9df18/overons_home_contact.jpg", 
					"/nsvastgoed_sites/objects/5374c9cb1a3216cd81e0d92d811529fd/overons_home_ns.jpg", 
					"/nsvastgoed_sites/objects/4cbbdc01207d657144140effa21c58cb/overons_home_mensen.jpg", 
					"/nsvastgoed_sites/objects/58bd2d0626e0bbf9c6f372ea472f9a4f/overons_home_vacatures.jpg");
	}
	if (page == "bezit") {
		preloadImages("/nsvastgoed_sites/objects/58e948119eebef947fbcbec04e412628/bezit_home_basisfonds.jpg", 
					"/nsvastgoed_sites/objects/bcdd36fe7afcb0e36070afb7fc2683f6/bezit_home_terreinen.jpg", 
					"/nsvastgoed_sites/objects/0c703bfdefe560ca8db548932b77eca2/bezit_home_gebouwen.jpg");
	}
}
// preload function
function preloadImages() { 
	if (document.images) {
		var imgStr = preloadImages.arguments;
		if (!document.preloadArray) document.preloadArray = new Array();
		var n = document.preloadArray.length;
		for (var i=0; i<preloadImages.arguments.length; i++) {
			document.preloadArray[n] = new Image;
			document.preloadArray[n].src = imgStr[i];
			n++;
		} 
	}
}
//======================



//====================== find input elements with the class name 'submit' and 
//====================== assign a rollover image to them
function submitRollovers() {
	this.buttons = new Array;
	// find all inputs
	var candidates = document.getElementsByTagName('input');
	for (var i=0; i<candidates.length; i++) {
		if ((candidates[i].className == 'button') || (candidates[i].id == 'site-search-submit')) {
			this.imgName = candidates[i].src;
			this.buttons[this.buttons.length] = new Button(this,candidates[i],this.imgName);
		}
	}
}
Button = function(buttons,subButton,imgName) {
	var srcRollOver = '';
  var loadArray = new Array();
  loadArray[1] =  '/cancel.gif' ;
  loadArray[2] =  '/nsvastgoed_sites/objects/c5a1a4dc6c861d092adb727656438c23/cancel_ro.gif' ;
  loadArray[3] =  '/ok.gif' ;
  loadArray[4] =  '/nsvastgoed_sites/objects/71b99a36e1719048404c0d7815323d34/ok_ro.gif' ;
  loadArray[5] =  '/send.gif' ;
  loadArray[6] =  '/nsvastgoed_sites/objects/9608a4e27ed6163ae73df132091b7411/send_ro.gif' ;
  loadArray[7] =  '/site_search_submit.gif' ;
  loadArray[8] =  '/nsvastgoed_sites/objects/96a1fa24c746b2ce4b4ac77b32b9ba01/site_search_submit_ro.gif' ;

	// alert('loadArray.length: ' + loadArray.length);
	// alert('imgName: ' + imgName	);
  for (var i=1; i < loadArray.length; i += 2) {
	// alert('i: ' + i + ' - loadArray[i]: ' + loadArray[i]	);
    if (imgName.indexOf(loadArray[i]) > -1) {
      srcRollOver = loadArray[i+1];
	    break;
    }
  } 
	// alert('srcRollOver: ' + srcRollOver	);

	this.buttons = buttons;
	this.subButton = subButton;
	this.imgName = imgName;
	this.imgNameOver = srcRollOver; // this.imgName.replace('.gif','-ro.gif')
	this.imgName.Button = this;
	this.imgNameOver.Button = this;
	this.subButton.Button = this;
	this.subButton.onmouseover = function() {
		this.Button.rollOver(true);
		return true;
	}
	this.subButton.onmouseout = function() {
		this.Button.rollOver(false);
		return true;
	}
}
// toggle rollover images
Button.prototype.rollOver = function(action) {
	if (action) {
		this.subButton.src = this.imgNameOver;
	}
	else
		{
		this.subButton.src = this.imgName;
	}
}
//====================== 

//====================== this function sets the rollover and link behaviour of banners on the homepage
function rolloverBanners() {
	this.banners = new Array;
	var startNode = document.getElementById("content-columns");
	var potentials = startNode.getElementsByTagName("div");
	// loop through all the divs inside content-columns
	for (var p=0; p<potentials.length; p++) {
		// find the divs with an id of banner-1, banner-2, etc
		// and with a classname of window
		if ((potentials[p].id.indexOf("banner") != -1) && (potentials[p].className.indexOf("window") != -1)) {
			// now we're in the right div, get the link
			this.banners[this.banners.length] = new Banner(this, potentials[p], potentials[p].getElementsByTagName("a")[0]);
		}
	}
}
// Banner object
Banner = function(banners, the_banner, the_link) {
	this.banners = banners;
	this.the_banner = the_banner;
	// get the classname of the banner
	var banner_class = this.the_banner.className;
	this.the_link = the_link;
	// get the href out of the link
	var link_href = this.the_link.getAttribute("href");
	this.the_banner.Banner = this;
	this.the_banner.onmouseover = function() {
		the_banner.className = banner_class + " over";
		return true;
	}
	this.the_banner.onmouseout = function() {
		the_banner.className = banner_class;
		return true;
	}
	this.the_banner.onclick = function() {
		// if banner is clicked, go to href in the header link
		window.location.href = link_href;
		return false;
	}
}
//======================

//====================== ShowPhotos() is the function that handles the display of 
// ===================== images in the project page's slideshow
var intervalID = null;

function showPhotos(sSrc) {
	var slider = document.getElementById("photo-slider");
	var selected_border = document.createElement("span");
	selected_border.id = "selected-slide";	
	var prev = document.getElementById("previous");
	var next = document.getElementById("next");	
	
	// Exception for IE5's different box-model:
	if(navigator.appVersion.indexOf("MSIE 5")!=-1){
		//selected_border.style.width = (slider.getElementsByTagName("img")[0].offsetWidth) + "px";
		//selected_border.style.height = (slider.getElementsByTagName("img")[0].offsetHeight) + "px";
	} else {
		//selected_border.style.width = (slider.getElementsByTagName("img")[0].offsetWidth-4) + "px";
		//selected_border.style.height = (slider.getElementsByTagName("img")[0].offsetHeight-4) + "px";
	}
	document.getElementById("photo-slider").appendChild(selected_border);
	var allThumbs = document.getElementById("photo-slider").getElementsByTagName("img");	
	// Exception for IE:
	var IECorrection = (document.all && document.getElementById) ? 3:0;
	// Exception for IE5's different box-model:
	if(navigator.appVersion.indexOf("MSIE 5")!=-1){ IECorrection += 2; }
	var sliderWidth = IECorrection; 
	for(var i=0; i<allThumbs.length; i++){
		sliderWidth += allThumbs[i].offsetWidth + 1; 
		allThumbs[i].parentNode.onclick = function(){
			document.getElementById("selected-slide").style.left = this.offsetLeft+"px";
			document.getElementById("selected-slide").style.top =  this.offsetTop+"px";
			// Exception for IE5's different box-model:
			if(navigator.appVersion.indexOf("MSIE 5")!=-1){
				//document.getElementById("selected-slide").style.width = (this.offsetWidth-1)+"px";
				//document.getElementById("selected-slide").style.height =  this.offsetHeight+"px";
			} else {
				//document.getElementById("selected-slide").style.width = (this.offsetWidth-5)+"px";
				//document.getElementById("selected-slide").style.height =  (this.offsetHeight-4)+"px";
			}
			document.getElementById("selected-slide").style.display =  "block";			
			if(sSrc && sSrc !='') {
				document.getElementById("photo-view").innerHTML = "<img src='"+sSrc+"' />";
			}
			return false;
		}
	}
	slider.style.width = sliderWidth+"px";
	
	prev.onmouseover = function () {
		intervalID = window.setInterval("moveThumbs(1)", 1);
	}
	prev.onmouseout = function () {
		window.clearInterval(intervalID);
		intervalID = null;
	}
	next.onmouseover = function () {
		document.getElementById("photo-slider").xNow = document.getElementById("photo-slider").offsetLeft;
		intervalID = window.setInterval("moveThumbs(-1)", 1);
	}
	next.onmouseout = function () {
		window.clearInterval(intervalID);
		intervalID = null;
	}
}

//======================
// ===================== moveThumbs(direction) handles the movement of the thumbnail-gallery
// ===================== for the project-page's slideshow

function moveThumbs(direction){
	var slider = document.getElementById("photo-slider");
	// Exception for IE:
	var IECorrection = (document.all && document.getElementById) ? 3:0;
	var minLeft=((-1*slider.offsetWidth) + (document.getElementById("photo-navigation").offsetWidth)+(16+IECorrection));
	// maxLeft includes an exception for Safari:
	var maxLeft=navigator.userAgent.toLowerCase().indexOf('safari') != -1?1:0;
	if(slider.offsetLeft>maxLeft){ slider.style.left="0px"; }
		if(slider.offsetLeft>minLeft && slider.offsetLeft<maxLeft){
			if(direction==-1){
				slider.xNow = slider.xNow+direction;
				slider.style.left = slider.xNow + "px";
			} else {
				slider.style.left = (slider.offsetLeft + direction) + "px";
			}
		} else if(slider.offsetLeft==minLeft && direction>0){
			slider.style.left = (slider.offsetLeft + direction) + "px";
		} else if(slider.offsetLeft==maxLeft && direction<0){
			slider.xNow = slider.xNow+direction;
			slider.style.left = slider.xNow + "px";
		} else {
			window.clearInterval(intervalID);
			intervalID = null;
		}
}

//======================


//====================== this function shows as many icons as given in the parking table
function parkingSpaces(tableNode) {
	this.parks = new Array;
	var check;
	this.amount;
	this.icons;
	var table = document.getElementById(tableNode);
	var table_contents = table.getElementsByTagName("TD");
	for (var t=0; t<table_contents.length; t++) {
		if (table_contents[t].className == "amount") {
			this.amount = table_contents[t];
		}
		if (table_contents[t].className == "icons") {
			this.icons = table_contents[t];
			check = t;
		}
		if (check == t) {
			this.parks[this.parks.length] = new Park(this, this.amount, this.icons);
		}
	}
}
Park = function (parkingSpaces, amount, icons) {
	this.parkingSpaces = parkingSpaces;
	this.amount = amount;
	this.icons = icons;
	this.createIcons();
}
Park.prototype.createIcons = function () {
	this.total = this.amount.innerHTML;
	for (var i=0; i<this.total; i++) {
		icon_span = document.createElement("SPAN");
		icon_span.setAttribute("className", "icon"); // for ie
		icon_span.setAttribute("class", "icon"); // for nice browsers
		this.icons.appendChild(icon_span);
	}
}

//====================== Calculate screenHeight
	function winHeight() {
		var thisHeight = 0;
		if( typeof( window.innerHeight ) == 'number' ) {
			//Non-IE
			thisHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			thisHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			thisHeight = document.body.clientHeight;
		}
		return thisHeight;
	}
//======================

//====================== stickyfooter() handles the placement of the footer to the bottom of 
//====================== the page on content-pages
function stickyFooter(){
	if(document.getElementById("page-footer")){
		if(document.getElementsByTagName("body")[0].className == "home" || (document.getElementById("projecten") && (document.getElementById("projecten").className=="werken" || document.getElementById("projecten").className=="parkeren" || document.getElementById("projecten").className=="project"))){
			//
		} else {
			document.getElementById("page-footer").style.marginTop = "0px";
			var headerHeight = document.getElementById("page-header").offsetHeight;
			var navigationHeight = document.getElementById("site-navigation").offsetHeight;
			var contentHeight = document.getElementById("page-content").offsetHeight;
			var footerHeight = document.getElementById("page-footer").offsetHeight;
			var windowHeight = winHeight();
			var totalHeight = headerHeight+navigationHeight+contentHeight+footerHeight;
			if(totalHeight<windowHeight){
				document.getElementById("page-footer").style.marginTop = (windowHeight-totalHeight) + "px";
			}
		}
	}
}
//======================
//-->