// -- 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 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 url = "/sf7/modules/common/executeSearch.jsp";
 var params = params+"&search_scope="+search_scope+"&searchFormName="+SMName+"&itemName=&listProductsSearched="+listProductsSelected+"&searchType=";
 
 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(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 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].name.indexOf("cb_toc_") == 0) {
			tocIds += currentForm[i].name + ",";
		}
	}
	return encodeURI(tocIds);
}

function getTocSearchValue()
{
	var value = "all_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;
        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("No product in your selection");
			 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();
			xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4 && xhr.status == 200)
				{
					var listPropertiesDivObj = document.getElementsByTagName("div");
					// 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();
					}
                    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;
                    		}
                    	}
                    }
                                            
					var parentDiv=document.getElementById('content-all');
					
					for (var j=0;j<listPropertiesDivObj.length;j++)
					{                                                
						// Hides the wait message
						if (listPropertiesDivObj[j].id == "cluster-links-wait")
						{
							listPropertiesDivObj[j].style.display = "none";
						
						}				
						// Fills the cluster result list
						
						if (listPropertiesDivObj[j].id == ("search-trail_"+search_scope))
						{
							listPropertiesDivObj[j].style.display = "block";
						}
						
						if (listPropertiesDivObj[j].id == ("search-result_"+search_scope))
						{
							listPropertiesDivObj[j].style.display = "block";
							listPropertiesDivObj[j].innerHTML = xhr.responseText;
						}
						
						// Hides the wait message
						if (listPropertiesDivObj[j].id == ("search-wait_"+search_scope))
						{
							listPropertiesDivObj[j].style.display = "none";
						}		
						
						
						//linklist
                        if (listPropertiesDivObj[j].id == ("search-linklist_"+search_scope))
                        {                                                        							
	                        listPropertiesDivObj[j].style.display = "inline";
	                        listPropertiesDivObj[j].style.width="26%"                                                        
	                          
	                        if(request_query)
	                            listParams += request_query;
	                        listParams += "&searchMode=quickSearch";                                                        
	
	                        loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp',listPropertiesDivObj[j],listParams);
							//SFI_2010
							if(isFullMode != null)
							{
								if(!isFullMode)
									displayResult();
							}
                        }
						
						
						// Sitestat
						if ((listPropertiesDivObj[j].id == "siteStatCode") && (listPropertiesDivObj[j].innerHTML != null))
						{
							var theInnerHTML = Remplace(listPropertiesDivObj[j].innerHTML, "&amp;","&");							
							eval(theInnerHTML);
							listPropertiesDivObj[j].innerHTML = "";
						}
					}
                                        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>$/, ''));
                                            }
                                        }
                                        startGetThesaurus("form_"+search_scope);
				}
			}			
			
			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;
			
			xhr.send(listParams);

			var listDivObj = document.getElementsByTagName("div");
			for (var j=0;j<listDivObj.length;j++)
			{
				if (listDivObj[j].id == ("search-trail_"+search_scope))
						{
							listDivObj[j].style.display = "none";
						}
				if (listDivObj[j].id == ("search-result_"+search_scope))
						{
							listDivObj[j].style.display = "none";
							listDivObj[j].innerHTML = "";
						}
																	
				if (listDivObj[j].id == ("search-wait_"+search_scope))
				{
					listDivObj[j].style.display = "block";
				}
											
			}
		}
	}else{
	executeQS_kluwer(search_scope);	
}
}	
// TOC SEARCH
function getTocIdsParamForTocSearch(tocFormName, search_scope) {

	var currentForm = document.forms[tocFormName];	
	var listParams = "";
	
	if(currentForm){		
		var scopeRadio=null;
		
		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){
    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 && 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);
        }
    }			
    
    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 executeAS(search_scope, portal_type, fLabel, menu_module,request_query, isBewaardeSM,portalId,isDegrade)
{
    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("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("No product in your selection");
        } else {

            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)+"="+listInputObj[j].value;
                    }
            }

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


                    // no field can be empty
                    if (emptySM)
                    {
                            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();
                            xhr.onreadystatechange = function()
                            {
                                    if(xhr.readyState == 4 && xhr.status == 200)
                                    {
                                            var listPropertiesDivObj = document.getElementsByTagName("div");
                                            // 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();
                                            }
                                            
                                            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;
												                    		}
												                    	}
												                    }
                                                             
										                        var parentDiv=document.getElementById('content-all');

                                            for (var j=0;j<listPropertiesDivObj.length;j++)
                                            {

                                                    // Hides the SM
                                                    if (listPropertiesDivObj[j].id == ("search-specific_"+search_scope))
                                                    {
                                                            listPropertiesDivObj[j].style.display = "none";

                                                    }	
                                                    // show the search Summary 

                                                    if (listPropertiesDivObj[j].id == ("search-summary_"+search_scope))
                                                    {
                                                            loadDiv('/sf7/modules/common/advancedSearch_SM_Summary.jsp',listPropertiesDivObj[j],listParams);			
			
                                                            //listPropertiesDivObj[j].style.display = "block";

                                                    }	

                                                    // Fills the cluster result list

                                                    if (listPropertiesDivObj[j].id == ("search-trail_"+search_scope))
                                                    {
                                                            listPropertiesDivObj[j].style.display = "block";
                                                    }

                                                    if (listPropertiesDivObj[j].id == ("search-result_"+search_scope))
                                                    {
                                                            listPropertiesDivObj[j].style.display = "block";
                                                            listPropertiesDivObj[j].innerHTML = xhr.responseText;
                                                    }

                                                    // Hides the wait message
                                                    if (listPropertiesDivObj[j].id == ("search-wait_"+search_scope))
                                                    {
                                                            listPropertiesDivObj[j].style.display = "none";
                                                    }		


                                                    //linklist
                                                    if (listPropertiesDivObj[j].id == ("search-linklist_"+search_scope))
                                                    {
                                                        listPropertiesDivObj[j].style.display = "inline";
                                                        listPropertiesDivObj[j].style.width = "26%";
                                                        if(request_query)
                                                            listParams += request_query;
                                                        listParams += "&searchMode=quickSearch";                                                        
                                                        loadDivScriptEnable('/sf7/modules/results/refineResultList.jsp',listPropertiesDivObj[j],listParams);
                                                    }
                                                    //}

                                                    // Sitestat
                                                    if ((listPropertiesDivObj[j].id == "siteStatCode") && (listPropertiesDivObj[j].innerHTML != null))
                                                    {
                                                            var theInnerHTML = Remplace(listPropertiesDivObj[j].innerHTML, "&amp;","&");							
                                                            eval(theInnerHTML);
                                                            listPropertiesDivObj[j].innerHTML = "";
                                                    }
                                            }
                                            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>$/, ''));
                                                }       
                                            }   
                                            //for dislpay thesaurus term
                                            startGetThesaurus("form_"+search_scope);
                                            
                                            if(portalId)
										    {
												PNG_remindProducts('png_'+search_scope+portalId, 'form_'+search_scope+'_productListForm');
										    }                     
                                    }
                            } 
                            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 += param_SM;
                            listParams += "&listSearchedTerms="+listSearchedTerms;
                            listParams += "&newSearch=true";
                            
                            if(document.getElementById("isFromIntegratedSearch") && document.getElementById("isFromIntegratedSearch").value != "")				
                				listParams += "&isFromIntegratedSearch="+document.getElementById("isFromIntegratedSearch").value;
                            
                            //alert("PARAMS : "+listParams);
                            xhr.send(listParams);

                            var listDivObj = document.getElementsByTagName("div");
                            for (var j=0;j<listDivObj.length;j++)
                            {
                                    if (listDivObj[j].id == ("search-trail_"+search_scope))
                                                    {
                                                            listDivObj[j].style.display = "none";
                                                    }
                                    if (listDivObj[j].id == ("search-result_"+search_scope))
                                                    {
                                                            listDivObj[j].style.display = "none";
                                                            listDivObj[j].innerHTML = "";
                                                    }

                                    if (listDivObj[j].id == ("search-wait_"+search_scope))
                                    {
                                            listDivObj[j].style.display = "block";
                                    }

                            }
                    }
            //}
     }
}

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){
             //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";
                    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){            
            var fieldValue = "";
            var first = 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;
                    }
            }            
            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);
    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");	
			
			for( var i = 0; i< formElt[inputChkBoxName].length;i++)
			{
	             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 subInfoType_PI_value = (subInfoType_PI_value && subInfoType_PI_value.checked) ? document.getElementById("subInfoType_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+"&subInfoType_PI_value="+subInfoType_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 subInfoType_PI_value = document.getElementById('subInfoType_PI_value');			
			subInfoType_PI_value = (subInfoType_PI_value && subInfoType_PI_value.checked) ? subInfoType_PI_value.value : "" ; 
			
			var sv = urlEncoding(searchString);
			sv = sv.replace(/\€/g,'--euro--');
			
			window.open("/sf7/modules/common/savedSearches.jsp?searchString="+sv+"&theTabs="+theTabs+"&subInfoType_PI_value="+subInfoType_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) {
    getXhr();
    var randomNumber = Math.random();
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            var propertiesDivObj = document.getElementById("infotype-sort");
            propertiesDivObj.innerHTML = xhr.responseText;
        } 
    }
    xhr.open("POST","/sf7/modules/results/refineBox.jsp",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");
        //var allInput = document.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(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;
    end=parseInt(start)+parseInt(nbResult);
    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);
								if(!editList.inArray(slotId))
									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);
}