 /*
	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;
} /*
company top tab

*/

function initTopTab() {
		if(document.getElementById('topTabContainer')) {
			var topTab = 	document.createElement('div');
			topTab.id = 'topTabNavigation';
			topTabMap = document.createElement('a');
			topTabMap.onclick= function() {showTopTab('map');return false;};
			topTabMapText = document.createTextNode('map');
			topTabMap.appendChild(topTabMapText);
			topTabPhoto = document.createElement('a');
			topTabPhoto.onclick = function() {showTopTab('photo');return false;};
			topTabPhotoText = document.createTextNode('photo');
			topTabPhoto.appendChild(topTabPhotoText);
			topTab.appendChild(topTabMap);
			topTab.appendChild(topTabPhoto);
			if(document.getElementById('topTabContainer').firstChild) {
				document.getElementById('topTabContainer').insertBefore(topTab, document.getElementById('topTabContainer').firstChild);
			} else {
				document.getElementById('topTabContainer').appendChild(topTab);
			}
			
			showTopTab('map');
		}

	}
	function showTopTab(option) {
		if (option == 'map') {
			document.getElementById('mapTab').style.display = 'block';

			document.getElementById('photoTab').style.display = 'none';
			document.getElementById('mapTab').className = 'active';
			document.getElementById('photoTab').className = '';
		} else {
			document.getElementById('mapTab').style.display = 'none';
			document.getElementById('photoTab').style.display = 'block';
			document.getElementById('mapTab').className = '';
			document.getElementById('photoTab').className = 'active';

		}
	}
 /*
  europemap switcher
*/

function switchkaart(img) {
	var imgTitle = 'Europe';
	var europeKaart = document.getElementById('europeImg');
	europeKaart.src = '/img/europemap/'+img;
}

function switchkaarttotaal() {
	var europeKaart = document.getElementById('europeImg');
	europeKaart.src = '/img/europemap/europe.png';
} /*
  fixInputs
*/

function fixInputs() {
 if (document.all && document.getElementById) {

  var nodes = document.getElementsByTagName('input');
  for (i = 0; i < nodes.length; i++) {
   if (nodes[i].type.toUpperCase() == 'TEXT') {
    nodes[i].onfocus = function(){
     this.className += ' focus';
    }
    nodes[i].onblur = function() {
     this.className = this.className.replace('focus', '');
    }
   }
  }

  var areaNodes = document.getElementsByTagName('textarea');
  for (i = 0; i < areaNodes.length; i++) {
    areaNodes[i].onfocus = function(){
     this.className += ' focus';
    }
    areaNodes[i].onblur = function() {
     this.className = this.className.replace('focus', '');
    }
   }
  }
} // 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;
} /*

handleBodyLoad

*/

function handleBodyLoad() {

       document.body.className +=' jsEnabled';
	initMainNav();
	fixInputs();
	markLinks();
	initZoom();
        initTab2008();
        initTabs2008();

        highlightQuery();

}
 /*
  main-nav for IE6
*/
function initMainNav() {
	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';
				}
				
				nodes[i].onmouseout = function() {
					this.className = this.className.replace('hover', '');

				}
			}
		}
	} 
} /*
  interactive
*/
function handleFeedBack(){
	feedback();
}

function handleMailThisPage(){
	mailThisPage();
}


/*
	MAIL THIS PAGE
*/
var mailThisPageWrapper;
function mailThisPage(){
	if(!mailThisPageWrapper){
		var html = '';
                var lang = '';
		
		mailThisPageWrapper = document.createElement('div');
		mailThisPageWrapper.className = 'mailThisPageWrapper';
		mailThisPageWrapper.style.height = '0px';
		mailThisPageWrapper.style.width = '0px';
		document.getElementsByTagName('body')[0].appendChild(mailThisPageWrapper);
		
		
		// position of wrapper
		var xPos = document.body.clientWidth;
			xPos = parseInt((xPos / 2) - 200);
		mailThisPageWrapper.style.left = xPos + 'px';

                if(window.location.href.toLowerCase().indexOf('/de/') != -1){
			lang = 'de';
		}else if(window.location.href.toLowerCase().indexOf('/nl/') != -1){
			lang = 'nl';
               } else if(window.location.href.toLowerCase().indexOf('/nl-nl/') != -1){
			lang = 'nl';
               } else if(window.location.href.toLowerCase().indexOf('/nl-be/') != -1){
			lang = 'nl';
               } else if(window.location.href.toLowerCase().indexOf('/fr-be/') != -1){
			lang = 'fr';
               } else if(window.location.href.toLowerCase().indexOf('/fr/') != -1){
			lang = 'fr';
		}else{
			lang = 'en';
		}

		html += '<h2>Mail this page <a href="javascript:closeMailThisPage()"><img src="/data/closePopup.gif" /></a></h2>';
		html += '<iframe src="/mailThisPage.cfm?language='+lang+'" frameborder="0"></iframe>';
		
		mailThisPageWrapper.innerHTML = html;
		
		mailThisPage();
	}else{
		
		var height = mailThisPageWrapper.style.height;
			height = parseInt(height.replace('px', ''));
			height = height + 9;
		var width = mailThisPageWrapper.style.width;
			width = parseInt(width.replace('px', ''));
			width = width + 12;
		
		mailThisPageWrapper.style.height =  height + 'px';
		mailThisPageWrapper.style.width =  width + 'px';
		
		if(height < 300){
			setTimeout('mailThisPage()', 0);
		}
		
	}
	
}


function closeMailThisPage(){
	document.getElementsByTagName('body')[0].removeChild(mailThisPageWrapper);
	mailThisPageWrapper = null;
}
/*
	// MAIL THIS PAGE
*/



/*
	FEEDBACK
*/
var feedbackWrapper;
function feedback(){
	if(!feedbackWrapper){
		var html = '';

		feedbackWrapper = document.createElement('div');
		feedbackWrapper.className = 'feedbackWrapper';
		feedbackWrapper.style.height = '0px';
		feedbackWrapper.style.width = '0px';
		document.getElementsByTagName('body')[0].appendChild(feedbackWrapper);
		
		// position of wrapper
		var xPos = document.body.clientWidth;
			xPos = parseInt((xPos / 2) - 300);
		feedbackWrapper.style.left = xPos + 'px';

		html += '<h2>Feedback <a href="javascript:closeFeedBack()"><img src="/data/closePopup.gif" /></a></h2>';

		if(window.location.href.toLowerCase().indexOf('/de/') != -1){
			lang = 'de';
		}else if(window.location.href.toLowerCase().indexOf('/nl/') != -1){
			lang = 'nl';
               } else if(window.location.href.toLowerCase().indexOf('/nl-nl/') != -1){
			lang = 'nl';
               } else if(window.location.href.toLowerCase().indexOf('/nl-be/') != -1){
			lang = 'nl';
               } else if(window.location.href.toLowerCase().indexOf('/fr-be/') != -1){
			lang = 'fr';
               } else if(window.location.href.toLowerCase().indexOf('/fr/') != -1){
			lang = 'fr';
		}else{
			lang = 'en';
		}
		
		html += '<iframe src="/feedback.cfm?language=' + lang + '" frameborder="0"></iframe>';
		
		feedbackWrapper.innerHTML = html;
		
		feedback();
	}else{
		
		var height = feedbackWrapper.style.height;
			height = parseInt(height.replace('px', ''));
			height = height + 8;
		var width = feedbackWrapper.style.width;
			width = parseInt(width.replace('px', ''));
			width = width + 12;
		
		feedbackWrapper.style.height =  height + 'px';
		feedbackWrapper.style.width =  width + 'px';
		
		if(height < 400){
			setTimeout('feedback()', 0);
		}
		
	}
	
}


function closeFeedBack(){
	document.getElementsByTagName('body')[0].removeChild(feedbackWrapper);
	feedbackWrapper = null;
} /*
 mark links
*/
function markLinks(){
	var links = document.getElementsByTagName('a');
	var link, href, mark;
	
	for(var i = 0; i < links.length; i++){
		link = links[i];
		
			
		switch(link.getAttribute('rel')){
			case 'ext': case 'external':
				link.className += ' external';
				link.target = '_blank';
				
				
				if(link.getElementsByTagName('img').length == 0){
					href = link.getAttribute('href').toLowerCase();
					href = href.substring((href.length - 4), (href.length));
					switch(href){
						case '.pdf':
							link.className += ' pdf';
							mark = document.createElement('img');
							mark.src = '/data/link-icons/pdf.png';
							link.insertBefore(mark , (link.firstChild));
							break;
						
						case '.xls':
							link.className += ' pdf';
							mark = document.createElement('img');
							mark.src = '/data/link-icons/xls.png';
							link.insertBefore(mark , (link.firstChild));
							break;
							
						case '.doc':
							link.className += ' pdf';
							mark = document.createElement('img');
							mark.src = '/data/link-icons/doc.png';
							link.insertBefore(mark , (link.firstChild));
							break;
							
						case '.ppt':
							link.className += ' pdf';
							mark = document.createElement('img');
							mark.src = '/data/link-icons/ppt.png';
							link.insertBefore(mark , (link.firstChild));
							break;
							
						default:
							mark = document.createElement('img');
							mark.src = '/data/link-icons/external.png';
							link.appendChild(mark);
							break;
				}
			}
		}
	}
	
	links = document.getElementById('content').getElementsByTagName('a');
	
	for(var i = 0; i < links.length; i++){
		if(links[i].getAttribute('href')){
			href = document.createElement('span');
				href.className = 'print';
				href.appendChild((document.createTextNode(' [' + links[i].href + ']')));
			
			links[i].appendChild(href);
		}
	}
	
	mark = null;
	href = null;
	link = null;
	links = null;
} 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(URL, name, features, width, height)
{
	var left	= (screen.availWidth - width) / 2;
	var top		= (screen.availHeight - height) / 2;
	
	return window.open(URL, name, features + ', width=' + width + ', height=' + height + ', left=' + left + ', top=' + top);
	
	left = null;
	top = null;
}
 /*
  search highlighting
*/
var words;
function highlightQuery() {
	notAllowed = ["home/search/"];	
	for (var i=0; i < notAllowed.length; i++) {
		if (window.location.href.indexOf(notAllowed[i])>=0) {
			return;
		}
	}	

	// google	
	var startIndex = document.referrer.indexOf('&q='); 
	if (startIndex < 0) {
		startIndex = document.referrer.indexOf('?q='); 
	}
	
	// yahoo
	if(startIndex < 0){
		startIndex = document.referrer.indexOf('&p=');
		
		if(startIndex < 0){
			startIndex = document.referrer.indexOf('?p=');
		}
	}
	
	var endIndex = -1;
	if (startIndex >= 0) {
		endIndex = document.referrer.substr(startIndex+3).indexOf('&') + startIndex  +3; 
		
		if (endIndex < (startIndex+3)) {
			endIndex = document.referrer.length;
		}
	}

	var query = '';
	if ((startIndex>0 ) && (endIndex>0) && (startIndex+3 < endIndex)) {
		query = document.referrer.substring(startIndex+3, endIndex);
	}else{
		if( (getCookie('q')) && ((getCookie('q')).length > 0)){
			query = getCookie('q');
			document.cookie = 'q=; path=/';
		}
	}
        
	if(query != ''){
		words = query.toLowerCase().split('+');
		
		for (var i = 0; i < words.length; i++) {
			highlightLeave(document.getElementsByTagName('body')[0], i);
		}
	}
}


function highlightLeave(X, n) {
	var currentNode='';
	if (X.childNodes.length > 0) {
		while((currentNode=='') || (currentNode.nextSibling)) {
			
			if (currentNode=="") {
				currentNode = X.firstChild; 
			} else {
				currentNode = currentNode.nextSibling;
			}
					
			if (currentNode.nodeType != 3) {
				highlightLeave(currentNode, n);
			} else {
				nodeValue = currentNode.nodeValue;
				while (nodeValue.toLowerCase().indexOf(words[n]) >= 0) {
					var startIndex = nodeValue.toLowerCase().indexOf(words[n]);
					var endIndex = nodeValue.toLowerCase().indexOf(words[n]) + words[n].length;
					

					var preText = document.createTextNode(nodeValue.substring(0, startIndex));
					var highlightText = document.createTextNode(nodeValue.substring(startIndex,endIndex));
					var highlightContainer = document.createElement('span');
					highlightContainer.className = 'searchHighlight' + ((n%10)+1);
					highlightContainer.appendChild(highlightText);
					currentNode.parentNode.insertBefore(preText,currentNode);
					currentNode.parentNode.insertBefore(highlightContainer,currentNode);
					nodeValue = nodeValue.substr(endIndex);
					currentNode.nodeValue = nodeValue; 
				}
			}

		}
	}

} 
 /* 

tab navigation

*/

function isValidHash(value, hashes) {
for(var i=0; i < hashes.length; i++) {
   if (('#'+hashes[i]) == value) return true;
}
return false;
}
function initTab2008(){
	var hash = (window.location.hash).toString();
	var tabHashes = ['products', 'emailform'];

	var tabNavigation = document.getElementsByClassName('tabnavigation');
        if(!tabNavigation.length) {
              return;
        }

        if (!isValidHash(hash, tabHashes)) {
          if(document.getElementById('productsTab')){
            window.open('#products','_self');
            hash = (window.location.hash).toString();
          } else {
            window.open('#emailform','_self');
            hash = (window.location.hash).toString();
          }
        }
   
	var tab= hash.replace('#', ''); 
	tabNavigation = tabNavigation[0];

	var links = tabNavigation.getElementsByTagName('a');
	for(var i = 0; i < links.length; i++){
			if(links[i].href.indexOf(tab) == -1){
				links[i].parentNode.className = '';
			} else {
				links[i].parentNode.className = 'active';
			}
	}
		
		var documentBody = document.getElementsByTagName('body')[0];
		
		for (var i=0; i < tabHashes.length; i++) {
			documentBody.className = documentBody.className.replace(tabHashes[i],'');
		}


		documentBody.className += ' ' + tab;		
  
		
     

}


function initTabs2008(){
	var tabNavigation = document.getElementsByClassName('tabnavigation');

if(!tabNavigation.length) {
return;
}

tabNavigation = tabNavigation[0];
	
	
	
	if(tabNavigation){
		var links = tabNavigation.getElementsByTagName('a');
		for(var i = 0; i < links.length; i++){
			links[i].onclick = function(){
				window.open(this.getAttribute('href'), '_self');
                             
				initTab2008();
                                 if (vIE() == 6) {
                                     window.location.reload();
                                   }
	
				return false;
			}
		}

	}
}

function vIE(){
return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;
} /*
	zebra tables
*/
function zebraTables(){

	var rows = document.getElementsByTagName('tr');

	for(var i = 0; i< rows.length; i++){

		if((i % 2) == 0){

			rows[i].className += ' odd';

		}else{

			rows[i].className += ' even';

		}
	}
} // zoomlinks
function initZoom(){
	var zoom = getCookie('zoom');
	
	if(zoom == null){
		document.getElementsByTagName('body')[0].className += ' normal';
	}else{
		document.getElementsByTagName('body')[0].className += ' ' + zoom;
	}
}

function zoom(factor){
	var className = document.getElementsByTagName('body')[0].className;
	className = className.replace(' big', '');
	className = className.replace('big', '');
	className = className.replace(' normal', '');
	className = className.replace('normal', '');
	className = className.replace(' small', '');
	className = className.replace('small', '');
	className += ' ' + factor;
	
	document.cookie = 'zoom=' + factor + '; path=/';
	document.getElementsByTagName('body')[0].className = className;
}

