/*
  handleBodyLoad
*/

function handleBodyLoad(){

  initMainNav();
  markLinks();
  initZebraTables();
  initForms();
  initImageText();
  doSIFR();
  initExternalInfoPopups();

  initCollapseSitemap('di1816');
  initCollapseSitemap('datasheets');
  uncollapseFromHash();

  fixPNG();
  initShadowOverlay();
  initSidebarWordbreak();
  initHeaderImgAndText();

  //onbeforeprint bericht
  function handleOnBeforePrint(){
    if((document.getElementsByClassName('template-18').length) || (document.getElementsByClassName('template-7').length)){
      alert('Wij adviseren u de PDF te downloaden voor een beter printresultaat');
    }
    window.top.focus();
  }

  window.onbeforeprint = handleOnBeforePrint;


// technivent popup
//  popupCookie();

//  searchAsYouType = new searchAsYouType();
//  searchAsYouType.initHandler('qGlobalSearch');
//  searchAsYouType.initHandler('q-0');

  
  /* search inputs */
  initInputFocus('qGlobalSearch', 'Zoeken');

  var spInputVal = '';
  if(document.getElementById('q-0')) spInputVal = document.getElementById('q-0').value;
  if(spInputVal == '') spInputVal = 'Zoeken';
  initInputFocus('q-0', spInputVal);


  /*
    documentationShop
  */
  try{
    handleTabMenu();
    handleDatasheetButtons();
    handleDownloadFilter();
  } catch(e){}
 
  initAdBar();
  if ($('.site-3 div#site ul#main-nav').attr('id') !== undefined) {
    setMenuSize();
  }
}

window.onload =   function() {

}


 /*
  adBar
*/

function initAdBar(){
  var body = document.getElementById('body');
  var adbarWrapper = document.getElementById('adbarWrapper');
  var url = window.location.href;
  var height = '';
  var sign = '?';

  // first delete all children
  while(adbarWrapper.firstChild){
    adbarWrapper.removeChild(adbarWrapper.firstChild);
  }

  // get uri
  url = url.replace('http://', '');
  url = url.replace('https://', '');
  url = url.replace(document.domain, '');

  if(url.search('/nl/') == -1) url = newsURI;

  if(url.search('=') != -1) sign = '&';
 
  // get height of content area
  height = body.offsetHeight;
  if(height < 145) height = 145;

  if(navigator.appVersion.indexOf('MSIE 7.0') != -1){
    height += 28;
  } else {
    height += 5;
  }

  var iframe = document.createElement('iframe');
  iframe.id = 'adbar';
  iframe.src = '/ads' + url + sign + 'height=' + height;
  iframe.setAttribute('frameBorder', '0');
  iframe.style.height = height + 'px';

  adbarWrapper.appendChild(iframe);
} /*
  adBar
*/

function initAdBar(){
  var body = document.getElementById('body');
  var adbarWrapper = document.getElementById('adbarWrapper');
  var url = window.location.href;
  var height = '';
  var sign = '?';

  // first delete all children
  while(adbarWrapper.firstChild){
    adbarWrapper.removeChild(adbarWrapper.firstChild);
  }

  // get uri
  url = url.replace('http://', '');
  url = url.replace('https://', '');
  url = url.replace('localhost', '');
  url = url.replace('workstation6', '');
  url = url.replace('eriks-at.nl.vh5.sigmasolutions.eu', '');
  url = url.replace('eriks.nl.vh5.sigmasolutions.eu', '');
  url = url.replace('eriks.nl.vh6.sigmasolutions.eu', '');
  url = url.replace('test.eriks-at.nl.vh6.sigmasolutions.eu', '');
  url = url.replace('test.eriks.nl', '');
  url = url.replace('eriks.nl', '');
  url = url.replace('#tab1', '');
  url = url.replace('#tab2', '');
  url = url.replace('test.eriks-at.nl', '');
  url = url.replace('eriks-at.nl', '');

  if(url.search('/nl/') == -1) url = newsURI;

  if(url.search('=') != -1) sign = '&';
 
  // get height of content area
  height = body.offsetHeight;
  if(height < 145) height = 145;

  if(navigator.appVersion.indexOf('MSIE 7.0') != -1){
    height += 28;
  } else {
    height += 5;
  }

  var iframe = document.createElement('iframe');
  iframe.id = 'adbar';
  iframe.src = '/ads' + url + sign + 'height=' + height;
  iframe.setAttribute('frameBorder', '0');
  iframe.style.height = height + 'px';

  adbarWrapper.appendChild(iframe);
} /*
  banners
*/

function initBanners(){
	// hide for old browsers
	if(!document.getElementById || !document.createElement) return;

	var li = document.getElementById('listContainer').getElementsByTagName('li');
	
	for(var i=0; i<li.length; i++){
		var a = li[i].getElementsByTagName('a');
		
		// there are always 2 anchors
		// first anchor has the link to a document or external url
		// second anchor has the src of the image
		a[0].setAttribute('imgSrc', a[1].href);
		li[i].removeChild(a[1]);
	}
	
	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('imageContainer').getElementsByTagName('a');
	
	// get the rest of the image that are loaded in the listBanners pagelet
	window.alternateImgs = document.getElementById('listContainer').getElementsByTagName('ul')[0].getElementsByTagName('a');			
	window.totalImages = window.alternateImgs.length + anchors.length;
	
	anchors[0].style.display = 'block';
	anchors[0].getElementsByTagName('img')[0].xOpacity = .99;
	anchors[0].getElementsByTagName('img')[0].onload = function(){
		window.loaded = 0;
		 // if there are more images availbale fade them in
		if(window.alternateImgs.length) addImage(window.alternateImgs[0].href, window.alternateImgs[0].getAttribute('imgSrc'));
		
		setTimeout(fadeBanners, 3000);
	}
}

function fadeBanners(){
	if(window.loading){
		setTimeout(fadeBanners, 3000);
		return;
	}
	
	cOpacity = anchors[current].getElementsByTagName('img')[0].xOpacity;
	nIndex = anchors[current+1]?current+1:0;
	nOpacity = anchors[nIndex].getElementsByTagName('img')[0].xOpacity;
	cOpacity -= .05;
	nOpacity += .05;
	
	anchors[nIndex].style.display = 'block';
	anchors[current].getElementsByTagName('img')[0].xOpacity = cOpacity;
	anchors[nIndex].getElementsByTagName('img')[0].xOpacity = nOpacity;
	
	setOpacity(anchors[current].getElementsByTagName('img')[0]); 
	setOpacity(anchors[nIndex].getElementsByTagName('img')[0]);
	
	if(cOpacity<=0){
		anchors[current].style.display = 'none';
		current = nIndex;

		if(window.alternateImgs.length > window.loaded){
			window.loading=true;
			addImage(window.alternateImgs[window.loaded].href, window.alternateImgs[window.loaded].getAttribute('imgSrc'));
		}
		
		setTimeout(fadeBanners,3000);
	}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(href, imgSrc){
	var newAnchor = document.createElement('a');
	newAnchor.href = href;
	
	var newImage = document.createElement('img');
	newImage.src = imgSrc;
	newImage.xOpacity = 0;
	
	newAnchor.appendChild(newImage);
	document.getElementById('imageContainer').appendChild(newAnchor);
	newAnchor.style.display =  'none';
	
	newImage.onload = function(){
		window.loading = false;
		window.anchors = document.getElementById('imageContainer').getElementsByTagName('a');
	}
	
	window.loaded++;
} /*
  datasheets
*/
function handleDatasheetList(object, action){
  var node = document.getElementById('datasheets').childNodes;
  var className = 'block';

  if(object){ node = object.childNodes; }
  
  if(action){ className = action; }
  
  for(var i=0; i < node.length; i++){
   if(node[i].nodeName.toLowerCase() == 'ul'){
    node[i].style.display = className;
    
    if(node[i].childNodes.length > 0){
     handleDatasheetList(node[i], 'none');
    }
   }
   
   if(node[i].nodeName.toLowerCase() == 'li'){
    if(node[i].childNodes.length > 0){
     handleDatasheetList(node[i], 'none');
    }
   }
   
   if(node[i].nodeName.toLowerCase() == 'a'){
    if(node[i].href.indexOf('javascript') == 0 || node[i].href == ''){
     node[i].parentNode.className = action;
    }
    
    if(node[i].href.indexOf('javascript') == 0){
     node[i].onclick = showList;
    }
   }
  }
}
 
function showList(){
  var nodes = this.parentNode.childNodes;
  var action = 'none';
  if(this.parentNode.className == 'none'){
   action = 'block';
  }
  
  for(var i=0; i<nodes.length; i++){
   if(nodes[i].nodeName.toLowerCase() == 'ul'){
    nodes[i].style.display = action;
   }
  }
  
  this.parentNode.className = action;
}

/*
function showListItems(object){
	var hash = object.href.substring(object.href.indexOf('#')+9, object.href.length);
	var array = hash.split('|');
	var li = '';
	
	try{
		for(var i = 0; i < array.length; i++){
			li = document.getElementById('datasheetGroup-'+array[i]);
			li.className = 'block';
			
			for(var j = 0; j < li.childNodes.length; j++){
			
				if(li.childNodes[j].nodeName.toLowerCase() == 'ul'){
					li.childNodes[j].style.display = 'block';
				}
			}
			
			while(li.parentNode.nodeName.toLowerCase() != 'div'){
				if(li.parentNode.nodeName.toLowerCase() == 'li'){
					li.parentNode.className = 'block';
					
					for(var k = 0; k < li.parentNode.childNodes.length; k++){
						if(li.parentNode.childNodes[k].nodeName.toLowerCase() == 'ul'){
							li.parentNode.childNodes[k].style.display = 'block';
						}
					}
				}
				
				li = li.parentNode;
			}
		}
	}catch(e){}
}*/ /*
  documentationShop
*/

var docItemCart = '';
var iframe = '';

function shoppingCartEdit(formID){
	var chkBox = document.getElementById(formID).getElementsByTagName('input');
	var insert = true;
	
	if(docItemCart.length > 0){
		docItemCart = '';
	}
	
	for(var i=0; i<chkBox.length; i++){
		
		if(chkBox[i].checked){
			docItemCart += chkBox[i].id + ',' + true + '|';
		}else{
			docItemCart += chkBox[i].id + ',' + false + '|';
		}
	}
	
	if(!iframe){
		iframe = document.createElement('iframe');
		iframe.name = 'shoppingCartIframe';
		document.getElementsByTagName('body')[0].appendChild(iframe);
		//iframe.style.display = 'none';
	}
	
	document.getElementById('docItemCart').value = docItemCart;
	document.getElementById('shoppingCartForm').submit();
}

function handleDownloadFilter(){
	var a = document.getElementById('documentationItemsList').getElementsByTagName('a');
	
	function checkFilter(){
		var className = this.className;
		
		if(className.indexOf('download') == -1){
			window.location.href = '/nl/home/login/';
			return false;
		}
	}
	
	for(var i = 0; i < a.length; i++){
		if(a[i].parentNode.className == 'pdf'){
			a[i].onclick = checkFilter;
		}
	}
}

function handleTabMenu(){
	var a = document.getElementById('documentationTabMenu').getElementsByTagName('a');
	var URIHash = window.location.hash.substring(1, 5);
	var documentationShop = document.getElementById('documentationShop');
	
	for(var i = 0; i < a.length; i++){
		a[i].onclick = handleHash;
	}

	if(URIHash == ''){
		documentationShop.className = 'tab1';
	}else{
		documentationShop.className = URIHash;
	}

}


function handleDatasheetButtons(){
	var td = document.getElementById('documentationItems').getElementsByTagName('td');
        
	for(var i = 0; i < td.length; i++){
		if(td[i].className == 'datasheet'){
			childNodes = td[i].childNodes;
		
			 for(var j = 0; j < childNodes.length; j++){
				if(childNodes[j].nodeName.toLowerCase() == 'a'){
					childNodes[j].onclick = handleHash;
				}
			 }
		}
	}
}

function handleHash(){
	var documentationShop = document.getElementById('documentationShop');
	var hash = this.href.substring(this.href.indexOf('#')+1, this.href.indexOf('#')+5);

	documentationShop.className = hash;

	if(this.parentNode.nodeName.toLowerCase() == 'td'){
		uncollapseFromHash(this);
	}
      
        initAdBar();

	this.blur();
}

function handleSubmit(value){
	var form = document.getElementById('documentationShopForm');
	var action = document.getElementById('action');
	
	action.value = value;
	
	form.submit();
} /*
  downloadFilter
*/
function handleDownloadFilter(){
	var a = document.getElementById('documentationItems').getElementsByTagName('a');
	
	for(var i=0; i < a.length; i++){
		if(a[i].parentNode.className == 'pdf'){
			a[i].onclick = checkFilter;
		}
	}
}

function checkFilter(){
  if(this.className.indexOf('allowDownload') == -1){
    window.location.href = '/nl/home/login/';
    return false;
  }
} function initExternalInfoPopups() {
	var pops = document.getElementsByClassName('externalInfo');
	for(var i=0; i <pops.length; i++) {
		var span= document.createElement('span');
		span.className = 'externalInfoPopup';
		var textContent = '';
		if (pops[i].getAttribute('title')) {
			textContent = pops[i].getAttribute('title');
			pops[i].removeAttribute('title');
		}
		var text = document.createTextNode(textContent);
		span.appendChild(text);
		pops[i].appendChild(span);
		pops[i].onmouseover= function() {
			spans = this.getElementsByTagName('span');
			for (var j=0; j<spans.length ; j++) {
				if(spans[j].className=='externalInfoPopup') {
					spans[j].style.display = 'block';
					spans[j].style.textDecoration = 'none';
				}
			}
			
		};
		pops[i].onmouseout=function() {
			spans = this.getElementsByTagName('span');
			for (var j=0; j<spans.length ; j++) {
				if(spans[j].className=='externalInfoPopup') {
					spans[j].style.display = 'none';
				}
			}

		};
	}

} /*
	fixPNG 2
*/

function fixPNG(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if(!(version >= 5.5) && !(version < 7) && !(document.body.filters)) return false;
	
	var headerImages = (document.getElementsByClassName('headertitle')) ? document.getElementsByClassName('headertitle') : '';
	var siteToolbarImages = (document.getElementsByClassName('siteToolbarCart')) ? document.getElementsByClassName('siteToolbarCart') : '';
	var locationsLogo = (document.getElementsByClassName('logo')) ? document.getElementsByClassName('logo') : '';
	var objectArray = [headerImages,siteToolbarImages, locationsLogo];

	for(var j = 0; j < objectArray.length; j++){
		var objects = objectArray[j];
		for(var i = 0; i < objects.length; i++){
			objects[i].onload = function(){
				var imgID = (this.id) ? "id='" + this.id + "' " : "";
				var imgClass = (this.className) ? "class='" + this.className + "' " : "";
				var imgTitle = (this.title) ? "title='" + this.title  + "' " : "title='" + this.alt + "' ";
				var imgStyle = "display:inline-block;" + this.style.cssText;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + this.width
					+ "px; height:" + this.height
					+ "px;" + imgStyle
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + this.src + "\', sizingMethod='scale');\"></span>";
				this.outerHTML = strNewHTML;
			}
		}
	}
}
 /*
  forms
*/
function initForms(){
	for(var i = 0; i < document.forms.length; i++){
		if(document.forms[i].id.indexOf('form-') != -1){

			for(var j = 0; j < document.forms[i].elements.length; j++){
				var element = document.forms[i].elements[j];
				
				switch(element.nodeName.toLowerCase()){
					
					// input[type=text]
					case 'input':
						
						switch(element.type.toLowerCase()){
							case 'text':
								if(element.value != ''){
									element.onfocus = function(){
										document.getElementById(this.id).select();
									}
								}
								
								break;
						}
						
						break;
					
					// textarea
					case 'textarea':
						if(element.value != ''){
							element.onfocus = function(){
								document.getElementById(this.id).select();
							}
						}
								
						break;
				}
				
			}
			
		}
	}
}
 /*
  general functions
*/

/*
  getcookie
*/
function getCookie(name){
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=");
		if (name == aCrumb[0]){
			return unescape(aCrumb[1]);
		}
	}
	
	return null;
}


/*
  XMLHttpRequest
*/
if (!window.XMLHttpRequest) {
	window.XMLHttpRequest = function() {
		var types = [
			'Microsoft.XMLHTTP',
			'MSXML2.XMLHTTP.5.0',
			'MSXML2.XMLHTTP.4.0',
			'MSXML2.XMLHTTP.3.0',
			'MSXML2.XMLHTTP'
		];

		for (var i = 0; i < types.length; i++) {
			try{
				return new ActiveXObject(types[i]);
			} catch(e) {}
		}
	
		return false; // XMLHttpRequest not supported
	}
}			


/*
  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;
}


/*
  findPos
*/
function findPos(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
} /*
  handleBodyLoad
*/

function handleBodyLoad(){

  // technivent popup
  // popupCookie();

  initMainNav();
  markLinks();
  initZebraTables();
  initForms();
  initImageText();
  doSIFR();
  initExternalInfoPopups();

/*  initCollapseSitemap('di1816');*/
  initCollapseSitemap('di8971');
  initCollapseSitemap('datasheets');
  uncollapseFromHash();

  fixPNG();
  initShadowOverlay();
  initSidebarWordbreak();
  initHeaderImgAndText();

  //onbeforeprint bericht
function handleOnBeforePrint(){
  if((document.getElementsByClassName('template-18').length) || (document.getElementsByClassName('template-7').length)){
    alert('Wij adviseren u de PDF te downloaden voor een beter printresultaat');
  }

  window.top.focus();
}

//window.onbeforeprint = handleOnBeforePrint;

//  searchAsYouType = new searchAsYouType();
//  searchAsYouType.initHandler('qGlobalSearch');
//  searchAsYouType.initHandler('q-0');

  
  document.getElementById('qGlobalSearch').value = 'Zoeken';
  document.getElementById('qGlobalSearch').onfocus = function(){
    if(this.value == 'Zoeken') this.value = '';
  }
  document.getElementById('qGlobalSearch').onblur = function(){
    if(this.value == '') this.value = 'Zoeken';
  }


/*
  documentationShop
*/
try{
  handleTabMenu();
  handleDatasheetButtons();
  handleDownloadFilter();
  
}catch(e){}

  initAdBar();
}

window.onload =   function() {

}
 /*
  initCollapseSitemap
*/

function initCollapseSitemap(prmDocId){
	if(!document.getElementById(prmDocId)) return;
	
	var lvlOne = document.getElementById(prmDocId).getElementsByTagName('ul')[0];
	lvlOne.className += ' collapseOn';
	var collapseListUl = lvlOne.getElementsByTagName('ul');

	// classifyDatasheetlinks
	if(prmDocId == 'datasheets'){
		var dsLinks = lvlOne.getElementsByTagName('a');
		for(var i = 0; i < dsLinks.length; i++){
			if(dsLinks[i].href.match('datasheets')){
				dsLinks[i].className += ' dsLink';
			} else {
				dsLinks[i].className += ' titleToggle';
			}
		}
	}

	if(!jsLoggedInCheck) return;
	
	for(var i = 0; i < collapseListUl.length; i++){
		if(collapseListUl[i].parentNode.className == 'd1' ||collapseListUl[i].parentNode.className == 'd1 '){
			collapseListUl[i].style.display = 'none';
		} else {
			collapseListUl[i].parentNode.className = 'collapseListClosed';
			
			var toggleLink;
			toggleLink = document.createElement('a');
			toggleLink.href = '';
			toggleLink.className = 'toggleAnchor';
			toggleLink.onclick = function(){
				var dsId = this.parentNode.id.replace('datasheetGroup-','');
				if(this.parentNode.className == 'collapseListClosed'){
					this.parentNode.className = 'collapseListOpen';
					if(window.location.hash.indexOf(dsId) == -1){
						window.location.hash = window.location.hash+'|'+dsId;
					}
				} else {
					this.parentNode.className = 'collapseListClosed';
					if(window.location.hash.indexOf(dsId)){
						window.location.hash = window.location.hash.replace('|'+dsId,'');
					}
				}
				return false;
			}
			collapseListUl[i].parentNode.insertBefore(toggleLink,collapseListUl[i].parentNode.firstChild);
		}
	}

	// Make links that dont have datasheetURLs (un)collapse
	var titleTogglers = document.getElementsByClassName('titleToggle');
	for(var i = 0; i < titleTogglers.length; i++){
		titleTogglers[i].href = '#';
		titleTogglers[i].onclick = function(){
			var dsId = this.parentNode.id.replace('datasheetGroup-','');
			if(this.parentNode.className == 'collapseListClosed'){
				this.parentNode.className = 'collapseListOpen';
				if(window.location.hash.indexOf(dsId) == -1){
					window.location.hash = window.location.hash+'|'+dsId;
				}
			} else {
				this.parentNode.className = 'collapseListClosed';
				if(window.location.hash.indexOf(dsId)){
					window.location.hash = window.location.hash.replace('|'+dsId,'');
				}
			}
			return false;
		}
	}
}
 /*
initHeaderImgAndText
*/

function initHeaderImgAndText(){
	
	var bottomAligned = new Array();
	
	var b1 = document.getElementsByClassName('photoText1bottom');
	var b2 = document.getElementsByClassName('photoText2bottom');
	var b3 = document.getElementsByClassName('photoText3bottom');
	var b4 = document.getElementsByClassName('photoText4bottom');

	for(i = 0; i < b1.length; i++){
		bottomAligned.push(b1[i]);
	}
	
	for(i = 0; i < b2.length; i++){
		bottomAligned.push(b2[i]);
	}
	
	for(i = 0; i < b3.length; i++){
		bottomAligned.push(b3[i]);
	}
	
	for(i = 0; i < b4.length; i++){
		bottomAligned.push(b4[i]);
	}
	
	if(bottomAligned.length == 0) return false;
	
	for(i = 0; i < bottomAligned.length; i++){
		var di = bottomAligned[i];
		var inner = di.getElementsByTagName('div')[0];
		var headerImg = di.getElementsByTagName('img')[0];
		
		if(headerImg) headerImg.style.display = 'none';
		if(headerImg) di.style.backgroundImage = 'url('+headerImg.src+')';
		
		inner.style.position = 'absolute';
		inner.style.bottom = '20px';
	}
} /*
initImageText
*/

function initImageText(){
	if(!jsLoggedInCheck) return;
	var p = document.getElementsByClassName('imageText');
	for(var i = 0; i < p.length; i++){
		if(p[i].nodeName.toUpperCase() == 'P'){
			p[i].parentNode.removeChild(p[i]);
		}
	}
} /*
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;
		}
	}
}



/*
initPasswordFocus
*/
function initPasswordFocus(elemId, elemValue){
	if(!document.getElementById(elemId)) return false;
	var elem = document.getElementById(elemId);
	
	elem.value = '';
	elem.style.display = 'none';
	
	var fauxPw = document.createElement('input');
	fauxPw.id = 'Faux'+elemId;
	fauxPw.value = elemValue;
	fauxPw.style.display = 'block';
	elem.parentNode.insertBefore(fauxPw,elem);
	
	fauxPw.onfocus = function(){
		this.blur();
		this.style.display = 'none';
		elem.style.display = 'block';
		elem.focus();
		elem.select();
	}


	elem.onfocus = function(){
		this.select();
	}
	
	elem.onblur = function(){
		if(this.value == ''){
			this.style.display = 'none';
			document.getElementById('Faux'+elemId).style.display = 'block';
			document.getElementById('Faux'+elemId).value = elemValue;
		}
	}
}




 /*
  main-nav menus delay
*/

function initMainNav() {
	var appName = navigator.appName;
	if(appName == 'Microsoft Internet Explorer'){
		var navVersion = navigator.appVersion.split(";");
		navVersion = navVersion[1].replace('MSIE ', '');
		if(navVersion <= 6.0){
			initMainNavOld();
		} else {
			initMainNavNew();
		}
	} else {
		initMainNavNew();
	}
	
	// hide UL's with hidden LI's
	var ULs = document.getElementById('main-nav').getElementsByTagName('ul'); //39
	for (i = 0; i < ULs.length; i++) {
		
		var ULchlds = ULs[i].childNodes;
		var hide = true;
		for (j = 0; j < ULchlds.length; j++) {
			if(!ULchlds[j].className.match('hide') && ULchlds[j].nodeName.toUpperCase() == 'LI'){
				hide = false;
			}
		}
		if(hide == true) ULs[i].className += ' hide';
	}
}
	
function initMainNavNew() {
	// only get those listitems with a child-ul	
	window.mainNavNodes = new Array();
	
	var ULnodes = document.getElementById('main-nav').getElementsByTagName('ul');
	
	for (i = 0; i < ULnodes.length; i++) {
		mainNavNodes.push(ULnodes[i].parentNode);
	}
	
	for (i = 0; i < mainNavNodes.length; i++) {

		// init out
		mainNavNodes[i].className += ' out';

		// over
		mainNavNodes[i].onmouseover = function(){

			// close others
			for (j = 0; j < mainNavNodes.length; j++) {
				if (mainNavNodes[j] != this) {
					mainNavNodes[j].className = mainNavNodes[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
		mainNavNodes[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');
				} 
			}, 600);
		}
	}
}


/*
  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';
				}
				
				nodes[i].onmouseout = function() {
					this.className = this.className.replace('hover', '');
				}
			}
		}
	}
}



 /*
initShadowOverlay
*/

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function switchShadowOverlay(onoff) {
var objOverlay = document.getElementById('overlay');
	var arrayPageSize =getPageSize(); 
	switch(onoff) {
		case 'on':
			objOverlay.style.height = (arrayPageSize[1] + 'px');
			objOverlay.style.display = 'block';
			break;
		default:
			objOverlay.style.display = 'none';	
	}
}

function initShadowOverlay() {
var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {
		if(document.getElementById('flvPlayerPopup')){
			document.getElementById('flvPlayerPopup').parentNode.removeChild(document.getElementById('flvPlayerPopup')); 
		}
		switchShadowOverlay('off');
		return false;
	}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '991';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
}


 /*
initSidebarWordbreak
*/

function initSidebarWordbreak(){
	if(!document.getElementById('sidenav')) return;

	var linkList = [['d1073', 'Tussenbouw schijf- terugslagkleppen'],
		['d1121', 'Perslucht- behandelingssets en toebehoren'],
		['d580', 'Stuurmagneet- ventielen 3-weg'],
		['d581', 'Stuurmagneet- ventielen 5-weg'],
		['d582', 'Stuurmagneet- ventielen Namur 3/5-weg'],
		['d567', 'drukverschil- manometers'],
		['d605', 'Temperatuur- regelaars'],
		['d606', 'Temperatuur- schakelaars'],
		['d607', 'Temperatuur- sensoren'],
		['d560', 'Vlotterdoorstro- mingsmeters'],
		['d559', 'Turbinedoorstro- mingsmeters'],
		['d985', 'doorstromings- schakelaars'],
		['d987', 'Vlotter- balschakelaars'],
		['d935', 'Brandstof/ olieslangen'],
		['d939', 'Riool- reinigingsslangen'],
		['d911', 'Stopbuspakkingen aramide en aramide/ PTFE/ grafiet'],
		['d1258', 'Metaalbewerkings- machines'],
		['d776', 'Flens- beschermingskappen'],
		['d1266', 'Bevestigings- materialen']];

	var sidebarLinks = document.getElementById('sidenav').getElementsByTagName('li');
	
	for(var i = 0; i < sidebarLinks.length; i++){
		for(var j = 0; j < linkList.length; j++){
			if(sidebarLinks[i].className.indexOf(linkList[j][0]) != -1){
				sidebarLinks[i].getElementsByTagName('em')[0].innerHTML = linkList[j][1];
			}
		}
	}
}

 /*
initZebraTables
*/

function initZebraTables(){

	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';
		}

		if(rows[i].cells.length){
			rows[i].cells[0].className += ' firstCell';
		}
	}


	var theads = document.getElementsByTagName('thead');
	for(var i = 0; i< theads.length; i++){
		if(theads[i].rows.length){
			theads[i].rows[0].className += ' firstRow';
			theads[i].rows[theads[i].rows.length-1].className += ' lastRow';
		}
	}


	var tbodies = document.getElementsByTagName('tbody');
	for(var i = 0; i< tbodies.length; i++){
		if(tbodies[i].rows.length){
			tbodies[i].rows[0].className += ' firstRow';
			tbodies[i].rows[tbodies[i].rows.length-1].className += ' lastRow';
		}
	}


	var tFoots = document.getElementsByTagName('tfoot');
	for(var i = 0; i< tFoots.length; i++){
		if(tFoots[i].rows.length){
			tFoots[i].rows[0].className += ' firstRow';
			tFoots[i].rows[tFoots[i].rows.length-1].className += ' lastRow';
		}
	}

}


 /*
	MAIL THIS PAGE
*/
var mailThisPageWrapper;
function mailThisPage(){
	var lang = document.getElementsByTagName('html')[0].getAttribute('lang');
	var popupWidth = 420;

	if(!mailThisPageWrapper){
		var html = '';
		
		mailThisPageWrapper = document.createElement('div');
		mailThisPageWrapper.className = 'mailThisPageWrapper';
		mailThisPageWrapper.style.height = '0px';
		mailThisPageWrapper.style.width = '0px';
		document.getElementById('sendtofriend').appendChild(mailThisPageWrapper);
		
		// position of wrapper
		var xPos = document.body.clientWidth;
		xPos = parseInt((xPos / 2) - (popupWidth/2));
		mailThisPageWrapper.style.left = xPos + 'px';

		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 width = mailThisPageWrapper.style.width;
			width = parseInt(width.replace('px', ''));
			width = width + 20;
		var height = mailThisPageWrapper.style.height;
			height = parseInt(height.replace('px', ''));
			height = height + 15;
		
		if(width >= popupWidth) return false;
		
		mailThisPageWrapper.style.height =  height + 'px';
		mailThisPageWrapper.style.width =  width + 'px';
		
		if(width < popupWidth){
			setTimeout('mailThisPage()', 0);
		}
		
	}
	
}

function closeMailThisPage(){
	document.getElementById('sendtofriend').removeChild(mailThisPageWrapper);
	mailThisPageWrapper = null;
}


 /*
 mark links
*/
function markLinks(){
	var links = document.getElementsByTagName('a');
	var link, uri, href, mark, nodeName, nodeID;

	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){
					uri = decodeURI(link.getAttribute('href')).toLowerCase();
					href = uri.substring((uri.length - 4), (uri.length));

					switch(href){
						case '.pdf':
							link.className += ' pdf';
							mark = document.createElement('img');
                                                        mark.className = 'externalImage';
							mark.src = '/data/link-icons/pdf.png';
							link.insertBefore(mark , (link.firstChild));
							link.onclick = handleDownloadClick;
							break;
						
						case '.xls':
							link.className += ' xls';
							mark = document.createElement('img');
							mark.src = '/data/link-icons/xls.png';
							link.insertBefore(mark , (link.firstChild));
							link.onclick = handleDownloadClick;
							break;
							
						case '.doc':
							link.className += ' pdf';
							mark = document.createElement('img');
                                                        mark.className = 'externalImage';
							mark.src = '/data/link-icons/doc.png';
							link.insertBefore(mark , (link.firstChild));
							link.onclick = handleDownloadClick;
							break;
							
						case '.ppt':
							link.className += ' pdf';
							mark = document.createElement('img');
                                                        mark.className = 'externalImage';
							mark.src = '/data/link-icons/ppt.png';
							link.insertBefore(mark , (link.firstChild));
							link.onclick = handleDownloadClick;
							break;
							
						default:
							nodeName = link.parentNode.parentNode.nodeName ? link.parentNode.parentNode.nodeName.toLowerCase() : '';
							nodeID = link.parentNode.parentNode ? link.parentNode.parentNode.id.toLowerCase() : '';
							
							if(uri.indexOf('tradcom') != -1 && nodeName == 'ul' && nodeID == 'main-nav'){
								if(ERIKSSessionID.length > 0){
                                                                        if(uri.indexOf('?') != -1){
									  link.href += '&sessionID=' + ERIKSSessionID;
                                                                        }else{
									  link.href += '?sessionID=' + ERIKSSessionID;
                                                                        }
								}
							}  
							
							mark = document.createElement('img');
							mark.className = 'externalImage';
							mark.src = '/data/link-icons/external.png';
							link.appendChild(mark);
							link.onclick = handleExternalSiteClick;
							break;
				}
			}
		}
	}
	
	mark = null;
	uri = null;
	href = null;
	link = null;
	links = null;
	nodeName = null;
	nodeID = null;
}

function handleDownloadClick(){
	if(typeof pageTracker._trackPageview == 'function'){
		pageTracker._trackPageview(this.href);
	}
}

function handleExternalSiteClick(){
	if(typeof pageTracker._trackPageview == 'function'){
		pageTracker._trackPageview('/externalSites/' + this.href);
	}
}

 /*
  myEriks
*/

function handleLogin(){
	window.location = '/nl/home/login/';
}

function handleLogout(){
	window.location = '/controllers/sessionValidator.cfc?method=logout';
}

function handleMyDetails(){
  window.location = '/nl/home/myDetails/';
}
 /*
  openFlashPlayerMovie
*/

function openFlashPlayerMovie(swfPath,flvPath,flvPopupWidth,flvPopupHeight){

	switchShadowOverlay('on');

	if(swfPath.indexOf('?')) swfPath = swfPath.split('?')[0];
	
	if(document.getElementById('flvPlayerPopup')){
		fpp = document.getElementById('flvPlayerPopup');
	} else {
		fpp = document.createElement('div');
		fpp.id = 'flvPlayerPopup';
		fpp.style.display = 'none';

		var fppHeader = document.createElement('div');
		fppHeader.id = 'flvPlayerHeader';
		fpp.appendChild(fppHeader);
		
		var fppClose = document.createElement('a');
		fppClose.innerHTML = '<em>Sluiten</em>';
		fppClose.href = '#';
		fppClose.onclick = function(){
			switchShadowOverlay('off'); 
			document.getElementById('flvPlayerPopup').parentNode.removeChild(document.getElementById('flvPlayerPopup')); 
			return false; 
		}
		fppHeader.appendChild(fppClose);
		
		var fppFlashHolder = document.createElement('div');
		fppFlashHolder.id = 'flvPlayerHolder';
		fpp.appendChild(fppFlashHolder);
		
		document.body.appendChild(fpp);
		
		var fppSWFObject = new SWFObject(swfPath+'?flvPath='+flvPath+'&popupWidth='+flvPopupWidth+'&popupHeight='+flvPopupHeight+'&isPopup=true', 'flvPlayerHolder-flashembed', flvPopupWidth, flvPopupHeight, 'false', '8');
		fppSWFObject.addParam('wmode', 'transparent');
		fppSWFObject.addParam('salign', 'T');
		fppSWFObject.addParam('menu', 'false');
		fppSWFObject.addParam('quality', 'high');
		fppSWFObject.write('flvPlayerHolder');
		
	}

	// position y of wrapper
	var Geometry = {};
	if(window.innerWidth) { //All but IE
		Geometry.getVerticalScroll = function() { return window.pageYOffset; };
	} else if (document.documentElement && document.documentElement.clientWidth) { //IE6 with doctype
		Geometry.getVerticalScroll = function() { return document.documentElement.scrollTop; };
	} else if (document.body.clientWidth){
		Geometry.getVerticalScroll = function() { return document.body.scrollTop; };
	}
	var yPos = Geometry.getVerticalScroll();
	document.getElementById('flvPlayerPopup').style.top = 100+yPos + 'px';

	document.getElementById('flvPlayerPopup').style.display = 'block';
	document.getElementById('flvPlayerPopup').style.zIndex = '999';
	document.getElementById('flvPlayerPopup').style.position = 'absolute';
	document.getElementById('flvPlayerPopup').style.left = '50%';
	document.getElementById('flvPlayerPopup').style.marginLeft = (flvPopupWidth/2)*-1 +'px';
	document.getElementById('flvPlayerPopup').style.width = flvPopupWidth+'px';
	document.getElementById('flvPlayerPopup').style.overflow = 'auto';
	document.getElementById('flvPlayerPopup').style.paddingBottom = '20px';
	document.getElementById('flvPlayerPopup').style.backgroundColor = '#ffffff';
	document.getElementById('flvPlayerPopup').style.border = '4px #0071bd solid';
	
}


 	/*
     Pagetracking for google analytics
	*/       
function pagetracking() {
// set the end date stamp
	var plend = new Date();

	// calculate the elapsed time between the start and the end. 
	// This is in milliseconds
	var plload = plend.getTime() - plstart.getTime();
	
	// determine the load thresholds
	
	if(plload<500) // less than 500 ms is very fast
		lc = "< 500 ms";
	else if (plload< 1000) // < 1 sec
		lc = "< 1 sec";
	else if (plload< 2000) // < 2 sec
		lc = "< 2 sec";
	else if (plload< 3000) // < 3 sec
		lc = "< 3 sec";
	else if (plload< 5000) // < 5 sec
		lc = "< 5 sec";
	else if (plload<10000) // < 10 sec
		lc = "< 10 sec";
	else if (plload<15000) // < 15 sec
		lc = "< 15 sec";
	else if (plload<20000) // < 20 sec
		lc = "< 20 sec";
	else if (plload<25000) // < 25 sec
		lc = "< 25 sec";
	else if (plload<30000) // < 30 sec
		lc = "< 30 sec";
	else if (plload<45000) // < 45 sec
		lc = "< 45 sec";
	else if (plload<60000) // < 60 sec
		lc = "< 60 sec";
	else
		lc="> 60 sec "; // wow more than a minute
	// capture the URL that we are going to record
	var fn = document.location.pathname;
	if( document.location.search)
		fn += document.location.search;

 	// track this as a page view in ga.js
	try
	{
		pageTracker2._trackEvent("Page Load",lc + "  Loading Pages", fn, Math.round(plload/1000));
		// replace pageTracker with the appropriate 
		// object name (e.g. pageTracker2)

	}
	catch(err)
	{
		
	}
} /*
	popupCookie technivent
*/
function popupCookie(){

	// clear cookie
	// document.cookie = "sessionStart=false;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/";

	
	if(document.cookie.match('sessionStart=')){
		// cookie found
		return false;
	} else {
		// no cookie found
		// create popup

		var html = '';
		html += '<a class="close" href="javascript:closeTechnivent();"><em>Sluiten</em></a>';
		html += '<a href="http://www.technivent.nl/" target="_blank">';
		html += '<img src="/img/tv-popup.gif"/>';
		html += '</a>';
		
		tPopup = document.createElement('div');
		tPopup.id = 'tPopup';
		tPopup.innerHTML = html;
		document.body.appendChild(tPopup);

		tOverlay = document.createElement('div');
		tOverlay.id = 'tOverlay';

		var body = document.body,
		html = document.documentElement;
		var docH = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
		tOverlay.style.height = docH+'px';
		document.body.appendChild(tOverlay);
		
		// set cookie
		document.cookie = "sessionStart=false;path=/"; 
	}
}

function closeTechnivent(){
	document.getElementById('tPopup').style.display = 'none';
	document.getElementById('tOverlay').style.display = 'none';
}

 /*
  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, name, sFeatures, iWidth, iHeight){
	var iLeft	= (screen.availWidth - iWidth) / 2;
	var iTop	= (screen.availHeight - iHeight) / 2;
	
	return window.open(sURL, name, sFeatures + ', width=' + iWidth + ', height=' + iHeight + ', left=' + iLeft + ', top=' + iTop);
} /*
  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, name, sFeatures, iWidth, iHeight){
	var iLeft	= (screen.availWidth - iWidth) / 2;
	var iTop	= (screen.availHeight - iHeight) / 2;
	
	return window.open(sURL, name, sFeatures + ', width=' + iWidth + ', height=' + iHeight + ', left=' + iLeft + ', top=' + iTop);
} /*	sIFR v2.0.7
	Copyright 2004 - 2008 Mark Wubben and Mike Davidson. Prior contributions by Shaun Inman and Tomas Jogin.
	
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.substr(b.indexOf(".")-2,2),10)>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("(\\s|^)"+k[1]+"(\\s|$)")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("(\\s|^)"+f[3]+"(\\s|$)")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m&&g.match(/.*gecko\/(\d{8}).*/))f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d&&g.match(/.*opera(\s|\/)(\d+\.\d+)/))f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a&&g.match(/.*applewebkit\/(\d+).*/))f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.substr(aj.indexOf(".")-2,2),10)}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<312)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312);return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&(f.p||f.n)))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||al.getElementsByTagName("body").length==0)return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+="</a>"}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){if(!f.g){if(!f.n)p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");else p.innerHTML=['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" sifr="true" width="',V,'" height="',W,'" class="sIFR-flash"><param name="movie" value="',J,'"></param><param name="flashvars" value="',Z,'"></param><param name="quality" value="best"></param><param name="wmode" value="',T,'"></param><param name="bgcolor" value="',N,'"></param> </object>'].join('')}else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)){
	sIFR.setup();
}; /*
	SIFR
*/


function doSIFR(){
  if(typeof sIFR == "function"){

       sIFR.replaceElement(named({sSelector:".photoText1 h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

       sIFR.replaceElement(named({sSelector:".photoText2 h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

       sIFR.replaceElement(named({sSelector:".photoText3 h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

       sIFR.replaceElement(named({sSelector:".photoText4 h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));
       sIFR.replaceElement(named({sSelector:".photoText1bottom h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

       sIFR.replaceElement(named({sSelector:".photoText2bottom h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

       sIFR.replaceElement(named({sSelector:".photoText3bottom h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

       sIFR.replaceElement(named({sSelector:".photoText4bottom h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#ffffff", 
		sLinkColor:"#ffffff", 
		sBgColor:"#ffffff", 
		sHoverColor:"#ffffff", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));




       sIFR.replaceElement(named({sSelector:".content h2 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#19539d", 
		sLinkColor:"#19539d", 
		sBgColor:"#fff", 
		sHoverColor:"#19539d", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

/*
	sIFR.replaceElement(named({sSelector:"#tradcomSearch h2", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#19539d", 
		sLinkColor:"#19539d", 
		sBgColor:"#fff", 
		sHoverColor:"#19539d", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));
*/

	sIFR.replaceElement(named({sSelector:"#eriksSearch h2", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#19539d", 
		sLinkColor:"#19539d", 
		sBgColor:"#fff", 
		sHoverColor:"#19539d", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"
		}));

	

         sIFR.replaceElement(named({sSelector:".content h3 span", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#19539d", 
		sLinkColor:"#19539d", 
		sBgColor:"#fff", 
		sHoverColor:"#19539d", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"

   		}));

         sIFR.replaceElement(named({sSelector:".content #myDetails h3", 
		sFlashSrc:"/scripts/tahoma.swf", 
		sColor:"#19539d", 
		sLinkColor:"#19539d", 
		sBgColor:"#fff", 
		sHoverColor:"#19539d", 
		nPaddingTop:0, 
		nPaddingBottom:0, 
		sFlashVars:"", 
		sCase:"", 
		sWmode:"transparent"

   		}));




	
  }
} /*
  uncollapseFromHash
*/

function uncollapseFromHash(pHash){
	if(!document.getElementById('datasheets')) return false;

	var dsHash = window.location.hash.split('|');

	if(pHash){
		dsHash = pHash.href.split('|');
	}

	if(!jsLoggedInCheck) return;

	if(dsHash.length >= 3){
		for(i = 0; i < dsHash.length; i++){
			if(document.getElementById('datasheetGroup-'+dsHash[i])){
				var openDsGroup = document.getElementById('datasheetGroup-'+dsHash[i]);
				openDsGroup.className = 'collapseListOpen';
				openParentGrp(openDsGroup);
			}
		}
	}


/*
	if(dsHash.length >= 3){
		var openDsGroup = document.getElementById('datasheetGroup-'+dsHash[dsHash.length-1])
		openDsGroup.className = 'collapseListOpen';
		
		openParentGrp(openDsGroup);
		
	}
*/
}


function openParentGrp(thisNode){
	if(thisNode.parentNode.id.match('datasheetGroup-')){
		thisNode.parentNode.className = 'collapseListOpen';
	}
	
	if(thisNode.parentNode.id == 'datasheets'){
		return;	
	} else {
		openParentGrp(thisNode.parentNode);	
	}
} getVacancies = function(){
	var url = '/controllers/vacancyGrid.cfc';
	
	selectedCompany = 0;
	selectedFunctionGroup = 0;
	selectedRegion = 0;
	
	var i = 0;
        if($('#languageCode').val() != '') {
                languageCode = $('#languageCode').val();
        }

        if($('#languageid').val() != '') {
                languageID = $('#languageid').val();
        }

	if ($('#byCompany').val() > 0) {
		selectedCompany = $('#byCompany').val();
	}
	if ($('#byFunctionGroup').val() > 0) {
		selectedFunctionGroup = $('#byFunctionGroup').val();
	}
	if ($('#byRegion').val() > 0) {
		selectedRegion = $('#byRegion').val();
	}
	var data = {method:'getVacancies', companyID:selectedCompany, functionGroupID:selectedFunctionGroup, regionID:selectedRegion, languageID:languageID, languageCode: languageCode};
	$.post(url, data, displayVacancies);
}

displayVacancies = function(result){
	var data = eval(result);
	
	var vacancyHTML = '';
	rowclass = 'odd';
	for(i=0;i<data.length;i++) {
		uri = data[i].TITLE;
		uri = uri.toLowerCase();
		uri = uri.replace(" ","-");
		vacancyHTML = vacancyHTML + '<li onclick="window.location=\'/' + data[i].CODE + '/vacatures/' + uri + '\'">';
		vacancyHTML = vacancyHTML + '<div class="vacancyintroduction vacancycontent">';
		vacancyHTML = vacancyHTML + '<h2><span>' + data[i].TITLE;
                if (data[i].HOURS > 0) {
                    vacancyHTML = vacancyHTML + ' (' + data[i].HOURS + ' uur per week)</span></h2>';
                } else {
                    vacancyHTML = vacancyHTML + '</span></h2>';
                }
		vacancyHTML = vacancyHTML + '<h3><span>' + data[i].CITY + '</span></h3>';
		vacancyHTML = vacancyHTML + data[i].INTRO;
		vacancyHTML = vacancyHTML + '</div>';
if (data.THUMBNAIL != '') {
                vacancyHTML = vacancyHTML + '<div class="functionGroupImage">';
                vacancyHTML = vacancyHTML + '<img src="http://admin.eriksgroup.com/jobs/img/functiongroups/' + data[i].THUMBNAIL + '" alt="' + data.FUNCTIONGROUPTITLE + '">';
                vacancyHTML = vacancyHTML + '</div>';
}
                vacancyHTML = vacancyHTML + '<div class="clear"></div>';
		vacancyHTML = vacancyHTML + '</li>';
	}
	
	$('#vacancylist').html(vacancyHTML);
        doSIFR();
}

