//-- global XmlHttpRequest object
var xhr;
var number_max_of_searchmask = 50;
var nbSearchMask;
var SearchMaskScope = "Mijn abonnementen";
var currentLabelDate;

//-- return an XmlHttpRequest for all navigators
function getXhr()
{
	if (window.ActiveXObject)
	{
		try
		{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else if(window.XMLHttpRequest)
		// Firefox et autres
		xhr = new XMLHttpRequest(); 
	else
	{
		// XMLHttpRequest not supported by browser
		alert("Your browser doesn't support XMLHTTPRequest objects..."); 
		xhr = false; 
	}
}

//[BEGIN]QUOTE 376 RFC_20070516

//-- return an XmlHttpRequest for all navigators
//usefull when launching many Ajax in the same time
function getMultiXhr()
{
	var multiXhr;
	if (window.ActiveXObject)
	{
		try
		{
			multiXhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			multiXhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else if(window.XMLHttpRequest)
		// Firefox et autres
		multiXhr = new XMLHttpRequest(); 
	else
	{
		// XMLHttpRequest not supported by browser
		alert("Your browser doesn't support XMLHTTPRequest objects..."); 
		multiXhr = false; 
	}
	return multiXhr;
}


//[END]QUOTE 376 RFC_20070516
//replace a by b in expr
function Remplace(expr,a,b)
{
	var i=0
	while (i!=-1)
	{
		i=expr.indexOf(a,i);
		if (i>=0)
		{
			expr=expr.substring(0,i)+b+expr.substring(i+a.length);
			i+=b.length;
		}
	}
	return expr;
}


function sitestat(ns_l)
{
	//alert(ns_l);
	ns_l+="&ns__t="+(new Date()).getTime();
	ns_pixelUrl=ns_l; 
	ns_0=parent.document.referrer; 
	ns_0=(ns_0.lastIndexOf("/")==ns_0.length-1)?ns_0.substring(ns_0.lastIndexOf("/"),0):ns_0; 
	if(ns_0.length>0)
		ns_l+="&ns_referrer="+escape(ns_0); 
	if(document.images){
		ns_1=new Image();ns_1.src=ns_l;
	}
	else		
		document.write("<img src="+ns_l+" width=1 height=1>");
}

function executeQS_kluwer(search_scope)
{
	var currentForm = document.forms["form_"+search_scope];
	var searchString = currentForm.elements["search-string"].value;

	// The field "search_string" should not be empty
	if (currentForm.elements["search-string"].value == "")
	{
		alert("Vul een zoekterm in");
		document.getElementById('search-string').focus();
	}
	else
	{
		window.document.location.href = "/sf7/modules/kluwer/kluwerSearch.jsp?searchString="+urlEncoding(searchString);
	}
}

function executeKluwerQS(search_scope,searchString,isSearchOnAll,gc,scenario)
{
	var theType = "Allkluwer";
	if(isSearchOnAll!="true")theType = "kluwerMyProduct";
	// Launch the QS via an AJAX call
	getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{

			var parentDiv=document.getElementById('content-all');

			parentDiv.innerHTML = xhr.responseText;

			executeQS(search_scope, '', 'form_'+search_scope, '');
		}
	}
	xhr.open("POST","/sf7/modules/kluwer/search.jsp",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	var listParams = "&searchType=simple&type="+theType+"&search_scope="+search_scope+"&searchString="+urlEncoding(searchString)+"&isSearchOnAll="+isSearchOnAll+"&gc="+gc+"&scenario="+scenario;
	//listParams = "fLabel="+fLabel+"&menu_module="+menu_module+"&search_scope="+search_scope+"&cluster=true&portal_type="+portal_type+"&theFormLabel=form_"+search_scope+"&searchedWord="+currentForm.elements["search-string"].value+"&listProductsSearched=";
	xhr.send(listParams);
}

function calculateExtendPage(search_scope, portal_type, fLabel, menu_module,request_query,isBewaardeSM, isDegrade, searchType,url)
{
	var currentForm = document.forms["form_"+search_scope];
	var listProductsSelected = currentForm.elements["listProductsSearched"].value;
	var searchTerm = currentForm.elements["search-string"].value;
	
	// Launch the QS via an AJAX call
	getXhr();

	xhr.onreadystatechange = function()
        {
          if(xhr.readyState == 4 && xhr.status == 200)
          {
	    nav.loadDiv(url,'navigatorRight');
	  }
	}

	xhr.open("POST","/sf7/modules/common/executeSearch.jsp",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

	if ( searchType == "simple" )
	{
	  listParams = "fLabel="+fLabel+"&menu_module="+menu_module+"&search_scope="+search_scope+"&cluster=true&portal_type="+portal_type+"&theFormLabel=form_"+search_scope+"&searchedWord="+urlEncoding(currentForm.elements["search-string"].value);
	  listParams+="&searchType=simple";

	  if(currentForm.elements["use-thesaurus"].checked)
	  {
	    listParams+="&useThesaurus=true";
	  }
	  else
	  {
	    listParams+="&useThesaurus=false";
	  }
	
 	  // TOC SEARCH
	  listParams += getTocIdsParamForTocSearch('tocSearchForm', search_scope);
	  if(request_query)
	    listParams += request_query + "&";

	  listParams += "&listProductsSearched="+listProductsSelected;
  	  listParams += "&listSearchedTerms="+urlEncoding(currentForm.elements["search-string"].value);
	  listParams += "&newSearch=true";

	  if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")					 listParams += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;
	}
	else
	{
	  var currentForm = document.forms["form_"+search_scope];
	  var listProductsSelected = currentForm.elements["listProductsSearched"].value;
	  var theTabs = currentForm.elements["theTabs"].value;
	  var searchTerm = currentForm.elements["search-string"].value;

	  if(document.getElementById('tocSearchScopeHidden'))
  	    document.getElementById('tocSearchScopeHidden').value = getTocSearchValue();

	  listParams = "fLabel="+fLabel+"&menu_module="+menu_module+"&search_scope="+search_scope+"&cluster=true&portal_type="+portal_type+"&theFormLabel=form_"+search_scope+"_"+"&searchedWord="+urlEncoding(currentForm.elements["search-string"].value)+"&searchType=advanced"+"&theTabs="+theTabs;
	  var param_SM ="";
	  var emptySM = true;
	  var listSearchedTerms = "";

	  var listInputObj = currentForm;

	  for (var j=0;j<listInputObj.length;j++)
	  {                
	    if(((listInputObj[j].name.indexOf("_inputValue")!=-1) || listInputObj[j].name=="search-string" )&&(listInputObj[j].value!=""))
	    {
	      if (listInputObj[j].value != "")
	      {
		emptySM = false;
	      }
	      listSearchedTerms+=listInputObj[j].value+",";
	    }
	
            if(listInputObj[j].type=="checkbox" && !listInputObj[j].checked)
 	    {
		// rien
	    }
	    else
    	    {
	      param_SM +="&"+escape(listInputObj[j].id)+"="+listInputObj[j].value;
	    }
	  }

	  listSearchedTerms = listSearchedTerms.substr(0,listSearchedTerms.length-1);

	  if(request_query)
	    listParams += request_query;

	  if(currentForm.elements["use-thesaurus"].checked)
	  {
	    listParams+="&useThesaurus=true";
	  }
	  else
	  {
	    listParams+="&useThesaurus=false";
	  }

  	  // TOC SEARCH
	  listParams += getTocIdsParamForTocSearch('tocSearchForm', search_scope);
	  listParams += param_SM;
	  listParams += "&listSearchedTerms="+listSearchedTerms;
	  listParams += "&newSearch=true";

	  if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")					 listParams += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;
	}


	//Asynchroneous request => the following instructions executes before response reception:
	xhr.send(listParams);

}

function loadRefineBox(params,search_scope)
{
	var searchList = document.getElementById('search-linklist_'+search_scope);
	if(document.getElementById('toggler-zoeken') && document.getElementById('toggler-zoeken').style.display == 'none')
		searchList.style.display = "inline";				
	loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp',searchList,params);

}

function rexecuteSearchMask(search_scope,itemName,SMName,params)
{
	var currentForm = document.forms["form_"+search_scope];
	var listProductsSelected = currentForm.elements["listProductsSearched"].value;
	var url = "/sf7/modules/common/executeSearch.jsp";
	var params = params+"&search_scope="+search_scope+"&searchFormName="+SMName+"&itemName="+encodeURIComponent(itemName)+"&listProductsSearched="+listProductsSelected+"&searchType=bewaarde";

	if(listProductsSelected == ""){
		alert("No product in your selection");
	}else {
		var contentElt = document.getElementById('search-result_'+search_scope);
		contentElt.style.display = "block";
		loadDivScriptEnableRexecuteSearchMask(url,contentElt,params,search_scope);
	}
}

function sortingSearchResult(search_scope,SMName,params)
{
	//use to sort the result updating the SearchMask with sort criteria
	var currentForm = document.forms["form_"+search_scope];
	var listProductsSelected = currentForm.elements["listProductsSearched"].value;
	var listProductsFiltered = "";
	var url = "/sf7/modules/common/executeSearch.jsp";
	
	//get search type from params
	var searchType = params.substring(params.indexOf("searchType=")+("searchType=").length,params.length);
	var indexOf = searchType.indexOf("&");
	if(indexOf != -1) {
		searchType = searchType.substring(0, indexOf);
	}
	
	var params = params+"&search_scope="+search_scope+"&searchFormName="+SMName+"&itemName=&searchType=";

	if(currentForm.elements["search-period"]) 
	{
	params += "&search-period="+urlEncoding(currentForm.elements["search-period"].value);
	}
	
	if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")				
		params += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;

	//get the toc search value

	if(document.getElementById('tocSearchScopeHidden'))
	{	 
		params+= "&tocSearchScope="+document.getElementById('tocSearchScopeHidden').value;
	}

	//if searchtype nieuw
	if(searchType == "nieuw") {
		//filter for nieuw search
		if(listProductsSelected != "isPumaContent")
		{
			var tempArray = listProductsSelected.split(",");
		
			for(i=0;i<tempArray.length;i++)
			{
				if( (tempArray[i].length >= "WKNL-KL-PHC-PCI-PUMA#".length)
					&& (tempArray[i].substring(0,"WKNL-KL-PHC-PCI-PUMA#".length) == "WKNL-KL-PHC-PCI-PUMA#") )
				{
					listProductsFiltered += ","+tempArray[i];
				}
			}
			listProductsFiltered = listProductsFiltered.substring(1);
		} else {
			listProductsFiltered = "isPumaContent";
		}
		listProductsSelected = listProductsFiltered;
	}
	//endif searchtype nieuw
	
	params += "&listProductsSearched="+listProductsSelected;
	
	if(listProductsSelected == "")
	{
		if(searchType != "nieuw") {
			alert("U heeft geen uitgaven geselecteerd.");
		}else {
			alert("Er zijn geen nieuwe documenten gevonden voor de opgegeven periode.");
		}
	}else {
		var contentElt = document.getElementById('search-result_'+search_scope);
		contentElt.style.display = "block";
		loadDivScriptEnableRexecuteSearchMask(url,contentElt,params,search_scope);
	}
}

function dateUpdate(SMid,newDate)
{
	document.getElementById('date_'+SMid).innerHTML=newDate;
}


function loadDivScriptEnableRexecuteSearchMask(url,item,params,search_scope){

	var xhrLoc = getLocalXhr();

	//Specific function to be define for each specific search page (if needed)
	if(window.actionAfterSearch)actionAfterSearch();

	item.innerHTML="<img src=\"/sf7/images/loader.gif\" width=\"16\" height=\"16\" />";

	xhrLoc.onreadystatechange = function()
	{
		if(xhrLoc.readyState == 4 && xhrLoc.status == 200)
		{	
			item.innerHTML = xhrLoc.responseText;
			document.getElementById("search-linklist_"+search_scope).style.width="26%";
			if(document.getElementById('toggler-zoeken') && document.getElementById('toggler-zoeken').style.display == 'none')
				document.getElementById("search-linklist_"+search_scope).style.display = "inline";
			if(scripts = xhrLoc.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){

				for(var i=0;i< scripts.length;i++){                            
					eval(scripts[i].replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
				}
			}
			loadRefineBox(params,search_scope);
		}
	}			

	xhrLoc.open("POST", url, true);
	xhrLoc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');    
	xhrLoc.send(params);
}


function editSearchMask(params){

	var xhrLoc = getLocalXhr();

	xhrLoc.onreadystatechange = function()
	{
		if(xhrLoc.readyState == 4 && xhrLoc.status == 200)
		{	
			var resp = xhrLoc.responseText;	
			resp = resp.replace(/(^\s*)|(\s*$)/g,"");
			if(resp.match("navUse") == null)
			{
				window.document.location.href = xhrLoc.responseText;
			}
			else
			{	
				nav.loadDiv(resp,'tab-search-content');	
			}
		}
	}			

	xhrLoc.open("POST", "/sf7/modules/common/editSearchMask.jsp", true);
	xhrLoc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');    
	xhrLoc.send(params);
}

//TOC SEARCH
function getSelectedTocIds(currentForm) {
	var tocIds = "";
	for (i=0 ; i<= currentForm.length-1 ; i++)	{
	
		if (currentForm[i].type == 'checkbox' && currentForm[i].checked && currentForm[i].id.indexOf("cb_toc_") == 0 ) {
			
               if(currentForm[i].id.indexOf("#") != -1)
               {
                    tocIds += currentForm[i].id + ",";
               }
               else  
               {
                    tocIds = "";
                    break;
               }
		}
	}
	return encodeURI(tocIds);
}

function getTocSearchValue()
{
	var value = "all_scope";

	if(document.getElementById("tocsearch_scope") && document.getElementById("tocsearch_scope").type == "hidden")
	{
          //SOO search scope
          value = document.getElementById("tocsearch_scope").value;
     }
     else
     {          
          //cl2 search scope
          var currentForm = document.forms['tocSearchForm'];	 
     	if(currentForm && currentForm.elements["tocsearch_scope"])
     	{		
     		for(i=0; i<currentForm.elements["tocsearch_scope"].length; i++)
     		{
     			scopeRadio = currentForm.elements["tocsearch_scope"][i];
     			if(scopeRadio.checked)
     			{
     				value = scopeRadio.value			
     			}
     		}
     	}
     }	
	return value;
}

function executeQS(search_scope, portal_type, fLabel, menu_module,request_query,isBewaardeSM, isDegrade, isFullMode)
{
	if(search_scope!="kluwerbar"){

		var currentForm = document.forms["form_"+search_scope];
		var listProductsSelected = currentForm.elements["listProductsSearched"].value;
		
	        listProductsSelected = listProductsSelected.replace(/; /g,",WKNL-KL-PHC-PCI-PUMA#");
			// Remove last character if it is a ,
			if (listProductsSelected.substring(listProductsSelected.length-2,listProductsSelected.length-1) == ",")
				listProductsSelected = listProductsSelected.substring(0,listProductsSelected.length-1);


		var searchTerm = currentForm.elements["search-string"].value;

		if(document.getElementById('tocSearchScopeHidden'))
			document.getElementById('tocSearchScopeHidden').value = getTocSearchValue();

		// The field "search_string" should not be empty
		if (currentForm.elements["search-string"].value == "")
		{
			alert("Vul een zoekterm in");
			currentForm.elements["search-string"].focus();
		}
		else if (searchTerm.indexOf("\'",0) != -1 || searchTerm.indexOf("\\",0) != -1){
			//alert("The search term contains invalid characters such as \\ and \' .");
			alert("Het zoekwoord bevat ongeldige tekens zoals \\ in en \' .");
			currentForm.elements["search-string"].focus();
		}
		else if(listProductsSelected == ""){
			alert("U heeft geen uitgaven geselecteerd.");
			currentForm.elements["search-string"].focus();
		}
		else
		{
			if(!isZoekenButtonEnable()){
				return;
			}

			//Specific function to be define for each specific search page (if needed)
			if(window.actionAfterSearch)actionAfterSearch();

			// Launch the QS via an AJAX call
			getXhr();

			var searchResultDiv = document.getElementById("search-result_"+search_scope);

                        var searchMaskDiv = document.getElementById("search-form");
                        if ( searchMaskDiv != null)
                        {
                          if ( searchMaskDiv.style.display == "none")
                          {
                            if ( searchResultDiv != null )
                            {
                              searchResultDiv.style.display = "block";
                              searchResultDiv.innerHTML="<img src=\"/componentLibrary/images/loader.gif\" width=\"13\" height=\"13\" />";
                            }
                          }
                        }

			//------------------------- Executed on ajax request reception: ---------------------------------------------
			xhr.onreadystatechange = function()
			{
				//When the response is fully received
				if(xhr.readyState == 4)
				{
					//if the return status is OK
					if(xhr.status == 200){
						// HPOV 127.034 : S&F : Changing search results page in sidebar gives error
						if(document.getElementById("search-form").style.display != "none"){
							currentForm.elements["search-string"].focus();
						}

						//Saved Searches (activate links when results are received)
						if(document.getElementById('saved-searches-link'))
						{
							if (isDegrade == "true"){
								resultNode="<a style='color:#666666' href='javascript: void(0);'>Zoekopdracht bewaren</a>&nbsp;&nbsp;|&nbsp;&nbsp";
								tagName="id_"+search_scope;                                     
								if(document.getElementById(tagName))
									document.getElementById(tagName).innerHTML=resultNode;
								else
									document.getElementById('saved-searches-link').innerHTML=resultNode;
							}
							else{
								var greyOut = "";

								if(document.getElementsByName("tocsearch_scope"))
								{
									if( (document.getElementsByName("tocsearch_scope")[1] && document.getElementsByName("tocsearch_scope")[1].value=="toc_scope" && document.getElementsByName("tocsearch_scope")[1].checked) 
											|| (document.getElementsByName("tocsearch_scope")[2] && document.getElementsByName("tocsearch_scope")[2].value=="toc_scope" && document.getElementsByName("tocsearch_scope")[2].checked) )
										greyOut = 'style="color:#666666"';                      				
								}                    		

								var greyOutJsAction;
								if(isBewaardeSM == "true")
								{
									greyOutJsAction = (greyOut == '') ? "savedSearches(\""+isBewaardeSM+"\");" : "void(0);";
									resultNode="<a "+greyOut+" href='javascript: "+greyOutJsAction+"'>Zoekopdracht bewaren</a>&nbsp;&nbsp;|&nbsp;&nbsp";
									tagName="id_"+search_scope;                                     
									if(document.getElementById(tagName))
										document.getElementById(tagName).innerHTML=resultNode;
									else
										document.getElementById('saved-searches-link').innerHTML=resultNode;
								}
								else if (document.getElementById("bewaarde_link"))
								{
									greyOutJsAction = (greyOut == '') ? "new_window();" : "void(0);";
									resultNode="<a "+greyOut+" href='javascript: "+greyOutJsAction+"'>Zoekopdracht bewaren</a>&nbsp;&nbsp;|&nbsp;&nbsp";
									tagName="id_"+search_scope;                                     
									if(document.getElementById(tagName))
										document.getElementById(tagName).innerHTML=resultNode;
									else
										document.getElementById('saved-searches-link').innerHTML=resultNode;
								}
							}
						}
						
						//Thesaurus
						startGetThesaurus("form_"+search_scope);

						//linklist
						var searchLinkListDiv = document.getElementById("search-linklist_"+search_scope);
						if(searchLinkListDiv != null){
							searchLinkListDiv.style.display = "inline";
							searchLinkListDiv.style.width="26%"                                                        

								if(request_query){
									listParams += request_query;
								}
							listParams += "&searchMode=quickSearch";                                                        

							loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp', searchLinkListDiv, listParams);
							//SFI_2010
							if(isFullMode != null){
								if(!isFullMode){
									displayResult();
								}
							}
						}

						// Sitestat
						var siteStatDiv = document.getElementById("siteStatCode");
						if(siteStatDiv != null && siteStatDiv.innerHTML != null){
							var theInnerHTML = Remplace(siteStatDiv.innerHTML, "&amp;","&");							
							eval(theInnerHTML);
							siteStatDiv.innerHTML = "";
						}

						// ---------- Display result -------------------
						var searchResultDiv = document.getElementById("search-result_"+search_scope);
						if(searchResultDiv != null){
							searchResultDiv.style.display = "block";
							searchResultDiv.innerHTML = xhr.responseText;
						}
						
						//Eval scripts in response
						if(scripts = xhr.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
							for(var i=0;i< scripts.length;i++){                            
								eval(scripts[i].replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
							}
						}
					}
					//if the returned status is NOK
					else{
						// ---------- Display result NOK -------------------
						var searchResultDiv = document.getElementById("search-result_"+search_scope);
						if(searchResultDiv != null){
							searchResultDiv.style.display = "block";
							searchResultDiv.innerHTML = "<p>Uw zoekvraag kan niet worden uitgevoerd, mogelijk door een incorrect zoekterm. " +
							"In de Help-pagina's kunt u vinden welke zoektermen niet toegestaan zijn. </p>" +
							"<p>Unexpected error occured during search, please try again (returned status: " + xhr.status + ")</p>";
						}
					}
					// Enable the Zoeken button
					enableZoekenButton();

					// Hides the wait message
					var clusterDiv = document.getElementById("cluster-links-wait");
					if(clusterDiv != null){
						clusterDiv.style.display = "none";
					}

					// Show search trail
					var searchTrailDiv = document.getElementById("search-trail_" + search_scope);
					var searchMaskDiv = document.getElementById("search-form");
					if ( searchMaskDiv != null )                        
					{
						if ( searchMaskDiv.style.display != "none" )
						{
							if(searchTrailDiv != null)
							{
								searchTrailDiv.style.display = "block";
							}
						}
						else
						{
							if(searchTrailDiv != null)
							{
									searchTrailDiv.style.display = "none";
							}
						}
					}

					// Hide the wait image
					var searchWaitDiv = document.getElementById("search-wait_"+search_scope);
					if(searchWaitDiv != null){
						searchWaitDiv.style.display = "none";
					}
				}				
			};
			//-------------------------------------------------------------------------------------------


			xhr.open("POST","/sf7/modules/common/executeSearch.jsp",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			listParams = "fLabel="+fLabel+"&menu_module="+menu_module+"&search_scope="+search_scope+"&cluster=true&portal_type="+portal_type+"&theFormLabel=form_"+search_scope+"&searchedWord="+urlEncoding(currentForm.elements["search-string"].value);
			listParams+="&searchType=simple";

			if(currentForm.elements["use-thesaurus"].checked)
			{
				listParams+="&useThesaurus=true";
			}
			else
			{
				listParams+="&useThesaurus=false";
			}
			// TOC SEARCH
			listParams += getTocIdsParamForTocSearch('tocSearchForm', search_scope);
			if(request_query)
				listParams += request_query + "&";

			listParams += "&listProductsSearched="+listProductsSelected;

			listParams += "&listSearchedTerms="+urlEncoding(currentForm.elements["search-string"].value);
			listParams += "&newSearch=true";

			if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")				
				listParams += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;


			//Asynchroneous request => the following instructions executes before response reception:
			xhr.send(listParams);

			// Disable the Zoeken button
			disableZoekenButton();

			// Hide the search trail
			var searchTrailDiv = document.getElementById("search-trail_" + search_scope);
			if(searchTrailDiv != null){
				searchTrailDiv.style.display = "none";
			}

			// Hide previous results
			var searchResultDiv = document.getElementById("search-result_"+search_scope);
			var searchMaskDiv = document.getElementById("search-form");

			if ( searchMaskDiv != null)
			{
				if ( searchMaskDiv.style.display != "none")
				{
					if(searchResultDiv != null){
						searchResultDiv.style.display = "none";
						searchResultDiv.innerHTML = "";
					}
				}
			}

			// Display wait image
			var searchWaitDiv = document.getElementById("search-wait_"+search_scope);
			var searchMaskDiv = document.getElementById("search-form");

			if ( searchMaskDiv != null )
			{
				if ( searchMaskDiv.style.display != "none" )
				{
					if(searchWaitDiv != null)
					{
					searchWaitDiv.style.display = "block";
					}
				}
				else
				{
					if(searchWaitDiv != null)
					{
						searchWaitDiv.style.display = "none";
					}
				}
			}
		}
	}else{
		executeQS_kluwer(search_scope);
	}
}


function executeNS(search_scope, portal_type, fLabel, menu_module, request_query, isBewaardeSM, isDegrade, isFullMode)
{
		var currentForm = document.forms["form_"+search_scope];
		var listProductsSelected = currentForm.elements["listProductsSearched"].value;
		
	        listProductsSelected = listProductsSelected.replace(/; /g,",WKNL-KL-PHC-PCI-PUMA#");
			// Remove last character if it is a ,
			if (listProductsSelected.substring(listProductsSelected.length-2,listProductsSelected.length-1) == ",")
				listProductsSelected = listProductsSelected.substring(0,listProductsSelected.length-1);

		if(document.getElementById('tocSearchScopeHidden'))
			document.getElementById('tocSearchScopeHidden').value = getTocSearchValue();

		var listProductsFiltered = "";

		if(listProductsSelected != "isPumaContent")
		{
			var tempArray = listProductsSelected.split(",");
		
			for(i=0;i<tempArray.length;i++)
			{
				if( (tempArray[i].length >= "WKNL-KL-PHC-PCI-PUMA#".length)
					&& (tempArray[i].substring(0,"WKNL-KL-PHC-PCI-PUMA#".length) == "WKNL-KL-PHC-PCI-PUMA#") )
				{
					listProductsFiltered += ","+tempArray[i];
				}
			}
			listProductsFiltered = listProductsFiltered.substring(1);
		} else {
			listProductsFiltered = "isPumaContent";
		}

		if(listProductsFiltered == "")
		{
			alert("Er zijn geen nieuwe documenten gevonden voor de opgegeven periode.");
		}
		else
		{
			if(!isZoekenButtonEnable()){
				return;
			}

			//Specific function to be define for each specific search page (if needed)
			if(window.actionAfterSearch)actionAfterSearch();

			// Launch the QS via an AJAX call
			getXhr();

			var searchResultDiv = document.getElementById("search-result_"+search_scope);

                        var searchMaskDiv = document.getElementById("search-form");
                        if ( searchMaskDiv != null)
                        {
                          if ( searchMaskDiv.style.display == "none")
                          {
                            if ( searchResultDiv != null )
                            {
                              searchResultDiv.style.display = "block";
                              searchResultDiv.innerHTML="<img src=\"/componentLibrary/images/loader.gif\" width=\"13\" height=\"13\" />";
                            }
                          }
                        }

			//------------------------- Executed on ajax request reception: ---------------------------------------------
			xhr.onreadystatechange = function()
			{
				//When the response is fully received
				if(xhr.readyState == 4)
				{
					//if the return status is OK
					if(xhr.status == 200){
						
						//Thesaurus
						startGetThesaurus("form_"+search_scope);

						//linklist
						var searchLinkListDiv = document.getElementById("search-linklist_"+search_scope);
						if(searchLinkListDiv != null){
							var searchMaskDiv = document.getElementById("search-form");
							if ( searchMaskDiv != null )
							{
								if ( searchMaskDiv.style.display != "none" )
								{
									searchLinkListDiv.style.display = "inline";
									searchLinkListDiv.style.width="26%"                                                        

									if(request_query){
										listParams += request_query;
									}
									listParams += "&searchMode=quickSearch";                                                        

									loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp', searchLinkListDiv, listParams);
									//SFI_2010
								}
							    else
							    {
								searchLinkListDiv.style.display = "none";
								}
							}
						}

						// Sitestat
						var siteStatDiv = document.getElementById("siteStatCode");
						if(siteStatDiv != null && siteStatDiv.innerHTML != null){
							var theInnerHTML = Remplace(siteStatDiv.innerHTML, "&amp;","&");							
							eval(theInnerHTML);
							siteStatDiv.innerHTML = "";
						}

						// ---------- Display result -------------------
						var searchResultDiv = document.getElementById("search-result_"+search_scope);
						if(searchResultDiv != null){
							searchResultDiv.style.display = "block";
							searchResultDiv.innerHTML = xhr.responseText;
						}
						
						//Eval scripts in response
						if(scripts = xhr.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
							for(var i=0;i< scripts.length;i++){                            
								eval(scripts[i].replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
							}
						}
					}
					//if the returned status is NOK
					else{
						// ---------- Display result NOK -------------------
						var searchResultDiv = document.getElementById("search-result_"+search_scope);
						if(searchResultDiv != null){
							searchResultDiv.style.display = "block";
							searchResultDiv.innerHTML = "<p>Uw zoekvraag kan niet worden uitgevoerd, mogelijk door een incorrect zoekterm. " +
							"In de Help-pagina's kunt u vinden welke zoektermen niet toegestaan zijn. </p>" +
							"<p>Unexpected error occured during search, please try again (returned status: " + xhr.status + ")</p>";
						}
					}
					// Enable the Zoeken button
					enableZoekenButton();

					// Hides the wait message
					var clusterDiv = document.getElementById("cluster-links-wait");
					if(clusterDiv != null){
						clusterDiv.style.display = "none";
					}

					// Show search trail
					var searchTrailDiv = document.getElementById("search-trail_" + search_scope);
					var searchMaskDiv = document.getElementById("search-form");
					if ( searchMaskDiv != null )                        
					{
						if ( searchMaskDiv.style.display != "none" )
						{
							if(searchTrailDiv != null)
							{
								searchTrailDiv.style.display = "block";
							}
						}
						else
						{
							if(searchTrailDiv != null)
							{
									searchTrailDiv.style.display = "none";
							}
						}
					}

					// Hide the wait image
					var searchWaitDiv = document.getElementById("search-wait_"+search_scope);
					if(searchWaitDiv != null){
						searchWaitDiv.style.display = "none";
					}
				}				
			};
			//-------------------------------------------------------------------------------------------


			xhr.open("POST","/sf7/modules/common/executeSearch.jsp",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			listParams = "fLabel="+fLabel+"&menu_module="+menu_module+"&search_scope="+search_scope+"&cluster=true&portal_type="+portal_type+"&theFormLabel=form_"+search_scope+"&searchedWord="+"&search-period="+urlEncoding(currentForm.elements["search-period"].value);
			if (currentForm.elements["search-limit"].checked)
			{
				listParams+="&search-limit=true";
			}
			else
			{
				listParams+="&search-limit=false";
			}
			listParams+="&searchType=nieuw";

				listParams+="&useThesaurus=false";

			// TOC SEARCH
			listParams += getTocIdsParamForTocSearch('tocSearchForm', search_scope);
			if(request_query)
				listParams += request_query + "&";

			listParams += "&listProductsSearched="+listProductsFiltered;

			listParams += "&listSearchedTerms=";
			listParams += "&newSearch=true";

			if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")				
				listParams += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;


			//Asynchroneous request => the following instructions executes before response reception:
			xhr.send(listParams);

			// Disable the Zoeken button
			disableZoekenButton();

			// Hide the search trail
			var searchTrailDiv = document.getElementById("search-trail_" + search_scope);
			if(searchTrailDiv != null){
				searchTrailDiv.style.display = "none";
			}

			// Hide previous results
			var searchResultDiv = document.getElementById("search-result_"+search_scope);
			var searchMaskDiv = document.getElementById("search-form");

			if ( searchMaskDiv != null)
			{
				if ( searchMaskDiv.style.display != "none")
				{
					if(searchResultDiv != null){
						searchResultDiv.style.display = "none";
						searchResultDiv.innerHTML = "";
					}
				}
			}

			// Display wait image
			var searchWaitDiv = document.getElementById("search-wait_"+search_scope);
			var searchMaskDiv = document.getElementById("search-form");

			if ( searchMaskDiv != null )
			{
				if ( searchMaskDiv.style.display != "none" )
				{
					if(searchWaitDiv != null)
					{
					searchWaitDiv.style.display = "block";
					}
				}
				else
				{
					if(searchWaitDiv != null)
					{
						searchWaitDiv.style.display = "none";
					}
				}
			}
		}
}	

	
//TOC SEARCH







function getTocIdsParamForTocSearch(tocFormName, search_scope) 
{
     var currentForm = document.forms[tocFormName];  
     var listParams = "";
     
     if(currentForm)
     {                
           var scopeRadio=null;
           
           if(currentForm.elements["tocsearch_scope"] && currentForm.elements["tocsearch_scope"].type == "hidden" )
           {
               //SOO search scope
               var tocs = getSelectedTocIds(currentForm);
               if(tocs != "")
                    listParams+= "&tocids=" + tocs;
               else
                    listParams+= "&notoc=true";
               listParams+= "&tocSearchScope="+document.getElementById("tocsearch_scope").value;
               
               lawName = "allLaws";
               if(document.getElementById("lawName") && document.getElementById("lawName").checked)
                    lawName = document.getElementById("lawName").value;               
                    
               listParams+= "&lawName="+lawName;               
           }           
           else
           {
               //cl2 search scope
           
                for(i=0; i<currentForm.elements["tocsearch_scope"].length; i++)
                {
                        scopeRadio = currentForm.elements["tocsearch_scope"][i];
                        if(scopeRadio.checked)
                        {
                                if(scopeRadio.value == "toc_scope" ) 
                                {
                                        var tocs = getSelectedTocIds(currentForm);
                                        if(tocs != "")
                                                listParams+= "&tocids=" + tocs;
                                        else
                                                listParams+= "&notoc=true";
                                }                               
                                listParams+= "&tocSearchScope="+scopeRadio.value;
                        }
                }       
                
                if(listParams == "")
                {
                
                        if(currentForm.elements["tocsearch_scope"].value == "all_scope" ) 
                        {
                                listParams+= "&tocSearchScope="+currentForm.elements["tocsearch_scope"].value;
                        }
                } 
           }      
                   
     }       
     //alert(listParams);
     return listParams;      
}


















function refineResult(search_scope, request_query){
	if(!isZoekenButtonEnable()){
		return;
	}
	disableZoekenButton()
	var url = "";
	url = "/sf7/modules/common/executeSearch.jsp";

	var contentElt = document.getElementById('search-result_'+search_scope);
	var searchList = document.getElementById('search-linklist_'+search_scope);				
	contentElt.style.display = "block";    
	loadDivScriptEnableSync1(url,contentElt,searchList,"&search_scope="+search_scope+request_query,true);
}

function loadDivScriptEnableSync1(url,item,item2,params,synchrone){
	item.innerHTML="<img src=\"/sf7/images/loader.gif\" width=\"16\" height=\"16\" />";

	xhrLoc1 = getLocalXhr();

	xhrLoc1.onreadystatechange = function()
	{
		if(xhrLoc1.readyState == 4)
		{
			if(xhrLoc1.status == 200){
				item.innerHTML = xhrLoc1.responseText;
				if(scripts = xhrLoc1.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
	
					for(var i=0;i< scripts.length;i++){                            
						eval(scripts[i].replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
					}
				}
	
				loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp',item2,params);
			}
			else{
				item.innerHTML = "<p>Uw zoekvraag kan niet worden uitgevoerd, mogelijk door een incorrect zoekterm. " +
				"In de Help-pagina's kunt u vinden welke zoektermen niet toegestaan zijn. </p>" +
				"<p>Unexpected error occured during search, please try again (returned status: " + xhr.status + ")</p>";
			}
			enableZoekenButton();			
		}
	}			

	if(synchrone)
		xhrLoc1.open("POST", url, true);
	else
		xhrLoc1.open("POST", url, false);
	xhrLoc1.setRequestHeader('Content-Type','application/x-www-form-urlencoded');    
	xhrLoc1.send(params);
}

function loadDivScriptEnableSync(url,item,params,synchrone){

	var xhrLoc = getLocalXhr();

	item.innerHTML="<img src=\"/sf7/images/loader.gif\" width=\"16\" height=\"16\" />";

	xhrLoc.onreadystatechange = function()
	{
		if(xhrLoc.readyState == 4 && xhrLoc.status == 200)
		{	
			item.innerHTML = xhrLoc.responseText;
			if(scripts = xhrLoc.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){

				for(var i=0;i< scripts.length;i++){                            
					eval(scripts[i].replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
				}
			}
		}
	}			

	if(synchrone)
		xhrLoc.open("POST", url, true);
	else
		xhrLoc.open("POST", url, false);
	xhrLoc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');    
	xhrLoc.send(params);
}

function preg_replace (array_pattern, array_pattern_replace, my_string)  {
	var new_string = String (my_string);

	for (i=0; i<array_pattern.length; i++) {
		var reg_exp= RegExp(array_pattern[i], "gi");
		var val_to_replace = array_pattern_replace[i];
		new_string = new_string.replace (reg_exp, val_to_replace);
	}

	return new_string;
}

function encode_accent (my_string) {
	var new_string = "";
	var pattern_accent = new Array("é", "è", "ê", "ë", "ç", "à", "â", "ä", "î", "ï", "ù", "ô", "ó", "ö");
	var pattern_replace_accent = new Array("&eacute;", "&egrave;", "&ecirc;", "&euml;", "&ccirc;", "&agrave;", "&acirc;", "&auml;", "&icirc;", "&iuml;", "&ugrave;", "&ocirc;", "&oacute;", "&ouml;");

	if (my_string && my_string!= "") {
		new_string = preg_replace (pattern_accent, pattern_replace_accent, my_string);
	}

	return new_string;
}

function executeAS(search_scope, portal_type, fLabel, menu_module,request_query, isBewaardeSM,portalId,isDegrade,sf7Value)
{
	var currentForm = document.forms["form_"+search_scope];
	var listProductsSelected = currentForm.elements["listProductsSearched"].value;


        listProductsSelected = listProductsSelected.replace(/; /g,",WKNL-KL-PHC-PCI-PUMA#");
        listProductsSelected += listProductsSelected + ",";
        listProductsSelected = listProductsSelected.substring(0,listProductsSelected.length-1);
		listProductsSelected = listProductsSelected.substring(0,listProductsSelected.length-1);

	var theTabs = currentForm.elements["theTabs"].value;
	var searchTerm = currentForm.elements["search-string"].value;

	if(document.getElementById("productList"))
	{
		document.getElementById("productList").style.display = "none";
		document.getElementById("productList").innerHTML = (document.getElementById("search-products") ) ? document.getElementById("search-products").innerHTML : document.getElementById("productList").innerHTML;

	}

	if(document.getElementById('tocSearchScopeHidden'))
		document.getElementById('tocSearchScopeHidden').value = getTocSearchValue();


	if(document.getElementById("bewaarde") != null) {
		refineResult(search_scope,request_query);
	}
	else if (searchTerm.indexOf("\'",0) != -1 || searchTerm.indexOf("\\",0) != -1){
		//alert("The search term contains invalid characters such as \\ and \' .");
		alert("Het zoekwoord bevat ongeldige tekens zoals \\ in en \' .");			
		currentForm.elements["search-string"].focus();
	}
	else if(listProductsSelected==""){
		alert("U heeft geen uitgaven geselecteerd.");
	} else {
		
		if(!isZoekenButtonEnable()){
			return;
		}

		listParams = "fLabel="+fLabel+"&menu_module="+menu_module+"&search_scope="+search_scope+"&cluster=true&portal_type="+portal_type+"&theFormLabel=form_"+search_scope+"_"+"&searchedWord="+urlEncoding(currentForm.elements["search-string"].value)+"&searchType=advanced"+"&theTabs="+theTabs;
		var param_SM ="";
		var emptySM = true;
		var listSearchedTerms = "";

		var listInputObj = currentForm;

		for (var j=0;j<listInputObj.length;j++)
		{                
			if(((listInputObj[j].name.indexOf("_inputValue")!=-1) || listInputObj[j].name=="search-string" )&&(listInputObj[j].value!=""))
			{
				if (listInputObj[j].value != "")
				{
					emptySM = false;
				}
				listSearchedTerms+=listInputObj[j].value+",";
			}
			if(listInputObj[j].type=="checkbox" && !listInputObj[j].checked){
				//alert("rien");
			}else{
				param_SM +="&"+escape(listInputObj[j].id)+"="+escape(encode_accent(listInputObj[j].value));
			}
		}

		if(sf7Value != "" && sf7Value != "null" && sf7Value != null){
			var tab = sf7Value.split(';');
			for(var i=0; i<tab.length; i++){
				var tab2 = tab[i].split(':');

				var currentDataName=tab2[0];
				var valueOfDataName=tab2[1];

				var tabValueOfDataName=valueOfDataName.split(',');
				
				param_SM +="&"+currentDataName+"=";

				for($j=0;$j<tabValueOfDataName.length;$j++){
					tabValueOfDataName[$j] = encode_accent(tabValueOfDataName[$j]);
					listSearchedTerms+=tabValueOfDataName[$j];
					listSearchedTerms+=",";
					param_SM += escape(tabValueOfDataName[$j])+',';
				}
				param_SM = param_SM.substr(0,param_SM.length-1);
			}
		}

		listSearchedTerms = listSearchedTerms.substr(0,listSearchedTerms.length-1);
		listSearchedTerms = encode_accent(listSearchedTerms);

		param_SM = encode_accent(param_SM);
		// no field can be empty
		if (emptySM && (sf7Value=="" || sf7Value==null) )
		{
			alert("Vul een zoekterm in");
			currentForm.elements["search-string"].focus();
		}
		else
		{
			//Specific function to be define for each specific search page (if needed)
			if(window.actionAfterSearch)actionAfterSearch();

			// Launch the QS via an AJAX call
			getXhr();
			

			var searchResultDiv = document.getElementById("search-result_"+search_scope);

			var searchMaskDiv = document.getElementById("search-form");
			if ( searchMaskDiv != null)
			{
				if ( searchMaskDiv.style.display == "none")
				{
					if ( searchResultDiv != null )
					{
						searchResultDiv.style.display = "block";
						searchResultDiv.innerHTML="<img src=\"/componentLibrary/images/loader.gif\" width=\"13\" height=\"13\" />";
					}
				}
			}


			//------------------------- Executed on ajax request reception: ---------------------------------------------
			xhr.onreadystatechange = function()
			{
				//When the response is fully received
				if(xhr.readyState == 4)
				{
					//if the return status is OK
					if(xhr.status == 200){
						// HPOV 127.034 : S&F : Changing search results page in sidebar gives error
						if(document.getElementById("search-form").style.display != "none"){
							currentForm.elements["search-string"].focus();
						}

						//Saved Searches (activate links when results are received)
						if(document.getElementById('saved-searches-link'))
						{
							if (isDegrade == "true"){

								resultNode="<a style='color:#666666' href='javascript: void(0);'>Zoekopdracht bewaren</a>&nbsp;&nbsp;|&nbsp;&nbsp";
								tagName="id_"+search_scope;                                     
								if(document.getElementById(tagName))
									document.getElementById(tagName).innerHTML=resultNode;
								else
									document.getElementById('saved-searches-link').innerHTML=resultNode;
							}
							else{
								var greyOutJsAction;										                    		
								var greyOut = "";

								if(document.getElementsByName("tocsearch_scope"))
								{
									if( (document.getElementsByName("tocsearch_scope")[1] && document.getElementsByName("tocsearch_scope")[1].value=="toc_scope" && document.getElementsByName("tocsearch_scope")[1].checked) 
											|| (document.getElementsByName("tocsearch_scope")[2] && document.getElementsByName("tocsearch_scope")[2].value=="toc_scope" && document.getElementsByName("tocsearch_scope")[2].checked) )
										greyOut = 'style="color:#666666"';                    				
								}  



								if(isBewaardeSM == "true")
								{
									greyOutJsAction = (greyOut == '') ? "savedSearches(\""+isBewaardeSM+"\");" : "void(0);";
									resultNode="<a "+greyOut+" href='javascript: "+greyOutJsAction+"'>Zoekopdracht bewaren</a>&nbsp;&nbsp;|&nbsp;&nbsp";
									tagName="id_"+search_scope;                                     
									if(document.getElementById(tagName))
										document.getElementById(tagName).innerHTML=resultNode;
									else
										document.getElementById('saved-searches-link').innerHTML=resultNode;
								}
								else if (document.getElementById("bewaarde_link"))
								{
									greyOutJsAction = (greyOut == '') ? "new_window();" : "void(0);";
									resultNode="<a "+greyOut+" href='javascript: "+greyOutJsAction+"'>Zoekopdracht bewaren</a>&nbsp;&nbsp;|&nbsp;&nbsp";
									tagName="id_"+search_scope;                                     
									if(document.getElementById(tagName))
										document.getElementById(tagName).innerHTML=resultNode;
									else
										document.getElementById('saved-searches-link').innerHTML=resultNode;
								}
							}
						}
						
						//Thesaurus
						startGetThesaurus("form_"+search_scope);
						
						//linklist
						var searchLinkListDiv = document.getElementById("search-linklist_"+search_scope);
						if (searchLinkListDiv.id == ("search-linklist_"+search_scope))
						{
						  var searchMaskDiv = document.getElementById("search-form");
	                                          if ( searchMaskDiv != null )
						  {
		                                    if ( searchMaskDiv.style.display != "none" )
		                                    {
							searchLinkListDiv.style.display = "inline";
							searchLinkListDiv.style.width = "26%";
							if(request_query)
							{
								listParams += request_query;
							}
							listParams += "&searchMode=quickSearch";
							
							loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp', searchLinkListDiv, listParams);
							//SFI_2010
							//?
						    }
						    else
						    {
							searchLinkListDiv.style.display = "none";
						    }
						  }
						}
						
						// Sitestat
						var siteStatDiv = document.getElementById("siteStatCode");
						if(siteStatDiv != null && siteStatDiv.innerHTML != null){
							var theInnerHTML = Remplace(siteStatDiv.innerHTML, "&amp;","&");							
							eval(theInnerHTML);
							siteStatDiv.innerHTML = "";
						}

						// ---------- Display result -------------------
						var searchResultDiv = document.getElementById("search-result_"+search_scope);
						if(searchResultDiv != null){
							searchResultDiv.style.display = "block";
							searchResultDiv.innerHTML = xhr.responseText;
						}
						
						//Eval scripts in response
						if(scripts = xhr.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
							for(var i=0;i< scripts.length;i++){                            
								eval(scripts[i].replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
							}       
						}
						
						// Show the search Summary 
						var searchSummaryDiv = document.getElementById("search-summary_"+search_scope);
						if(searchSummaryDiv != null){
							loadDiv('/sf7/modules/common/advancedSearch_SM_Summary.jsp', searchSummaryDiv, listParams);
						}
						
						if(portalId)
						{
							PNG_remindProducts('png_'+search_scope+portalId, 'form_'+search_scope+'_productListForm');
						}
					}
					//if the returned status is NOK
					else{
						// ---------- Display result NOK -------------------
						var searchResultDiv = document.getElementById("search-result_"+search_scope);
						if(searchResultDiv != null){
							searchResultDiv.style.display = "block";
							searchResultDiv.innerHTML = "<p>Uw zoekvraag kan niet worden uitgevoerd, mogelijk door een incorrect zoekterm. " +
									"In de Help-pagina's kunt u vinden welke zoektermen niet toegestaan zijn. </p>" +
									"<p>Unexpected error occured during search, please try again (returned status: " + xhr.status + ")</p>";
						}
					}
					// Enable the Zoeken button
					enableZoekenButton();
									
					// Hides the SM
					var specificSearchDiv = document.getElementById("search-specific_" + search_scope);
					if(specificSearchDiv != null){
						specificSearchDiv.style.display = "none";
					}

					// Show search trail
					var searchTrailDiv = document.getElementById("search-trail_" + search_scope);
					var searchMaskDiv = document.getElementById("search-form");
					if ( searchMaskDiv != null )
					{
						if ( searchMaskDiv.style.display != "none" )
						{
							if(searchTrailDiv != null)
							{
									searchTrailDiv.style.display = "block";
							}
					}
					else
					{
							if(searchTrailDiv != null)
							{
									searchTrailDiv.style.display = "none";
							}
						}
					}

					// Hide wait image
					var searchWaitDiv = document.getElementById("search-wait_" + search_scope);
					if(searchWaitDiv != null){
						searchWaitDiv.style.display = "none";
					}
				}				
			}
			//-------------------------------------------------------------------------------------------
			
			
			xhr.open("POST","/sf7/modules/common/executeSearch.jsp",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

			if(request_query)
				listParams += request_query;

			if(currentForm.elements["use-thesaurus"].checked)
			{
				listParams+="&useThesaurus=true";
			}
			else
			{
				listParams+="&useThesaurus=false";
			}
			// TOC SEARCH
			listParams += getTocIdsParamForTocSearch('tocSearchForm', search_scope);

			listParams += encode_accent(param_SM);
			listParams += "&listSearchedTerms="+escape(encode_accent(listSearchedTerms));
			listParams += "&newSearch=true";
			listParams=encode_accent(listParams);

			if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")				
				listParams += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;

			//Asynchroneous request => the following instructions executes before response reception:
			xhr.send(listParams);

			// Disable the Zoeken button
			disableZoekenButton();
			
			// Hide the cluster result list
			var searchTrailDiv = document.getElementById("search-trail_" + search_scope);
			if(searchTrailDiv != null){
				searchTrailDiv.style.display = "none";
			}

			// Hide previous results
			var searchResultDiv = document.getElementById("search-result_"+search_scope);
			var searchMaskDiv = document.getElementById("search-form");

			if ( searchMaskDiv != null)
			{
				if ( searchMaskDiv.style.display != "none")
				{
					if(searchResultDiv != null){
							searchResultDiv.style.display = "none";
							searchResultDiv.innerHTML = "";
					}
				}
			}

			// Display wait image
			var searchWaitDiv = document.getElementById("search-wait_"+search_scope);
			var searchMaskDiv = document.getElementById("search-form");

			if ( searchMaskDiv != null )
			{
				if ( searchMaskDiv.style.display != "none" )
				{
					if(searchWaitDiv != null)
					{
						searchWaitDiv.style.display = "block";
					}
				}
				else
				{
					if(searchWaitDiv != null)
					{
						searchWaitDiv.style.display = "none";
					}
				}
			}


		}
	}
}

function loadDiv(url,item,params){
	var xhrLoc = getLocalXhr();

	item.innerHTML="<img src=\"/componentLibrary/images/loader.gif\" width=\"13\" height=\"13\" />";

	xhrLoc.onreadystatechange = function()
	{
		if(xhrLoc.readyState == 4 && xhrLoc.status == 200)
		{							
			var propertiesDivObjSr = item;
			var responseString = xhrLoc.responseText;
			responseString = responseString.replace(/(^\s*)|(\s*$)/g,"");
			if(propertiesDivObjSr.id=="sidebar-tabs")
				propertiesDivObjSr.innerHTML = responseString;
			else
				document.getElementById(propertiesDivObjSr.id).innerHTML = responseString;
		}
	}			
	xhrLoc.open("POST", url, true);
	xhrLoc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	listParams = params ; 		
	xhrLoc.send(listParams);	
}	


/* date management */
function isLeapYear(yr) {
	return new Date(yr,2-1,29).getDate()==29;
}	

function getDaysInMonth(month,year)  {
	var days;
	if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;
	else if (month==4 || month==6 || month==9 || month==11) days=30;
	else if (month==2)  {
		if (isLeapYear(year)) { days=29; }
		else { days=28; }
	}
	return (days);
}


function dateIsValid(d) {
	//Check date format
	dateExpr = new RegExp ("^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]$");
	var matchExpr = dateExpr.test(d);
	if (matchExpr==false) {
		return false;
	}
	//Check date is valid
	var day = d.substring(0,1);
	var month = d.substring(4,5);
	var year = d.substring(6,9);
	if (day>getDaysInMonth(month,year)) {

		return false;
	}
	//Date is valid
	return true;
}


function DateFields(baseName){
	var selector = document.getElementById(baseName+"-range");
	var field =  document.getElementById(baseName+"-date-2");

	var value = selector.value;
	if (value=="between") {
		field.style.display = "inline";
	} else {
		field.style.display = "none";
	}



	var lowerBound_input = document.getElementById(baseName+"_icLowerBound_inputValue");
	var upperBound_input = document.getElementById(baseName+"_icUpperBound_inputValue");
	var rangeSelect = document.getElementById(baseName+"-range").value;
	var from_input = document.getElementById(baseName+"-from");
	var to_input = document.getElementById(baseName+"-to");

	/* suffixes list :
	_icLowerBound_inputValue
	_icUpperBound_inputValue
	-range -> can be : on, before, after, between
	-from
	-to
	 */
	var bValidDate = true;
	if((from_input.value!="")&&(!dateIsValid(from_input.value)))bValidDate=false;
	if((to_input.value!="")&&(!dateIsValid(to_input.value)))bValidDate=false;

	if(!bValidDate)
	{
		alert("date format not valid");
		return false;
	}

	if(rangeSelect=="on")
	{
		lowerBound_input.value = from_input.value;
		upperBound_input.value = from_input.value;

	}else if(rangeSelect=="before")
	{
		lowerBound_input.value = "";
		upperBound_input.value = from_input.value;

	}else if(rangeSelect=="after")
	{
		lowerBound_input.value = from_input.value;
		upperBound_input.value = "";
	}else if(rangeSelect=="between")
	{
		lowerBound_input.value = from_input.value;
		upperBound_input.value = to_input.value;

		//HPOV 99.993 : add a check on date.
		if(from_input.value!=null && to_input.value!= null && from_input.value!="" && to_input.value!="")
		{

			var dateDeb=from_input.value.split('-');
			var dateFin=to_input.value.split('-');
			var notValid=false;

			var date1 = new Date(dateDeb[2], dateDeb[1], dateDeb[0]);
			var date2 = new Date(dateFin[2], dateFin[1], dateFin[0]);

			if(date2 < date1)
			{
				notValid=true;
			}

			if(notValid)
			{
				alert("De einddatum moet na de begindatum liggen.");
				upperBound_input.value="";
				to_input.value="";
			}

		}


	}
}	

function loadScripts (item,responseString) {
	loadScriptsInString (responseString);
}


/***********************************************************************************************************************/
/*** 									INIT OF THE ACTIVE X OBJECT 															 ***/
/***********************************************************************************************************************/

function getXhrThesaurus(xhr){
	if (window.ActiveXObject){
		try{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else if(window.XMLHttpRequest)
		// Firefox et autres
		xhr = new XMLHttpRequest(); 
	else
	{
		// XMLHttpRequest not supported by browser
		alert("Your browser doesn't support XMLHTTPRequest objects..."); 
		xhr = false; 
	}
	return xhr;
}

/***********************************************************************************************************************/
/*** 									THESAURUS SEARCH 															 ***/
/***********************************************************************************************************************/
function startGetThesaurus(form){
	var delay = '250';
	var inputItemValue = document.forms[form].elements['search-string'].value;

	if (idTimer != null) {
		clearTimeout(idTimer);
		idTimer = null;
	}

	idTimer = setTimeout( function() {
		if(inputItemValue == document.forms[form].elements['search-string'].value){
			getAllThesaurusTerm(form,false,false);
		}
		clearTimeout(idTimer);
		idTimer =null;
	},delay); 
}

//Methodes qui seront appelees a partir de 3 caracteres saisis.
function getAllThesaurusTerm(form,narrow,related){
	getThesaurusTerm(form);
	getNarrowThesaurusTerm(form,narrow);
	getRelatedThesaurusTerm(form,related);
}

function getThesaurusTerm(form){
	term = urlEncoding(document.forms[form].elements['search-string'].value);
	term = term.replace(/\€/g,'--euro--');

	/**** Thesaurus terms (tt) ****/
	xhr_tt=getXhrThesaurus(xhr);
	// On definit ce qu'on va faire quand on aura la reponse
	xhr_tt.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout recu et que le serveur est ok
		if(xhr_tt.readyState == 4 && xhr_tt.status == 200){
			var searchwordassistant = null;
			searchwordassistant = getThesaurusElementDivById(form,'search-word-assistant');
			if(searchwordassistant!=null)
				searchwordassistant.innerHTML = xhr_tt.responseText;
			resizeSearchWordAssistant(form);
		}
	}		
	xhr_tt.open("POST","/sf7/modules/common/zoeken_thesaurus_terms.jsp",true);
	// ne pas oublier ca pour le post
	xhr_tt.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ne pas oublier de poster les arguments
	xhr_tt.send("term="+term+"&form="+form);            
}

function getNarrowThesaurusTerm(form,more){
	term = urlEncoding(document.forms[form].elements['search-string'].value);
	term = term.replace(/\€/g,'--euro--');
	/**** Narrow thesaurus terms (ntt) ****/
	xhr_ntt=getXhrThesaurus(xhr);
	// On definit ce qu'on va faire quand on aura la reponse
	xhr_ntt.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout recu et que le serveur est ok
		if(xhr_ntt.readyState == 4 && xhr_ntt.status == 200){
			var narrowthesaurusterms = null;
			narrowthesaurusterms= getThesaurusElementDivById(form,'narrow-thesaurus-terms');
			if(narrowthesaurusterms!=null)
				narrowthesaurusterms.innerHTML = xhr_ntt.responseText;
			resizeSearchWordAssistant(form);
		}
	}		
	xhr_ntt.open("POST","/sf7/modules/common/zoeken_narrow_thesaurus_terms.jsp",true);
	// ne pas oublier ca pour le post
	xhr_ntt.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ne pas oublier de poster les arguments
	xhr_ntt.send("term="+term+"&more="+more+"&form="+form);            
}


function getRelatedThesaurusTerm(form,more){
	term = urlEncoding(document.forms[form].elements['search-string'].value);
	term = term.replace(/\€/g,'--euro--');
	xhr_rtt=getXhrThesaurus(xhr);
	// On definit ce qu'on va faire quand on aura la reponse
	xhr_rtt.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout recu et que le serveur est ok
		if(xhr_rtt.readyState == 4 && xhr_rtt.status == 200){
			var relatedthesaurusterms=null;
			relatedthesaurusterms = getThesaurusElementDivById(form,'related-thesaurus-terms');
			if(relatedthesaurusterms!=null)
				relatedthesaurusterms.innerHTML = xhr_rtt.responseText;
			resizeSearchWordAssistant(form);
		}
	}		
	xhr_rtt.open("POST","/sf7/modules/common/zoeken_related_thesaurus_terms.jsp",true);
	// ne pas oublier ca pour le post
	xhr_rtt.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ne pas oublier de poster les arguments
	xhr_rtt.send("term="+term+"&more="+more+"&form="+form);            
}

function setThesaurusTerm(form,itemName,value){
	enableZoekenButton();
	//remplacement des espaces au d?but et ? la fin de la chaine
	value = value.replace(/(^\s*)|(\s*$)/g,"");
	//recherche si la cha?ne de caract?re poss?de au moins un espace
	if(value.search(/ /i)!= "-1")
	{
		//remplacement des caract?res de d?but et de fin par des guillemets
		value= value.replace(/(^\s*)|(\s*$)/g,"\"");
	}
	var item = document.forms[form].elements[itemName];
	item.value = value;
	item = getThesaurusElementDivById(form,'related-thesaurus-terms');
	item.innerHTML = "";
	item = getThesaurusElementDivById(form,'narrow-thesaurus-terms');
	item.innerHTML = "";
	item = getThesaurusElementDivById(form,'search-word-assistant');
	item.innerHTML = "";
	resizeSearchWordAssistant(form);
}

function getThesaurusElementDivById(form,id)
{
	var allDiv = document.forms[form].getElementsByTagName("div");
	for(i=0;i<allDiv.length;i++)
	{
		if(allDiv[i].id==id)
		{
			return allDiv[i];
		}
	}
}


/***********************************************************************************************************************/
/*** 									SPECIFIC SEARCHES 															 ***/
/***********************************************************************************************************************/

var more = false;
var tabOfCheckbox = new Array();
var tabOfCriteriaChecked = new Array();
var linkCriteriaLabelToPrint = "";

/**** USE LIST OF VALUES FOR SPECIFIC SEARCH CRITERIA ****/
function listOfValuesPickList(fieldLabel,fieldName,formName){
	var linkElt = document.getElementById('link_'+fieldLabel);
	var contentElt = document.getElementById('content_'+fieldLabel);
	var pictureElt = document.getElementById('picture_'+fieldLabel);

	if(contentElt.style.display == "none"){
		linkElt.className = linkElt.className.replace(/toggle\-closed/,'toggle-opened');                
		contentElt.style.display = 'block';
		pictureElt.src="/sf7/images/toc-min.gif";
	}
	else{
		linkElt.className = linkElt.className.replace(/toggle\-opened/,'toggle-closed');
		contentElt.style.display = 'none';
		pictureElt.src="/sf7/images/toc-plus.gif";

		//HPOV-131.100: Collapsing list must keep the choice for search: 
		//document.getElementById(fieldName).value="";
	}

	if(contentElt.className.indexOf("alreadyLoaded")==-1){
		//The div is loaded only once
		loadDivScriptEnable('/sf7/modules/common/list_values_specific_search_criteria.jsp',contentElt,"&currentFieldLabel="+fieldLabel+"&fieldName="+fieldName+"&formName="+formName);
		contentElt.className += " alreadyLoaded";
	}else{
		if(contentElt.style.display=="block"){
			computeHiddenFieldValue(document.forms[formName],"selectMany-" + fieldLabel,fieldName);
		}
	}

}

function computeHiddenFieldValue(formElt,inputChkBoxName,inputHiddenBoxName){
	//State of checkboxes have changed so we re-enable form
	enableZoekenButton();
	
	var fieldValue = "";
	var first = true;
	var allBoxesChecked = true;

	for( var i = 0; i< formElt[inputChkBoxName].length;i++){
		if(formElt[inputChkBoxName][i].checked){
			if(!first){
				fieldValue += " OF ";                            
			}
			else{
				first = false;
			}   
			fieldValue +=  formElt[inputChkBoxName][i].value;
		}
		else{
			allBoxesChecked = false;
		}
	}
	if(allBoxesChecked){
		formElt[inputHiddenBoxName].value = "";
	}
	else{
		formElt[inputHiddenBoxName].value = fieldValue;
	}
}

function allSelect(formElt,inputChkBoxName,inputHiddenBoxName){
	for( var i = 0; i< formElt[inputChkBoxName].length;i++){
		formElt[inputChkBoxName][i].checked = true;
	}
	document.getElementById('all-de'+inputChkBoxName).style.display = 'block';
	document.getElementById('all-'+inputChkBoxName).style.display = 'none';

	computeHiddenFieldValue(formElt,inputChkBoxName,inputHiddenBoxName);
}

function allDeselect(formElt,inputChkBoxName,inputHiddenBoxName){
	for( var i = 0; i< formElt[inputChkBoxName].length;i++){
		formElt[inputChkBoxName][i].checked = false;
	}
	document.getElementById('all-de'+inputChkBoxName).style.display = 'none';
	document.getElementById('all-'+inputChkBoxName).style.display = 'block';

	computeHiddenFieldValue(formElt,inputChkBoxName,inputHiddenBoxName)
}


function editSelected(fieldLabel,fieldName,formName)
{
	var formElt = document.forms[formName];
	var inputChkBoxName = "selectMany-" + fieldLabel;
	var contentElt = document.getElementById('content_'+fieldLabel);


	if(formElt.elements[fieldName] && formElt.elements[fieldName].value != "")
	{			        
		var param = inputChkBoxName+"-#--#-"+fieldLabel+"-#--#-"+fieldName+"-#--#-"+formName;
		loadDivScriptEnable('/sf7/modules/common/list_values_specific_search_criteria.jsp',contentElt,"&currentFieldLabel="+fieldLabel+"&fieldName="+fieldName+"&formName="+formName,param);
		contentElt.className += " alreadyLoaded";           	
	}
}

function SelectCheckBoxes(inputChkBoxName,fieldLabel,fieldName,formName){    var formElt = document.forms[formName];    var linkElt = document.getElementById('link_'+fieldLabel);    var contentElt = document.getElementById('content_'+fieldLabel);    var pictureElt = document.getElementById('picture_'+fieldLabel);    var valeurOF = "";    var valeurTmp = "";    if(formElt.elements[inputChkBoxName])    {      var selectedValues = formElt.elements[fieldName].value;      selectedValues = selectedValues.split(" OF ");             linkElt.className = linkElt.className.replace(/toggle\-closed/,'toggle-opened');      contentElt.style.display = 'block';      pictureElt.src="/sf7/images/toc-min.gif";                                       
      for( var j = 0; j< selectedValues.length;j++)
      {        var value = encodeURI(selectedValues[j]);        value = value.replace(/%20/g,"+");        value = value.replace(/\//g,"%2F");        value = value.replace(/,/g,"%2C");
        value = value.replace(/%27/g,"'");
        for( var i = 0; i< formElt[inputChkBoxName].length;i++)        {
          // on regarde si on un OF dans la value
          tabValeurOF = formElt[inputChkBoxName][i].value.split("+OF+");
          if ( tabValeurOF.length > 1 )
          {
            valeurMultiple=true;

            // regarde si check
            if ( selectedValues.length >= tabValeurOF.length )
            {
              for ( var k = 0; k< tabValeurOF.length; k++)
              {
                valeurOF = tabValeurOF[k];
                valeurOF = valeurOF.replace(/%20/g,"+");
                valeurOF = valeurOF.replace(/\//g,"%2F");
                valeurOF = valeurOF.replace(/,/g,"%2C");
                valeurOF = valeurOF.replace(/%27/g,"'");

                if ( valeurMultiple == true )
                {                  
		  // on continue
                  valeurMultiple = false;
                  for ( var l=0; l< selectedValues.length; l++ )
                  {

                    valueTmp = encodeURI(selectedValues[l]);
                    valueTmp = valueTmp.replace(/%20/g,"+");
                    valueTmp = valueTmp.replace(/\//g,"%2F");
                    valueTmp = valueTmp.replace(/,/g,"%2C");
                    valueTmp = valueTmp.replace(/%27/g,"'");

                    if ( valeurOF == valueTmp )
                      valeurMultiple = true;
                  }
                }
              }
            }
            else
              valeurMultiple = false;

            formElt[inputChkBoxName][i].checked = valeurMultiple;
          }
          else
          {
            if (value == formElt[inputChkBoxName][i].value)
              formElt[inputChkBoxName][i].checked = true;
          }
        }
      }
   }   
}   



/**** SMART LIST-PICKER FOR SPECIFIC SEARCH CRITERIA ****/
idTimer =null;

function smartListPicker(pageURL,inputItem,loaderSearchDivId,searchScope){
	var delay = '1000';

	if(inputItem.value != "")
	{
		if(navigator.appName.indexOf("Internet Explorer")!=-1)
		{
			//document.getElementById(loaderSearchDivId).style.marginLeft= "80px";
		}
		var loaderImage = '<img src="../../images/loader.gif" width="13" height="13" />'

			var loaderSearchDiv = document.getElementById(loaderSearchDivId);

		var inputItemValue = inputItem.value;

		if (idTimer != null) {
			clearTimeout(idTimer);
			idTimer = null;
		}

		idTimer = setTimeout( function() {
			if(inputItemValue == document.getElementById(inputItem.id).value)
			{
				loaderSearchDiv.innerHTML=loaderImage;                                  
				loadDivScriptEnable(pageURL,loaderSearchDiv,"__srch_expr__=" + inputItemValue + "&loaderSearchDivId=" + loaderSearchDivId + "&search_scope=" + searchScope+"&divId="+inputItem.id);
			}
			clearTimeout(idTimer);
			idTimer = null;
		},delay); 
	}
	else
	{
		document.getElementById(loaderSearchDivId).innerHTML = '';
	}
}


/***********************************************************************************************************************/
/*** 									SAVE/REMOVE SEARCHES 															 ***/
/***********************************************************************************************************************/
var xhr = null;

//Save searches
function savedSearches(isBewaardeSM)
{
	isBewaardeSM = (!isBewaardeSM) ? "false" : isBewaardeSM;

	if(document.getElementById('loaderSearchDiv'))
		document.getElementById('loaderSearchDiv').innerHTML = '<img src="../../images/loader.gif" width="13" height="13" />';
	var searchName = (isBewaardeSM == "false" ) ? document.getElementById("searchmaskName").value : isBewaardeSM;
	var theTabs = (document.getElementById("theTabs")) ? document.getElementById("theTabs").value : "";					

        var infoType_PI = document.getElementById("infoType_PI_value");
        var infoType_PI_value="";

        if ( infoType_PI != null )
        { 
          infoType_PI_value = document.getElementById("infoType_PI_value").value;
        }

	if(searchName != null && searchName != ""){
		if (searchName.indexOf("\'",0) != -1 || searchName.indexOf("\\",0) != -1){
			//alert("The search term contains invalid characters such as \\ and \' .");
			document.getElementById('loaderSearchDiv').innerHTML = '';
			alert("De naam mag geen ongeldige tekens bevatten zoals \\ en \'.");
			document.getElementById('searchmaskName').focus();
		}else{
			getXhr();
			// On d?finit ce qu'on va faire quand on aura la r?ponse
			xhr.onreadystatechange = function(){
				// On ne fait quelque chose que si on a tout re?u et que le serveur est ok
				if(xhr.readyState == 4 && xhr.status == 200)
				{							
					if(document.getElementById('loaderSearchDiv'))
						document.getElementById('loaderSearchDiv').innerHTML = '';

					var response = xhr.responseText;
					response = response.replace(/^\s+/g,'').replace(/\s+$/g,'');					
					if(response == "false")
					{
						alert("Naam bestaat al.");
					}
					else
					{
						alert("zoekopdracht bewaard");
						if(isBewaardeSM != "true")
							window.close();
					}					
				}
			}				
			xhr.open("POST","/sf7/modules/common/searchMaskSaving.jsp",true);
			// ne pas oublier ?a pour le post
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			// ne pas oublier de poster les arguments
			xhr.send("searchName="+encodeURIComponent(searchName)+"&theTabs="+theTabs+"&infoType_PI_value="+infoType_PI_value);			
		}			
	}else{
		alert("Er is geen naam voor deze zoekopdracht ingevuld");
	}
}

//Remove searches
function removeSearchMask(searchName,SM_date,searchScope){
	getXhr();
	// On d?finit ce qu'on va faire quand on aura la r?ponse
	xhr.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout re?u et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200){
			if(!searchScope || searchScope == "false")
			{
				document.location.reload();
			}
			else
			{
				nav.loadDiv(nav.lastUrlLoaded,'tab-search-content');										
			}
		}
	}				
	xhr.open("POST","/sf7/modules/common/searchMaskRemoving.jsp",true);
	// ne pas oublier ?a pour le post
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ne pas oublier de poster les arguments
	searchName = searchName.replace("&quote;","\"");
	xhr.send("SF7_currentSearchFormName="+encodeURIComponent(searchName)+"&SM_date="+SM_date);
}


//Popup d'enregistrement d'un searchMask
function new_window() 
{
	if(nbSearchMask >= number_max_of_searchmask){
		alert("U hebt het maximum aantal opgeslagen zoekvragen bereikt. Een overzicht van al uw zoekvragen kunt u vinden bij "+SearchMaskScope+".");
	}else{
		var searchString = document.getElementById('search-string').value;
		var theTabs = document.getElementById('theTabs');
		theTabs = (theTabs) ? theTabs.value : "" ;

		var ii=1;
		var infoType_PI_value='';
		while (document.getElementById('infoType_PI_value_'+ii)) {
			if (document.getElementById('infoType_PI_value_'+ii).checked) {
				if (infoType_PI_value=='') {
					infoType_PI_value = document.getElementById('infoType_PI_value_'+ii).value;
				} else {
					infoType_PI_value = infoType_PI_value+','+document.getElementById('infoType_PI_value_'+ii).value;
				}
			}
			ii++;
		} 

		var sv = urlEncoding(searchString);
		sv = sv.replace(/\€/g,'--euro--');

		window.open("/sf7/modules/common/savedSearches.jsp?searchString="+sv+"&theTabs="+theTabs+"&infoType_PI_value="+infoType_PI_value,'','width=700,height=300,left=250,top=300,scrollbars=yes,resizable=yes');
	}
}

function initNBSearchMask(nbMaxSearchmask,nbSearchmask,SearchMaskScopetmp){
	if(nbMaxSearchmask != '')
		number_max_of_searchmask = nbMaxSearchmask;
	if(nbSearchMask != '')
		nbSearchMask = nbSearchmask;
	if(SearchMaskScopetmp != '')
		SearchMaskScope = SearchMaskScopetmp;
}


//to hide the search mask part, to match component library requirements
function hideSM(searchScope){
	//document.getElementById("search-result").style.width="95%";
	document.getElementById("search-result").className = ""; 
	document.getElementById("search-tabs").style.display="none";
	document.getElementById("search-form").style.display="none";
	document.getElementById("search-trail_"+searchScope).style.display="none";
	document.getElementById("search-linklist_"+searchScope).style.display="none";
	if(document.getElementById("search-linklist_"+searchScope+"_fixed"))
		document.getElementById("search-linklist_"+searchScope+"_fixed").style.display="none";
	document.getElementById("toggler-zoeken").style.display="block";
	if(document.getElementById("tocsearch"))
		document.getElementById("tocsearch").style.display="none";
}

function showSM(searchScope){
	//document.getElementById("search-result").style.width="72%";
	document.getElementById("search-result").className = "search-result"; 
	document.getElementById("search-tabs").style.display="block";
	document.getElementById("search-form").style.display="block";
	document.getElementById("search-trail_"+searchScope).style.display="block";
	document.getElementById("search-linklist_"+searchScope).style.display="block";
	if(document.getElementById("search-linklist_"+searchScope+"_fixed"))
		document.getElementById("search-linklist_"+searchScope+"_fixed").style.display="block";
	document.getElementById("toggler-zoeken").style.display="none";
	if(document.getElementById("tocsearch"))
		document.getElementById("tocsearch").style.display="block";
}

function putListProductsSearchedInSession(listProductsSearched,searchScope)
{
	getXhr();
	xhr.onreadystatechange = function(){

		if(xhr.readyState == 4 && xhr.status == 200){

		}
	}				
	xhr.open("POST","/sf7/modules/common/putListProductsSearchedInSession.jsp",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("listProductsSearched="+listProductsSearched+"&search_scope="+searchScope);
}

function removePlus(s) {
	var i;
	var tmp="";
	for (i=0;i<s.length;i++) {
		if (s.charAt(i)!='+') {
			tmp=tmp+s.charAt(i);
		}
		else {
			tmp=tmp+'%2B';
		}
	}
	return tmp;
}

//[END]QUOTE 376 RFC_20070516

function displayHint(hint)
{
	ASpopup = window.open("/cl2/hint/hint"+hint+".html","hint","width=400,height=200,resizable=yes,scrollbars=yes");
	ASpopup.focus();
	return;
}

/** Fonction pour ouvrire ou fermer la branche d'un arbre **/
function processNode(nodeId,nodeState,anchor, piDetail,otherParam) {
    processNode2(nodeId,nodeState,anchor, piDetail,otherParam,"/sf7/modules/results/refineBox.jsp","infotype-sort");
}

/** Fonction pour ouvrire ou fermer la branche d'un arbre **/
function processNode2(nodeId,nodeState,anchor, piDetail,otherParam,url,elementId) {
    getXhr();
    var randomNumber = Math.random();
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            var propertiesDivObj = document.getElementById(elementId);
            propertiesDivObj.innerHTML = xhr.responseText;
        } 
    }
    xhr.open("POST",url,true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send("switch="+nodeId+"&state=" + nodeState + "&menuId="+piDetail+"&init=false&pi-detail="+ piDetail + "&" + randomNumber + otherParam);
}


function setCurrentLabelDate(value){
	currentLabelDate=value;
}

function setDateTypeSelect(prefixe,label, element)
{
	var select = document.getElementById(prefixe+"-"+element);					
	if(select)
	{
		var len = select.options.length;
		for(i=0; i< len; i++)
		{
			value=select.options[i].value;        
			if(value.indexOf(label) != -1)
				select.selectedIndex = i;
		}
	}
}

function setDateTypeInput(prefixe, label, element)
{
	if(document.getElementById(prefixe+"-"+element))
		document.getElementById(prefixe+"-"+element).value = label;
}

/*** Renome les champs date du formulaire  ***/
function replaceNameDateField(prefixe){
	select = document.getElementById(prefixe+"#"+currentLabelDate+"-type");
	indice=select.selectedIndex;
	value=select.options[indice].value; 
	value = value.substring(value.lastIndexOf(' ')+1,value.length);
	var allInput = document.getElementsByTagName("input");
	var reg=new RegExp(prefixe+"#"+currentLabelDate,"g");
	for(var i=0;i<allInput.length;i++) {	
		if(allInput[i].id.indexOf(prefixe+"#"+currentLabelDate)!=-1){
			allInput[i].id=allInput[i].id.replace(reg,prefixe+"#"+value);
			allInput[i].name=allInput[i].name.replace(reg,prefixe+"#"+value);
		}
	}

	var allSelect = document.getElementsByTagName("select");
	for(var i=0;i<allSelect.length;i++) {	
		if(allSelect[i].id.indexOf(prefixe+"#"+currentLabelDate)!=-1){
			allSelect[i].name=allSelect[i].name.replace(reg,prefixe+"#"+value);
			allSelect[i].id=allSelect[i].id.replace(reg,prefixe+"#"+value);
		}
	}

	var allSpan = document.getElementsByTagName("span");
	for(var i=0;i<allSpan.length;i++) {	
		if(allSpan[i].id.indexOf(prefixe+"#"+currentLabelDate)!=-1){
			//allSpan[i].name=allSpan[i].name.replace(reg,prefixe+"#"+value);
			allSpan[i].id=allSpan[i].id.replace(reg,prefixe+"#"+value);
		}
	}	
	currentLabelDate=  value;
}


/*** Recupere les produits checked ***/
function selectedProducts(formName){

	var productForm;    
	var listProducts="";

	if(document.forms[formName+"_productListForm"])    	
		productForm = document.forms[formName+"_productListForm"];

	if(productForm)
	{
		if(productForm != null ){
			var allInput = productForm.getElementsByTagName("input");
			var reg=new RegExp("SF6_5_PRODUCT_","g");
			for(var i=0;i<allInput.length;i++) {	
				if(allInput[i].id.indexOf("SF6_5_PRODUCT_")!=-1){
					if(allInput[i].checked){
						listProducts+=allInput[i].value+",";
					}
				}
			}
		}
	}

	if(listProducts == "")
	{  
		productForm = document.forms[formName+"_products"];    
		listProducts="";
		if(productForm != null ){
			var allInput = productForm.getElementsByTagName("input");
			var reg=new RegExp("SF6_5_PRODUCT_","g");
			for(var i=0;i<allInput.length;i++) {	
				if(allInput[i].id.indexOf("SF6_5_PRODUCT_")!=-1){
					if(allInput[i].checked){
						listProducts+=allInput[i].value+",";
					}
				}
			}
		}
	}
	if(listProducts != ""){
		var currentForm = document.forms[formName];
		currentForm.elements["listProductsSearched"].value=listProducts;
	}
}


/*** Modify the state of Product checkbox ***/
function checkProducts(value,search_scope){
	var currentForm = document.forms["form_"+search_scope+"_products"];
	if(currentForm != null ){
		var allInput = currentForm.getElementsByTagName("INPUT");

		if(allInput.length == 0){
			allInput = document.getElementsByTagName("input");
		}
		for(var i=0;i<allInput.length;i++) {
			if(allInput[i].id.indexOf("infoType_PI_value_")<0){	
				if(value == "true" ){
					allInput[i].checked = true;
				}else{
					allInput[i].checked = false;
				}
			}
		}
	}
}


/*** Resize the height of the words picklist regarding the search-input panel dimension ***/
function resizeSearchWordAssistant(form){
	var divToResizeparentDiv=null;
	var parentDiv=null;
	var term = null;                
	var tmpTerm=null;	

	if(form != null && form != "")
	{
		tmpTerm = document.forms[form].elements['search-string'];
		if(tmpTerm != null){
			term = document.forms[form].elements['search-string'].value;                
		}
		divToResizeparentDiv = getThesaurusElementDivById(form,'search-word-assistant');
		if(divToResizeparentDiv!=null)
			parentDiv = divToResizeparentDiv.parentNode;
	}else{
		tmpTerm = document.getElementById('search-string');
		if(tmpTerm != null){
			term = document.getElementById('search-string').value;
		}
		parentDiv = document.getElementById("search-terms");
		if(parentDiv!=null)
			divToResizeparentDiv = document.getElementById("search-word-assistant");
	}
	if(parentDiv && divToResizeparentDiv){  
		var bottomGap = 8;

		var newHeight = parentDiv.offsetHeight - bottomGap;
		if(parentDiv.offsetHeight > bottomGap)
		{

			var specificSearchHeight = (document.getElementById("search-criteria-wet")) ? document.getElementById("search-criteria-wet").offsetHeight + 20 : 0;
			newHeight = parentDiv.offsetHeight - bottomGap - specificSearchHeight - 35;

			//-- HPOV 124.493
			if(newHeight > 0){
				divToResizeparentDiv.style.height = newHeight + "px";
			}else{
				if(document.getElementById("search-input-div").offsetHeight <= (bottomGap + 35) ){
					divToResizeparentDiv.style.height = document.getElementById("search-input-div").offsetHeight;
				}else{
					divToResizeparentDiv.style.height = document.getElementById("search-input-div").offsetHeight - bottomGap - 35;
				}
			}

			/*< CQ1762 : EMA : 17112008 >*/
			divToResizeparentDiv.style.display = "block";
			/*</ CQ1762 : EMA : 17112008 >*/
		}
	}
}  


/*** Reload only the serchMask Display ***/
function relaodDisplaySearchMask(search_scope, productList){
	if(document.getElementById("search-specific_"+search_scope))
		document.getElementById("search-specific_"+search_scope).style.display="block";
	if(document.getElementById("search-summary_"+search_scope))
		document.getElementById("search-summary_"+search_scope).style.display="none";

	if(document.getElementById("tocsearch"))
		document.getElementById("tocsearch").style.display="block";

	if(productList)
	{
		document.getElementById(productList).style.display="block";
	}


}


/*** ComponentLibrary : HighLight the active summarry ***/
function highLigthSummary(offset, numStart, nbResult){
	start=numStart - 1;
	end=parseInt(start)+parseInt(nbResult) + 2;
	var i=0;
	for(i=start; i<end; i++)
	{
		var div = document.getElementById("result_"+i);
		if (div != null)
		{
			if (i==offset)
			{
				div.className="active";
			}
			else 
			{
				div.className="sf7_list";
			}
		}
	}
}


//function loadDoc_SF7(div_template)
function loadDoc_SF7(link,target)
{
	if(link != "" && target !=""){
		window.open(link, target);  
	}
}


function switchViewCL2(view1,view2){
	view1.style.display="none";
	view2.style.display="block";
}

function urlEncoding(params){
	var tmp = params.replace(/\+/,'%2B');	
	tmp = tmp.replace(/=/,'%3D');
	tmp = tmp.replace(/\&/,'%26');
	tmp = tmp.replace(/\?/,'%3F');
	tmp = tmp.replace(/\#/,'%23');

	return tmp;
}



//Dev 4.1 : remind product search scope simple
function remindProducts(obj,context,aboProduct)
{
	getXhr();


	var status;
	var product;
	if(aboProduct == "png")
	{	
		if(obj == "removeAll")
		{
			status = obj;
			product = "removeAll";
		}
		else if(obj == "addAll")
		{
			status = obj;
			product = "addAll";
		}			
		else
		{
			status = obj.checked;
			product = obj.id;
		}		
	}
	else
	{
		if(obj == "removeAll" || obj == "addAll" || obj == "addAbonnementen")
		{
			status = obj;
			product = "";
		}			
		else
		{
			status = obj.checked;
			product = obj.value;
		}
	}
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200)
		{							
		}
	}				
	xhr.open("POST","/sf7/modules/common/productList/remindProducts.jsp",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("product="+product+"&status="+status+"&context="+context+"&aboProduct="+aboProduct);
}


function init_PNG_remindProducts(context, form, editList)
{
	getXhr();

	var id;
	var initList = "";	
	var initProdList = "";	
	var elements = document.forms[form];      
	for(var i =0; i< elements.length; i++)
	{	  
		if(elements[i].type == "checkbox")
		{
			id = elements[i].id;
			initList +=id+","			
		} 	        
	}
	if(initList > 0)
		initList = initList.substring(0,initList.length-1);

	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			if(editList != "")
				PNG_remindProducts(context, form, editList);			
		}
	}				
	xhr.open("POST","/sf7/modules/common/productList/PNGInitRemindProducts.jsp",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("initList="+initList+"&context="+context);
}


function PNG_remindProducts(context, form, editList)
{
	getXhr();

	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			var liste = xhr.responseText;
			liste = liste.replace(/^\s+/g,'').replace(/\s+$/g,''); 	
			liste = liste.split(",");					
			var isEdit = false;

			if(editList && editList != "null")
			{					
				editList = editList.replace(/^\s+/g,'').replace(/\s+$/g,''); 	
				editList = editList.split(",");
				if(editList.length > 0)
					isEdit = true;
			}

			var elements = document.forms[form];      
			//-- HPOV 124.493 
			var nbre = 0;
			if(elements != null && elements != undefined){
				nbre = elements.length;
			} 
			for(var i =0; i< nbre; i++)
			{	  
				if(elements[i].type == "checkbox")
				{
					var aElts = (document.getElementById(elements[i].id).parentNode).getElementsByTagName('a');

					if(isEdit && (aElts.length>0))
					{
						var slotId = aElts[0].target;
						//if MIG-BOOt content (= SLOT) else PUMA content (= CS)
						slotId = (slotId.indexOf("SLOT") != -1) ? slotId : slotId.substring(slotId.indexOf("#")+1, slotId.length);
						slotIdList = slotId.split(";");
						for(var j=0; j<slotIdList.length;j++)
						{
							var idToTest = slotIdList[j];
							idToTest = idToTest.replace(/^\s+/g,'').replace(/\s+$/g,'');
						if(!editList.inArray(idToTest))
							elements[i].checked = false;

						}
					}
					else
					{
						if(!liste.inArray(elements[i].id))	
							elements[i].checked = false;	
					}					
				} 	        
			}

		}
	}				
	xhr.open("POST","/sf7/modules/common/productList/PNGRetrieveRemindProducts.jsp",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	var params = "context="+context;
	if(editList)
		params += "&editList="+editList;	
	xhr.send(params);
}

Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function hideDisplaySeveralElements(search_scope,tagNameCondition,classNameCondition){
	var currentForm = document.forms["form_"+search_scope+"_products"];
	if(currentForm != null ){
		var foundElements = currentForm.getElementsByTagName(tagNameCondition);
		for ( var idxElt = 0; idxElt < foundElements.length ; idxElt++){
			if(foundElements[idxElt].className == classNameCondition){
				if(foundElements[idxElt].style.display == "")
					foundElements[idxElt].style.display = "block";
				if(foundElements[idxElt].style.display == "block")
					foundElements[idxElt].style.display = "none";
				else
					foundElements[idxElt].style.display = "block";
			}
		}
		foundElements = currentForm.getElementsByTagName('a');
		for ( var idxElt = 0; idxElt < foundElements.length ; idxElt++){
			if(foundElements[idxElt].id == "contentUpdateInfoLink")
				foundElements[idxElt].innerHTML = (foundElements[idxElt].innerHTML == "Plaatsingsdata verbergen") ? "Plaatsingsdata tonen" : "Plaatsingsdata verbergen";
		}
	}
}

//Gestion onglet "Nieuw"
function executeSearchNieuws(periode,search_scope,params)
{
	if(window.nav)
		nav.loadDiv("/sf7/modules/contentUpdateInfo/executeSearchNieuws.jsp?search_scope="+search_scope+"&periode="+periode+params,"search-result_"+search_scope+"_ajax");
	else
		loadDiv("/sf7/modules/contentUpdateInfo/executeSearchNieuws.jsp",document.getElementById("search-result_"+search_scope),"search_scope="+search_scope+"&periode="+periode+params);
}

function popup(myurl)
{
	currentDate = new Date();
	var namepopup="";
	if (myurl.indexOf("?")>=0) {
		namepopup="&namepopup="+currentDate.getTime();
	}
	else {
		namepopup="?namepopup="+currentDate.getTime();
	}
	ASpopup = window.open(myurl+namepopup, currentDate.getTime(), "width=673,height=600,resizable=yes,scrollbars=yes");
	ASpopup.focus();
	return;
}



//HPOV 118.290
function loadDiv_withHighlighting(url,item,params,searchterm){
	var xhrLoc = getLocalXhr();

	item.innerHTML="<img src=\"/componentLibrary/images/loader.gif\" width=\"13\" height=\"13\" />";

	xhrLoc.onreadystatechange = function()
	{
		if(xhrLoc.readyState == 4 && xhrLoc.status == 200)
		{							
			var propertiesDivObjSr = item;
			var responseString = xhrLoc.responseText;
			responseString = responseString.replace(/(^\s*)|(\s*$)/g,"");
			if(propertiesDivObjSr.id=="sidebar-tabs")
				propertiesDivObjSr.innerHTML = responseString;
			else
				document.getElementById(propertiesDivObjSr.id).innerHTML = responseString;
			// HPOV 118.920
			highlighting(searchterm);
		}
	}			
	xhrLoc.open("POST", url, true);
	xhrLoc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	listParams = params ; 		
	xhrLoc.send(listParams);	
}

//SFI_2010
//uses to determine if the resultList is displayed in full mode or is displayed in the sidebar
//return true (full mode) or false (sidebar mode)
function resultList_is_full_mode(search_scope){
	var boolResult = true;

	//the refine box
	if (document.getElementById("search-linklist_"+search_scope))
	{
		if(document.getElementById("search-linklist_"+search_scope).style.display == 'none')
		{
			boolResult = false;
		}
	}
	//the search form
	if(document.getElementById("search-form"))
	{
		if(document.getElementById("search-form").style.display == 'none')
		{
			boolResult = false;
		}
	}
	return boolResult;
}

//SFI_2010
//tests the display mode of the result list and re-execute the search
function executeQS_extended(search_scope, type, param3, param4, url, param6, param7 ){
	//test if the resultList shoud be display in full mode or in sidebar mode
	var boolDisplayMode = resultList_is_full_mode(search_scope);   
	executeQS(search_scope, type, param3, param4, url, param6, param7, boolDisplayMode);
}

//HPOV
function disableZoekenButton(){
	// Simple Search
	var zoekenButton = document.getElementById("buttonZoek");
	if(zoekenButton != null){
		zoekenButton.className = 'searchbuttonNOTactive';
		zoekenButton.disabled = true;
	}
	
	// Advanced search
	var advZoekenButton = document.getElementById("button-submit");
	if(advZoekenButton != null){
		advZoekenButton.className = 'searchbuttonNOTactive';
		advZoekenButton.disabled = true;
	}
}

function enableZoekenButton(event){
	
	var touche=null;
	if(event!=null)
		touche = window.event ? event.keyCode : event.which;

	//do not enable if key is "enter"
        if(touche!=13){

		// Simple Search
		var zoekenButton = document.getElementById("buttonZoek");
		if(zoekenButton != null){
			zoekenButton.className = 'searchbuttonactive';
			zoekenButton.disabled = false;
		}
	
		// Advanced search
		var advZoekenButton = document.getElementById("button-submit");
		if(advZoekenButton != null){
			advZoekenButton.className = 'searchbuttonactive';
			advZoekenButton.disabled = false;
		}
	}
}

function isZoekenButtonEnable(){
	var enabled = true;
	
	// Simple Search
	var zoekenButton = document.getElementById("buttonZoek");
	if(zoekenButton != null && zoekenButton.className == 'searchbuttonNOTactive'){
		enabled = false;
	}
	
	// Advanced search
	var advZoekenButton = document.getElementById("button-submit");
	if(advZoekenButton != null && advZoekenButton.className == 'searchbuttonNOTactive'){
		enabled = false;
	}
	return enabled;
}

function refreshSooProductsSearchedList(name)
{           
     var productList = document.getElementsByName(name);
     listProductsSearched = "";
       
     if(productList)
     {
     	if(productList.length)
          {
             for(var i=0;i<productList.length;i++)
             {
                 if(productList[i].checked)
                 {
                     listProductsSearched += productList[i].value + ",";
                 }
             }
     	}
     	else{
     		if(productList.checked){
                listProductsSearched += productList.value + ",";
            }
     	} 
     }
     if(listProductsSearched != "")
          listProductsSearched = listProductsSearched.substring(0,listProductsSearched.length-1);        
     document.getElementById("listProductsSearched").value = listProductsSearched;
}

//--------------------------------
//* [2011-1 R2] RFC#2b -> F1-F6
//--------------------------------

/* Function used to enable / disable the "Open deze wet" button
 * @param: -
 */
function enableOpenDezeWetFunction()
{
	var text = document.getElementById('search-string').value;
	if(text.length >0)
	{
		if (document.getElementById('buttonSearchInLaw'))
        {
			document.getElementById('buttonSearchInLaw').disabled=false;
			document.getElementById('buttonSearchInLaw').className ='searchbuttonactive';
        }
	}
	else
	{
		if (document.getElementById('buttonSearchInLaw'))
        {
			document.getElementById('buttonSearchInLaw').disabled=true;
			document.getElementById('buttonSearchInLaw').className ='searchbuttonNOTactive';
        }
	}//end if/else
	
}//end enableOpenDezeWetFunction()

/* Function used to display the modal dialog box 
 * and to display the selected law
 * @param: word -> the zoeken input value
 * @param: search_scope -> the search_scope value
 */
function displayModalDialogBox(word, search_scope)
{
	var result = "";
	var dialogHeight = 750;
	var dialogWidth = 500;
	features = "dialogWidth="+dialogWidth+"px; dialogHeight="+dialogHeight+"px;";
	//alert("screen.height: " + screen.height + ", screen.width: "+ screen.width );
	var heightS = screen.height;
	var widthS = screen.width;
	var topMDB = ( ( heightS / 2 ) - ( dialogHeight / 2 ) );
	var leftMDB = ( ( widthS / 2 ) - ( dialogWidth / 2) );
	features = features + "dialogTop:"+topMDB+"px; dialogLeft: "+leftMDB+"px;";
	
	// remove brackets
	word = word.replace('\"','');
	
	result = window.showModalDialog('/sf7/modules/common/openDezeWet.jsp?term='+word+'&search_scope='+search_scope,'popup',features);
	
	//result contains the docId of the document to display
	//if result is null, then the user has clicked on Cancel button.
	if(result != null)
	{
		if(search_scope=="cl3_soo")
		{
			loadWetToc(result);
		}
		else
		{
			window.open("/cl3/application-context/SOO/index.jsp?gc=WKNL-KL-PNP-SOO-GC-MAIN&sc=WKNL-KL-PNP-SOO-MAIN&docId="+result);
		}
		
	}//end if
	
}//end displayModalDialogBox()

//--------------------------------
//* [2011-1 R2] RFC#2b -> F7-F13
//--------------------------------

/* Function used to remove / hide the suggestion div
 * @param: -
 */
function removeSuggestionDiv()
{
	var suggF = document.getElementById("SIL_suggestionsDiv");
	if ( suggF != null )
	  suggF.style.visibility = "hidden";
	
}//end removeSuggestionDiv()

/* Function used to retrieved all suggestions according to the user's text
 * @param: -
 */
function findSuggestions()
{
	var wetnaamF =document.getElementById("viewSearchMaskForm_icalt_commonAdvanced#wetnaam_inputValue");
	var currentWord = wetnaamF.value;
	var suggF = document.getElementById("SIL_suggestionsDiv");
	
	if(currentWord == "")
	{
		suggF.style.visibility = "hidden";
	}
	else
	{
		suggF.style.visibility = "visible";
		
		var xhr = getXMLHTTP();
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{	
				document.getElementById("SIL_suggestionsDiv").text = "";
				document.getElementById("SIL_suggestionsDiv").innerHTML = xhr.responseText;
			}
		}			
		xhr.open("POST", "/cl3/application-context/SOO/index.jsp", true);
		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		listParams = "gc=WKNL-KL-PNP-SOO-GC-SIDEBAR&sc=WKNL-KL-PNP-SOO-SEARCHINLAW&mode=suggest&ar=t&w="+escape(currentWord);
		xhr.send(listParams);
		
	}
}//end findSuggestions()

/* Used to get a XMLHttpRequest object 
 * depending on your browser
 * @param: -
 */
function getXMLHTTP()
{
	var xhr=null;
	if(window.XMLHttpRequest)
	{	// Firefox 
		xhr = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{	// Internet Explorer
		try
		{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e1)
			{
				xhr = null;
			}//end try/catch
		}//end try/catch
	}
	else
	{	// XMLHttpRequest not supported
		alert("Your browser do not support XMLHTTPRequest objects, please contact the helpdesk ...");
	}//end if/elseif/else
	return xhr;
}//end getXMLHTTP()

/* Function used to set the wetnaam field 
 * with the selected value by the user
 * @param: theSelectValue -> the selected table line
 */
function setSuggestion(theSelectedValue)
{
	var wetnaamF =document.getElementById("viewSearchMaskForm_icalt_commonAdvanced#wetnaam_inputValue");

	//remove the hx balises
	reg=new RegExp("<(span|\/span)>+", "gi" );
	theSelectedValue=theSelectedValue.replace(reg, "" );
	
	//delete the date and the blank space in front
	theSelectedValue = theSelectedValue.substring(0, theSelectedValue.lastIndexOf('(')-1);
	
	wetnaamF.value = theSelectedValue;
	
}//end setSuggestion()

/* Function used to position the suggestions div.
 * @param: fieldW -> the wetnaam field
 */
function positionSuggestionDiv(fieldW, search_scope)
{
	var MAX_ITEM = 5;
	var top = fieldW.offsetTop;
	var left = fieldW.offsetLeft;
	var height = fieldW.offsetHeight;
	var width = fieldW.offsetWidth;

	if ( height == 0 )
	  height = 22;

	if ( width == 0 )
	  width = 387;


        width += 90;


	var agt=navigator.userAgent.toLowerCase();

	if (agt.indexOf("firefox") != -1){
		
		if(search_scope.indexOf("soo") != -1)
		{	//SOO
			top = 67;
		}
		else if(search_scope.indexOf("navilite") != -1)
		{	//navilite
			top=98;
		}
		else if(search_scope.indexOf("VNI") != -1 || search_scope.indexOf("cl2") != -1)
        {
		    //VNI, DESK, cl2
            top=67;
        }
		else
		{	//png
			top=94;
		}
		left=170;
		
	}else if (agt.indexOf("safari") != -1){
		
		if(search_scope.indexOf("soo") != -1)
		{	//SOO
			top = 68;
		}
		else if(search_scope.indexOf("navilite") != -1)
		{	//navilite
			top=93;
		}
        else if(search_scope.indexOf("VNI") != -1 || search_scope.indexOf("cl2") != -1)
        {
             //VNI, DESK, cl2
             top=68;
        }
		else
		{	//png
			top=93;
		}
		left=170;
	
	}else if (agt.indexOf("msie 8") != -1){
			if(search_scope.indexOf("soo") != -1)
			{
				//SOO
				top = 72;
			}
			else if(search_scope.indexOf("navilite") != -1)
			{
				//navilite
				top=95;
			}
			else if(search_scope.indexOf("VNI") != -1 || search_scope.indexOf("cl2") != -1)
			{
				//VNI, DESK, cl2
				top=68;
			}
			else
			{
				//png
				top=96;
			}
			left=170;
  }else if (agt.indexOf("msie 9") != -1){

    if(search_scope.indexOf("soo") != -1)
    { //SOO
      top = 72;
    }
    else if(search_scope.indexOf("navilite") != -1)
    { //navilite
      top=92;
    }
    else if(search_scope.indexOf("VNI") != -1 || search_scope.indexOf("cl2") != -1)
    {
      //VNI, DESK, cl2
      top=68;
    }
    else
    { //png
      top=96;
    }
    left=170;	
	}else if (agt.indexOf("msie") != -1){
		
		if(search_scope.indexOf("soo") != -1)
		{	//SOO
			top = 72;
		}
		else if(search_scope.indexOf("navilite") != -1)
		{	//navilite
			top=97;
		}
		else if(search_scope.indexOf("VNI") != -1 || search_scope.indexOf("cl2") != -1)
		{
			//VNI, DESK, cl2
			top=68;
		}
		else
		{	//png
			top=96;
		}
		left=170;
		
	}//end position all browsers

	var suggF = document.getElementById("SIL_suggestionsDiv");
	suggF.style.position = "absolute";
	suggF.style.left = left + "px";
	suggF.style.top = top + height + "px";
	suggF.style.width = width + "px";
	suggF.style.height = (MAX_ITEM * 24) + "px";

	
}//end positionSuggestionDiv()

/* Function used to add event depending of the browser
 * @param: obj
 * 
 */
function addEventSF7(obj, type, fn, index)
{
	// for Firefox & Safari
	if(obj.addEventListener)
	{
		//Add function on the object
		obj.addEventListener(type, function(event){        
			return fn.call(obj, event, index);
		}, false );
	}
	else if(obj.attachEvent)//for IE
	{
		//Add function on the event
		obj.attachEvent("on"+type, function(e){
			if (!e) var e = window.event;   
			return fn.call(obj, e, index);
		});
	}//End if/else
	
}//end addEvent()

/* Function used to highlight the line in blue in the suggestion Box
 * @param: line the ID of the line 
 */
function addHighLight(line)
{
	document.getElementById(line).style.backgroundColor = '#D5E2FF';
}//end addHighLight()

/* Function used to put the line in white in the suggestion Box
 * @param: line the ID of the line 
 */
function removeHighLight(line)
{
	document.getElementById(line).style.backgroundColor = '#FFFFFF';
}//end removeHighLight()

/* Function used to init the suggestion dropdown list
 * @param: -
 */
function initWetnaamField(search_scope)
{
	//alert("test initWetnaamField");
	var wetnaamF = document.getElementById("viewSearchMaskForm_icalt_commonAdvanced#wetnaam_inputValue");
	//Add event when user entered text in wetnaam field
	addEventSF7(wetnaamF,"keyup",findSuggestions, 0);
	//Add event when user clicked anywhere -> dropdown is removed.
	addEventSF7(document,"click",removeSuggestionDiv, 0);
	//Put the div in the right place
	positionSuggestionDiv(wetnaamF, search_scope);
	
}//end initWetnaamField()

