

	// this file is called not in the head, but just below the home element so have the intro and home elements available in the DOM because flickering accured when setting the right one of the two elements visible ondomready or when polling for the elements periodically every 10 miliseconds untill they were found...


	var introDisplayTime = 3000; // time to display the intropage, in miliseconds
	var introFadeTime = 600; // timespan of the fade effect (in and out), in miliseconds
	var introHeightIncreaseTime = 400; // timespan of the time height increase effect, in miliseconds


	// on dom ready
	window.addEvent('domready', function(){

		// show intro or not?
		if (!unescape(location.search).match(/(\?|&)noIntro(&|$)/))
		{
			$('intro').setStyle('display', 'block');
			$('home').setStyle('display', 'none');
		}
		else
		{
			$('intro').setStyle('display', 'none');
			$('home').setStyle('display', 'block');
		}

		// make external links open in new window
		$$('a.externalLink').each(function(externalLink) {
			externalLink.target = '_blank';
		});

		// initializing block click events
		var block, blocks = $$('#blocks a'), textBlocks = $$('#textBlock div');
		for (var i = 0; block = blocks[i]; i++)
		{
			block.onmouseover = (function(block, index, blocks, textBlocks){
				return function(){
//					$('logoHome').style.display = 'none';
					for (var i = 0; i < textBlocks.length; i++)
					{
						textBlocks[i].setStyle('display', 'none');
					}
					for (var i = 0; i < blocks.length; i++)
					{
						if (i != index && blocks[i].getElement('span').getStyle('background-image').indexOf('Hover.png') != -1)
						{
							blocks[i].getElement('span').setStyle('background-image', 'url(images/blockTitleBackground.png)');
						}
					}
					$('text' + block.getElement('img').alt).style.display = 'block';
					if (block.getElement('span').getStyle('background-image').indexOf('Hover.png') == -1)
					{
						block.getElement('span').setStyle('background-image', 'url(images/blockTitleBackgroundHover.png)');
					}
				};
			})(block, i, blocks, textBlocks);
			block.onclick = function(e){
				var target = (document.all ? event.srcElement : e.target);
				target = (target.tagName.toLowerCase() == 'a' ? target : $(target).getParent('a'));
				target.blur();
				if (target.href.indexOf('aankoop.php') == -1 && target.href.indexOf('verkoop.html') == -1 && target.href.indexOf('taxatie.html') == -1)
				{
					return false;
				}
			}
		}

		// initializing searchForm button mouseover and mouseout events
		var searchFormButton, searchFormButtons = $$('#searchForm .button');
		for (var i = 0; searchFormButton = searchFormButtons[i]; i++)
		{
			searchFormButton.onmouseover = function(){
				this.style.backgroundImage = 'url(images/searchFormButtonBackgroundHover.gif)';
			};
			searchFormButton.onmouseout = function(){
				this.style.backgroundImage = 'url(images/searchFormButtonBackground.gif)';
			};
		}
		$('buttonShowAll').onclick = function(){
			this.addClass('active');
			document.location = 'resultaten.php';
		}

		// show intro or not?
		if (!unescape(location.search).match(/(\?|&)noIntro(&|$)/))
		{
			new Asset.image('images/header.jpg', {onload: // after the header has fully loaded
				function(){
					return function(){
						var introFx = new Fx.Tween($('intro'), {property: 'opacity', duration: introFadeTime, transition: Fx.Transitions.Quad.easeInOut});
						introFx.start(0).chain(function(){
							var introFx = new Fx.Tween($('content'), {property: 'height', duration: introHeightIncreaseTime, transition: Fx.Transitions.Quad.easeInOut});
							introFx.start(Fx.CSS.prototype.search('#home').height.toInt()).chain(function(){ // search is an internal method, see http://svn.mootools.net/tags/1-2b1/Source/Fx/Fx.CSS.js, perhaps 1.3 brings a public one.
								var introFx = new Fx.Tween($('home'), {property: 'opacity', duration: introFadeTime, transition: Fx.Transitions.Quad.easeInOut});
								// in IE6 fading in a container with a transparent PNG as background makes the textcontent not look nice, so hiding it
								// but setting the height of the container becuse we do want that to show, even without content
								if (Browser.Engine.trident4)
								{
								}
								$('intro').setStyle('display', 'none'); // next to opacity, setting the display also to hide to let the object not take up space
								introFx.set(0); // setting opacity to 0
								$('home').setStyle('display', 'block'); // then setting display to block
								$('header').className = 'home';
								var footerLogoFx = [];
								footerLogoFx[0] = new Fx.Tween($('logoVastgoedcert'), {property: 'opacity', duration: introFadeTime, transition: Fx.Transitions.Quad.easeInOut});
								footerLogoFx[1] = new Fx.Tween($('logoFunda'), {property: 'opacity', duration: introFadeTime, transition: Fx.Transitions.Quad.easeInOut});
								footerLogoFx[2] = new Fx.Tween($('logoLMV'), {property: 'opacity', duration: introFadeTime, transition: Fx.Transitions.Quad.easeInOut});
								footerLogoFx[0].set(0); // setting opacity to 0
								footerLogoFx[1].set(0); // setting opacity to 0
								footerLogoFx[2].set(0); // setting opacity to 0
								$('logoVastgoedcert').setStyle('display', 'block'); // then setting display to block
								$('logoFunda').setStyle('display', 'block'); // then setting display to block
								$('logoLMV').setStyle('display', 'block'); // then setting display to block
								footerLogoFx[0].start(1);
								footerLogoFx[1].start(1);
								footerLogoFx[2].start(1);
								introFx.start(1);
							});
						});
					}.delay(introDisplayTime); // then when the header has loaded, wait for a while
				}
			});
		}
		else
		{
			$('logoVastgoedcert').setStyle('display', 'block');
			$('logoFunda').setStyle('display', 'block');
			$('logoLMV').setStyle('display', 'block');
		}

	});


	// onload
	window.addEvent('load', function(){

		// preloading some images
		var myImages = new Asset.images([
			'images/blockTitleBackground.png',
			'images/blockTitleBackgroundHover.png',
			'images/textBlockBackground.png',
			'images/blockTitleAankoop.gif',
			'images/blockTitleVerkoop.gif',
			'images/blockTitleTaxatie.gif',
			'images/blockTitleContact.gif',
			'images/blockImageAankoop.jpg',
			'images/blockImageVerkoop.jpg',
			'images/blockImageTaxatie.jpg',
			'images/blockImageContact.jpg',
			'images/textAankoop.gif',
			'images/textVerkoop.gif',
			'images/textTaxatie.gif',
			'images/textContact.gif',
			'images/searchFormBackground.png',
			'images/searchFormButtonBackground.gif',
			'images/searchFormButtonBackgroundHover.gif',
			'images/logoVastgoedcert.gif',
			'images/logoFunda.gif',
			'images/logoLMV.gif'
		]);

	});


