var sitesearchDatabase="/rsn/search.nsf"; 
var dbIds="72,604,352,947"; 
var altTarget=""; 
var baseTarget="_self"; 

/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	searchSite
doel:	uitvoeren sitesearchnzoek opdracht
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function searchSite (pTarget,pZoekprofiel) { 
        var query =window.document.getElementById("schilQuery").value; 
        if ((query=="") || (query=="zoeken")) { 
                window.alert("U dient minstens 1 woord in te voeren!"); 
        } else { 
                //generate url for triggering the Search agent 
                qry=query.replace(/ /g,"+"); 
                filter="en"; 
                max = "10"; 
                sort = "1"; 
                target=pTarget; 
                profiel = pZoekprofiel; 
                var zoek = profiel.replace(/ /g,"+"); 
                var url = sitesearchDatabase+'/(Search)?openagent&zp='+zoek+'&ua=0&db=' +dbIds+'&st=1&end='+max+'&op=' +filter+'&srt='+sort+'&qry='+ qry;


                // determine the location to open the generated url 
                if (target=="_self"){ 
                        self.location=url; 
                } else { 
                        if (target=="_blank"){ 
                                window.open(url,'resultaten','width=950,height=650,scrollbars=1,resize=0'); 
                        } else { 
                                if (target=="_top"){ 
                                        top.location=url; 
                                } else { 
                                        if (top.frames[target]) { 
                                                top.frames[target].location = url; 
                                        } else { 
                                                openURLinFrame(url,target); 
                                                return false; 
                                        } 
                                } 
                        } 
                } 
        } 
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	searchWebGen
doel:	uitvoeren webgen zoek opdracht
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function searchWebGen(pTarget,pZoekprofiel,pResultOP,pHC,pSC,pSSC) {
	target=pTarget
	soort="FT"
	var select =window.document.getElementById("schilQuery").value;
	if ((select=="") || (select=="zoeken")) {
		window.alert("U dient minstens 1 woord in te voeren!")
	} else {
		//eerst categorie Query samenstellen
		var catQry="";
		iHc=pHC;
		iSc=pSC;
		iSsc=pSSC;
		hc=(iHc=="")? '' : '[Hoofdcategorie]="'+iHc+'\"';
		sc=(iSc=="")? '' : '+and+[Subcategorie]="'+iSc+'\"';
		ssc=(iSsc=="")? '' : '+and+[Subsubcategorie]="'+iSsc+'\"';
		catQry=hc+sc+ssc
	
	profiel = pZoekprofiel;
	var zoek = profiel.replace(/ /g,"+");
	resultOP=pResultOP;
	filter = "of"
	max = "25"
	sort = "1"
		if (filter=="exact") {
			zoekstring='[Body]="'+ select+'"+OR+[ZoekInfo]="'+select+'"+OR+[$File]="'+select+'"'
		} else {
			operator= (filter=="of") ? "+OR+" : "+AND+"
			zoekwoorden=new Array()
			zoekwoorden=select.split(" ")
			//voor beide velden moet de string met de zoekopdracht worden bepaalt
			var zoekstringBody="("
			var zoekstringTitel="("
			var zoekstringFiles="("
			if (zoekwoorden.length==1) {
				zoekstring='[Body]="'+ select+'"+OR+[ZoekInfo]="'+select+'"+OR+[$File]="'+select+'"'
			} else {
				//meerdere woorden
				for (x=0;x<zoekwoorden.length;x++) {
					if ((zoekstringBody=="(") && (zoekstringTitel=="(")&& (zoekstringFiles=="(")) {
						zoekstringBody+="[Body]="+ zoekwoorden[x]
						zoekstringTitel+="[ZoekInfo]="+ zoekwoorden[x]
						zoekstringFiles+="[$File]="+ zoekwoorden[x]
					} else {
						zoekstringBody+=operator+"[Body]="+ zoekwoorden[x]
						zoekstringTitel+=operator+"[ZoekInfo]="+ zoekwoorden[x]
						zoekstringFiles+=operator+"[$File]="+ zoekwoorden[x]
					}
				}
				zoekstring=zoekstringBody+")+OR+"+zoekstringTitel+")+OR+"+zoekstringFiles+")"
			}
		}
		//categorie query combineren met invoerquery
		if (catQry!="") zoekstring=catQry+' and ('+zoekstring+')'
		url = curdbPad+'/webgensearch/?SearchView&Query='+zoekstring+'&Count='+max+'&SearchOrder='+sort+'&Start=1&ZP='+zoek+'&QS='+select.replace(/ /g,"+")+'&OPS='+filter+"&RS="+resultOP;
	
	//doel bepalen
	if (target=="_self"){
		self.location=url
	} else {
		if (target=="_blank"){
			window.open(url)
		}else{
			if (target=="_top"){
				top.location=url
			}else{
				if(top.frames[target])
					{top.frames[target].location = url
				}else{
					openURLinFrame(url,target)
					   return false;			
		     	}
	        	}
		}
	}
}     
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	createCookie
doel:	aanmaken cookie
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	readCookie
doel:	uitlezen cookie
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	resetTextSize
doel:	herstellen tekst grootte
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function resetTextSize() {  
	document.body.style.fontSize="1.0em";
	createCookie("textsizeC1256CDB:002659DC",0,1)
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	resizeText
doel:	aanpassen tekst grootte
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function resizeText(pFactor) {  
	document.body.style.fontSize="1.0em";
	document.body.style.fontSize=parseFloat(document.body.style.fontSize)+(pFactor*0.2)+"em";
	//kijken of er al een cookie bestaat, dan waarde ophalen en huidige factor erbij op tellen
	//maar alleen indien pFactor 1 of -1 is
/*
	iTextsizeCookie = readCookie("textsizeC1256CDB:002659DC");
	if ((pFactor.toString()=="1") || (pFactor.toString()=="-1")) {
		iCurTextsize=parseInt(iTextsizeCookie);
		if (!isNaN(iCurTextsize)) {
			pFactor=Number(pFactor);
			iFactor=(pFactor)+(iCurTextsize);
		}  else {
			iFactor=pFactor;
		}
	} else {
		iFactor=pFactor;
	}
*/
	createCookie("textsizeC1256CDB:002659DC",pFactor,1)
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	loadTextsize
doel:	laden tekst grootte uit cookie
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function loadTextsize() {
	textsizeCookie=null;
	textsizeCookie = readCookie("textsizeC1256CDB:002659DC");
	if (textsizeCookie) {
		if (document.body.style.fontSize=="") document.body.style.fontSize="1.0em";
		document.body.style.fontSize=parseFloat(document.body.style.fontSize)+(textsizeCookie*0.2)+"em";
	}
}
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
functie:	clickLink
doel:	openen document in weergave
-------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 
function clickLink(pObject,pUrl,pTargetProps) {
	
	if (pTargetProps=='') {
		//gaat om link naar hetzelfde document, dus kijken naar base target
		if (baseTarget.indexOf('_blank^^')>=0) {
			//linkjes naar zelfde document openen in blanco scherm met properties
			iTarget='_blank';
			blankwindowprops=baseTarget.substring(baseTarget.indexOf('^^')+2,baseTarget.length).replace(/~/g,"#")
		} else {
			iTarget=baseTarget
			blankwindowprops=""
		}
	} else {
		//gaat om link uit document of naar andere url, dus kijken naar target properties
		if (pTargetProps.indexOf('_blank^^')>=0) {
			//linkjes openen in blanco scherm met properties
			iTarget='_blank'
			blankwindowprops=pTargetProps.substring(pTargetProps.indexOf('^^')+2,pTargetProps.length).replace(/~/g,"#");
		} else {
			iTarget=pTargetProps
			blankwindowprops=""
		}	
	}
	
	switch(iTarget) {
		case "":
		case "_self":
			document.location=pUrl;
			break;
		case "_top":
			top.location=pUrl;
			break;
		case "_blank":
			if (blankwindowprops!='') {
				OpenNewWindow('doc',pUrl,blankwindowprops) 
			} else {
				window.open(pUrl)
			}
			break;
		default:
			if (top.frames[iTarget]) {
				top.frames[iTarget].location=pUrl;
			} else {
				openURLinFrame(pUrl,iTarget)
			}
			break;
	}
	
}			
