/*

	handleBodyLoad

*/

function handleBodyLoad() {

	document.body.className += ' jsOn';

	markLinks();
	initMainNav();
	pageToolbar();

	var docLang = document.getElementsByTagName('html')[0].getAttribute('lang');
	if(docLang == 'nl' || docLang == 'nl-nl' ){
		initInputFocus('qGlobal', 'Zoeken...');
	} else if(docLang == 'fr'){
		initInputFocus('qGlobal', 'Recherche...');
	} else {
		initInputFocus('qGlobal', 'Search...');
	}

	$(".photoFader").sisoFader({
		'speed': 800, 	
		'timeout': 5000
	});

//	initInputFocusByTitle();
//	initInputFocus('newsLetterServiceEmailAddress', 'E-mailadres');

	initStorelocator();
	langNavKlapper();
	initPopupByClassname();
} /*
  popups
*/
var aPopups = new Array();
var aModalPopups = new Array();

window.onfocus = function()
{
	if(aModalPopups.length != 0)
	{
		aModalPopups[0].focus();
	}
}


var sDefaultFeatures = 'channelmode=0, fullscreen=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0';

// create popup
function createPopup(sURL, sName, sFeatures, iWidth, iHeight)
{
	var iLeft	= (screen.availWidth - iWidth) / 2;
	var iTop	= (screen.availHeight - iHeight) / 2;
	
	return window.open(sURL, sName, sFeatures + ', width=' + iWidth + ', height=' + iHeight + ', left=' + iLeft + ', top=' + iTop);
}

/*
	getCookie
*/
function getCookie(sName){
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]){
			return unescape(aCrumb[1]);
		}
	}
	
	return null;
}



/*
  getElementsByClassName
*/
document.getElementsByClassName = function (needle){
    var s = [document.documentElement || document.body], i = 0, r = [], l = 0, e;
    var re = new RegExp('(^|\\s)' + needle + '(\\s|$)');

    do{
        e = s[i];

        while (e){
            if (e.nodeType == 1){
                if (e.className && re.test(e.className)) r[l++] = e;

                s[i++] = e.firstChild;
            }

            e = e.nextSibling;
        }
    }
	
    while (i--);

    return r;
}

 handleContentInnerLinks = function(){
	tabLinks = $('#productDetailsMenu a');
	
	for(var i = 0; i < tabLinks.length; i++){
		value = tabLinks[i];
		
		$(value).attr('href', $(value).attr('href') + '#productDetailsMenu' );
	}
	
	$('.template-69 #siteWrapper #area1 .contentInner a:not([href*=#]), .template-70 #siteWrapper #area1 .contentInner a:not([href*=#]), .template-69 #siteWrapper #area2 .contentInner a:not([href*=#]), .template-70 #siteWrapper #area2 .contentInner a:not([href*=#])').each(function(){this.hash='productDetailsMenu'});
} /*
  initFader
*/
  
function initFader(){

	// hide for old browsers
	if(!document.getElementById || !document.createElement || !document.getElementById('albumFader')) return;

	//var li = document.getElementById('listContainer').getElementsByTagName('a');

	window.fadeTime = 3200;

	window.anchors = new Array();
	window.current = 0;
	window.pause = false;
	window.loaded = -1;
	window.loading = true;

	// set opacity to 0 for all images, except the first image 
	anchors = document.getElementById('albumFader').getElementsByTagName('img');

	// get the rest of the images that are loaded in the listBanners pagelet
	//window.alternateImgs = document.getElementById('listContainer').getElementsByTagName('a');
	window.alternateImgs = faderImgList;
	window.totalImages = window.alternateImgs.length + anchors.length;

	anchors[0].style.display = 'block';
	anchors[0].xOpacity = .99;
	anchors[0].onload = function(){

		window.loaded = 0;
		 // if there are more images availbale fade them in
		if(window.alternateImgs.length) addImage(window.alternateImgs[0]);

		setTimeout(fadeBanners, fadeTime);
	}
}

function fadeBanners(){

	if(window.loading){
		setTimeout(fadeBanners, fadeTime);
		return;
	}

	cOpacity = anchors[current].xOpacity;
	nIndex = anchors[current+1]?current+1:0;
	nOpacity = anchors[nIndex].xOpacity;
	cOpacity -= .05;
	nOpacity += .05;

	anchors[nIndex].style.display = 'block';
	anchors[current].xOpacity = cOpacity;
	anchors[nIndex].xOpacity = nOpacity;

	setOpacity(anchors[current]); 
	setOpacity(anchors[nIndex]);

	if(cOpacity<=0){
		anchors[current].style.display = 'none';
		current = nIndex;

		if(window.alternateImgs.length > window.loaded){
			window.loading=true;
			addImage(window.alternateImgs[window.loaded]);
		}

		setTimeout(fadeBanners,fadeTime);
	}else{
		setTimeout(fadeBanners,50);
	}

	function setOpacity(obj){
		if(obj.xOpacity>.99){
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}

function addImage(imgSrc){

	var newImage = document.createElement('img');
	newImage.src = imgSrc;
	newImage.xOpacity = 0;

	document.getElementById('albumFader').appendChild(newImage);
	newImage.style.display = 'none';

	newImage.onload = function(){
		window.loading = false;
		window.anchors = document.getElementById('albumFader').getElementsByTagName('img');
	}

	window.loaded++;
}

 /*
initInputFocus
*/
function initInputFocus(elemId, elemValue){
	if(!document.getElementById(elemId)) return false;
	var elem = document.getElementById(elemId);
	
	elem.value = elemValue;

	elem.onfocus = function(){
		if(this.value == elemValue){
			this.value = '';
		}
		this.select();
	}
	
	elem.onblur = function(){
		if(this.value == ''){
			this.value = elemValue;
		}
	}

	//hide label
	if(elem.parentNode.getElementsByTagName('span').length){
		elem.parentNode.getElementsByTagName('span')[0].style.display = 'none';
	}
	
}




/*
	initInputFocus by title
*/
function initInputFocusByTitle(){
	var inputs = document.getElementById('site').getElementsByTagName('input');
	var areas = document.getElementById('site').getElementsByTagName('textarea');
	
	var alLinputs = new Array();
	for(var i = 0; i < inputs.length; i++){
		if(inputs[i].getAttribute('type').toLowerCase() == 'text') alLinputs.push(inputs[i]);
	}
	for(var i = 0; i < areas.length; i++){
		alLinputs.push(areas[i]);
	}
	
	if(alLinputs.length == 0) return false;
	
	for(var i = 0; i < alLinputs.length; i++){
		
		if(alLinputs[i].parentNode.nodeName.toLowerCase() != 'label') continue;
		
		alLinputs[i].parentNode.getElementsByTagName('span')[0].style.display = 'none';
		alLinputs[i].value = alLinputs[i].parentNode.getAttribute('title');
		alLinputs[i].onfocus = function(){
			if(this.value == this.parentNode.getAttribute('title')){
				this.value = '';
			}
			this.select();
		}
		alLinputs[i].onblur = function(){
			if(this.value == ''){
				this.value = this.parentNode.getAttribute('title');
			}
		}
	}
}


 /*
	initLangNav
*/

function initLangNav(){
	if(!document.getElementById('langNav')) return false;
	if(!document.getElementById('langNav').getElementsByTagName('li')) return false;
	
	var listItems = document.getElementById('langNav').getElementsByTagName('li');
	var link;
	
	var select = document.createElement('select');
	select.id = 'langNavSelect';
	select.onchange = function(){
		window.open(this.value, '_self');
	}
	
	var lang = document.getElementsByTagName('html')[0].getAttribute('lang');
	
	if(lang == 'de') select.options[select.options.length] = new Option('Deutsch', '');
	if(lang == 'de-de') select.options[select.options.length] = new Option('Deutsch', '');
	if(lang == 'en') select.options[select.options.length] = new Option('English', '');
	if(lang == 'nl') select.options[select.options.length] = new Option('Nederlands', '');
	if(lang == 'nl-nl') select.options[select.options.length] = new Option('Nederlands', '');
	if(lang == 'nl-be') select.options[select.options.length] = new Option('Vlaams', '');
	if(lang == 'fr') select.options[select.options.length] = new Option('Nederlands', '');
	
	for(var i = 0; i < listItems.length; i++){
		link = listItems[i].getElementsByTagName('a')[0];
		select.options[select.options.length] = new Option(link.title, link.href);
	}
	document.getElementById('site').appendChild(select);
	document.getElementById('langNav').style.display = 'none';
}

 /*
  main-nav menus delay
*/
function initMainNav() {

	var nodes = document.getElementById('main-nav').getElementsByTagName('li');
	for (i = 0; i < nodes.length; i++) {
		// init out
		nodes[i].className += ' out';
		
		// over
		nodes[i].onmouseover = function(){
			// close others
			blockingElements('hide');
			var nodes = document.getElementById('main-nav').getElementsByTagName('li');
			for (j = 0; j < nodes.length; j++) {
				if (nodes[j] != this) {
					nodes[j].className = nodes[j].className.replace(' wait', ' out');
				}
			}

			this.className = this.className.replace(' wait', ' hover');
			this.className = this.className.replace(' out', ' hover');
			
			if(this.t){
				clearTimeout(this.t);
			}
		}
	
		// out
		nodes[i].onmouseout = function(){
			this.className = this.className.replace(' hover', ' wait');
			
			var _this = this;				
			this.t = setTimeout(function(){
				if(_this.className.match('wait')){
					_this.className = _this.className.replace(' wait', ' out');
					blockingElements('show');
				} 

			}, 600);
		}
	}
}


function blockingElements(visibity){

	var elements = ['noElementsToHide']; // add elementID's to hide here

	if(visibity == 'show'){
		visibity = 'visible';
	} else {
		visibity = 'hidden';
	}
	for (i = 0; i < elements.length; i++) {
		if(document.getElementById(elements[i])){
			document.getElementById(elements[i]).style.visibility = visibity;
		}
	}
}


/*
  main-nav for IE6
*/
function initMainNavOLD() {
	if (document.all && document.getElementById) {
		var nodes = document.getElementById('main-nav').getElementsByTagName('li');
		for (i = 0; i < nodes.length; i++) {
			if (nodes[i].nodeName.toUpperCase() == 'LI') {
				
				nodes[i].onmouseover = function(){
					this.className += ' hover';
				//	if(document.getElementById('breadcrumbs')) document.getElementById('breadcrumbs').style.visibility = 'hidden';
				//	if(document.getElementById('newsLetter')) document.getElementById('newsLetter').style.visibility = 'hidden';
				//	if(document.getElementById('toolbar')) document.getElementById('toolbar').style.visibility = 'hidden';
				}
				
				nodes[i].onmouseout = function() {
					this.className = this.className.replace(' hover', '');
					this.className = this.className.replace('hover', '');
				//	if(document.getElementById('breadcrumbs')) document.getElementById('breadcrumbs').style.visibility = 'visible';
				//	if(document.getElementById('newsLetter')) document.getElementById('newsLetter').style.visibility = 'visible';
				//	if(document.getElementById('toolbar')) document.getElementById('toolbar').style.visibility = 'visible';
				}
			}
		}
	}
} /*
	tab navigatie
*/

function initMultiTab(){ 
	var isTabs = document.getElementsByClassName('isTab');
	var hash = window.location.hash;
	var tabNavigations = document.getElementsByClassName('tabnavigation');
	
	// geen hash
	var newHash = '';
	if(hash.indexOf('#tab') == -1){
		
		var startTabs = document.getElementsByClassName('startTab');
		for(var i = 0; i < startTabs.length; i++){
			
			var startId = startTabs[i].id;
			var navId = '';
			for(var ii = 0; ii < tabNavigations.length; ii++){
				var links = tabNavigations[ii].getElementsByTagName('a');
				for(var iii = 0; iii < links.length; iii++){
					if(links[iii].href.indexOf(startId) != -1){
						navId = links[iii].parentNode.parentNode.parentNode.id;
					}
				}
			}

			if(i == 0){
				newHash = newHash+'#tab-'+navId+'-'+startId;
			} else {
				newHash = newHash+'&tab-'+navId+'-'+startId;
			}
		}
		
		if(newHash.length > 0){
			window.location.hash = newHash;
		}
		doTabsFromHash();
	}
	
	// wel hash
	else if(hash.indexOf('#tab-') != -1){
		doTabsFromHash();
	}
	
	// init onclicks
	for(var i = 0; i < tabNavigations.length; i++){
		var tablinks = tabNavigations[i].getElementsByTagName('a');
		for(var ii = 0; ii < tablinks.length; ii++){
			tablinks[ii].onclick = function(){
				var newOpen = this.href.split('#')[1];

				var thisnavId = '';
				var tabNavigations = document.getElementsByClassName('tabnavigation');
				for(var iii = 0; iii < tabNavigations.length; iii++){
					var navLinks = tabNavigations[iii].getElementsByTagName('a');
					for(var iiii = 0; iiii < navLinks.length; iiii++){
						if(navLinks[iiii].href.indexOf(newOpen) != -1){
							thisnavId = navLinks[iiii].parentNode.parentNode.parentNode.id;
						}
					}
				}

				var oldTabId = '';
				thisHash = window.location.hash.split('&');
				for(var iii = 0; iii < thisHash.length; iii++){
					var thish = thisHash[iii].split('-');
					if(thish[1] == thisnavId){
						oldTabId = thish[2];
					}
				}
				window.location.hash = window.location.hash.replace(oldTabId, newOpen);
				doTabsFromHash();
				this.blur();
				return false;
				
			}
		}
	}
}


function doTabsFromHash(){
	var isTabs = document.getElementsByClassName('isTab');
	
	for(var i = 0; i < isTabs.length; i++){
		isTabs[i].style.display = 'none';
	}

	var hash = window.location.hash;
	hash = hash.split('&');	
	for(var i = 0; i < hash.length; i++){
		var h = hash[i].split('-');
		var navId = h[1];
		var tabToOpen = h[2];
		
		if(document.getElementById(tabToOpen))document.getElementById(tabToOpen).style.display = 'block';
		
		// set startlink to active
		if(document.getElementById(navId)){
		var navLinks = document.getElementById(navId).getElementsByTagName('a');
			for(var ii = 0; ii < navLinks.length; ii++){
				navLinks[ii].parentNode.className = navLinks[ii].parentNode.className.replace(' active', '');
				navLinks[ii].parentNode.className = navLinks[ii].parentNode.className.replace('active', '');
				
				if(navLinks[ii].href.indexOf(tabToOpen) != -1){
					navLinks[ii].parentNode.className = navLinks[ii].parentNode.className + ' active';
				}
			}	
		}
	}

	hash = null;
	tabNavigations = null;
	startTabs = null;
	newHash = null;
	mediaObjects = null;
	mediaEmbeds = null;
}

function initStartCountry(){
	bodyClass = document.getElementsByTagName('body')[0].className;
	if(bodyClass.indexOf('country-') != -1){
		var index = bodyClass.indexOf('country-');
		countryCode = bodyClass.substring(index + 8,index + 10);
		
		var startId = '';
		var countryLi = document.getElementsByClassName(countryCode);
		if(!countryLi.length == 0){
			startId = countryLi[0].getElementsByTagName('a')[0].href.split('#')[1];
		}
		if(document.getElementById(startId))document.getElementById(startId).className = document.getElementById(startId).className + ' startTab';
	}
}


 /*
  initSignavureCarousel
*/

function initSignavureCarousel(){
	if(!document.getElementsByClassName('carousel').length) return false;
	
	var referencePage = 'd1169';

	// default: tWidth = 1000
	var cPadding = 0;
	var buttonWidth = 333;
	var cViewWidth = 333;
	var cHeight = 200;
	var tWidth = cPadding+buttonWidth+cViewWidth+buttonWidth+cPadding;
	var white = '/img/siteTemplate/carousel/white.png';
	var buttonPrevActive = '/img/siteTemplate/carousel/white-active.png';
	var buttonNext = '/img/siteTemplate/carousel/white.png';
	var buttonNextActive = '/img/siteTemplate/carousel/white-active.png';

	//get elements
	var carousel = document.getElementsByClassName('carousel')[0];
	var carouselList = carousel.getElementsByTagName('ul')[0];
	var carouselItems = carousel.getElementsByTagName('li');
	
	//minimun of 2 items
	//if(carouselItems.length <= 1) return false;
	if(carouselItems.length <= 0) return false;

	carousel.className += ' carouselOn';
	carousel.style.position = 'relative';
	carousel.style.width = buttonWidth+cViewWidth+buttonWidth+'px';
	carousel.style.height = cHeight+'px';
	carousel.style.overflow = 'hidden';
	carousel.style.borderLeft = cPadding+'px white solid';
	carousel.style.borderRight = cPadding+'px white solid';


	carouselList.style.display = 'block';
	carouselList.style.listStyleType = 'none';
	carouselList.style.position = 'absolute';
	carouselList.style.margin = '0';
	carouselList.style.padding = '0';
	carouselList.style.left = '0px';
	carouselList.style.width = (cViewWidth*carouselItems.length)+100+'px';
	
	//clone first to last
	carouselList.appendChild(carouselItems[0].cloneNode(true));
	
	//clone last to first
	carouselList.insertBefore(carouselItems[carouselItems.length-2].cloneNode(true),carouselItems[0]);
	
	
	for(i = 0; i < carouselItems.length; i++){
		carouselItems[i].style.position = 'absolute';
		carouselItems[i].style.left = (cViewWidth)*i+'px';
		carouselItems[i].style.width = cViewWidth+'px';
		carouselItems[i].style.height = (cHeight)+'px';
		carouselItems[i].style.cursor = 'pointer';
		
		var span = carouselItems[i].getElementsByTagName('span')[0];
		span.style.display = 'none';
		span.style.position = 'absolute';
		span.style.cursor = 'pointer';
		
		//if(!document.body.className.match(referencePage)){
		if(_reference_showPopUp){
			carouselItems[i].getElementsByTagName('a')[0].onclick = function(){
				var spn = this.getElementsByTagName('span')[0];
				if(spn.style.display == 'block'){
					spn.style.display = 'none';
				} else {
					spn.style.display = 'block';
				}
				return false;
			}
		}
	}
	
	var totalPages = carouselItems.length-3;
	var currentPage = 0;
	var speed = 0.8;
	var pageSize = cViewWidth;
	
	//prevButtonWrapper
	var prevWrapper = document.createElement('div');
	prevWrapper.id = 'prevButtonWrapper';
	prevWrapper.style.display= 'block';
	prevWrapper.style.width = buttonWidth+'px';
	prevWrapper.style.height = cHeight+'px';
	prevWrapper.style.position = 'absolute';
	prevWrapper.style.top = '0px';
	prevWrapper.style.left = '0px';
	prevWrapper.style.backgroundImage = 'url("'+white+'")';
	prevWrapper.style.opacity = 0.8;
	prevWrapper.style.MozOpacity = 0.8;
	prevWrapper.style.filter = 'alpha(opacity=80)';
	
	
	//prevButton
	var prevButton = document.createElement('a');
	prevButton.id = 'prevButton';
	prevButton.style.href= '#';
	prevButton.style.display= 'block';
	prevButton.style.width = buttonWidth+'px';
	prevButton.style.height = cHeight+'px';
	prevButton.style.cursor = 'pointer';
	prevButton.style.backgroundImage = 'url("'+buttonPrevActive+'")';
	prevButton.onclick = handlePrev;
	
	//nextButtonWrapper
	var nextWrapper = document.createElement('div');
	nextWrapper.id = 'nextButtonWrapper';
	nextWrapper.style.display= 'block';
	nextWrapper.style.width = buttonWidth+'px';
	nextWrapper.style.height = cHeight+'px';
	nextWrapper.style.position = 'absolute';
	nextWrapper.style.top = '0px';
	nextWrapper.style.left = cViewWidth + cViewWidth +'px';
	nextWrapper.style.backgroundImage = 'url("'+white+'")';
	nextWrapper.style.opacity = 0.8;
	nextWrapper.style.MozOpacity = 0.8;
	nextWrapper.style.filter = 'alpha(opacity=80)';

	//nextButton
	var nextButton = document.createElement('a');
	nextButton.id = 'nextButton';
	nextButton.style.href= '#';
	nextButton.style.display= 'block';
	nextButton.style.width = buttonWidth+'px';
	nextButton.style.height = cHeight+'px';
	nextButton.style.cursor = 'pointer';
	nextButton.style.backgroundImage = 'url("'+buttonNextActive+'")';
	nextButton.onclick = handleNext;

	prevWrapper.appendChild(prevButton);
	nextWrapper.appendChild(nextButton);

	carousel.appendChild(prevWrapper);
	carousel.appendChild(nextWrapper);
	
	function handlePrev() {
		if (currentPage == 0) {
			currentPage = totalPages;
		} else {
			currentPage--;
		}
		
		var spans = carousel.getElementsByTagName('span');
		for(i = 0; i < spans.length; i++){
			spans[i].style.display = 'none';
		}

		new Effect.Morph(carouselList , {style: 'left:-'+ (currentPage * (pageSize))+'px', duration: speed});
		return false;
	}
	
	function handleNext() {
		if ((currentPage+1) > totalPages) {
			currentPage = 0;
		} else {
			currentPage++;
		}
		
		var spans = carousel.getElementsByTagName('span');
		for(i = 0; i < spans.length; i++){
			spans[i].style.display = 'none';
		}
		
		new Effect.Morph(carouselList , {style: 'left:-'+ (currentPage * (pageSize))+'px', duration: speed});
		return false;
	}	
}



 /*
  langNavKlapper
*/

var langNavKlapper = function(){

	$('#langNavWrapper #langNav').toggle();

	$('#langNavWrapper #languagePicker').click(function(){
		$('#langNavWrapper #langNav').toggle();
		this.blur();
		return false;
	});

	$('#langNavWrapper #langNav').prepend($('<a class="closeLangnav" href="#"><em>X</em><a/>'));
	$('#langNavWrapper #langNav .closeLangnav').click(function(){
		$('#langNavWrapper #langNav').toggle();
		this.blur();
		return false;
	});

}
 // noscript

var initStorelocator = function() {
     /* storeLocator */
        $('.mapNoShow').removeClass('mapNoShow');
        $('.mapShow').addClass('mapNoShow');
        $('.mapShow').removeClass('mapShow');

        $('#kaart').click(function() {
            $('#mapcontainer').removeClass('mapNoShow');
            $('#mapcontainer').addClass('mapShow');

            $('#addressescontainer').removeClass('mapShow');
            $('#addressescontainer').addClass('mapNoShow');

            $('#findaddress').removeClass('mapNoShow');
            $('#findaddress').addClass('mapShow');
            $('#findaddressGet').removeClass('mapShow');
            $('#findaddressGet').addClass('mapNoShow');

            initializeCompanyMap(0);
            if ($('#query').val() != '') {
                $('#findaddress').trigger('click');
            }
        });
        $('#adreslijst').click(function() {
            $('#mapcontainer').removeClass('mapShow');
            $('#mapcontainer').addClass('mapNoShow');

            $('#addressescontainer').removeClass('mapNoShow');
            $('#addressescontainer').addClass('mapShow');

            $('#findaddress').removeClass('mapShow');
            $('#findaddress').addClass('mapNoShow');
            $('#findaddressGet').removeClass('mapNoShow');
            $('#findaddressGet').addClass('mapShow');
        });

        // when user selects the addresslist and form is filled, then submit it and load addresses
        $('#adreslijst').mouseup(function() {
            if ($('#query').val() != '') {
                $('form#slocSearchWrapper').submit();
            }
        });

        // when adreslijst is selected when page loads, then also trigger clickevent on it to submit form
        if ($('#adreslijst').is(':checked')) {
            $('#adreslijst').trigger('click');
        }
        
}

var goToMap = function(address) {
    $('#query').val(address);
    $('input#kaart').attr('checked','checked');
    $('input#kaart').trigger('click');
} /*
	markLinks
*/

function markLinks(){

	var extIcon = '/img/template/link-icons/external.png';	
	var emailIcon = '/img/template/link-icons/email.png';
	var twitIcon = '/img/template/link-icons/twitter-white.png';
	var linkedIcon = '/img/template/link-icons/linkedIn.png';
	var vCardIcon = '/img/template/link-icons/vCard.png';
	var pdfIcon = '/img/template/link-icons/pdf.png';
	var xlsIcon = '/img/template/link-icons/xls.png';
	var docIcon = '/img/template/link-icons/doc.png';
	var pptIcon = '/img/template/link-icons/ppt.png';
	var zipIcon = '/img/template/link-icons/zip.png';
	var wmvIcon = '/img/template/link-icons/wmv.png';
	
	var links = document.getElementsByTagName('a');
	var link, mark;
	
	for(var i = 0; i < links.length; i++){
		link = links[i];

		// skip itteration for addthis links
		if(link.parentNode.className.match('addthis_toolbox')) continue;
		
		// ext
		if(link.getAttribute('rel') == 'ext' || link.getAttribute('rel') == 'external'){
			link.className += ' external';
			link.target = '_blank';
		}
				
		// mailto
		if(link.getElementsByTagName('img').length == 0){
			// email (niet obv rel)
			if(link.getAttribute('href').indexOf('mailto:') != -1){
				link.className += ' external mail';
				link.target = '_blank';
				mark = document.createElement('img');
				mark.src = emailIcon;
				link.appendChild(mark);
			}
		}
		
		// ext & specific site
		if(link.getElementsByTagName('img').length == 0){
			if(link.getAttribute('rel') == 'ext' || link.getAttribute('rel') == 'external'){
				// twitter
				if(link.getAttribute('href').match('twitter.com')){
					link.className += ' twitter';
					mark = document.createElement('img');
					mark.src = twitIcon;
					link.insertBefore(mark , (link.firstChild));
				}
				// linkedIn
				if(link.getAttribute('href').match('linkedin.com')){
					link.className += ' linkedin';
					mark = document.createElement('img');
					mark.src = linkedIcon;
					link.insertBefore(mark , (link.firstChild));
				}
			}
		}
		
		// ext & filetypes
		if(link.getElementsByTagName('img').length == 0){
			if(link.getAttribute('rel') == 'ext' || link.getAttribute('rel') == 'external'){
				// file types
				var hEnd = link.getAttribute('href').substring(link.getAttribute('href').length-4).toLowerCase();
				switch (hEnd){
				case '.vcf':
					mark = document.createElement('img');
					mark.src = vCardIcon;
					link.className += ' file vcf';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				case '.zip':
					mark = document.createElement('img');
					mark.src = zipIcon;
					link.className += ' file zip';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				case '.wmv':
					mark = document.createElement('img');
					mark.src = wmvIcon;
					link.className += ' file wmv';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				case '.pdf': case 'pdfx':
					mark = document.createElement('img');
					mark.src = pdfIcon;
					link.className += ' file pfd';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				case '.xls': case 'xlsx':
					mark = document.createElement('img');
					mark.src = xlsIcon;
					link.className += ' file xls';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				case '.doc': case 'docx':
					mark = document.createElement('img');
					mark.src = docIcon;
					link.className += ' file doc';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				case '.ppt': case 'pptx':
					mark = document.createElement('img');
					mark.src = pptIcon;
					link.className += ' file ppt';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					break;
				default:
					mark = document.createElement('img');
					mark.src = extIcon;
					link.appendChild(mark);
					link.onclick = handleExternalSiteClick;
				}
			}
		}
	}
	
	// print text
	links = document.getElementById('content').getElementsByTagName('a');
	for(var i = 0; i < links.length; i++){
		if(links[i].getAttribute('href')){
			oHref = document.createElement('span');
			oHref.className = 'print';
			oHref.appendChild((document.createTextNode(' [' + links[i].href + ']')));
			links[i].appendChild(oHref);
		}
	}

	mark = null;
	href = null;
	link = null;
	links = null;
}

function handleDownloadClick(){
	if(typeof pageTracker._trackPageview == 'function'){
		pageTracker._trackPageview('/downloads/' + this.href);
	}
}

function handleExternalSiteClick(){
	if(typeof pageTracker._trackPageview == 'function'){
		pageTracker._trackPageview('/externalSites/' + this.href);
	}
}

 /*
	popup
*/
function openPopup(url){

	if(!document.getElementById('popupWrapper')){
		var popupWrapper = document.createElement('div');
		popupWrapper.id = 'popupWrapper';
		popupWrapper.onclick = function(){ closePopup() };

		popupWrapper.innerHTML = '<div class="header"><a href="javascript:closePopup();"><em>Sluiten</em></a></div><div class="body" id="popupBody"></div>';

		document.body.appendChild(popupWrapper);

	}
	// empty popup
	document.getElementById('popupBody').innerHTML = '';

	// new img
	$(document.createElement('img'))
	.attr('src', url)
	.attr('id', 'popupPhoto')
	.load(function(){
		$('#popupWrapper').css("width", $(this).width()+20+"px");
		$('#popupWrapper').css("height", $(this).height()+30+"px");
		$('#popupWrapper').css("marginLeft", ($(this).width()/2)*-1+"px");
	})
	.appendTo('#popupBody');

	$('#popupWrapper').css("width", $('#popupPhoto').width()+20+"px");
	$('#popupWrapper').css("height", $('#popupPhoto').height()+30+"px");
	$('#popupWrapper').css("marginLeft", ($('#popupPhoto').width()/2)*-1+"px");

	$('#popupWrapper').css("top", $('html').scrollTop()+80+"px");
	document.getElementById('popupWrapper').style.display = 'block';
	blockingElements('hide');
}


function closePopup(){
	document.getElementById('popupWrapper').style.display = 'none';
	blockingElements('show');
}


/*
	initPopupByClassname
*/

function initPopupByClassname(){
	$('a.fotoPopup').add('a.popupFoto').click(function () {
		openPopup($(this).attr('href'));
		return false;
	});
}

 /*
	pageToolBar handicare
*/

function pageToolbar(){
	
	var language = document.getElementsByTagName('html')[0].getAttribute('lang');
	
	var contrastTxt = 'Contrast';
	var fontSizeText = 'Text size';
	var iconLetter = 'A';
	
	if(language == 'nl' || language == 'nl-be' || language == 'nl-nl'){
		contrastTxt = 'Contrast';
		fontSizeText = 'Tekstgrootte';
		iconLetter = 'A';
	} else if(language == 'fr') {
		contrastTxt = 'Contraste';
		fontSizeText = 'Taille de police';
	}


	// toolbar div
	var toolbar = document.createElement('div');
	toolbar.id = 'toolbar';
	document.getElementById('siteWrapper').appendChild(toolbar);

	// contrast div
	var contrastWrapper = document.createElement('div');
	contrastWrapper.id = 'contrastWrapper';
	contrastWrapper.innerHTML = contrastTxt;
	toolbar.appendChild(contrastWrapper);
	
	// contrast a
	var toggleContrast = document.createElement('a');
	toggleContrast.rel = 'int';
	toggleContrast.id = 'toggleContrast';
	toggleContrast.href = '#';
	toggleContrast.innerHTML = '<em>'+iconLetter+'</em>';
	toggleContrast.onclick = function(){
		initContrast();
		this.blur();
		return false;
	}
	contrastWrapper.appendChild(toggleContrast);

	initContrast('fromCookie');

	// font-size div
	var fontSizeWrapper = document.createElement('div');
	fontSizeWrapper.id = 'fontSizeWrapper';
	fontSizeWrapper.innerHTML = fontSizeText;
	toolbar.appendChild(fontSizeWrapper);

	// A
	var zA = document.createElement('a');
	zA.rel = 'int';
	zA.className = 'zoomSmall';
	zA.href = '#';
	zA.innerHTML = '<em>'+iconLetter+'</em>';
	zA.onclick = function(){
		initZoom('small');
		this.blur();
		return false;
	}
	fontSizeWrapper.appendChild(zA);
	
	// AA
	var zAA = document.createElement('a');
	zAA.rel = 'int';
	zAA.className = 'zoomNormal';
	zAA.href = '#';
	zAA.innerHTML = '<em>'+iconLetter+'</em>';
	zAA.onclick = function(){
		initZoom('normal');
		this.blur();
		return false;
	}
	fontSizeWrapper.appendChild(zAA);
	
	// AAA
	var zAAA = document.createElement('a');
	zAAA.rel = 'int';
	zAAA.className = 'zoomBig';
	zAAA.href = '#';
	zAAA.innerHTML = '<em>'+iconLetter+'</em>';
	zAAA.onclick = function(){
		initZoom('big');
		this.blur();
		return false;
	}
	fontSizeWrapper.appendChild(zAAA);

	initZoom('fromCookie');

}


// initContrast
function initContrast(toggle){
	// fromCookie
	var dBody = document.getElementsByTagName('body')[0];

	if(toggle == 'fromCookie'){
		// getCookie
		var cContrast = getCookie('highContrast');
		if(cContrast == 'on'){
			dBody.className += ' highContrast';
		}
		
	} else {
		// click + set cookie
		var contrast = 'on';
		if(dBody.className.match('highContrast')){
			dBody.className = dBody.className.replace(' highContrast', '');
			dBody.className = dBody.className.replace('highContrast', '');
			contrast = 'off';

		} else {
			dBody.className+= ' highContrast';
		}

		// set cookie
		document.cookie = 'highContrast='+ contrast +'; path=/';

	}
}


// initZoom
function initZoom(factor){
	var dBody = document.getElementsByTagName('body')[0];
	dBody.className = dBody.className.replace(' big', '');
	dBody.className = dBody.className.replace('big', '');
	dBody.className = dBody.className.replace(' normal', '');
	dBody.className = dBody.className.replace('normal', '');
	dBody.className = dBody.className.replace(' small', '');
	dBody.className = dBody.className.replace('small', '');

	if(factor != 'fromCookie'){
		// click + set cookie
		dBody.className += ' '+factor;
		document.cookie = 'zoom=' + factor + '; path=/';

	} else {
		// getCookie
		var zoom = getCookie('zoom');
		if(zoom != null){
			dBody.className += ' '+zoom;
		}
	}
}






 /*
	sisoFader - Sigma Solutions
	.photoFader ul li
	.links ul li
	.faderText
*/

(function($) {
    $.fn.sisoFader = function(options) {
        return this.each(function() {   
            $.sisoFader(this, options);
        });
    };

    $.sisoFader = function(container, options) {
		//$('body').addClass('photoFaderOn');
        var o = {
            'speed': 1000,
            'timeout': 2000
        };
		if (options) $.extend(o, options);
		
		// set id's
		var photos = $('.photoFader li');
		var links = $('.photoFaderLinks li');
		var texts = $('.photoFader .phototext');
		
		for (var i = 0; i < links.length; i++) {
			photos[i].id = 'photo'+i;
			links[i].id = 'link'+i;
			texts[i].id = 'text'+i;
		}
		 
        // init fading
		$.sisoFader.doFade(0, o);
		
		// hover link
		links.find('a').hover(function(){
			var thislink = $(this).parent().attr('id').split('link')[1];// get current group-id
			$.sisoFader.doFade(thislink,o);
			return false;
		});
	};
	
	// doFade
	$.sisoFader.doFade = function(id,o){
		// return false if new == old
		if(id == $('.photoFader li:last-child').attr('id').split('photo')[1]) return false;
		
		// clear existing timeout
		if(window.t)clearTimeout(window.t);
		
		// link
		$('.photoFaderLinks li').removeClass('active');
		$('#link'+id).addClass('active');

		// text
		$('.photoFader .phototext').hide();
		$('#text'+id).show();
		
		// photo
		$('.photoFader li .photo').stop(); // stop animation
		$('.photoFader li .photo').css("opacity",1); // show all photos
		$('#photo'+id+' .photo').css("opacity",0); // hide new photo
		$('.photoFader').append($('#photo'+id)); // move new photo to end of list (on top)
		$('#photo'+id+' .photo').animate({ opacity: 1 }, o.speed, function() {
			// fadein callback, setTimeout for next fade
			id++;
			if(id > $('.photoFader li').length-1) id = 0;
			window.t = setTimeout(function(){
				$.sisoFader.doFade(id,o);
			}, o.timeout);
		});
	};

})(jQuery);

 /**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;



