
	// get all variables from URL query
	if (location.search)
	{
		arrayOfSearchAttributes = location.search.substr(1, location.search.length).split('&');
		for (i = 0; i < arrayOfSearchAttributes.length; i++)
		{
			parts = arrayOfSearchAttributes[i].split('=');
			if (parts[0] != undefined && parts[1] != undefined)
			{
				eval(parts[0] + "='" + parts[1] + "'");
			}
		}
	}


	// on dom ready
	Window.onDomReady(function()
	{

		// load page on request
		if (window["page"])
		{
			$$('div.page').each(function(div, i){
				if (page == div.id)
				{
					switchContent(div.id);
				}
			});
		}

		// fetch overlibTexts and put on overlib link for the onmouseover overlib event to be able to pick it up
		// set onmouseover and onmouseout events
		$$('div.overlibText').each(function(overlibText, i){
			overlibText.style.display = 'none';
			overlibText.getPrevious().overlibText = overlibText.innerHTML;
			overlibText.getPrevious().onmouseover = portfolioItemHover;
			overlibText.getPrevious().onmouseout = portfolioItemQuench;
			overlibText.getParent().getPrevious().getElementsByTagName('img')[0].onmouseover = portfolioItemHover;
			overlibText.getParent().getPrevious().getElementsByTagName('img')[0].onmouseout = portfolioItemQuench;
		});

	});

	// instanciate, configure and start the slideshow
	slideshow = new IXF();
	slideshow.sources =
	[
		"images/headerSlideReal.jpg",
		"images/headerSlideCustomProgramming.jpg",
		"images/headerSlideInternetSolutions.jpg",
		"images/headerSlideInternetTechnology.jpg"
	];
	slideshow.intervalSeconds = 5;
	slideshow.scrambleSequence();
	slideshow.cacheImages();
	slideshow.loadFirst(true);


	var externalLinkClassName = "externalLink";

	var old = (window.onload) ? window.onload : function () {};
	window.onload = function(){old(); addTargets();}

	// TODO: convert to ajax and initialize menu onload and meanwhile set a wait cursor on menu.

	// page navigation
	var identifier = "intro";
	function switchContent(identifier)
	{
		// not changing when the page is already visible and ensuring that the HTML is loaded (requested page is found)
		if (identifier != this.identifier && document.getElementById(this.identifier))
		{
			// switching content
			document.getElementById(identifier).style.display = "block";
			document.getElementById(identifier + "MenuItem").style.textDecoration = "underline";
			document.getElementById(this.identifier).style.display = "none";
			document.getElementById(this.identifier + "MenuItem").style.textDecoration = "none";

			// core cap
			document.getElementById("coreCap").style.display = (identifier == "productenEnDiensten" ? "none" : "block");

			// right header
			document.getElementById("headerSpiralRight").style.display = (identifier == "contact" ? "block" : "none");
			document.getElementById("slideImageContainer").style.display = (identifier == "contact" ? "none" : "block");

			// slideshow
			if (identifier == "contact")
			{
				slideshow.pause();
				slideshow.hide();
			}
			if (this.identifier == "contact")
			{
				slideshow.show();
				slideshow.play();
			}

			// moving absolute positioned elements depending on "anchors"
			allDivs = document.getElementsByTagName("div");
			for (i = 0; i < allDivs.length; i++)
			{
				if (allDivs[i].id == "anchor")
				{
					allDivs[i].style.position = "static";
					allDivs[i].style.position = "absolute";
				}
			}

			this.identifier = identifier;
		}
	}


	// add target attribute to external links
	function addTargets()
	{
		allLinks = document.getElementsByTagName("a");
		for (i = 0; i < allLinks.length; i++)
		{
			if (allLinks[i].className.indexOf(this.externalLinkClassName) != -1)
			{
				allLinks[i].setAttribute("target", "_blank");
			}
		}
	}


	// get computed style property of an element
	// cssProperty is the javascript property notation (e.g. "backgroundColor") and mozillaEquivalentCSS is the CSS notation (e.g. "background-color")
    function computedStyle(htmlElement, cssProperty, mozillaEquivalentCSS) {
        if (arguments.length == 2) {
            mozillaEquivalentCSS = cssProperty;
        }   
        if (htmlElement.currentStyle) {
            return htmlElement.currentStyle[cssProperty];
        }
        if (typeof(document.defaultView) == 'undefined') {
            return undefined;
        }
        if (document.defaultView === null) {
            return undefined;
        }
        var style = document.defaultView.getComputedStyle(htmlElement, null);
        if (typeof(style) == "undefined" || style === null) {
            return undefined;
        }
        return style.getPropertyValue(mozillaEquivalentCSS);
    }


	// change fontsize of a certain area
	function changeAreaFontSize(area, value)
	{
		computedFontSize = computedStyle(area, 'fontSize', 'font-size');
		area.style.fontSize = computedFontSize.replace(/\d+/g, parseInt(computedFontSize.replace(/\D+/g, '')) + value);
		// and all tables
		allTables = area.getElementsByTagName('table');
		for (var i = 0; table = allTables[i]; i++)
		{
			computedFontSize = computedStyle(table, 'fontSize', 'font-size');
			table.style.fontSize = computedFontSize.replace(/\d+/g, parseInt(computedFontSize.replace(/\D+/g, '')) + value);
		}
	}


	// returns the abbreviated version of a string
	// 'length' specifying the max length of the abbreviation including the traling '...'
	String.prototype.abbreviate = function (length)
	{
		if (this.length > length)
		{
			return this.substr(0, length - 3) + "...";
		}
		return this;
	}


	// mouseover events
	function hover(id)
	{
		switch (id)
		{
			case "ISaulmadeCMSAndCMSEditorEventArea":
				document.getElementById('ICMSEditor').src = 'images/ICMSEditorColor.gif';
				document.getElementById('ITitleSaulmadeCMSAndCMSEditor').src = 'images/ITitleSaulmadeCMS+CMSEditorColor.gif';
				break;
			case "ICMSBackboneEventArea":
				document.getElementById('ITitleCMSBackbone').src = 'images/ITitleCMSBackboneColor.gif';
				break;
			case "IPLECEventArea":
				document.getElementById('ITitlePLEC').src = 'images/ITitlePLECColor.gif';
				break;
		}
	}

	// mouseout events
	function quench(id)
	{
		switch (id)
		{
			case "ISaulmadeCMSAndCMSEditorEventArea":
				document.getElementById('ICMSEditor').src = 'images/ICMSEditor.gif';
				document.getElementById('ITitleSaulmadeCMSAndCMSEditor').src = 'images/ITitleSaulmadeCMS+CMSEditor.gif';
				break;
			case "ICMSBackboneEventArea":
				document.getElementById('ITitleCMSBackbone').src = 'images/ITitleCMSBackbone.gif';
				break;
			case "IPLECEventArea":
				document.getElementById('ITitlePLEC').src = 'images/ITitlePLEC.gif';
				break;
		}
	}


	// show all portfolio texts
	function showPortfolioTexts()
	{
		$$('div.overlibText').each(function(overlibText, i){
			overlibText.style.display = 'block';
		});
		$('portfolioTextsToggler').innerHTML = 'Klik <a href="#" onclick="hidePortfolioTexts(); return false;" class="link">hier</a> om de teksten te verbergen';
	}


	// show all portfolio texts
	function hidePortfolioTexts()
	{
		$$('div.overlibText').each(function(overlibText, i){
			overlibText.style.display = 'none';
		});
		$('portfolioTextsToggler').innerHTML = 'Ga met de muis over de links om de bijbehorende uitleg te zien, of klik <a href="#" onclick="showPortfolioTexts(); return false;" class="link">hier</a> om alle teksten zichtbaar te maken.';
	}


	// portfolioItem mouseover event
	function portfolioItemHover()
	{
		var image;

		if (this.tagName.toLowerCase() == 'img') image = this;
		else image = this.getParent().getPrevious().getElementsByTagName('img')[0];

		image.src = image.src.replace(/\.[^\.]*$/, '') + 'Color' + image.src.match(/\.[^\.]*$/);

		if (this.tagName.toLowerCase() == 'a' && this.getNext().style.display == 'none') return overlib(this.overlibText);
	}


	// portfolioItem mouseout event
	function portfolioItemQuench()
	{
		var image;

		if (this.tagName.toLowerCase() == 'img') image = this;
		else image = this.getParent().getPrevious().getElementsByTagName('img')[0];

		image.src = image.src.replace(/Color(\.[^\.]*)$/, '$1');

		if (this.tagName.toLowerCase() == 'a' && this.getNext().style.display == 'none') return nd();
	}

