if(!window.cmn) var cmn={}

/**
 * Displays body after onload
 *
 * @type void
 */
cmn.displayBody = function(){
var w, show = function(){window.setTimeout(function(){document.body.style.visibility="visible"},10)}
	this.attachEvent(window, "load", show);

};

/**
 * Attachs event to object
 * 
 * @param obj Object
 * @param evn String event name
 * @param func Function event handler function
 * @type void
 */
cmn.attachEvent = function(obj, evn, func){
	if(obj.attachEvent) obj.attachEvent("on"+evn, func);
	else if(obj.addEventListener) obj.addEventListener(evn, func, false);
};

function divideUls(){
		var c = 0;
		var uls = document.getElementsByTagName("ul");
		for(var i=0;i<uls.length;i++){
			if(uls[i].className=="twoColumns" && uls[i].id.indexOf(String("__dividedUL_"+c))!=0){
				c++;
				divideList(uls[i],2,String("__dividedUL_"+c));
			}
		}
		//var c = 0;
		var ols = document.getElementsByTagName("ol");
		for(var i=0;i<ols.length;i++){
			if(ols[i].className=="twoColumns" && ols[i].id.indexOf(String("__dividedUL_"+c))!=0){
				c++;
				divideList(ols[i],2,String("__dividedUL_"+c));
			}
		}
}
function divideList(parentId,n,prefix){
	var counter=1;
	var tag=(typeof parentId=="string")?document.getElementById(parentId):parentId;
	var ch = getChildren(tag);
	var childrenStartCount = ch.length;
	if(tag.tagName=="DL") assignSubChildren(ch);
	var olStart=1;
	for(var x=n;x>1;x--){
		var arrA = getChildren(tag);
		var newTag = document.createElement(tag.tagName);
		var dividedListnum = Math.ceil(arrA.length/x);
		if(tag.tagName=="OL"){
			olStart+=dividedListnum;
			newTag.start = olStart;
		}
		newTag.id = prefix+counter;		
	    newTag.className = tag.className;
		if(tag.nextSibling) tag.parentNode.insertBefore(newTag,tag.nextSibling);
		else tag.parentNode.appendChild(newTag);	
		
		for(i=dividedListnum;i<arrA.length;i++){
			var newChild = arrA[i].cloneNode(true);
			appendNewChild(newTag.id,newChild);
		}
		for(var j=arrA.length-1;j>=dividedListnum;j--){
			if(arrA[j].removeNode) arrA[j].removeNode(true);
			else if(arrA[j].parentNode.removeChild) arrA[j].parentNode.removeChild(arrA[j]);
		}
		tag = document.getElementById(newTag.id);
		counter++;
		initLinkManager(newTag.id);
	}
	if(tag.tagName=="DL") appendSubChildren(n,prefix);
}

function getChildren(o){
	if(o.tagName=="UL" || o.tagName=="OL") return o.getElementsByTagName("LI");
	else if(o.tagName=="DL") return o.getElementsByTagName("DT");
}

function assignSubChildren(dtArr){
		var resArr = [];
		for(var i=0;i<dtArr.length;i++){
			var ddArr = [];
			dtArr[i].setAttribute("__index__",String(i))
			var dd = dtArr[i].nextSibling;
			while(dd){
				if(dd && dd.tagName && dd.tagName=="DT") break;
				if(dd.tagName && dd.tagName=="DD"){
					ddArr[ddArr.length] = dd;
				}
				dd = dd.nextSibling;
			}
			resArr[resArr.length] = [String(i),ddArr];
		}
		window.tempNodesArray = resArr;
}

function appendNewChild(newTagId,o){
	if(o.tagName=="LI") document.getElementById(newTagId).appendChild(o);
	else if(o.tagName=="DT"){
		document.getElementById(newTagId).appendChild(o);
	}
}

function appendSubChildren(n,prefix){
	for(var z=1;z<n;z++){
		var dl = document.getElementById(prefix+z);
		var dtChildren = dl.getElementsByTagName("DT");
		for(var v=0;v<dtChildren.length;v++){
			for(var i=0;i<window.tempNodesArray.length;i++){
				if(window.tempNodesArray[i][0]==dtChildren[v].getAttribute("__index__")){
					for(var j=0;j<window.tempNodesArray[i][1].length;j++){
						var cloneDD = window.tempNodesArray[i][1][j].cloneNode(true);
						if(window.tempNodesArray[i][1][j].removeNode) window.tempNodesArray[i][1][j].removeNode(true);
						else if(window.tempNodesArray[i][1][j].parentNode.removeChild) window.tempNodesArray[i][1][j].parentNode.removeChild(window.tempNodesArray[i][1][j]);
						if(dtChildren[v+1]){
							dl.insertBefore(cloneDD,dtChildren[v+1]);
						}else{
							dl.appendChild(cloneDD);
						}
					}
					break;
				}
			}
		}
	}
}
	
function initLinkManager(parentId) {
	var tag=document.getElementById(parentId);
	var anchors = tag.getElementsByTagName("A");
    for(var i=0; i<anchors.length; i++){
    	var atag = anchors[i];
    	if ( atag.className == 'listItem' ) {
   	    	atag.onclick=insertLink;
    	}
	}	
}

function initLinkManagerN(parentId, n) {	
    var pID = parentId;
    for (var j=1; j<=n; j++) {        
        tag = document.getElementById(parentId);
        var anchors = tag.getElementsByTagName("A");
        for(var i=0; i<anchors.length; i++){
            var atag = anchors[i];
            if ( atag.className == 'listItem' ) {
                atag.onclick=insertLink;
            }
        }        
        parentId = pID + j;        
    }
}


function makeRelativeURL(url){
	var str = url.split("://")[1];
  str = str.substr(str.indexOf("/"));
  return str;
}


function insertLink() {
	var url = this.href;
    var w = window;
    var place = null; 
    if(w.place){
        place = w.place;
    }else if(w.opener && opener.window.place){
        place = opener.window.place;
    }        
    if (place) {
        place.setLink(makeRelativeURL(url));
        w.close();
    }
    return false;
}

function initLinkManagerIPC(parentId, n) {	
    var pID = parentId;    
    for (var j=1; j<=n; j++) {        
        tag = document.getElementById(parentId);
        var anchors = tag.getElementsByTagName("A");
        for(var i=0; i<anchors.length; i++){
            var atag = anchors[i];
            if ( atag.className == 'listItem' ) {
                atag.onclick=insertLabel;
            }
        }        
        parentId = pID + j;        
    }
}

function insertLabel() {
	var url = this.name;
    var w = window;
    var place = null; 
    if(w.place){
        place = w.place;
    }else if(w.opener && opener.window.place){
        place = opener.window.place;
    }        
    if (place && url) {
        place.setLink(url);
        w.close();
    }
    return false;
}

function changeRatingsState(ratingsAverage, fullImg, halfImg, emptyImg, item, state) {
	var ratingsInt = parseInt(String(ratingsAverage).split('.')[0]);
	var ratingsHalf = String(ratingsAverage).split('.')[1];
	 if(String(ratingsAverage).split('.')[1]!=null && String(String(ratingsAverage).split('.')[1]).length>=1){
	  ratingsHalf = String(ratingsAverage).split('.')[1].charAt(1);
	 }
	var i = 0;
	if(ratingsInt > 0 && ratingsInt <= 5) {			
		for(i=1 ; i<= ratingsInt ; i++) {
			document.getElementById(state + String(i) + item).style.background = fullImg;
		}
		ratingsInt = parseInt(ratingsInt) + 1;
		if(ratingsHalf >= '5' && ratingsHalf <= '9') {
			document.getElementById(state + String(ratingsInt) + item).style.background = halfImg;				
			ratingsInt = parseInt(ratingsInt) + 1;
		}
		for(i=ratingsInt; i<=5 ; i++) {
			document.getElementById(state + String(i) + item).style.background = emptyImg;			
		}
	} else {
		for(i=1 ; i<= 5 ; i++) {
		 	var emptyObj = document.getElementById(state + String(i) + item);
   			if ( emptyObj != null ){
			    emptyObj.style.background = emptyImg;
   			}
		}
	}
}
function changeRatingsStateOnMouseOver(starNumber, lightImg, item) {
	var i = 0;
	for(i=1 ; i<= starNumber ; i++) {
		document.getElementById(String(i) + item).style.background = lightImg;
	}
}

/**
* Browser tools
*/
function addToFavorites() {
 
  if (window.external) 
	  window.external.AddFavorite(location.href,document.title);
  else  
  if (window.sidebar)
    window.sidebar.addPanel(document.title,location.href, "");
}
function makeCurrentPageStartPage(obj) {
	if (window.external) {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(location.href);
  } else {
		alert("Your browser doesn't support this function.");
  }
}
/**
* Popup functions
*/
function openModalPopup(a, w, h, name, sc, st){
	if ( !w ) {
		w = 650;
	}
	sc=sc?"yes":"no";
	st=st?"yes":"no";
	if ( !h ) {
		h = 600;
	}
	if ( !name ) {
		name = "";
	}
	
	if(typeof a=="object" && a.tagName=="A"){
		var href=a.href;
	}else if(typeof a=="string"){
		var href=a;
	}
	var attributes="width="+w+", height="+h+", scrollbars="+sc+", status="+st;
	var _wpopup_ = window.open(href, name, attributes);
	   
	window.onfocus=function(){ try{ if(!_wpopup_.closed) _wpopup_.focus(); }catch(e){} }
	return _wpopup_;
}
function openModalPopupWithAttrs(a,name,attrs){
	if(typeof a=="object" && a.tagName=="A"){
		var href=a.href;
	}else if(typeof a=="string"){
		var href=a;
	}
	var _wpopup_ = window.open(href, name, attrs);
	   
	window.onfocus=function(){ try{ if(!_wpopup_.closed) _wpopup_.focus(); }catch(e){} }
	return _wpopup_;
}
function closeModalPopup(windowObject) {
  windowObject.close();
}

if(!window.ps) var ps={}

/**
 * Displays body after onload
 *
 * @type void
 */
ps.displayBody = function(){
	var w, show = function(){document.body.style.visibility="visible"}
	this.attachEvent(window, "load", show);
};

/**
 * Attachs event to object
 * 
 * @param obj Object
 * @param evn String event name
 * @param func Function event handler function
 * @type void
 */
ps.attachEvent = function(obj, evn, func){
	if(obj.attachEvent) obj.attachEvent("on"+evn, func);
	else if(obj.addEventListener) obj.addEventListener(evn, func, false);
};
//ps.displayBody();

function moveImage(){
	var divs = document.body.getElementsByTagName("DIV");
	for(var i=0;i<divs.length;i++){
		if(divs[i].className=="elsAnkeilerBottomLeftImage" || divs[i].className=="elsAnkeilerBottomRightImage"){
			var height = divs[i].offsetHeight;
			var divImages = divs[i].getElementsByTagName("DIV");
			for(var j=0;j<divImages.length;j++){
				if(divImages[j].className=="imgLeft"){
					divImages[j].style.marginTop = height -divImages[j].offsetHeight+10+ "px";
				}
			}
		}
	}
}
ps.attachEvent(window,"load",moveImage);

function isLink(/* string */ link){
	return StringStartsWith(link, "http://")||StringStartsWith(link, "https://")||StringStartsWith(link, "ftp://");
}

function StringStartsWith(/* string */ link, prefix){
	return link.indexOf(prefix)==0;
}

function tryDelete() {
  return confirm( "Are you sure you want to remove this item?" );
}
function tryDeleteExt(/* string */ confText) {
  return confirm(confText);
}
if(window.opener && window.opener.previewInAction){
    window.opener.previewInAction = false;
    window.onload = function(){
        var el = document.body.getElementsByTagName("*");
        document.body.onmouseup=function(e){if(confirm("The preview window is readonly, do you want to close the window ?"))window.close();return false}
        for(var i=0;i<el.length;i++){
            el[i].onmousedown=function(){return false}
            el[i].onclick=function(){return false}
            el[i].onkeydown=function(){return false}
        }
    }
}

function changeState(showAddComment,reaction){   
	 document.getElementById('showAddComment').style.display = showAddComment;
	 document.getElementById('reaction').style.display = reaction; 
}

  function submitParentPreview(varform) {
  	if ( window.previewInAction ) {
  		return false;
  	}
  	window.previewInAction = true;
  	
	var popup = openModalPopup("about:blank", 1024, 768, "preview",1,1);
    
	varform.target='preview';
	if ( !varform.saveAction ) {
		varform.saveAction = varform.action;
	}
	varform.action=previewURL;
	    //window.close();
  	//window.previewInAction = false;
	return true;
  }
  
  function restoreAfterPreview(varform) {
  	if ( window.previewInAction ) {
  		window.previewInAction = false;
  	}
  	try{
	  	varform.target = backupTarget;
	  	varform.action = backupAction;
  	}catch(e){}
  	return true;
  }

  function submitParentSave (varform) {
	  varform.target='_self';
	  if ( varform.saveAction ) {
		  varform.action=varform.saveAction;
		  varform.saveAction=null;
	  }
	  return true;
  }
  
  /*(boolean)
  function toggleAll( expand) {
    var elements = document.getElementsByTagName('div');
    for(var i = 0; i < elements.length; i++ ) {
      if (elements[i].id.length > 8 && elements[i].id.substring(0, 8) == "tinymce_") {
        var image = document.getElementById(elements[i].id + "_toggleButton");
        if (expand) {
          elements[i].style.display="block";
          image.src=__imagePath+"less.gif";
        } else {
          elements[i].style.display="none";
          image.src=__imagePath+"more.gif";
        }
      }
    }
  }
  
  (String)	
  function toggle(containerId) {
    var container = document.getElementById(containerId);
    var image = document.getElementById(containerId + "_toggleButton");
    if ( container.style.display=="none" ) {
	    container.style.display="block";
	    image.src=__imagePath+"less.gif";
    } else {
	    container.style.display="none";
	    image.src=__imagePath+"more.gif";
    }
  }
  */
  
  function fillRtfTextareas(){
    for(var i=0;i<rtfArray.length;i++){
        var rtf = rtfArray[i][0];
        var txtarea = document.getElementById(rtfArray[i][1]);
        txtarea.value = rtf.getHTML();
    }
  }
  
   function fillTinyMCETextareas(){
    for(var i=0;i<tinymceArray.length;i++){
        var textareaid = tinymceArray[i];
        var txtarea = document.getElementById(textareaid);
        txtarea.value = tinyMCE.getInstanceById(textareaid).getBody().innerHTML;
    }
  }
  
  function showHideRtf(idcore){
  	var d=document;
  	var id="block_"+idcore+"_value";
  	var o=d.getElementById(id);
  	var h3=o.getElementsByTagName("H3");
  	if(o.style.position=="absolute"){
	  	o.style.position="static";
	  	if(h3.length)h3[0].style.position="static";
  	}else{
	  	o.style.position="absolute";
	  	if(h3.length)h3[0].style.position="absolute";
	  	o.style.left=-1000+"px";
	}
  }
  
  function hideExtraRtf(){
  	var m, con, divs, d=document;
  	con=d.getElementById("extraRtfContainer");
  	divs=con.getElementsByTagName("DIV");
  	m=0;
  	var exRtfAr=[];
  	for(var i=0;i<divs.length;i++){
  		var dI=divs[i];
  		if(dI.id && dI.id.substring(0, 6)=="block_" && dI.id.indexOf("_value")!=-1){
  			if (!d.getElementById("checkbox_" + dI.id.substring(6,dI.id.indexOf("_value"))).checked){
	 			exRtfAr[m]=dI;m++;		
	 		}
  		}
  	}
  	for(var j=0;j<exRtfAr.length;j++) {
  		var eR=exRtfAr[j];
  		var h3=eR.getElementsByTagName("H3");
  		eR.style.position="absolute";	
  		eR.style.left = -1000+"px";
  		if(h3.length)h3[0].style.position="absolute";
  	}
  }

   function isRelativeUrl(url) {
	      var result = true;
	      var protocols = ["http:", "https:", "ftp:", "file:"];
	      for(var i = 0; i < protocols.length; i++) {
	         var protocol = protocols[i];
	         if(url.substring(0, protocol.length) == protocol) {
	            result = false;
	            break;
	         }
	      }
	      return result;
	   }
	   
function getElementsByName_iefix(tag, name) {
   var elem = document.getElementsByTagName(tag);
   var arr = new Array();
   for(i = 0,iarr = 0; i < elem.length; i++) {
  	   att = elem[i].getAttribute("name");
    	 if(att == name) {
     		arr[iarr] = elem[i];
            iarr++;
         }
    }
   return arr;
}
function getHeightArr(elem,name){
  var heightArr = new Array();
  if(elem.length>0){
		for(i=0;i<elem.length;i++){
		 	if(elem[i].getAttribute("name")==name){
			    heightArr[i] = elem[i].clientHeight;
			}
		}
  }
  return heightArr;
}

function getMaxHeight(arr){
	var maxHeight = arr[0];
   	for(i= 1;i<arr.length;i++){
	    maxHeight = Math.max(maxHeight, arr[i]);
	}
	return maxHeight;
}

function updateSummary(tag,name){
   var elems = getElementsByName_iefix(tag,name);
   if((elems!=null)&& (elems.length>0)){
   		for(var i=0;i<elems.length;i++){
			var elem = elems[i].innerHTML;
			if(elem.length>255){
				newValueElem = elem.substring(0,255);
				elems[i].innerHTML = newValueElem; 
			}
	     }
	}
	return elems;
}
function getNavHeight(id,minHeight){
  var elemHeight = document.getElementById(id).offsetHeight;
  if(elemHeight<minHeight){
     return String(minHeight)+"px";
  }  
  return String(elemHeight)+"px";
}
function updateHeight(tag,name){
	var arr = new Array();
	arr = updateSummary(tag,name);
	if((arr!=null) && (arr.length>0)){
		var maxHeight = getMaxHeight(getHeightArr(arr,name))
		for(i=0;i<arr.length;i++){
			arr[i].style.height = String(maxHeight)+"px";
		}
	}
}

function updateTitleHeight(tag,name){
   var elems = getElementsByName_iefix(tag,name);
   if((elems!=null)&& (elems.length>0)){
        var maxHeight = getMaxHeight(getHeightArr(elems,name));
		for(var i=0;i<elems.length;i++){
		   elems[i].style.height =String(maxHeight)+"px";
		}
   }
}
function xmlhttpPost(strURL,id)
{	 
	if (window.XMLHttpRequest)
	{
	  xmlhttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    if (xmlhttp)
    {
		xmlhttp.open("POST",strURL,true);
    	xmlhttp.onreadystatechange = function()
    	{
			if (xmlhttp.readyState == 4)
			{
				if (xmlhttp.status == 200){
                    var element = document.getElementById(id);
                    var html = xmlhttp.responseText;
                    element.innerHTML = html;
                    try{
                    	updateTitleHeight('div','shopItemCellTitle');
                    	updateHeight('div','itemDesc');
						updateTitleHeight('div','itemSeries');
						updateTitleHeight('div','itemSubtitle');
                    }catch(err){}	
             }
				else{
					var resp="some Problem";
				}
			}
	  	}	    
	if (window.XMLHttpRequest)
	    		xmlhttp.send(null);
		else
			xmlhttp.send();
	}
}

// This function it's used to collapse/expand a div element
// id of the div to be collapsed 
// obj the div that contains the plus/minus sign
function collapseDiv(id,obj){
	if (document.getElementById(id).style.display=='none'){
 		document.getElementById(id).style.display='';
		obj.className='expand minus';
	}else{
 		document.getElementById(id).style.display='none';
		obj.className='expand';
	}
}

function collapseDivContent(id){
	if (document.getElementById(id).style.display=='none'){
 		document.getElementById(id).style.display='';		
	}else{
 		document.getElementById(id).style.display='none';
	}
}

function getMoreShopItems(id){
	var obj= document.getElementById(id).getElementsByTagName('table')[0];
	var trows=obj.rows.length;
	var result=0;
	for(var i=0;i<trows;i++){
	   result+=obj.rows[i].cells.length;
	}
return result;
}

function updateTitle(id,currentPage,items,totalResults){
	var obj = document.getElementById(id);
	var str_title = obj.getElementsByTagName('h1')[0].innerHTML;
	str_title += " <span class='moreTitleResult'>( "+currentPage+" - "+items +" van "+totalResults+" )</span>";
	obj.getElementsByTagName('h1')[0].innerHTML = str_title;

}

function updateTitleAjax(id,currentPage,items,totalResults){
	var obj=document.getElementById(id).getElementsByTagName('span')[1]; 
	var str_title=obj.innerHTML;
	if (items > totalResults)
		items = totalResults;
	var newTitleMore="( "+currentPage+" - "+items +" van "+totalResults+" )";
	obj.innerHTML=newTitleMore;
}

function updateShopResultsTitle(portletTitle, id, count) {
	try{		
		var obj = document.getElementById(id).getElementsByTagName('div')[0]; 
		var str_title = obj.getElementsByTagName('h1')[0].innerHTML;
		var newTitle = "<br />" + portletTitle + " " + count;
		str_title = str_title.replace(portletTitle, newTitle);
		obj.getElementsByTagName('h1')[0].innerHTML = str_title;
	}
	catch(err){		
	}
}

// SearchFilters functions

String.prototype.reverse = function() { // String reverse
	splitext = this.split("");
	revertext = splitext.reverse();
	reversed = revertext.join("");
	return reversed;
}

// Convert string containing binary representation of integer to string containing radix 32 representation
function binIntStrToRad32Str(binIntStr){
	var result = "";
	
	if(binIntStr!=null) while(binIntStr.substring(0,5)!="") {
		var bin32 = binIntStr.substring(0,5);
		while(bin32.length<5) bin32+='0';
		var intval = parseInt(bin32.reverse(), 2);
		var rad32digit = intval.toString(32);
		result+=rad32digit;
		binIntStr = binIntStr.substring(5);
	}
	
	return result.toUpperCase();		
	/* 
	var values = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
        "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V");
	var array= new Array();
	
	var j = 0;
    var i;
    for (i = 0; i < filterString.length; i++) {
      if (array[j] == null) {
        array[j] = "";
      }
      array[j] += filterString.charAt(i);
      if (i != 0 && (i + 1) % 5 == 0) {
        j++;
      }
    }
      
    if (array[j] == null) { 
		array[j] = ""; 
	}
    var k;
	for (k = 0; k < 5 - i % 5; k++) {
      array[j] += "0";
    }
		
	for (k = 0; k < array.length; k++) {
      var index = array[k];
      var value = values[parseInt(index, 2)];
      result += value;
	
	}*/
}

function getNumberOfFilters(name){
 //var objUls = document.getElementsByName(name);
 var objUls = $$("[name='"+name+"']") ;

  
 var result = "";
 var sub_elements;
 var active = 0;
 var totalFilters = 0;
 for(var k = 0; k<objUls.length; k++) {
	 var objLi = objUls[k].getElementsByTagName('li'); 
	 for ( i = 0; i < objLi.length ; i++) {
		sub_elements=objLi[i].getElementsByTagName('input');
		for(var j = 0; j < sub_elements.length; j++) {
			// If the element is a check box, get active filters
			if(sub_elements[j].type == "checkbox") {
				totalFilters = totalFilters +1;
	           if(sub_elements[j].checked) {			
				active = active + 1;
	           } 
	        }
	    }
	 }
 }
 result = "" + active + "/" + totalFilters;
 return result; 
}

// This function it's used to get the decoded active filters
function getFilters(name){
 var result = '';
 $$('[name="'+name+'"] > li > input[type=checkbox]').each(function(box){
	result += box.checked?'0':'1';
 });
 return result; 
}

// This function it's used to create the nice url with encoded filters
function createNiceURL(url, filters){
	var result = "";
	var strArray;
	var catArray = new Array("boeken", "online_naslagwerken_en_vakbladen", "opleidingen_en_evenementen", "software_en_andere_bedrijfsmiddelen"); 
	strArray = url.split("/");
	if (strArray.indexOf("overzicht") != -1){
		strArray[strArray.indexOf("overzicht")+2] = filters;
	}
	for(i = 0; i < catArray.length; i++) {
		if (strArray.indexOf(catArray[i]) != -1) {
			if(strArray.length ==7){
				strArray[strArray.indexOf(catArray[i])+1] = ""; // domains
				strArray[strArray.indexOf(catArray[i])+2] = filters; //filters
				strArray[strArray.indexOf(catArray[i])+3] =""; //keyword
				strArray[strArray.indexOf(catArray[i])+4] ="index.html"; //keyword
			}else{
				strArray[strArray.indexOf(catArray[i])+2] = filters; //filters
			}
		}
	}
	 
	if (strArray.indexOf("products") != -1){
		strArray[strArray.indexOf("products")+2] = filters;
	}
	for (i = 0 ; i < strArray.length ; i++){
		result += strArray[i] + "/";
	}
	result = result.substring(0, result.length-1);
	return result;
}

// These functions are used to update Filters in the url
 function createFiltersStrParam(filtersUlsName, categoryFiltersUlsName) {
 	var filters = binIntStrToRad32Str(getFilters(categoryFiltersUlsName) + getFilters(filtersUlsName));
	// Remove trailing zeroes
	var i = filters.length;
	while((filters.charAt(i-1)=='0') && (i>1)) i--;
	filters=filters.substring(0,i);
	
 	return filters;
 }
 
 function createUpdateFiltersUrl(url, filtersStrParam) {	
 	return createNiceURL(url, filtersStrParam);
 }
 
 /* function updateFilters(url, filtersUlsName) {
 	window.location = createUpdateFiltersUrl(url, createFiltersStrParam(filtersUlsName));
 }*/
// -> End SearchFilters functions


// Sitestat functions
  	function addSitestatClickoutStatOnExternalLinks(){
    		   var domain = document.domain;
    		   var links = document.getElementsByTagName("A");
        		for (var i = 0; i < links.length; i++) {
            	   if((StringUtils.hasPrefix('http://',links[i]) ||
            	       StringUtils.hasPrefix('www.',links[i]) || 
            	       StringUtils.hasPrefix('mms://',links[i]) || 
            	       StringUtils.hasPrefix('https://',links[i])) && 
            	       (!new RegExp("^(http://|https://|)[^/:]*"+domain+"(:|/|$)").test(links[i]))) {
            	       
                    	if (document.getElementById("tellernaam") != "undefined" &&
                    		   document.getElementById("tellernaam") != "" && 	
                    		   document.getElementById("tellernaam") != null) {
                        		var tellernaam = document.getElementById("tellernaam").innerHTML;
                        		if (tellernaam != "undefined" &&
                            		tellernaam != "" && tellernaam != null) {
                            		tellernaam = tellernaam + "." + "link." + replaceIllegalChars(links[i].innerHTML);
                            	    links[i].onclick = new Function("ns_softclick(this, '', '" + tellernaam + "', 'clickout'); return false");
			                       			}
			                    		}
			       	} 
        	}
     	  
    	}

    	function  encodeHTML(text) {
    		var re = /([^\u0000-\u0080])/i;
    		while ( re.test( text ) ) {
      			text = text.replace( re, "&#" + String( RegExp.$1 ).charCodeAt( 0 ) + ";" );
    		}
    		text = text.replace(/\x22/gi,"&quot;" );
    		text = text.replace(/\x27/gi,"&#39;" );
    		return( text );
  		}
  		
  		function decodeHTML(text) {
    		var re = /([&][#])([0-9]{3,4})(;)/i;
    		while (re.test(text)) {
      			text = text.replace( re, String.fromCharCode( RegExp.$2 ) );
    		}
    		return( text );
  		}
  		
    	
    	function replaceIllegalChars(str) {
    		str = str.replace(/^\s*/, "").replace(/\s*$/, "");
    		str = str.replace(/\s+/g, "_");
    		str = str.toLowerCase();
    		str = encodeHTML(str);
    		str = str.replace(/&nbsp;/g, "");
    		str = str.replace(/&#234;/g, "e");
    		str = str.replace(/&#201;/g, "e");
    		str = str.replace(/&#233;/g, "e");
    		str = str.replace(/&#235;/g, "e");
    		str = str.replace(/&#232;/g, "e");
    		str = str.replace(/&euml;/g, "e");
    		str = str.replace(/&#228;/g, "a");
    		str = str.replace(/&#226;/g, "a");
    		str = str.replace(/&#224;/g, "a");
    		str = str.replace(/&#196;/g, "a");
    		str = str.replace(/&#252;/g, "u");
    		str = str.replace(/&#250;/g, "u");
    		str = str.replace(/&#251;/g, "u");
    		str = str.replace(/&#249;/g, "u");
    		str = str.replace(/&#220;/g, "u");
    		str = str.replace(/&#239;/g, "i");
    		str = str.replace(/&#238;/g, "i");
    		str = str.replace(/&#236;/g, "i");
    		str = str.replace(/&#237;/g, "i");
    		str = str.replace(/&#243;/g, "o");
    		str = str.replace(/&#246;/g, "o");
    		str = str.replace(/&#242;/g, "o");
    		str = str.replace(/&#214;/g, "o");
    		str = str.replace(/&#35;/g, "");
    		str = str.replace(/&#36;/g, "");
    		str = str.replace(/&#37;/g, "");
    		str = str.replace(/&amp;/g, "");
    		str = str.replace(/&#39;/g, "");
    		str = str.replace(/\./g, "_");
    		str = decodeHTML(str);
    		str = str.replace(/[^a-z0-9_-]/gi, "");
    		return str;
		}

// BEGIN: Add sitestat campaign parameters parameters (ns_*) to all links, forms and frames.
function appendSitestatParamsToURLs() {
	var urlParams = getUrlVars("^ns_.*");
		
	if(urlParams.length>0) {
		var anchors = document.getElementsByTagName("A");
		appendUrlParamsToAnchors(anchors, urlParams);
		var frames = document.getElementsByTagName("frame");
		appendUrlParamsToFrames(frames, urlParams);
		var iframes = document.getElementsByTagName("iframe");
		appendUrlParamsToFrames(iframes, urlParams);
		var forms = document.forms;
		appendHiddenFieldsToForms(forms, urlParams);
	}
}

// Somewhat generic stuff - consider moving

function appendUrlParamsToAnchors(anchors, parameters) {
	for (var i = 0; i < anchors.length; i++) {
		anchor = anchors[i];
		var oldUrl = anchor.href;
		
		if(!isLocalHttpUrl(oldUrl)) continue; // Update only local HTTP URLs
		
		var newUrl=appendParametersToUrl(oldUrl, parameters);
		anchor.href = newUrl;
	}
}

function appendUrlParamsToFrames(frames, parameters) {
	for (var i = 0; i < frames.length; i++) {
		frame = frames[i];
		var oldUrl = frame.src;
		
		if(!isLocalHttpUrl(oldUrl)) continue; // Update only local HTTP URLs
		
		var newUrl=appendParametersToUrl(oldUrl, parameters);
		frame.src = newUrl;
	}
}

function appendHiddenFieldsToForms(forms, parameters) {
	for (var i = 0; i < forms.length; i++) {
		form = forms[i];
		
		if(form.method.toUpperCase()=="POST") form.action=appendParametersToUrl(form.action, parameters);
		else for (var j = 0; j < parameters.length; j++) {
			var paramName = parameters[j][0];
			var paramValue = parameters[j][1];		
			if(form[paramName]==null) {
				var input = document.createElement('INPUT');
				input.type = "hidden";
				input.name = paramName;
				input.value = paramValue;
				form.appendChild(input);
			}
		}
	}
}

function appendParametersToUrl(urlString, parameters) {
		var oldUrl = urlString;
		var newUrl = urlString;
		
		if(oldUrl.length==0 || (oldUrl.charAt(oldUrl.length-1)!='&' && oldUrl.charAt(oldUrl.length-1)!='?')) {
			if(oldUrl.indexOf('?')>=0) newUrl+="&";
			else newUrl+="?";
		}
		for (var i = 0; i < parameters.length; i++) {
			var paramName = parameters[i][0];
			var paramValue = parameters[i][1];
			var paramPresentRegex = new RegExp("(\\?|&)"+paramName+"=");
			if(!paramPresentRegex.test(oldUrl)) newUrl+=paramName+"="+paramValue+"&";
		}
		if(newUrl.charAt(newUrl.length-1)=='&') newUrl = newUrl.substring(0, newUrl.length-1);
		return newUrl;
}

// More generic stuff - consider moving
function isLocalHttpUrl(url) {
	var domain = document.domain;
	if(domain==null || new RegExp("^\\s*$").test(domain)) {
		if(new RegExp("^(http://|https://)").test(url)) return true;
	} else {
		if(new RegExp("^(http://|https://|)[^/:]*"+domain+"(:|/|$)").test(url)) return true;
	}
	return false;
}

function getUrlVars() {
	return getUrlVars('');
}

function getUrlVars(nameFilterRegexStr) {
	if(nameFilterRegexStr && nameFilterRegexStr.length>0) var nameFilterRegex = new RegExp(nameFilterRegexStr);
	
    var vars = [];
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        var key = hash[0];
        if(nameFilterRegex) if(!nameFilterRegex.test(key)) continue;
        var value = hash[1];
        vars.push(hash);
    }
    return vars;
}
// END: Add sitestat campaign parameters parameters (ns_*) to all links, forms and frames.

// this function is used to display page numbers for MoreShopResults and ShopOverview pages
function renderPageScroller(id, items, tAmount, cPage, iLabel, cId, pUrl){
	var pages = Math.ceil( tAmount / items );
	var html='';
	
	if(typeof(linkFormat)=='undefined'){
		var linkFormat=new Object();
		linkFormat.format=function(s){
			var i=1;
			while(i<arguments.length) s=s.replace("{"+(i-1)+"}",arguments[i++]);
			return s;
		 }
	}
	var link = '<a href="javascript:;" {0} onclick="javascript:showShopResults({1},\''+iLabel+'\' ,\''+cId+'\' ,\''+pUrl+'\' ,'+tAmount+')">{2}</a>';
	var linkPages = '<a class="linkPages" href="javascript:;" {0} onclick="javascript:showShopResults({1},\''+iLabel+'\' ,\''+cId+'\' ,\''+pUrl+'\' ,'+tAmount+')">{2}</a>';

	html += '<span class="prev">';
	if (cPage > 1){
		html += linkFormat.format(link, 'title="vorige"', cPage-1, 'vorige');
	} else {
		html += 'vorige';
	}
	html += '</span>';
	
	html += '<span class="pages">';
	
	if (pages <= 3){
		var tempHtml = "";
		for (var i=1 ;i <= pages; i++){
			if (i !=cPage ) {
				tempHtml += '&nbsp;' + linkFormat.format(linkPages, '', i, i);
			} else {
				tempHtml += '&nbsp;'+i;
			}
		}
		html += tempHtml.replace('&nbsp;','');
	} else{
		if (cPage != pages) { // cPage is not lastPage 
			if (cPage == 1) { // cPage is firstPage
				html += cPage+'&nbsp;';	
				html += linkFormat.format(linkPages, '', cPage+1, cPage+1);
				html += '&nbsp;' + linkFormat.format(linkPages, '', cPage+2, cPage+2);
			} else {
				html += linkFormat.format(linkPages, '', cPage-1, cPage-1);
				html += '&nbsp;'+cPage+'&nbsp;';
				html += linkFormat.format(linkPages, '', cPage+1, cPage+1);
			}
		} else {
			html += linkFormat.format(link, '', cPage-2, cPage-2);
			html += '&nbsp;' + linkFormat.format(linkPages, '', cPage-1, cPage-1);
			html += '&nbsp;'+cPage;	
		}
	}
	html += '</span>';
	html +='<span class="next">';
	if (cPage != pages){
		html += linkFormat.format(link, 'title="volgende"', cPage+1, 'volgende');
	}else{
		html += 'volgende';
	}
	html +='</span>';
	if (pages <= 1){ html = '';}
	html += '<div class="results">' + tAmount + '&nbsp;resultaten </div>';
	document.getElementById(id).innerHTML = html;
}

function updateSearchFormState(enoughDetails, totalResults){
 if (totalResults != 0)
	if (enoughDetails > totalResults){
		   document.getElementById('searchContNoResult').style.display = 'none';
           document.getElementById('searchCont').style.display = 'none';
   	       document.getElementById('searchContReadOnly').style.display = '';
	       document.getElementById('searchFormNumberResults').innerHTML ='totaal '+totalResults+' items';
		}else{
		   document.getElementById('searchContNoResult').style.display = 'none';
		   	       document.getElementById('searchContReadOnly').style.display = 'none';
	       document.getElementById('searchCont').style.display = '';
	}
}