
	function barnworksInitPlattegrond() {
		var activeImage = false;
		$$('.ce_text.plattegrond').each(function(element, index) {
			var imgSmall = element.getElement('img');
			var divLarge = new Element('div', {
				'class': 'large-image',
			});
			var imgLarge = new Element('img', {
				'src': imgSmall.get('src').replace('-small', '-large'),
				'style': ''
			});
			imgLarge.inject(divLarge);
			divLarge.fade('hide');
			divLarge.inject($('page2'));
			
			imgSmall.addEvent('click', function(event) {
				if (activeImage) {
					//activeImage.setStyle('display', 'none');
					activeImage.fade('out');
				}
				activeImage = divLarge; //.setStyle('display', 'block');
				activeImage.fade('in');
				event.stop();
			});
			/*imgSmall.addEvent('mouseout', function() {
				imgLarge.setStyle('display', 'none');
			});*/
		});
		
		$$('body').addEvent('click', function() {
			if (activeImage) {
				activeImage.fade('out');
			}
		});
	}

	/*function barnworksInitActiveMenu() {
		$$('ul.nav').each(function(element, index) {
			var parent = element.getParent();
			var img = new Element('img', {
				'src': 'tl_files/beleggenaanhetwater-theme/active.png',
				'alt': '',
				'class': 'active-image'
			});
			img.inject(parent.getParent().getParent());
		});
	}*/

	function barnworksInitFooterHeight () {
		var footer = $('page4');
		var minHeight = footer.getSize();
		
		function setWindowHeight() {
			var winSize = $(window).getSize();
			if (winSize.y > minHeight.y) {
				footer.setStyle('height', winSize.y+'px');
			}
		}
		
		window.addEvent('resize',setWindowHeight); 		
		setWindowHeight();
	}
	
	function barnworksInitPage1Height () {
		var home = $('page1');
		var minHeight = home.getSize();
		
		function setWindowHeight() {
			var winSize = $(window).getSize();
			if (winSize.y > minHeight.y) {
				home.setStyle('height', winSize.y+'px');
			}
		}
		
		window.addEvent('resize',setWindowHeight); 		
		setWindowHeight();
	}
	
	function barnworksInitPage3Height () {
		var home = $('page3');
		var minHeight = home.getSize();
		
		function setWindowHeight() {
			var winSize = $(window).getSize();
			if (winSize.y > minHeight.y) {
				home.setStyle('height', winSize.y+'px');
			}
		}
		
		window.addEvent('resize',setWindowHeight); 		
		setWindowHeight();
	}
	
	function barnworksInitPageScroller() {
		var scrollFx = new Fx.Scroll(window);
		$$('ul.nav li a, div.ce_hyperlink.more-info a').each(function(a, index) {
			var href = a.get('href');
			if (href.indexOf('#') != -1) {
				var id = href.substr(href.indexOf('#')+1);
				a.addEvent('click', function() {
					scrollFx.toElement(id, 'y');
					return false;
				});
			}
		});
	}

	var mooPlaceholder = new Class({
		// behaviour for default values of inputs class
		Implements: [Options],

		options: {
			// default options
			htmlPlaceholder: "placeholder", // the element attribute, eg, data-placeholder="MM/YY" -> "data-placeholder"
			unmoddedClass: "unchanged", // apply a class to the unmodded input, say, to grey it out
			parentNode: document, // limit to a particular set of child nodes
			defaultSelector: "input[placeholder]"
		},

		initialize: function(options) {
			this.setOptions(options);
			this.nativeSupport = 'placeholder' in document.createElement('input');
			$$('label').each(function(label, index) {
				var id = label.get('for');
				if (id) {
					var el = $(id);
					if (el.get('type') == 'text') {
						var placeholder = el.get(this.options.htmlPlaceholder);
						if (!placeholder || !placeholder.length) {
							label.getElements('.invisible').each(function(child, index) {
								child.dispose();
							});
							
							el.set(this.options.htmlPlaceholder, label.get('text'));
							label.setStyle('display', 'none');
						}
					}
				}
			}, this);
		},

		attachToElements: function(selector) {		
			// basic function example that uses a class selector to
			var inputs = this.options.parentNode.getElements(selector || this.options.defaultSelector);

			if (inputs.length) {
				inputs.each(function(el) {
					this.attachEvents(el);
				}, this);
			}
		}, // end attachToElements

		attachEvents: function(el, placeholder) {
			// method that attaches the events to an input element.
			var placeholder = placeholder || el.get(this.options.htmlPlaceholder);
			if (this.nativeSupport || !$(el) || !placeholder || !placeholder.length)
				return;

			el.set("value", placeholder).store("placeholder", placeholder);

			// append unmodded class to input at start
			if (this.options.unmoddedClass)
				el.addClass(this.options.unmoddedClass);

			// now cater for the events
			el.addEvents({
				change: function() {
					// when value changes
					var value = el.get("value").trim(), placeholder = el.retrieve("placeholder");
					if (value != placeholder) {
						// once it changes, remove this check and remove the unmoddedClass
						el.removeClass(this.options.unmoddedClass).removeEvents("change");
					}
				}.bind(this),

				focus: function() {
					var value = el.get("value").trim(), placeholder = el.retrieve("placeholder");
					if (value == placeholder) {
						el.set("value", "").removeClass(this.options.unmoddedClass);
					}
				}.bind(this),
				blur: function() {
					var value = el.get("value").trim(), placeholder = el.retrieve("placeholder");
					if (value == placeholder || value == "") {
						el.set("value", placeholder).addClass(this.options.unmoddedClass);
					}
				}.bind(this)
			});
		}

	});

window.addEvent('domready', function(){
	new mooPlaceholder().attachToElements();
	//barnworksInitActiveMenu();
	barnworksInitFooterHeight();
	//barnworksInitPage1Height();
	//barnworksInitPage3Height();
	barnworksInitPageScroller();
	barnworksInitPlattegrond();
});
