var Share = {
	version   : '1.3.1',
	util      : function(options){
		this._option = options;
	},
	add 	  : function(){},
	mail      : function(){}
}
/**-------------------------------------------------------------------------------
	utilities
  -------------------------------------------------------------------------------*/
Share.util.prototype = {
			//  --- write a div in the document whit the generated url ------
		  debug : function(data, margin){
			if(this._option.debug_mode){	
			
				var _margin = 40, _debugHolder = $('.debugAddthis');;
	
				if(!$('.debugAddTitle').length > 0){
					$('<div>').addClass('debugAddthis').css({
						'position': 'absolute',
						'z-index' : 1,
						'top': 5 + 'px', 
						'width':'80%', 
						'background-color':'#5a0101', 
						'border':'1px #5a0101 solid', 
						'padding':'2px 10px 2px 10px', 
						'color' : '#fff',
						'font-size' : '16px'
					}).html('<b>addThis '+ this._option.version +'</b> &nbsp; debug mode').appendTo('body');
				}
				for(var i=0; i < _debugHolder.length; i++){
					_margin += $(_debugHolder[i]).height() + 5;
				}
				$('<div>').addClass('debugAddthis').css({
					'position': 'absolute', 
					'top': _margin + 'px', 
					'z-index' : 1,
					'width':'80%', 
					'line-height':'30px', 
					'background-color':'#fdd8d8', 
					'border':'1px #5a0101 solid', 
					'padding':'10px', 'color' : '#5a0101'
				}).html(data).appendTo('body');
			}	
		  },
		  
		  // sleep function temout and clearing
		  sleep : function(fn, time){
				var t = window.setTimeout(function(){
					fn();
					window.clearTimeout(t);
				}, time);
		 },	 
		  //  --- grab the query and store it in the lang attribute ------
		 storeQuery    : function(obj){
			if(obj.attr('lang') == ''){
					obj.attr({'lang' : obj.html()});
					obj.html('');
			}		 
		 },
		 
		 /**
		  * get the query and return obejct
		  * return object;
		  * @object[id]    (String)  the id query before the separator in the query string
		  * @object[title] (String)  the title of the queryafter the separator in the query string
		  *
		 */
		 getQuery : function(selector){
			var _str   = $(selector).attr('lang');
			var _data  = _str.split('#');
			return {
				id 		: _data[0],
				title 	: _data[1]
			}
		 },
		 
		 //  ---  ------
		 createTitle : function(query){
			if(this._option.query){
				return this._option.paramTitle + this._option.encoding( query.title );
			}else{
				return this._option.paramTitle +this._option.encoding( $('title').html() );
			}
		 },
		 
         // ------ url ------
         createUrl : function(query){
	
				if(this._option.query){
					return  (this._option.url || '')+         					// the url to the share website "eg.facebook"
							(this._option.paramUrl || '')+     					// parameter name "&url="
							this._option.encoding( this._option.jsp_handler + query.id);
				}else{
					return  (this._option.url || '')+         					// the url to the share website "eg.facebook"
							(this._option.paramUrl || '')+     					// parameter name "&url="
							this._option.encoding(window.location);
				}
				
         },
 
         // ------ title ------
         title : function(pr){
			this._option.paramTitle + this._option.encoding( _data[1] );
         },
		 
		 // ------ create the image ------
		 createImage : function(){
			var _out = '';
			if(this._option.img){
				_out = '<img src="'+this._option.img.src +'" title="'+ this._option.img.title +'" alt="'+ this._option.img.alt +'" />';
			}else{
				alert(_error.img);
			}
			return _out;
		 },
		 
		// ---- request handler  ---- 
		request : function(data){			
			$.ajax({
				  url: data.url || alert(this._option.request_url),
				  data : data.data || {},
				  dataType 	: data.dataType || 'html', 
				  type 		: data.type 	|| 'POST', 
				  beforeSend : function(){
					  	if(data.beforeSend){
					  		data.beforeSend();
					  	}
				  },
				  success: function(respons) {
				  		if(data.success){
					  		data.success(respons);
					  	}
				  },
				  error : function(XMLHttpRequest){
				  	if(_option.debug_mode){
				  		$$(XMLHttpRequest);
				  	}
				  }
			});
		},
		
		// ---- detect boundary view port handler  ---- 
		/**
		 * patram = option
		 * option[viewport]		(String)	the view port default 
		 * option[event]		(Object)	the mouse cursor position
		 * option[element]		(Object)	the element to colculate th detect boundery viewport
		 * return true of boundery is reatch
		 */
		boundaryViewPort : function(option){
			
			option.viewport = option.viewport || window;
			var _viewport_height 	= $(option.viewport).height();
			var _viewport_width  	= $(option.viewport).width();
			var _element_height		= $(option.element).height();
			var _element_width		= $(option.element).width();
			var _event				= option.event.offset();

			return {
				top 	: ( ((_viewport_height - _event.top) + _element_height)  >  _viewport_height )? true : false,
				right 	: ( (_event.left + _element_width) >  _viewport_width)?   true : false,	
				bottom 	: ( (_event.top + _element_height) > _viewport_height)? true   : false,	
				left   	: ( _event.left <  _element_width)? true : false
			}
		}		
};


/**----------------------------------------------------------------------------------------------------------------------------------------------------------
	share this object
  ----------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /**
  * paramter = option
  * @param[target]			(String)	jQuery selector of the target element to place the adds share link    	(required)
  * @param[url]				(String)	the url of the add this including open get "?"    						(required)
  * @param[paramUrl]		(String)	the get attribute name of the url 			     						(optional) default		"&url="
  * @param[paramTitle]		(String)	the get attribute name of the title 			     					(optional) default		"&title="
  * @param[jsp_handler]		(String)	the jsp handler file for aletta										  	(optional) default 		false
  * @param[query]			(Boolean)	let te functionality now if there is a query or not					  	(optional) default 		false
  * @param[debug_mode]		(Boolean)	if the debug mode is turn on he wil genereate urls in to a overlay	  	(optional) default 		false
  * @param[querySeparator]	(String)	the separator character  for the query to seporate						(optional) default 		"#"
  * @param[encoding]		(Function)	geef op welke native javascript functie gebruikt 
  *									moet worden als encoding	  											(optional) default 		encodeURIComponent
  *  @param[img] = attribute
  *    @[img][src]            (String)     src of the image icon
  *    @[img][alt]            (String)     alt text for the image
  *    @[img][title]          (String)     title attr for the image
  *
  */

Share.add = function(options){

	 var _error = {
		url 	: "url van de addthis webiste is required!!",
		target  : "html jQuery selector required \n\n bijvoorbeeld: '.share_object'",
		img  	: "the 'img' property is required!"
	 }

	
     var _method = {	 
         // ------ contstruct ------
         init : function(opt){
            return {
				version     : Share.version,
				jsp_handler : (opt.jsp_handler == undefined)? '' : opt.jsp_handler,
				query 		: (opt.jsp_handler == undefined)? false : opt.query,
				debug_mode 	: (opt.debug_mode  == undefined)? false : opt.debug_mode,
				target      : opt.target 		|| alert(_error.target),
				encoding    : opt.encoding 		|| encodeURIComponent,
				url         : opt.url 			|| alert(_error.url),
				paramUrl    : opt.paramUrl 		|| '&url=',
				paramTitle  : opt.paramTitle 	|| '&title=',
				img         : opt.img			|| false,
				querySeparator   : opt.querySeparator || '#'
	
				// update storige point
			}
  
         },
		 		 
         // ------ create the addThis ------
         create : function(){
		 
			var _out  = '', _text = '';
			
			 $(_option.target).each(function (i){
					// 
					_util.storeQuery( $(this) );
					
					 var _query = _util.getQuery( $(this) );
					 var _html  = $(this).html();
					 var _link  = _util.createUrl( _query )+ _util.createTitle(_query );
						 _text += (_option.debug_mode)? '<b>div '+(i+1)+':</b> &nbsp; '+_link+'<br />' : '';
						
						_out = '<a style="background-image:none;" href="'+_link+'" target="_blank">'+ _util.createImage() +'</a>';
					
				   $(this).html(_html + _out);
			 });
			 _util.debug(_text);
         }
     };
	 
	 // initialisation 
	 var _option = _method.init(options);
	 // retrieving utilities 
	 var _util  =  new Share.util(_option);

	 //
     var method = {
         set : function(){
			_method.create();
         }
     };
     return method;
};
 



/**----------------------------------------------------------------------------------------------------------------------------------------------------------
	share mail object
  ----------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /**
  * paramter = option
  * @param[target]			(String)	jQuery selector of the target element to place the adds share link    		(required)
  * @param[paramTitle]		(String)	the get attribute name of the title 			     						(optional) default		"&title="
  * @param[jsp_handler]		(String)	the jsp handler file for aletta										  		(optional) default 		false
  * @param[mail_handler]	(String)	the jsp mail handler file for aletta										(required) 
  * @param[template]		(String)	the html template for the mail handler it will be loaded in to the overlay	(required) 
  * @param[query]			(Boolean)	let te functionality now if there is a query or not					  		(optional) default 		false
  * @param[debug_mode]		(Boolean)	if the debug mode is turn on he wil genereate urls in to a overlay	  		(optional) default 		false
  * @param[querySeparator]	(String)	the separator character  for the query to seporate							(optional) default 		"#"
  * @param[encoding]		(Function)	geef op welke native javascript functie gebruikt 
  * @param[speed]		    (Function)	geef de snelhijd op van the start and close animation						(optional) default 		400
  *									    moet worden als encoding	  												(optional) default 		encodeURIComponent
  *  @param[img] = attribute
  *    @[img][src]            (String)     src of the image icon
  *    @[img][alt]            (String)     alt text for the image
  *    @[img][title]          (String)     title attr for the image
  *
  */
Share.mail = function(options){
	
	var _option = {};
	var _error = {
			target 		 : "html jQuery selector required \n\n bijvoorbeeld: '.share_object'",
			template 	 : "The url to the html template is required",
			mail_handler : "The url to the mail handler is required",
			img  		 : "the 'img' property is required!",
			request_url  : "url is required for ajax request"
	}
	
	var _method = {
		
		init : function(opt){
			return {
				version     	: Share.version,
				jsp_handler  	: (opt.jsp_handler == undefined)? ''    : opt.jsp_handler,
				query 		 	: (opt.query       == undefined)? false : opt.query,				
				debug_mode 	 	: (opt.debug_mode  == undefined)? false : opt.debug_mode,
				encoding     	: opt.encoding 	|| encodeURIComponent,
				paramTitle   	: opt.paramTitle 	 || '&title=',
				target		 	: opt.target 		 || alert( _error.target ),
		 		template     	: opt.template 		 || alert( _error.template ),
		 		mail_handler 	: opt.mail_handler   || alert( _error.mail_handler ),
		 		img          	: opt.img			 || false,
		 		speed        	: opt.speed			 || 400,
		 		querySeparator  : opt.querySeparator || '#'			
			}
		},
		
		//  ---  activate layer ---- 
		activateOverLay : function(layer, button, content){
		
			layer.css({
					'left' : button.offset().left,
					'display' : 'none'				
			})
				.html(content)
				.attr({id : 'addthisOverlay'})
				.appendTo('body')
				.fadeIn(_option.speed);	
				
				var _detect = _util.boundaryViewPort({
								event 	: button,
								element : layer
							 });
				layer.css({
					'top'  : (_detect.bottom)? (button.offset().top - button.height()*2) - layer.height() : button.offset().top
				});					
		},
		
		// ---- create overlay mailer ---- 
		addOverlay : function(button, content){
			// close others
			if($('#addthisOverlay').length > 0){
				
				_method.activateOverLay($('#addthisOverlay') ,button, content);
			}else{
				_method.activateOverLay($('<div>') ,button, content);
			}
		},
		

		// ----  ste the icon in to the dom ---- 
		create : function(){
			var _out  = '';			
			 $(_option.target).each(function (i){
					// 	
			     var _html  = $(this).html();				
				     _out = '<a style="background-image:none;" href="#" target="_blank" class="shareAddMail">'+ _util.createImage() +'</a>';
				 $(this).html(_out + _html);
			 });			
		},
		
		// ----  get form data ---- 
		getFormData : function(){
				 
			return $('#shareForm').serializeArray();
		},
		
		// ----  loader ---- 
		loader : function(bool){
			if(bool){
				return '<img src="images/small-loader.gif" />';
			}else{
				return '';
			}
		},
		
		// ----  create mail link and add the link in the hidden input field ---- 
		createMailLink : function(addHolder){
				
				var _query = _util.getQuery( addHolder );
				var _link  = _util.createUrl( _query )+ _util.createTitle(_query );
				$('#toWebsite').val( _link );
				return _link;		
		},
		
		// send the  mail
		send  : function(button){

			_util.request({
				 url  : _option.mail_handler,
				 data : _method.getFormData(),
				 beforeSend : function(){
					$('#shareLoader').html( _method.loader(true) ); 	
				 },
				 success : function(data){
				 	$('#shareLoader').html( _method.loader(false) ); 	
				 	$('#success').css({'display' : 'block'}).html(data); 
				 	
				 	// close the overlay
				 	_util.sleep(function(){
				 		
				 		method.close( button.parents('#addthisOverlay')  );
				 	},1000);
				 }
			});
		}		
	};
	
	_option = _method.init( options );
	//retrieving utilities
	var _util  =  new Share.util( _option );
	
     var method = {
         set : function(){
         	
			_method.create();
			// click icon
			$('a.shareAddMail').click(function(){
				var _slef = $(this);

				_util.request({
					 url : _option.template,
					 success : function(data){
					 	
					 	_method.addOverlay( _slef , data);
						// create the mail link
						var _url = _method.createMailLink( _slef.parents(_option.target) );
						// debug mode 
						if(_option.debug_mode){
							_util.debug('<b>no ecode: </b> &nbsp;'+decodeURIComponent(_url) +'<br />'+ '<b>url ecode:</b> &nbsp; '+ _url);
						}
					 	// ----------- click close button -------------
						$('a#closeShare').click(function(){
							method.close( $(this).parents('#addthisOverlay')  );
							return false;
						}); 
						
						// ----------- click close button -------------
						$('a#send').click(function(){
							_method.send( $(this));
							return false;
						}); 
						// --------------------------------------------						
					 } 
				});
				return false;
			});
         },
         
         // close target ust be the layer
         close : function(target){
			 if(_option.debug_mode){
					$('.debugAddthis').remove();
			 }
		      target.fadeOut(_option.speed, function(){
		         	$(this).remove();
         	});
         }
     };
     return method;
};


$(document).ready(function(){

 	var jsp_handler = 'http://www.aletta.nu/aletta/zoek/ext_zoek.jsp?res1=';
	var _jsp_handler = 'http://www.aletta.nu/aletta/jub_object.jsp?res1=';
	
	// =========== Links voor jubileum objecten ======
	// ----------- linkedin ----------- 
	var _linkedin = new Share.add({
			   target      : '.share_object',
			   jsp_handler : _jsp_handler,
               url 		   : 'http://www.linkedin.com/shareArticle?mini=true',
			   query 	   : false,
			   debug_mode  : false,
			   encoding    : encodeURI,
			   mail        : {},
               paramUrl    : '&url=',
               paramTitle  : '&title=',
               img : {
                   src   : '/aletta/images/vk_op_linkedin.gif',
                   alt   : 'Deel dit artikel op Linkedin',
                   title : 'Deel dit artikel op Linkedin'
               }	
		});
		_linkedin.set();
 
		
    // ----------- facebook  ----------- 
 	var _facebook = new Share.add({
			   target      : '.share_object',
			   jsp_handler : _jsp_handler,
               url 		   : 'http://www.facebook.com/sharer.php?',
			   query 	   : false,
			   debug_mode  : false,
               paramUrl    : '&u=',
               paramTitle  : '&t=',
               img : {
                    src   : '/aletta/images/vk_op_facebook.gif',
                    alt   : 'Deel dit artikel op Facebook',
                    title : 'Deel dit artikel op Facebook'
               }	
		});
		_facebook.set();
 
 
     // ----------- delicious  ----------- 
 	var _delicious = new Share.add({
			   target      : '.share_object',
			   jsp_handler : _jsp_handler,
               url 		   : 'http://www.delicious.com/save?v=5&noui&jump=close',
			   query 	   : false,
			   debug_mode  : false,
               img : {
                     src   : '/aletta/images/vk_op_delicious.gif',
                     alt   : 'Deel dit artikel op Delicious',
                     title : 'Deel dit artikel op Delicious'
               }	
		});
		_delicious.set();
 
 
     // ----------- twitter  ----------- 
 	var _twitter = new Share.add({
			   target      : '.share_object',
			   jsp_handler : _jsp_handler,
               url 		   : '/aletta/zoek/share.jsp?share=twitter',
			   query 	   : false,
			   debug_mode  : false,
               paramUrl   : '&url=',
               paramTitle : '&title=',			   
               img : {
                     src   : '/aletta/images/vk_op_twitter.gif',
                     alt   : 'Tweet op Twitter',
                     title : 'Tweet op Twitter'
               }	
		});
		_twitter.set();

 	// ---------------- mailer ---------------
 	var _mailer = new Share.mail({
 		target 	     : '.share_object',
 		template     : '/aletta/template.html',
 		mail_handler : '/aletta/mail_gen.jsp',
 		jsp_handler  : _jsp_handler,
 		debug_mode   : false,
 		query        : false,
        img : {
             src   : '/aletta/images/mail.png',
             alt   : 'mail to a friend',
             title : 'Mail to a friend'
       }			
 	}).set();


	// =========== Links voor artikelen ======
	// ----------- linkedin addthis----------- 
	var _linkedin = new Share.add({
			   target      : '.addthis',
			   jsp_handler : _jsp_handler,
               url 		   : 'http://www.linkedin.com/shareArticle?mini=true',
			   query 	   : false,
			   debug_mode  : false,
			   encoding    : encodeURI,
			   mail        : {},
               paramUrl    : '&url=',
               paramTitle  : '&title=',
               img : {
                   src   : '/aletta/images/vk_op_linkedin.gif',
                   alt   : 'Deel dit artikel op Linkedin',
                   title : 'Deel dit artikel op Linkedin'
               }	
		});
		_linkedin.set();
 
		
    // ----------- facebook  ----------- 
 	var _facebook = new Share.add({
			   target      : '.addthis',
			   jsp_handler : _jsp_handler,
               url 		   : 'http://www.facebook.com/sharer.php?',
			   query 	   : false,
			   debug_mode  : false,
               paramUrl    : '&u=',
               paramTitle  : '&t=',
               img : {
                    src   : '/aletta/images/vk_op_facebook.gif',
                    alt   : 'Deel dit artikel op Facebook',
                    title : 'Deel dit artikel op Facebook'
               }	
		});
		_facebook.set();
 
 
     // ----------- delicious  ----------- 
 	var _delicious = new Share.add({
			   target      : '.addthis',
			   jsp_handler : _jsp_handler,
               url 		   : 'http://www.delicious.com/save?v=5&noui&jump=close',
			   query 	   : false,
			   debug_mode  : false,
               img : {
                     src   : '/aletta/images/vk_op_delicious.gif',
                     alt   : 'Deel dit artikel op Delicious',
                     title : 'Deel dit artikel op Delicious'
               }	
		});
		_delicious.set();
 
 
     // ----------- twitter  ----------- 
 	var _twitter = new Share.add({
			   target      : '.addthis',
			   jsp_handler : _jsp_handler,
               url 		   : '/aletta/zoek/share.jsp?share=twitter',
			   query 	   : false,
			   debug_mode  : false,
               paramUrl   : '&url=',
               paramTitle : '&title=',			   
               img : {
                     src   : '/aletta/images/vk_op_twitter.gif',
                     alt   : 'Tweet op Twitter',
                     title : 'Tweet op Twitter'
               }	
		});
		_twitter.set();

 	// ---------------- mailer ---------------
 	var _mailer = new Share.mail({
 		target 	     : '.addthis',
 		template     : '/aletta/template.html',
 		mail_handler : '/aletta/mail_gen.jsp',
 		jsp_handler  : _jsp_handler,
 		debug_mode   : false,
 		query        : false,
        img : {
             src   : '/aletta/images/mail.png',
             alt   : 'mail to a friend',
             title : 'Mail to a friend'
       }			
 	}).set();
	
	// =========== Links voor zoekresultaten ======
	// ----------- linkedin share_search----------- 
	
 	var jsp_handler = 'http://www.aletta.nu/aletta/zoek/ext_zoek.jsp?res1=';

	var _linkedin = new Share.add({
			   target      : '.share_search',
			   jsp_handler : jsp_handler,
               url 		   : 'http://www.linkedin.com/shareArticle?mini=true',
			   query 	   : true,
			   debug_mode  : false,
			   encoding    : encodeURI,
			   mail        : {},
               paramUrl    : '&url=',
               paramTitle  : '&title=',
               img : {
                   src   : '/aletta/images/vk_op_linkedin.gif',
                   alt   : 'Deel dit artikel op Linkedin',
                   title : 'Deel dit artikel op Linkedin'
               }	
		});
		_linkedin.set();
 
		
    // ----------- facebook  ----------- 
 	var _facebook = new Share.add({
			   target      : '.share_search',
			   jsp_handler : jsp_handler,
               url 		   : 'http://www.facebook.com/sharer.php?',
			   query 	   : true,
			   debug_mode  : false,
               paramUrl    : '&u=',
               paramTitle  : '&t=',
               img : {
                    src   : '/aletta/images/vk_op_facebook.gif',
                    alt   : 'Deel dit artikel op Facebook',
                    title : 'Deel dit artikel op Facebook'
               }	
		});
		_facebook.set();
 
 
     // ----------- delicious  ----------- 
 	var _delicious = new Share.add({
			   target      : '.share_search',
			   jsp_handler : jsp_handler,
               url 		   : 'http://www.delicious.com/save?v=5&noui&jump=close',
			   query 	   : true,
			   debug_mode  : false,
               img : {
                     src   : '/aletta/images/vk_op_delicious.gif',
                     alt   : 'Deel dit artikel op Delicious',
                     title : 'Deel dit artikel op Delicious'
               }	
		});
		_delicious.set();
 
 
     // ----------- twitter  ----------- 
 	var _twitter = new Share.add({
			   target      : '.share_search',
			   jsp_handler : jsp_handler,
               url 		   : '/aletta/zoek/share.jsp?share=twitter',
			   query 	   : true,
			   debug_mode  : false,
               paramUrl   : '&url=',
               paramTitle : '&title=',			   
               img : {
                     src   : '/aletta/images/vk_op_twitter.gif',
                     alt   : 'Tweet op Twitter',
                     title : 'Tweet op Twitter'
               }	
		});
		_twitter.set();

	// ------reageer---------
	$('<a>')
	.attr({
	  'href' : '#reageer'
	})
	.attr({
	  'title' : 'U moet ingelogd zijn om te kunnen reageren'
	})
	.text('Reactie toevoegen')
	.appendTo('div.reageer');
		
	// ------reageer_login---------
	$('<a>')
	.attr({
	  'href' : '/aletta/nl/community/inloggen'
	})
	.attr({
	  'title' : 'U moet ingelogd zijn om te kunnen reageren'
	})
	.text('Reactie toevoegen')
	.appendTo('div.reageer_login');
		
});


var countDebug = 0;
var property = 'none';
function debug(para){
	var timer = [];
	var span = 'style="color: #4f0101; font-size: 11px;"';
	var id_name = 'debug';
	var id_name2 = 'debug2';
	var IE = document.all ? true: false;
	
	if(document.getElementById(id_name) == null){
		var obj = document.createElement('div');
		var obj2 = document.createElement('div');
		var obj3 = document.createElement('div');
		var image = document.createElement('img');
		
		obj.style.border = "1px solid #960000";
		obj.style.padding = "10px";
		obj.style.top = "40%";
		obj.style.left = "40%";
		obj.style.position = "absolute";
		obj.style.color = "#960000";
		obj.style.cssFloat = "left";
		obj.style.backgroundColor = "#FFD0D0";
		obj.id = id_name;
		window.document.body.appendChild(obj);
		
		obj3.id = 'butjeF';
		obj3.style.textAlign = 'center';
		obj3.style.width = '50px';
		obj3.style.color = '#fff';
		obj3.style.backgroundColor = '#960000';
		obj3.style.padding = "2px";
		obj3.style.paddingLeft = "10px";
		obj3.style.paddingRight = "10px";
		obj3.style.fontSize = "11px";
		obj3.style.cssFloat = "right";
		obj3.style.cursor = "pointer";

		obj.appendChild(obj3);
		obj3.innerHTML = 'freeze';
		obj3.onclick = function(){
			if(obj3.innerHTML == 'freeze'){
				property = 'block';
				obj3.innerHTML = 'close';
				window.clearTimeout(timer['timer']);	
			}else{
				property = 'none';
				obj3.innerHTML = 'freeze';
				obj.style.display = 'none';
				document.getElementById(id_name2).innerHTML = '';
				countDebug = 0;	
			}
		}			
		image.style.cssFloat = 'left';
		image.src = 'http://www.deontwikkelfabriek.nl/images/bug.png';
		obj.appendChild(image);
		
		obj2.style.padding = "12px";
		obj2.style.cssFloat = 'left';
		obj2.id = id_name2;
		obj.appendChild(obj2);
		
		
		obj2.innerHTML += '<br /> '+ para;
		if(!IE){
			obj2.innerHTML += '<div '+span+'>'+ para.toSource();
		}
		timer['timer'] = window.setTimeout(function(){
			obj.style.display = property;
			if(property == 'none'){
				obj2.innerHTML = '';
				countDebug = 0;
				window.clearTimeout(timer['timer']);
			}
		}, 2000);
		
	}else{
		document.getElementById(id_name).style.display = 'block';
		document.getElementById(id_name2).innerHTML += '<br /> '+ para;
		if(!IE){
			document.getElementById(id_name2).innerHTML += '<div '+span+'>'+ para.toSource() + '</div>';
		}
		timer['timer'] = window.setTimeout(function(){
			document.getElementById(id_name).style.display = property;
			if(property == 'none'){
				document.getElementById(id_name2).innerHTML = '';
				countDebug = 0;
				window.clearTimeout(timer['timer']);
			}
		}, 2000);
	}
	countDebug++;
}

 function encodeUrl(url) {  
        if (url.indexOf("?")>0)  
        {  
            encodedParams = "?";  
            parts = url.split("?");  
            params = parts[1].split("&");  
            for(i = 0; i < params.length; i++)  
            {  
               if (i > 0)  
               {  
                   encodedParams += "&";  
               }  
               if (params[i].indexOf("=")>0) //Avoid null values  
               {  
                   p = params[i].split("=");  
                   encodedParams += (p[0] + "=" + escape(encodeURI(p[1])));  
               }  
               else  
               {  
                   encodedParams += params[i];  
               }  
           }  
           url = parts[0] + encodedParams;  
       }  
       return url;  
}  

function PutinSession(res1,res2,start,rows,nw,frm) {
//	var url1 = '/aletta/PutinSession';
	var url1 = '../../zoek/putinsession.jsp';
	var rmo = new RegExp(/([+])/g);
	var eu = encodeURIComponent(res1.replace(rmo, "%2B"));
	var par = 'qs='+eu+'&sh='+res2+'&start='+start+'&rows='+rows+'&nw='+nw;
//	var par = 'qs='+res1+'&sh='+res2+'&start='+start+'&rows='+rows+'&nw='+nw;
	SendS(url1,par,'Popup',frm);
}	

function FPutinSession(res1,res2,start,rows,nw,frm,q_org) {
	var url1 = '../../zoek/putinsession.jsp';
	
	var rmo = new RegExp(/([+])/g);
	var eu = encodeURIComponent(res1.replace(rmo, "%2B"));
	var eo = encodeURIComponent(q_org.replace(rmo, "%2B"));
	var par = 'qs='+eu+'&sh='+res2+'&start='+start+'&rows='+rows+'&nw='+nw+'&qo='+q_org;
	SendS(url1,par,'Popup',frm);
}	

function keyCapture(key_code, key){
	if( !key_code ) {
	    if( window.event) {
	      //Internet Explorer
	      key_code = window.event;
	    }
	  }
	  if(typeof( key_code.keyCode ) == 'number'  ) {
	    //DOM
	    key_code = key_code.keyCode;
	  } else if(typeof(key_code.which) == 'number' ) {
	    //NS 4 compatible
	    key_code = key_code.which;
	  } else if( typeof( key_code.charCode ) == 'number'  ) {
	    //also NS 6+, Mozilla 0.9+
	    key_code = key_code.charCode;
	  }
	  if(key_code == key){
	  		return true;
	  }
}

function enterSubmit(obj, event, functie, key){
	
	key = (key !== undefined)? key : 13;
	if(keyCapture(event, key)){
		if(functie !== undefined){
			functie(obj);
		}		
	}
}


function submitRes3(obj){
		// alert(obj.form.action);	
		developersMode('@'+obj.value+'@', 'all',obj.form);
}


// Enable disable						
function AbleDisable(fieldId, id, idVinkje, event){

	var _event=(event==undefined)?window.event:event;
	if (event)
	{
	if (_event.cancelBubble) _event.cancelBubble = true;
	if (_event.stopPropagation) _event.stopPropagation();

//console.log(fieldId);
	var search = document.getElementById(fieldId);
	//var search = fieldId;
//	alert(search.value);
	var object = document.getElementById(id);
	var objectVinkje = document.getElementById(idVinkje);
	
	var lengte =(search==null)?0:search.value.length;
		if(lengte >= 2 && objectVinkje.checked == true){
			object.disabled = false;
			object.style.opacity = (100 / 100);
			object.style.MozOpacity = (100 / 100);
			object.style.filter = 'alpha(opacity=' + 100 + ')';

			
		}else{
			object.disabled = true;
			object.style.opacity = (35 / 100);
			object.style.MozOpacity = (35 / 100);
			object.style.filter = 'alpha(opacity=' + 35 + ')';				
	}
	if(keyCapture(_event, 13)){
			var a = 0;
			var forms = window.document.body.getElementsByTagName('form');
			while(a < forms.length){
			  	if(forms[a].name == VRIJZOEKEN_FORM_NAME){
			  		formOutput('Form');
			  	}
			  	if(forms[a].name == GROTE_ZOEKVELD_FORM_NAME){  		
			  		submitRes2('Form','InputSearch_1');
			  	}
			  	a++;
			}	
	}
	}

}

function urlReplace(haystack, needle, replacement, zoekstring){
	var r = new RegExp(needle, 'gi');
	window.open(haystack.replace(r, replacement) +'#search='+ zoekstring);
}

//function simuleert anker links om scroll probleem op te lossen in div popup
function anchor(idpara){
	
	var holder = document.getElementById(idpara).parentNode;
	var divjes = holder.getElementsByTagName('div');
	
	//alert(divjes.length);
	var content = document.getElementById('contentMenuPopup'); 
	var a = 0;
	var count = 0;
	while(a < divjes.length){
		if(divjes[a].id !== idpara){
			if(divjes[a].className == 'eaddata'){
				count = (count + parseInt(divjes[a].offsetHeight)) + 5;
			}		
		}else{
			content.scrollTop = (count);
			return;
		}
		a++;
	}
	
	//obj.offsetHeight
	
}

// plus en minnetjes worden gezet
function PlusMin(bool, inter){
	var object = document.getElementById('OpenClose_'+inter);
	var objectLink = document.getElementById('OpenCloseLink_'+inter);

	var makePlus = function(obj, link){
		obj.style.backgroundImage="url(../../img/plus_hover.jpg)";
		obj.onmouseout = function(){obj.style.backgroundImage="url(../../img/plus.jpg)";}

		link.onmouseout = function(){obj.style.backgroundImage="url(../../img/plus.jpg)";}		
	}

	var makeMin = function(obj, link){
		obj.style.backgroundImage="url(../../img/min_hover.jpg)";
		obj.onmouseout = function(){obj.style.backgroundImage="url(../../img/min.jpg)";}

		link.onmouseout = function(){obj.style.backgroundImage="url(../../img/min.jpg)";}				
	}	
		if(bool){
			makeMin(object, objectLink);
		}else{
			makePlus(object, objectLink);
		}		
}

// style de online available artikelen
function setOrangeBorderStyle(inter){
	var holder = document.getElementById('online_' + inter);
		holder.style.border = '1px #FF9600 solid';
		holder.style.backgroundColor = '#fff';
		holder.style.padding = '10px';
		//holder.className = 'onlineAvailable';
		/*
		var linkjes = holder.getElementsByTagName('a');
		for(i in linkjes){
			linkjes[i].className = 'onlineAvailable';
			//linkjes[i].style.color = '#FF9600';
			//alert(linkjes[i].innerHTML);
		}
		*/
}

function OpenClose(inter){
	
//inter is # resultaat, zoek de zoekstring
var str_quot = inter;
var intvar = str_quot.replace(/&quot;/gi, "");

	var object = document.getElementById('box_'+ intvar);
	var result = document.getElementById('Result_'+ intvar);
	var google = document.getElementById('google_'+ intvar);
	var objectLinkPlus = document.getElementById('OpenClose_'+intvar);
	var objectLinkText = document.getElementById('OpenCloseLink_'+intvar);
	
	if(document.getElementById('online_available_'+intvar) != null){
		var online_available = document.getElementById('online_available_'+intvar);
		
		online_available.onclick = function(){
			functionOpen();
			OpenClose(inter);
			setOrangeBorderStyle(inter);	
			return false;
		}
	}
	
	if(objectLinkPlus.title == 'close' || objectLinkText.title == 'close'){
		PlusMin(true,intvar); // execute
	}else{
		PlusMin(false,intvar); // execute
	}

	var functionOpen = function(){
		result.style.borderLeft = '0px';
		result.style.borderRight = '0px';
		
		if(object.style.display == 'none'){
			object.style.display = 'block';
			result.style.borderColor = '#00a2b5';
			result.style.borderWidth = '3px';
			result.style.backgroundColor = '#ffffff';
			google.style.display = 'none';
			objectLinkPlus.title = 'close';
			objectLinkText.title = 'close';
			
		}else if(object.style.display == ''){
			object.style.display = 'block';
			result.style.borderColor = '#00a2b5';
			result.style.borderWidth = '3px';
			result.style.backgroundColor = '#ffffff';
			google.style.display = 'none';
			objectLinkPlus.title = 'close';
			objectLinkText.title = 'close';
	
		}else{
			object.style.display = 'none';
			result.style.borderColor = '';
			result.style.borderWidth = '1px';
			result.style.backgroundColor = '#fff';
			google.style.display = 'inline';
			objectLinkPlus.title = 'open';
			objectLinkText.title = 'open';
		}		
	}

	objectLinkText.onclick = function(){
		functionOpen();
		OpenClose(inter);
	}
	objectLinkPlus.onclick = function(){
		functionOpen();
		OpenClose(inter);
	}


}

function FragenOpenClose(inter){
	
//inter is # resultaat, zoek de zoekstring
var str_quot = inter;
var intvar = str_quot.replace(/&quot;/gi, "");

	var object = document.getElementById('box_'+ intvar);
	var result = document.getElementById('Result_'+ intvar);
	var google = document.getElementById('google_'+ intvar);
	var objectLinkPlus = document.getElementById('OpenClose_'+intvar);
	var objectLinkText = document.getElementById('OpenCloseLink_'+intvar);
	
	if(objectLinkPlus.title == 'close' || objectLinkText.title == 'close'){
		PlusMin(true,intvar); // execute
	}else{
		PlusMin(false,intvar); // execute
	}

	var functionOpen = function(){
		result.style.borderLeft = '0px';
		result.style.borderRight = '0px';
		
		if(object.style.display == 'none'){
			object.style.display = 'block';
			result.style.borderColor = '#523196';
			result.style.borderWidth = '3px';
			result.style.backgroundColor = '#fff';
			google.style.display = 'none';
			objectLinkPlus.title = 'close';
			objectLinkText.title = 'close';
			
		}else if(object.style.display == ''){
			object.style.display = 'block';
			result.style.borderColor = '#523196';
			result.style.borderWidth = '3px';
			result.style.backgroundColor = '#fff';
			google.style.display = 'none';
			objectLinkPlus.title = 'close';
			objectLinkText.title = 'close';
	
		}else{
			object.style.display = 'none';
			result.style.borderColor = '';
			result.style.borderWidth = '1px';
			result.style.backgroundColor = '#fff';
			google.style.display = 'inline';
			objectLinkPlus.title = 'open';
			objectLinkText.title = 'open';
		}		
	}
	
	objectLinkText.onclick = function(){
		functionOpen();
		OpenClose(inter);
	}
	objectLinkPlus.onclick = function(){
		functionOpen();
		OpenClose(inter);
	}
}

function str_replace_reg(haystack, needle, replacement) {
	var r = new RegExp(needle, 'gi');
	return haystack.replace(r, replacement);
}


//================================[Highlighting ]========================================
// Highlighting content 
jQuery.fn.extend({
		highlight: function(search, insensitive, klass){
			var regex = new RegExp('(<[^>]*>)|(\\b'+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +')', insensitive ? 'ig' : 'g');
			return this.html(this.html().replace(regex, function(a, b, c){
				return (a.charAt(0) == '<') ? a : '<em class="'+ klass +'">' + c + '</em>'; 
			}));
		}
});

// Highlighting on places
var arraySearchResult = [];
jQuery(function(){
	findAndReplace(zoek);
		for(var a = 1; a > 0 && document.getElementById('box_'+a)!= null; a++){
			for(var b = 0; b < arraySearchResult.length; b++){
					$('#box_'+a).highlight(arraySearchResult[b], true, 'found');
			}				
		}

		//
});	


function findAndReplace(search){

	var step_1 = search.replace(/(\()|(\))|(&quot;)|(AND)|(OR)|(NOT)|(text:)|(titel_vz:)|(auteur_vz:)|(periode_vz:)|(persoon_vz:)|(organisatie_vz:)|(jaar_vz:)|(isbn_vz:)|(\*)|(NOW)|(TO)|(\[)|(\])/g, '');
	var tmparray = new Array();
	var quoteArray = step_1.split('"');
		
	for(var a = 0; a < quoteArray.length; a++){
		
		if(quoteArray[a] != " "){
			//alert('>'+quoteArray[a]+'<');
				if(a % 2 == 0){
					tmparray = quoteArray[a].split(' ');
					for(var c = 0; c < tmparray.length; c++){
					//	alert('value: '+tmparray[c]);
						if(tmparray[c] != ""){
							if (!found(tmparray[c])) {
									//alert(tmparray[c]);
									arraySearchResult.push(tmparray[c]);
							}	
						}
					}
					
				}else{
					//alert(quoteArray[a]);
					arraySearchResult.push(quoteArray[a]);
				}
		}
	}
}


function found(value){
	var d = 0;
	var e = 3;
	while(d <= valueReplace.length){		
		if(value == valueReplace[d]){
			//alert('>'+value+'<');
			return true;
		}else{	
			while(e <= valueReplace.length){	
				if(value.indexOf(valueReplace[e])!=-1){
					arraySearchResult.push(value.replace(valueReplace[e],''));
					return true;
				}
				e++;
			}
		}
		d++;
	}
	return false;
}
//===============================

// toont de popup en geeft de scroll mee 
function popUp(id, property){
	var X = 0; 
	var Y = 0;
	
	if( typeof(window.pageYOffset ) == 'number' ) {
		Y = window.pageYOffset; 
		X = window.pageXOffset;
	} 
	else if(document.body && ( document.body.scrollLeft || document.body.scrollTop )) {
		Y = document.body.scrollTop; 
		X = document.body.scrollLeft;
	} 
	else if(document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop )) {
		Y = document.documentElement.scrollTop; 
		X = document.documentElement.scrollLeft;
	}
	document.getElementById('Popup').style.marginTop = parseInt(40) + parseInt(Y) + 'px';
	
	document.getElementById(id).style.display = property;
}

function menuNav_1(id, id_2, key){
	var navObject_1 = document.getElementById(id).getElementsByTagName('a');

	for (var i = 0; i < navObject_1.length; i ++){
			navObject_1[i].style.backgroundColor = '';
			navObject_1[i].style.color = '';
	}
	navObject_1[key].style.backgroundColor = '#00a2b5';
	navObject_1[key].style.color = '#fff';
	
	var navObject_2 = document.getElementById(id_2).getElementsByTagName('a');
	
	
	for (var a = 0; a < navObject_2.length; a ++){ 
			navObject_2[a].style.backgroundColor = '';
			navObject_2[a].style.color = '';
	}

	navObject_2[key].style.backgroundColor = '#00a2b5';
	navObject_2[key].style.color = '#fff';
}


// ================= [ Controle in the value query ] ====================

var countQute = 0; // global counts
var count = 0;
var isMSIE = /*@cc_on!@*/false; // any Internet Explorer

var Find = new Array();
	Find[0] = "'";
	Find[1] = "and";
	Find[2] = "+";
	Find[3] = "|";
	Find[4] = "or";
	Find[5] = "/";
	Find[6] = "-";
	Find[7] = "not";

var Replacement = new Array();
	Replacement[0] = '"';
	Replacement[1] = 'AND';
	Replacement[2] = 'AND';
	Replacement[3] = 'AND';
	Replacement[4] = 'OR';
	Replacement[5] = 'OR';
	Replacement[6] = 'NOT';
	Replacement[7] = 'NOT';


// string replace functie
function goReplace(input){
		for (var x = 0; x < Find.length; x++){
			if(Find[x] == input){
				var output = input.replace(input, Replacement[x]);
				break;//
			}else{
				output = input;
			}
	}return output;
}	


// deze functie retourneerd een array gebaseerd op quote's
function getString(incString){
	
	var string = incString;
	var quoteArray = string.split('"');
	var num = 0;
	var a = 0;
	var arr = new Array;
	
		countQute = quoteArray.length -1;
	 		
		while (num < quoteArray.length){
			if(countQute > 1){
					
				if(num % 2 == 0){
					arr[num] = ''; // zet lege var undefined
		  			arr[num] += ''+ quoteArray[num] + '';
				}else{
					arr[num] = ''; // zet lege var undefined
					arr[num] += '"'+ quoteArray[num] + '"';
				} 
			}else{
				arr[num] = string;
			}
		  	num ++;		
		}
		
		return seperate_Value(arr); // evalueer en doe de nieuwe dingen		
}


// funtie retourneerd de gewenste query en execute functions
function seperate_Value(array){
	var output = '';
	
	//alert(array.length);
	for (var x = 0; x < array.length; x++){
			if(array[x].indexOf('"') == -1){
				output += slice_on_white_space(array[x]);
				count++;
							
			}else{
				output += array[x];
			}
	}
	// stel de string samen
	return output;
	
}

function slice_on_white_space(sliceArr){
	var output = '';
	var whiteArray = sliceArr.split(' ');
	var num = 0;
	while (num < whiteArray.length){
		output +=  " "+goReplace(whiteArray[num]);
		//alert(whiteArray[num]);
		num ++;	
	}
	return output;	
}
//==================== [ einde Controle value query ] ===================


var label = new Array();
	label[0]  = new Array('en', 'and');
	label[1]  = new Array('of', 'or');
	label[2]  = new Array('niet','not');
	label[3]  = new Array('Alles', 'All');
	label[4]  = new Array('Woorden uit de titel', 'Title');	
	label[5]  = new Array('Auteur','Author');	
	label[6]  = new Array('Periode','time frame');	
	label[7]  = new Array('Persoon','Person');
	label[8]  = new Array('Organisatie','Organization');	
	label[9]  = new Array('Jaar van uitgave','Year');	
	label[10] = new Array('ISBN','ISBN');	
	
	label[11] = new Array(IIAV_WEB, IIAV_WEB);	
	label[12] = new Array(VROUW_INFO, VROUW_INFO);	
	label[13] = new Array(ANDER_IIAV, ANDER_IIAV);	
	label[14] = new Array(WEB, WEB);	
	label[15] = new Array(BOEKEN, BOEKEN);	
	label[16] = new Array(BIOGRAFIE, BIOGRAFIE);	
	label[17] = new Array(TIJDSCHR, TIJDSCHR);	
	label[18] = new Array(DOSSIERS, DOSSIERS);	
	label[19] = new Array(ARTIKELEN, ARTIKELEN);	
	label[20] = new Array(FAQ, FAQ);	
	label[21] = new Array(EGO, EGO);	
	label[22] = new Array(MUZIEK, MUZIEK);	
	label[23] = new Array(FOTO, FOTO);	
	label[24] = new Array(DESK, DESK);	
	label[25] = new Array(AFFICHES, AFFICHES);	
	label[26] = new Array(ORG, ORG);	
	label[27] = new Array(ARCHIEVEN, ARCHIEVEN);	
	label[28] = new Array(DIGITALE_DOC, DIGITALE_DOC);	
	label[29] = new Array(ARCHIEVEN_ELDERS, ARCHIEVEN_ELDERS);	
	label[30] = new Array(ARCHIEVEN_EAD, ARCHIEVEN_EAD);	
	label[31] = new Array(EVOLUTIE, EVOLUTIE);	
	label[32] = new Array(PARAFERNALIA, PARAFERNALIA);
	label[33] = new Array('Pagina\'s', 'Pages');	
	label[34] = new Array(FRAGEN, FRAGEN);

	var valueReplace = new Array();	
		valueReplace[0] = _EN;
		valueReplace[1] = _OF;
		valueReplace[2] = _NIET;
		valueReplace[3] = _ALLES;
		valueReplace[4] = _TITLE;
		valueReplace[5] = _AUTEUR;
		valueReplace[6] = _PERIODE;
		valueReplace[7] = _PERSOON;
		valueReplace[8] = _ORGANISATIE;
		valueReplace[9] = _YEAR;
		valueReplace[10] = _ISBN;

		valueReplace[11] = _IIAV_WEB;
		valueReplace[12] = _VROUW_INFO;
		valueReplace[13] = _ANDER_IIAV;
		valueReplace[14] = _WEB;
		valueReplace[15] = _BOEKEN;
		valueReplace[16] = _BIOGRAFIE;
		valueReplace[17] = _TIJDSCHR;
		valueReplace[18] = _DOSSIERS;
		valueReplace[19] = _ARTIKELEN;
		valueReplace[20] = _FAQ;
		valueReplace[21] = _EGO;
		valueReplace[22] = _MUZIEK;
		valueReplace[23] = _FOTO;
		valueReplace[24] = _DESK;
		valueReplace[25] = _AFFICHES;
		valueReplace[26] = _ORG;
		valueReplace[27] = _ARCHIEVEN;
		valueReplace[28] = _DIGITALE_DOC;
		valueReplace[29] = _ARCHIEVEN_ELDERS;
		valueReplace[30] = _ARCHIEVEN_EAD;
		valueReplace[31] = _EVOLUTIE;
		valueReplace[32] = _PARAFERNALIA;
		valueReplace[33] = _FRAGEN;
		valueReplace[34] = _FRAGEN;

var result_0 = '';
var result_1 = '';
var result_2 = '';
var result_3 = '';
		
// string replace functie
function selectReplace(input){
		for (var x = 0; x < label.length; x++){
			if(label[x][LANGUAGE] == input){
				var output = input.replace(input, valueReplace[x]);
				break;//
			}
	}return output;
}
// strip default value
function stripValue(input){
	var output;
	if(input.value == ZOEKTERM[LANGUAGE] + POINTS){
		output = input.value = '';
	}else{
		output= input.value;
	}
	return output;
}

// zet in de onload dit: setFocus('InputSearch_1');"
function setFocus(id){
	if(document.getElementById(id)){
		document.getElementById(id).focus();  
	}
}


// velden toe voegen activeren deactiveren
function ableDisable_Add_fields(incomingObj,boolean){	
	
	 $(incomingObj.getElementsByTagName('a')[0]).unbind('click');

	if(boolean){
		incomingObj.getElementsByTagName('a')[0].setAttribute('className','Plus-SearchTerm');
		$(incomingObj.getElementsByTagName('a')[0]).click(function(){ Fieldedit('moreFields'); return false; });
		incomingObj.style.color = '';
	}else{	
		incomingObj.getElementsByTagName('a')[0].setAttribute('className','Plus-Disabled');
		$(incomingObj.getElementsByTagName('a')[0]).click(function(){ return false; });
		incomingObj.style.color = '#9c9c9c';
	}
}


// zet disabled on true if select is select
function DisableFirst_Area(id){

	var object = document.getElementById(id);
	if(object){
		var arrea = object.getElementsByTagName('div');
		var input = arrea[3].getElementsByTagName('input');
		var select = arrea[3].getElementsByTagName('select');
		var searchField_first = arrea[0].getElementsByTagName('input')[0];
		
		var toevoeg = arrea[6];
		var moreFields = arrea[5];
		var moreFieldsCilderen = moreFields.getElementsByTagName('div');
		
		
			select[1].disabled = true;
			input[1].disabled = true;
	
			// controle eerste veld
					
			
		var checking = function(){
				//alert(moreFieldsCilderen[1].getElementsByTagName('input')[0].value);
				
				if(input[0].checked){
					
					// eerste veld wel of niet disabled aan de hand van het grote veld
					if(searchField_first.value.length > 1){
						select[0].disabled = false;
						select[0].style.opacity = (100 / 100);
						select[0].style.filter = 'alpha(opacity=' + 100 + ')';
					}else{
						select[0].disabled = true;
						select[0].style.opacity = (35 / 100);
						select[0].style.filter = 'alpha(opacity=' + 35 + ')';
					}
	
					select[1].disabled = false;
					select[1].style.opacity = (100 / 100);
					select[1].style.filter = 'alpha(opacity=' + 100 + ')';
					input[1].disabled =  false;
					input[1].style.opacity = (100 / 100);	
					input[1].style.filter = 'alpha(opacity=' + 100 + ')';	
					if(input[2]){ // tweede veld
						input[2].style.opacity = (100 / 100);
						input[2].style.filter = 'alpha(opacity=' + 100 + ')';
						input[2].disabled =  false;	
					}						
					// meer velden //  bug fix
					if(moreFieldsCilderen && moreFieldsCilderen.length != 0){
						
						for(var a = 0; a <= moreFieldsCilderen.length; a++){
								if(moreFieldsCilderen[a]){
									moreFieldsCilderen[a].getElementsByTagName('input')[0].disabled = false;
									moreFieldsCilderen[a].getElementsByTagName('input')[0].style.opacity = (100 / 100);
									moreFieldsCilderen[a].getElementsByTagName('input')[0].style.filter = 'alpha(opacity=' + 100 + ')';
									moreFieldsCilderen[a].getElementsByTagName('select')[0].disabled = false;
									moreFieldsCilderen[a].getElementsByTagName('select')[0].style.opacity = (100 / 100);
									moreFieldsCilderen[a].getElementsByTagName('select')[0].style.filter = 'alpha(opacity=' + 100 + ')';
									moreFieldsCilderen[a].getElementsByTagName('select')[1].disabled = false;
									moreFieldsCilderen[a].getElementsByTagName('select')[1].style.opacity = (100 / 100);
									moreFieldsCilderen[a].getElementsByTagName('select')[1].style.filter = 'alpha(opacity=' + 100 + ')';
								
								if(moreFieldsCilderen[a].getElementsByTagName('input')[1]){ // tweede veld
									moreFieldsCilderen[a].getElementsByTagName('input')[1].style.opacity = (100 / 100);
									moreFieldsCilderen[a].getElementsByTagName('input')[1].style.filter = 'alpha(opacity=' + 100 + ')';
									moreFieldsCilderen[a].getElementsByTagName('input')[1].disabled =  false;	
								}
							}							
						}
					}
				}else{
					select[0].disabled = true;
					select[0].style.opacity = (35 / 100);
					select[0].style.filter = 'alpha(opacity=' + 35 + ')';
					select[1].disabled = true;
					select[1].style.opacity = (35 / 100);		
					select[1].style.filter = 'alpha(opacity=' + 35 + ')';	
					input[1].disabled =  true;		
					input[1].style.opacity = (35 / 100);
					input[1].style.filter = 'alpha(opacity=' + 35 + ')';
					if(input[2]){ // tweede veld
						input[2].style.opacity = (35 / 100);
						input[2].style.filter = 'alpha(opacity=' + 35 + ')';
						input[2].disabled =  true;	
					}
					// bug fix dit uitvoeren als het object niet leeg is
					if(moreFieldsCilderen.length != 0){
						for(var a = 0; a <= moreFieldsCilderen.length; a++){
							if(moreFieldsCilderen[a]){
								moreFieldsCilderen[a].getElementsByTagName('input')[0].disabled = true;
								moreFieldsCilderen[a].getElementsByTagName('input')[0].style.opacity = (35 / 100);
								moreFieldsCilderen[a].getElementsByTagName('input')[0].style.filter = 'alpha(opacity=' + 35 + ')';
								moreFieldsCilderen[a].getElementsByTagName('select')[0].disabled = true;
								moreFieldsCilderen[a].getElementsByTagName('select')[0].style.opacity = (35 / 100);
								moreFieldsCilderen[a].getElementsByTagName('select')[0].style.filter = 'alpha(opacity=' + 35 + ')';
								moreFieldsCilderen[a].getElementsByTagName('select')[1].disabled = true;
								moreFieldsCilderen[a].getElementsByTagName('select')[1].style. opacity = (35 / 100);
								moreFieldsCilderen[a].getElementsByTagName('select')[1].style.filter = 'alpha(opacity=' + 35 + ')';
								
								if(moreFieldsCilderen[a].getElementsByTagName('input')[1]){ // tweede veld
									moreFieldsCilderen[a].getElementsByTagName('input')[1].style.opacity = (35 / 100);
									moreFieldsCilderen[a].getElementsByTagName('input')[1].style.filter = 'alpha(opacity=' + 35 + ')';
									moreFieldsCilderen[a].getElementsByTagName('input')[1].disabled =  true;
								}	
							}						
						}
					}			
				}
		}
		
		// onclick object slect
		input[0].onclick = function(){	

			ableDisable_Add_fields(toevoeg,input[0].checked);
			checking();
			
		}
		ableDisable_Add_fields(toevoeg,input[0].checked);
		return checking();
	}
}





/*------[checkbox]-------*/

// checkbox kontrole
function checkboxCheck(incoming){
 	var check =  incoming.getElementsByTagName('input');
 	var ObjeCheck = '';
    for (var i = 0; i < check.length; ++i) {
	    if (check[i].type == "checkbox" && check[i].checked && check[i].name != 'verfijnen') {
	    	ObjeCheck += selectReplace(check[i].name) + ',';
	    }
   } 
  	return  ObjeCheck;
}


// radio button controle
function checkSelects(incomingObj,tableId){
	var table =  document.getElementById(tableId);
	var check =  table.getElementsByTagName('input');
	
	var selectAll = function(){
		for(var s = 0; s < check.length; s++){

			if(check[s].type == 'checkbox' && check[s].disabled == false){
					check[s].checked = true;				
			}
		}
	}
	var deselectAll = function(){
		for(var s = 0; s < check.length; s++){
			if(check[s].type == 'checkbox'){
				check[s].checked = false;
			}
		}
	}
	var selectInvert = function(){
		for(var s = 0; s < check.length; s++){
			if(check[s].type == 'checkbox' && check[s].disabled == false){
				if(check[s].checked == true){
					check[s].checked = false;
				}else{
					check[s].checked = true;					
				}
			}
		}
	}
	var allOnline = function(){
		for(var s = 0; s < check.length; s++){
			if(check[s].type == 'checkbox'){
				if(check[s].name == 'Egodocumenten' || check[s].name == 'Muziekwerken' ){
					check[s].disabled = true;
					check[s].checked = false;
					check[s].parentNode.style.color = '#9c9c9c';
				}
			}
		}	
	}
	var allCollections = function(){
		for(var s = 0; s < check.length; s++){
			if(check[s].type == 'checkbox'){
				if(check[s].name == 'Egodocumenten' || check[s].name == 'Muziekwerken' ){
					check[s].disabled = false;
					check[s].parentNode.style.color = '';
				}
			}
		}		
	}
	switch(incomingObj.name){
		case 'select_all' : selectAll();
	   break;
		case 'deselect_all' : deselectAll();
	   break;
		case 'select_invert' : selectInvert();
	   break;
		case 'collecties' : 
			if(incomingObj.name == 'collecties' && incomingObj.id == 'radio1'){
				allOnline();
			}else{
				allCollections();
			};
	   break;
	}
}



// functie retourneerd de controle op het eerste veld 
function staticField(OBJ){
			var error;
			// :: eerste zoek velden verfijnd zoeken met en/of/niet uitzetten
			var FirstObject = document.getElementById(OBJ[4].id);
			var FirstSelect = FirstObject.getElementsByTagName('select');
			var	firstOption_1 = FirstSelect[0].options[FirstSelect[0].selectedIndex].text;
			var firstOption_2 = FirstSelect[1].options[FirstSelect[1].selectedIndex].text;
			var FirstInput = FirstObject.getElementsByTagName('input');
			var First_option_year = FirstSelect[1].options[FirstSelect[1].selectedIndex].text;
			var InputOut = '';
			var selectje = '';	
	
			// als veld gelijk is aan label :: error
			if(FirstInput[0].value == ZOEKTERM[LANGUAGE]+ POINTS || FirstInput[0].value == '' && FirstInput[0].name !== TOT[LANGUAGE]){
				formError(FirstInput[0],1);
				error = true;
				return error;	

				
			}else if(FirstInput[0].name == TOT[LANGUAGE] && FirstInput[0].value.length != 4 && FirstInput[0].value !== '' && FirstInput[0].value !== VAN[LANGUAGE]+ POINTS){ // als het wel een van veld is maar niet 4 karakters
				formError(FirstInput[0],3);
				error = true;
				return error;
				
			}else if(FirstInput[0].name == TOT[LANGUAGE] && isNaN(FirstInput[0].value) && FirstInput[0].value !== '' && FirstInput[0].value !== VAN[LANGUAGE]+ POINTS){
				formError(FirstInput[0],3);
				error = true;
				return error;				

			}else{
				formError(FirstInput[0],0);
			}
			if(First_option_year == YEAR[LANGUAGE]){
				if(FirstInput[1].name == TOT[LANGUAGE] && FirstInput[1].value.length != 4 && FirstInput[1].value !== '' && FirstInput[1].value !== TOT[LANGUAGE]+ POINTS){
					formError(FirstInput[1],3);
					error = true;
					return error;
				}else if(FirstInput[1].name == TOT[LANGUAGE] && isNaN(FirstInput[1].value) && FirstInput[1].value !== '' && FirstInput[1].value !== TOT[LANGUAGE]+ POINTS){
					formError(FirstInput[1],3);
					error = true;
					return error;					
					
				}else{
					var firstField =   (FirstInput[0].value == '' || FirstInput[0].value == VAN[LANGUAGE] + POINTS)? '*'   : FirstInput[0].value;
					var seccondField = (FirstInput[1].value == '' || FirstInput[1].value == TOT[LANGUAGE] + POINTS)? 'NOW' : FirstInput[1].value;
					
					InputOut = '[' + firstField  + ' TO ' + seccondField + ']';	
				}
			}else{
				InputOut = FirstInput[0].value;
			}
			// disabled: versturen of niet
			if(FirstSelect[0].disabled == true){
				selectje = ' ' + selectReplace(firstOption_2);
			}else{
				selectje = selectReplace(firstOption_1) + " " + selectReplace(firstOption_2)+ "";		
			}
			var outputFirst = selectje + '('+ InputOut +')';	
			
	return outputFirst;
}



// form validatie
function formValid(id){
	var output_1 = '';
	var object = document.getElementById(id);
	var divObj = object.getElementsByTagName('div');

	var moreFields = document.getElementById(divObj[3].id);
	var divObj_2 = moreFields.getElementsByTagName('div');
	
	var objectsID;
	var moreOjcts;
	var selectObj;
	var inputObj;
	var output_2 = '';
	var option_year;
	var option_1;
	var error;

	// :: grote zoek veld
	var field_1 = divObj[0].getElementsByTagName('input')[0].value; // grote zoekveld

		
	// er mag max 1 value in staan  
	var returnField_1 = '';
	if(field_1.length <= 1){
		returnField_1 = returnField_1;
	}else{
		returnField_1 = getString(field_1);
			
	}
	

	
	// check of verfijnen wel mag of niet
	var field_v = divObj[3].getElementsByTagName('input');
	var verfijn = field_v[0].name;
	
	if(field_v[0].checked == true){
		// controleer weer als er een fout optreed
		if(staticField(divObj) == true){
			return error;
		}else{
			var outputFirst = staticField(divObj);
		}
	}else{
		outputFirst = '';
	}


	
	// :: dynamische toevoeg velden ::
	// als het vinkje wel is gezet doe dan
	 if(field_v[0].checked == true){	
		
		for(var x = 2; x < divObj_2.length; x++){
			objectsID = divObj_2[x].id;
			moreOjcts = document.getElementById(objectsID);
			selectObj = moreOjcts.getElementsByTagName('select');
			inputObj = moreOjcts.getElementsByTagName('input');
			option_1 = selectObj[0].options[selectObj[0].selectedIndex].text;	
			option_2 = selectObj[1].options[selectObj[1].selectedIndex].text;	
			
			// controle voor uitbrijding input fields
			option_year = selectObj[1].options[selectObj[1].selectedIndex].text;
			
			// als velden niet gewijzigd zijn
				if(inputObj[0].value == ZOEKTERM[LANGUAGE]+ POINTS || inputObj[0].value == '' && inputObj[0].name !== TOT[LANGUAGE]){
					formError(inputObj[0],1);
					error = true;
					return error;
						
				}else if(inputObj[0].name == TOT[LANGUAGE] && inputObj[0].value.length != 4 && inputObj[0].value !== '' && inputObj[0].value !== VAN[LANGUAGE]+ POINTS){ // als het wel een van veld is maar niet 4 karacters
					formError(inputObj[0],3);
					error = true;
					return error;
					
				}else if(inputObj[0].name == TOT[LANGUAGE] && isNaN(inputObj[0].value) && inputObj[0].value !== '' && inputObj[0].value !== VAN[LANGUAGE]+ POINTS){ // als het wel een van veld is maar niet 4 karacters
					formError(inputObj[0],3);
					error = true;
					return error;
							
				}else{
					// seccond field
					formError(inputObj[0],0);
					if(option_year == YEAR[LANGUAGE]){ // maak string twee waarden
	
						// controle als het tweede veld niet egwijzicht wordt
						if(inputObj[1].value == TOT[LANGUAGE]){
							formError(inputObj[1],1);
							error = true;
						    return error;	
						    
						}else if(inputObj[1].name == TOT[LANGUAGE] && inputObj[1].value.length != 4 && inputObj[1].value !== ''  && inputObj[1].value !== TOT[LANGUAGE]+ POINTS){
							formError(inputObj[1],3);
							error = true;
						    return error;
						   				
						}else if(inputObj[1].name == TOT[LANGUAGE] && isNaN(inputObj[1].value) && inputObj[1].value !== '' && inputObj[1].value !== TOT[LANGUAGE]+ POINTS){ // als het wel een van veld is maar niet 4 karacters
							formError(inputObj[0],3);
							error = true;
							return error;
							
						}else{
							var firstField =   (inputObj[0].value == '' || inputObj[0].value == VAN[LANGUAGE] + POINTS)? '*'   : inputObj[0].value;
							var seccondField = (inputObj[1].value == '' || inputObj[1].value == TOT[LANGUAGE] + POINTS)? 'NOW' : inputObj[1].value;
							output_2 = '[' + firstField +' TO '+ seccondField + ']';
						}
					}else{// maak string met een waarde
						output_2 = '('+ getString(inputObj[0].value) +')';
						
					}
					
					// :: dynamische toevoeg velden ::
					output_1 += ' ' + selectReplace(option_1) +UND+ selectReplace(option_2) + output_2;	
//					output_1 += '#' + selectReplace(option_1) + selectReplace(option_2) + output_2;
				}
			
		}
	 }else{
	 	// als het vinkje niet is gezet geen output
	 	output_1 = '';
	 }

	// :: query opbouw
	// zet tekens om aan te geven dat dit het grote zoek veld is 
	result_0 = returnField_1; // eerste veld	
	result_1 = '@'+returnField_1+'@' + getString(outputFirst) +  output_1;	
	result_2 = checkboxCheck(object); // functie controle checkbox
	result_3 = field_v[1].value; // eerste verfijning
}	

// deze functie maakt het nesten mogelijk 
function makeNestStatement(string){
	
	var output = '';
	var a = 0;
	var splitje1 = string.split('@');
	var grote_zoekveld = splitje1[1];
	
	var splitje2 = splitje1[2].split(' ');
	
	
		while(a < splitje2.length){		
			output += replaceFinal(splitje2[a]);
			a++;		
		}

	return generateHaakje(grote_zoekveld, replaceFinalCount)+output;
}

var replaceFinalCount = 0;
function replaceFinal(input){
	var a = 0;
	var output = '';
		while(a < 3){		
			if(input.indexOf(valueReplace[a])!=-1){
				output = input.replace(valueReplace[a],') '+valueReplace[a])+ ' ';
				replaceFinalCount++;
				return output; // return om op te hopen
			}
			a++;		
		}
		return output = input+' ';	// return the value als hij niet match
		
}
function generateHaakje(zoekveld, count){
	var a = 0;
	var output = '';
	while(a < count){
		output +='(';
		a++;
	}
	replaceFinalCount = 0; // leeg deze global 
	return output + zoekveld;
}

// de developers function 
function developersMode(res1, res2, frm){
	var nres = makeNestStatement(res1);
	if(DEVELOPERS_MODE == true){
		
		document.getElementById('test').innerHTML = nres +'<br />'+ res2;
	}else{
//		document.getElementById('test').innerHTML = nres +'<br />'+ res2;

//		var url1 = '../../PutinSession?qs='+nres+'&sh='+res2+'&start=0&init=1&nw=1';
		var url1 = '/aletta/zoek/putinsession.jsp';
		var par = 'qs='+nres+'&sh='+res2+'&start=0&init=1&nw=1';
//			alert(result_1);
//alert(res2);
			SendS(url1,par,'sess',frm);
//			alert('erna '+result_2);			

//		request.open('GET', URL, 'false');	//extra param false voor asynchroon = false werkt niet voor keywords en getallen selectie en historie
//		request.send('');			
		
//		form.submit();
	}
}

//verzend de date of niet
function formOutput(id){
	
	var vinkje = document.getElementById('verfijnen_check');
	
	if(formValid(id) !== true){
		if(result_0.length > 1 && !result_2.length < 1){
			developersMode(result_1, result_2, document.zoekForm);
		}

		if(vinkje.checked == true && !result_2.length < 1){
		  developersMode(result_1, result_2, document.zoekForm);
		}
	}
}

// geef een style aan het veld
function formError(incomingObj,status){
	var melding = document.getElementById('MeldingMax');
	var span = melding.getElementsByTagName('span');
	var img = melding.getElementsByTagName('img');

	var errorCreate = function(text, imgsrc){
		span[0].innerHTML = text;		
		img[0].src = imgsrc;
		img[0].title = text;
//		img[0].alt = 'error';
		img[0].style.cssFloat = 'right';			
	}

	if(status == 1){
		melding.style.display = 'block';
		incomingObj.style.borderColor = '#b50008';
		incomingObj.style.color = '#b50008';
		incomingObj.style.backgroundColor = '#ffe4e5';
		errorCreate(EMPTY_WARNING, '../../img/error1.png');

	}else if(status == 2){
		melding.style.display = 'block';
		incomingObj.style.borderColor = '#b50008';
		incomingObj.style.color = '#b50008';
		incomingObj.style.backgroundColor = '#ffe4e5';
		errorCreate(EMPTY_WARNING_2[LANGUAGE], '../../img/error1.png');
		
	}else if(status == 3){
		melding.style.display = 'block';
		incomingObj.style.borderColor = '#b50008';
		incomingObj.style.color = '#b50008';
		incomingObj.style.backgroundColor = '#ffe4e5';	
		errorCreate(FOUR_WARNING[LANGUAGE], '../../img/error1.png');	
		
	}else if(status == 4){
		melding.style.display = 'block';
//		incomingObj.style.borderColor = '#b50008';
//		incomingObj.style.color = '#b50008';
//		incomingObj.style.backgroundColor = '#ffe4e5';	
		errorCreate(CHECK_WARNING[LANGUAGE], '../../img/error1.png');	
		
	}
	else{	
		melding.style.display = 'none';
		span[0].innerHTML = '';
		incomingObj.style.borderColor = '#9c9a9c';
		incomingObj.style.color = '#636563';
		incomingObj.style.backgroundColor = '#fff';		
	}
}


function checkSingleQuote(incoming){

	var str = incoming.value;
	var melding = document.getElementById('MeldingMax');
	var span = melding.getElementsByTagName('span');
	var img = melding.getElementsByTagName('img');
		
	
	if(str.indexOf("'") > -1){	
		melding.style.display = 'block';
		span[0].innerHTML = QUOTE_ERROR[LANGUAGE];
		span[0].style.color = "#e37804";

		img[0].src = '../../img/error2.png';
		img[0].title = QUOTE_ERROR[LANGUAGE];
//		img[0].alt = 'error';
		img[0].style.cssFloat = 'right';
		
		incoming.style.borderColor = '#e37804';
		incoming.style.color = '#e37804';
	}else{
		melding.style.display = 'none';
		span[0].style.color = "";
		img[0].src = '';
		incoming.style.borderColor = '#9c9a9c';
		incoming.style.color = '#636563'
	}

}


function lisnerQuote(){
	var field_erea = document.getElementById('Form');
	if(field_erea){
	var inputs = field_erea.getElementsByTagName('input');
	
	var a;

	field_erea.onkeyup = function(){
		for(a = 0; a < inputs.length; a++){	
			if(inputs[a].type == 'text'){
				
				$(inputs[a]).keyup(function() { checkSingleQuote(this); return false;});
			}		
		}
	}
	}
}


// functie meer velden 
// DE GLOBAL SET
var counter = 1;
var counterSubId = 1;
var maximum = 9;
var set = 0; 



 function Fieldedit(id){

	var object = document.getElementById(id);
	
 	var div = 	 document.createElement('div');
 	var a = 	 document.createElement('a');
	var input =  document.createElement('input');
	
	//  slect box 1
	var select_1 = document.createElement('select');
	var option_1 = document.createElement('option');
	var option_2 = document.createElement('option');
	var option_3 = document.createElement('option');
	
	var text_1 = document.createTextNode(EN[LANGUAGE]);
	var text_2 = document.createTextNode(OF[LANGUAGE]);
	var text_3 = document.createTextNode(NIET[LANGUAGE]);	

	option_1.appendChild(text_1);
	option_2.appendChild(text_2);
	option_3.appendChild(text_3);
	
	
	
	//  slect box 2 creeeren
	var select_2 = document.createElement('select');
	
	var option_a = document.createElement('option');
	var option_b = document.createElement('option');
	var option_c = document.createElement('option');
	var option_d = document.createElement('option');
	var option_e = document.createElement('option');
	var option_f = document.createElement('option');
	var option_g = document.createElement('option');
	var option_h = document.createElement('option');
	// scrijf text in de dom variabelen
	var text_a = document.createTextNode(ALLES[LANGUAGE]);
	var text_b = document.createTextNode(TITLE[LANGUAGE]);
	var text_c = document.createTextNode(AUTEUR[LANGUAGE]);
	var text_d = document.createTextNode(PERIODE[LANGUAGE]);
	var text_e = document.createTextNode(PERSOON[LANGUAGE]);
	var text_f = document.createTextNode(ORGANISATIE[LANGUAGE]);
	var text_g = document.createTextNode(YEAR[LANGUAGE]);
	var text_h = document.createTextNode(ISBN[LANGUAGE]);
	// zet de text
	option_a.appendChild(text_a);
	option_b.appendChild(text_b);
	option_c.appendChild(text_c);
	option_d.appendChild(text_d);
	option_e.appendChild(text_e);
	option_f.appendChild(text_f);
	option_g.appendChild(text_g);
	option_h.appendChild(text_h);
	
  	if(counter != maximum){

  		// maak de div aan
	   	object.appendChild(div);
	   	div.id = counter + '_field';
	   	div.className = 'boxRefine';
	  	// voeg select 1 toe
	  	div.appendChild(select_1);
	  	select_1.id = counter + '_select';
	  	select_1.className = 'select';
	  	select_1.appendChild(option_1);
	  	select_1.appendChild(option_2);
	  	select_1.appendChild(option_3);
	  	
	  	// voeg select 2 toe
	    div.appendChild(select_2);
	    select_2.className = 'select';
	    select_2.id = String.fromCharCode(97 + counter) + '_select';
	    select_2.onchange = function(){
	    	var subId = counter; // sending id int to other function
	    	selectYear(input.id, this);
	    }
	  	select_2.appendChild(option_a);
	  	select_2.appendChild(option_b);
	  	select_2.appendChild(option_c);
	  	select_2.appendChild(option_d);
	  	select_2.appendChild(option_e);
	  	select_2.appendChild(option_f);
	  	select_2.appendChild(option_g);
	  	select_2.appendChild(option_h);
	  	
	  	// voeg input field toe
	    input.type = 'text';
	  	input.name = ZOEKTERM[LANGUAGE];
	  	input.value = ZOEKTERM[LANGUAGE] + POINTS;
	    input.id = counter + '_input';
	    input.className = 'InputSearch_2';
		input.onmouseup = function(){ // functie om te legen wordt uitgevoerd
			emptyField(input);
		}
	  	div.appendChild(input);	
	  	// voeg delete toe
	  	a.className = 'Min-SearchTerm';
	  	a.title = 'Verwijder dit veld';
	  	div.appendChild(a);	
		a.onclick = function(){ // functie om te deleten wordt uitgevoerd
			deleteField(div);
			melding(); // melding maximaal
		}
  		// counter
  		counter ++;  	
  	}else{
		// counter 
		// hij vald in de andere controle dus max een hoger plaatsen	
  		counter = maximum;
  		melding(); // melding maximaal
  	}

}
// delete function 
function deleteField(div){
	div.parentNode.removeChild(div);
	counter --;
}
// melding maximaal
function melding(){
	var melding = document.getElementById('MeldingMax');
	var span =  melding.getElementsByTagName('span');
	var img = melding.getElementsByTagName('img');
	
	if(counter == maximum){
		span[0].innerHTML = MAX_WARNING[LANGUAGE];
		img[0].src = '../../img/error1.png';
		img[0].title = MAX_WARNING[LANGUAGE];
		img[0].alt = 'error';
		img[0].style.cssFloat = 'right';
		melding.style.display = 'block';
	}else{
		span[0].innerHTML = '';
		melding.style.display = 'none'		
	}
}

// velden leeg maak functie  :: oud
function emptyField(input){
	if(input.value == ZOEKTERM[LANGUAGE]+ POINTS){
		input.value = '';
	}else{
		input.value = input.value;
	}
}

// velden leeg maken functie global
function empty(obj){
	var cache = obj.value;

	obj.value = '';
	obj.onkeyup = function(){
		cache = obj.value;
	}
	obj.onblur = function(){
		obj.value = cache;
	}
}

// submit de rechts-boven form
function submitRes1(incObj){
	var html = incObj.parentNode;
	var input = html.getElementsByTagName('input');
	var cache = input[0].form.action;
	if(input[0].value == VALUE_TEXT_1[LANGUAGE] || input[0].value ==''){
		//input[0].form.action = window.location;
		return;
		
	}else{
		input[0].value = getString(input[0].value);		

		input[0].form.action = cache;
		// developers mode
		developersMode('@'+input[0].value+'@', 'all', input[0].form);
	}
}

// submit de enkele grote zoekveld
function submitRes2(formname, zoekveld){
	
	var formarea = document.getElementById(formname);
	var searchfield = document.getElementById(zoekveld);
	var cache = searchfield.form.action;
	var url = '';
	var countCheck = 0;
	
		var ceckboxen = formarea.getElementsByTagName('input');
		var a = 0;
		if(searchfield.value ==''){
			return;
			
		}else{
			while(a  < ceckboxen.length){
				if(ceckboxen[a].type == 'checkbox'){
				   countCheck ++;
					if(ceckboxen[a].checked == true){
					  url += selectReplace(ceckboxen[a].name) +",";	
					}					
				}
				a++;
			}
			if(countCheck > 0){
				formError(searchfield, 0);
				developersMode('@'+searchfield.value+'@', url, searchfield.form);
			}else{
				formError(searchfield, 4);
			}
		}
}


// generate select box for results
function rowSelect(inter){
	var html;
	var a = 1;
	html =  '<select name="rows">';
		while(a <= 5){
			b = a *10;
			if(b == inter){
				html += '<option value="'+ b +'" selected="selected">'+ b +'</option>';
			}else{
				html += '<option value="'+ b +'">'+ b +'</option>';
			}
			a++;
		}
	html += '</select>';
	// schrijf weg in de dom
	document.write(html);
}

// functie controleerd als velden aan string lengte en int waarde voldoet
function checkNumbers(incomingObj){
	//alert(incomingObj.value);

	var melding = document.getElementById('MeldingMax');
	var span =  melding.getElementsByTagName('span');	
	var img =  melding.getElementsByTagName('img');	
	var text_1 = INT_WARNING[LANGUAGE];
	var text_2 = FOUR_WARNING[LANGUAGE];
	var error;
	
	if(incomingObj.value.length != 4 && incomingObj.value.length != ''){ // als hij niet gelijk is aan 4
		melding.style.display = 'block';
		span[0].innerHTML = text_2;
		img[0].src = '../../img/error1.png';
		img[0].title = text_2;
		img[0].alt = 'error';
		img[0].style.cssFloat = 'right';
		incomingObj.style.borderColor = '#b50008';
		incomingObj.style.color = '#b50008';
		incomingObj.style.backgroundColor = '#ffe4e5';
		error = true;
		
	}else if(isNaN(incomingObj.value)){ // als het geen nummers zijn
		melding.style.display = 'block';
		span[0].innerHTML = text_1;
		img[0].src = '../../img/error1.png';
		img[0].title = text_1;
		img[0].alt = 'error';
		img[0].style.cssFloat = 'right';
		incomingObj.style.borderColor = '#b50008';
		incomingObj.style.color = '#b50008';
		incomingObj.style.backgroundColor = '#ffe4e5';
		error = true;
		
	}else{
		melding.style.display = 'none';
		span[0].innerHTML = '';	
		incomingObj.style.borderColor = '';
		incomingObj.style.color = '';
		incomingObj.style.backgroundColor = '';	
	}
}

// select YEAR functie van een veld naar twee velden
function selectYear(idInput, incomingObj){
	
	counterSubId ++;
	var object = incomingObj;
	var Option = object.options[object.selectedIndex].text;	
	var Input = document.getElementById(idInput);
	var InputYear_1 = document.createElement('input');
	var InputYear_2 = document.createElement('input');
	var resetInput = document.createElement('input');
	
	if(Option == YEAR[LANGUAGE]){
		set = 1;
		InputYear_1.name = TOT[LANGUAGE];
		InputYear_1.value = VAN[LANGUAGE] + POINTS;
		InputYear_1.className = 'Year_1';
		InputYear_1.id = counterSubId + 'sub_field';
		InputYear_2.name = TOT[LANGUAGE];
		InputYear_2.value = TOT[LANGUAGE] + POINTS;
		InputYear_2.id = counterSubId + 1 + 'sub_field';
		InputYear_2.className = 'Year_2';
		
		InputYear_1.onclick = function(){ // functie om te legen wordt uitgevoerd
			// maak leeg value text als anders is dan niet
			InputYear_1.value = (InputYear_1.value == VAN[LANGUAGE] + POINTS)? InputYear_1.value = '' : InputYear_1.value = InputYear_1.value;
		}
		InputYear_1.onblur = function(){// roep check functie aan
			checkNumbers(this);
		}
		InputYear_2.onclick = function(){ // functie om te legen wordt uitgevoerd
			
			InputYear_2.value = (InputYear_2.value == TOT[LANGUAGE] + POINTS)? InputYear_2.value = '' : InputYear_2.value = InputYear_2.value;
		}
		InputYear_2.onblur = function(){// roep check functie aan
			checkNumbers(this);
		}
		// vervang het opbject
		if (Input != null) {
		 object.parentNode.replaceChild(InputYear_2 ,Input); // vervang object
		 object.parentNode.insertBefore(InputYear_1 ,InputYear_2); // voeg new object voor object
		} 
	}else if(Option != YEAR[LANGUAGE] && set == 1){
		set = 0;
		var typeInput = object.parentNode.getElementsByTagName('input');
		
		// reset and rewrite waarden
			resetInput.id = idInput;
			resetInput.type = 'text';
			resetInput.className = 'InputSearch_2';
			resetInput.value = ZOEKTERM[LANGUAGE] + POINTS;
			resetInput.onclick = function(){
				// weer veld leeg kunnen maken
				resetInput.value = (resetInput.value == ZOEKTERM[LANGUAGE] + POINTS)? resetInput.value = '' : resetInput.value = resetInput.value;
			}
		object.parentNode.replaceChild(resetInput ,typeInput[0]);
		object.parentNode.removeChild(typeInput[1]);
	}
}


// BUTTON SPUL
/* select function periodiek  */
function select(){
	var object = document.getElementById('0_field');
	var inputObject = object.getElementsByTagName('input');
	
}


// set button zoeken
function hoverButton(incObj){

	incObj.style.backgroundColor = '#9C9A9C';
	incObj.style.color = '#fff';

	incObj.onmousedown = function(){
		incObj.style.backgroundColor = '#00a2b5';
		incObj.style.color = '#fff';		
	}
	
	incObj.onmouseout = function(){
		incObj.style.backgroundColor = '';
		incObj.style.color = '';		
	}
}


function alphaMenu(incomingObj){		
	var html = incomingObj.parentNode;
	var linkjes = html.getElementsByTagName('a');
	
	// opschonen van gezette velden
	for(var c = 0; c < linkjes.length; c++){
		linkjes[c].id = '';
		incomingObj.id = 'alphaSet';
	}
	if (alfa_target == 'thes_keyword') {
		Send('../../zoek/keyword_thes.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'keyword') {
		Send('../../zoek/keyword.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'land') {
		Send('../../zoek/land.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'vorm') {
		Send('../../zoek/vorm.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'auteur') {
		Send('../../zoek/auteur-list.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'boek_auteur') {
		Send('../../zoek/boek_auteur.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'tijdschrift_titel') {
		Send('../../zoek/tijdschrift_titel.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'tijdschrift_digitaal') {
		Send('../../zoek/tijdschrift_digitaal.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'art_auteur') {
		Send('../../zoek/artikel_auteur.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'archief_naam') {
		Send('../../zoek/archief_naam.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'egodoc_naam') {
		Send('../../zoek/egodoc_naam.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'foto_fotograaf') {
		Send('../../zoek/foto_fotograaf.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'muziek_componist') {
		Send('../../zoek/muziek_componist.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'deskundige_naam') {
		Send('../../zoek/deskundige_naam.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'organisatie_naam') {
		Send('../../zoek/organisatie_naam.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'infocentra_naam') {
		Send('../../zoek/infocentra_naam.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'website_naam') {
		Send('../../zoek/website_naam.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
	if (alfa_target == 'fragen_auteur') {
			Send('../../zoek/fragen_auteur.jsp?key='+incomingObj.firstChild.nodeValue,'listdiv','true');
	}
}

// genereer alphabet menu
function alphabet(){
	var obj =  document.getElementById('menuAlpha');
	if (obj){
	var object2 = document.getElementById('SearchTerm');
		for(var c = 0; c <= 25; c++){
				if (c == 0){
    		obj.innerHTML += '<a id="alphaSet" href="#" class="NavThema" onclick="alphaMenu(this); return false;">' + String.fromCharCode(97 + c) + '</a>';
    		//object.style.textTransform = 'lowercase';
    	}
    	else{
    		obj.innerHTML += '<a href="#" class="NavThema" onclick="alphaMenu(this); return false;">' + String.fromCharCode(97 + c) + '</a>';
    	}	
		}
	}	
}

function antieSpatie(string){

	string = string.replace(new RegExp(/^\s+/),""); // START
	string = string.replace(new RegExp(/\s+$/),""); // END
	
	return string;
}

function submitPager(res_1,res_2,start,rows) {
	//document.pagerform.rows.value = rows;
	//document.pagerform.start.value = start;
// niet de inputparameter, maar de globale vars meegeven
	PutinSession('',res2,start,rows,"0",document.pagerform);
//	document.pagerform.submit();
}

function writePager(j,k,set,p,rows) {
	if (set==1) {
		document.writeln('<a class="Back_disabled"></a>');
	}	
	else {
		document.writeln('<a class="Back" onclick="submitPager(\'\',\'\','+((set-2)*rows)+','+rows+');"></a>');
	}	
	for (var i=j; i<=k; i++) {
		if(set==i){
			document.writeln('<a class="Nav" onclick="submitPager(\'\',\'\','+((i-1)*rows)+','+rows+');" id="Key">'+i+'</a>');
		}else{
			document.writeln('<a class="Nav" onclick="submitPager(\'\',\'\','+((i-1)*rows)+','+rows+');">'+i+'</a>');			
		}
	}	
	if (set==p) {
		document.writeln('<a class="Forward_disabled"></a>');
	}	
	else {
		document.writeln('<a class="Forward" onclick="submitPager(\'\',\'\','+(set*rows)+','+rows+');"></a>');
	}
	document.writeln('<a class="nPages">' + p + ' Pagina\'s</a>');
//	alert(set); 
}

function Pager(numFound, rows, start) {
	var DISPLAY_PAGES = 9;
	var p;
	var i=0;
	if (numFound % rows) {
		p = parseInt(numFound / rows)+1;
	}	
	else {
		p = parseInt(numFound / rows);
	}
	var set = (start / rows) + 1; //de actieve pagina 	
	if (p < DISPLAY_PAGES) {
		DISPLAY_PAGES = p;
	}
	var MID = parseInt(DISPLAY_PAGES/2); 
	if (p > DISPLAY_PAGES) {
		if (set > MID+1) {
			if ((set+MID)<p) {  //laatste resultaat pagina's nog niet bereikt
				writePager(set-MID,set+MID,set,p,rows);
			}
			else {
				writePager(p-DISPLAY_PAGES+1,p,set,p,rows);
			}
		}
		else { 		//onder de helft maar meer dan 9 pagina's
			writePager(1,DISPLAY_PAGES,set,p,rows);
		}	
	}
	else {  //minder dan DISPLAY_PAGES paginas 
		writePager(1,DISPLAY_PAGES,set,p,rows);
	}
}

function drillDown(rs,shard,rows) {
	var s = '';
	if (shard == 'totaal') { //deze event moet ook het onthouden van de getallen triggeren..
		s = res0;
	}
	else {
		s = selectReplace(shard);
	}
	facet_klik(shard);
//	alert('res1: '+res1);
//	document.facetform.res2.value = t;
//	PutinSession(res1,t,"0",rows,"0",'false');
//	document.facetform.submit();
	PutinSession('',s,"0",rows,"0",document.facetform);	//res1 wordt nu uit sessie gehaald!
}

function FdrillDown(rs,shard,rows) {
	var s = '';
	var q = '';
	if (shard == 'totaal') {
		s = res0;
		q = q_org;
	}
	else {
		s = selectReplace(shard);
		q = q_org+' '+rs;
	}
	var ffacet=new Array();
	ffacet = rs.split(":");
        facet_klik(ffacet[1]);
	FPutinSession(q,s,"0",rows,"0",document.facetform,q_org);	//res1 wordt nu uit sessie gehaald!
}

function FacetMenu(res1,rows,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22) {
	if (nw_search == '0' && sv1 != '') { //v uit sessie gebruiken ipv parameter
		v1=sv1;v2=sv2;v3=sv3;v4=sv4;v5=sv5;v6=sv6;v7=sv7;v8=sv8;v9=sv9;v10=sv10;
		v11=sv11;v12=sv12;v13=sv13;v14=sv14;v15=sv15;v16=sv16;v17=sv17;v18=sv18;v19=sv19;v20=sv20;v21=sv21;v22=sv22;
	}
	if (nw_search == '1') { // FacetinSession!
    var url = '../../FacetinSession?v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9+'&v10='+v10+'&v11='+v11+'&v12='+v12+'&v13='+v13+'&v14='+v14+'&v15='+v15+'&v16='+v16+'&v17='+v17+'&v18='+v18+'&v19='+v19+'&v20='+v20+'&v21='+v21+'&v22='+v22;
    Send(url,'textPopup','false');
    clicked = 'totaal';
	}

	document.writeln('<li class="facet" id="totaal"><a onclick="drillDown(\''+res1+'\',\'totaal\',\''+rows+'\');">'+FACET[0][LANGUAGE]+' ('+v1+')</a></li>');
if (v2 != "") {
	document.writeln('<li class="facet" id="Aletta-Website"><a onclick="drillDown(\''+res1+'\',\''+IIAV_WEB+'\',\''+rows+'\');">'+FACET[1][LANGUAGE]+' ('+v2+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Aletta-Website"><a>'+FACET[1][LANGUAGE]+' (-)</a></li>');
}
if (v3 != "") {
	document.writeln('<li class="facet" id="Andere-Aletta-Websites"><a onclick="drillDown(\''+res1+'\',\''+ANDER_IIAV+'\',\''+rows+'\');">'+FACET[2][LANGUAGE]+' ('+v3+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Andere-Aletta-Websites"><a>'+FACET[2][LANGUAGE]+' (-)</a></li>');
}
if (v4 != "") {
	document.writeln('<li class="facet" id="Boeken"><a onclick="drillDown(\''+res1+'\',\''+BOEKEN+'\',\''+rows+'\');">'+FACET[3][LANGUAGE]+' ('+v4+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Boeken"><a>'+FACET[3][LANGUAGE]+' (-)</a></li>');
}
if (v5 != "") {
	document.writeln('<li class="facet" id="Tijdschriften"><a onclick="drillDown(\''+res1+'\',\''+TIJDSCHR+'\',\''+rows+'\');">'+FACET[4][LANGUAGE]+' ('+v5+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Tijdschriften"><a>'+FACET[4][LANGUAGE]+' (-)</a></li>');
}
if (v6 != "") {
	document.writeln('<li class="facet" id="Artikelen"><a onclick="drillDown(\''+res1+'\',\''+ARTIKELEN+'\',\''+rows+'\');">'+FACET[5][LANGUAGE]+' ('+v6+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Artikelen"><a>'+FACET[5][LANGUAGE]+' (-)</a></li>');
}
//	document.writeln('<li class="facet" id="Archieven"><a onclick="drillDown(\''+res1+'\',\''+ARCHIEVEN+'\',\''+rows+'\');">'+FACET[6][LANGUAGE]+' ('+v7+')</a></li>');
if (v8 != "") {
	document.writeln('<li class="facet" id="Archieven-EAD"><a onclick="drillDown(\''+res1+'\',\''+ARCHIEVEN_EAD+'\',\''+rows+'\');">'+FACET[7][LANGUAGE]+' ('+v8+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Archieven-EAD"><a>'+FACET[7][LANGUAGE]+' (-)</a></li>');
}
if (v22 != "") {
	document.writeln('<li class="facet" id="Parafernalia"><a onclick="drillDown(\''+res1+'\',\''+PARAFERNALIA+'\',\''+rows+'\');">'+FACET[22][LANGUAGE]+' ('+v22+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Parafernalia"><a>'+FACET[22][LANGUAGE]+' (x)</a></li>');
}

if (v9 != "") {
	document.writeln('<li class="facet" id="Egodocumenten"><a onclick="drillDown(\''+res1+'\',\''+EGO+'\',\''+rows+'\');">'+FACET[8][LANGUAGE]+' ('+v9+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Egodocumenten"><a>'+FACET[8][LANGUAGE]+' (-)</a></li>');
}
//	document.writeln('<li class="facet" id="Archieven-elders"><a onclick="drillDown(\''+res1+'\',\''+ARCHIEVEN_ELDERS+'\',\''+rows+'\');">'+FACET[9][LANGUAGE]+' ('+v10+')</a></li>');
if (v11 != "") {
	document.writeln('<li class="facet" id="Foto"><a onclick="drillDown(\''+res1+'\',\''+FOTO+'\',\''+rows+'\');">'+FACET[10][LANGUAGE]+' ('+v11+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Foto"><a>'+FACET[10][LANGUAGE]+' (-)</a></li>');
}
if (v12 != "") {
	document.writeln('<li class="facet" id="Affiches"><a onclick="drillDown(\''+res1+'\',\''+AFFICHES+'\',\''+rows+'\');">'+FACET[11][LANGUAGE]+' ('+v12+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Affiches"><a>'+FACET[11][LANGUAGE]+' (-)</a></li>');
}
if (v13 != "") {
	document.writeln('<li class="facet" id="Muziekwerken"><a onclick="drillDown(\''+res1+'\',\''+MUZIEK+'\',\''+rows+'\');">'+FACET[12][LANGUAGE]+' ('+v13+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Affiches"><a>'+FACET[12][LANGUAGE]+' (-)</a></li>');
}
if (v14 != "") {
	document.writeln('<li class="facet" id="Deskundigen"><a onclick="drillDown(\''+res1+'\',\''+DESK+'\',\''+rows+'\');">'+FACET[13][LANGUAGE]+' ('+v14+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Deskundigen"><a>'+FACET[13][LANGUAGE]+' (-)</a></li>');
}
if (v15 != "") {
	document.writeln('<li class="facet" id="Organisaties"><a onclick="drillDown(\''+res1+'\',\''+ORG+'\',\''+rows+'\');">'+FACET[14][LANGUAGE]+' ('+v15+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Organisaties"><a>'+FACET[14][LANGUAGE]+' (-)</a></li>');
}
if (v16 != "") {
	document.writeln('<li class="facet" id="Vrouweninformatiecentra"><a onclick="drillDown(\''+res1+'\',\''+VROUW_INFO+'\',\''+rows+'\');">'+FACET[15][LANGUAGE]+' ('+v16+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Vrouweninformatiecentra"><a>'+FACET[15][LANGUAGE]+' (-)</a></li>');
}
if (v17 != "") {
	document.writeln('<li class="facet" id="Websites"><a onclick="drillDown(\''+res1+'\',\''+WEB+'\',\''+rows+'\');">'+FACET[16][LANGUAGE]+' ('+v17+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Vrouweninformatiecentra"><a>'+FACET[16][LANGUAGE]+' (-)</a></li>');
}
if (v18 != "") {
	document.writeln('<li class="facet" id="Biografieen"><a onclick="drillDown(\''+res1+'\',\''+BIOGRAFIE+'\',\''+rows+'\');">'+FACET[17][LANGUAGE]+' ('+v18+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Biografieen"><a>'+FACET[17][LANGUAGE]+' (-)</a></li>');
}
if (v19 != "") {
	document.writeln('<li class="facet" id="Dossiers"><a onclick="drillDown(\''+res1+'\',\''+DOSSIERS+'\',\''+rows+'\');">'+FACET[18][LANGUAGE]+' ('+v19+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Dossiers"><a>'+FACET[18][LANGUAGE]+' (-)</a></li>');
}
if (v20 != "") {
	document.writeln('<li class="facet" id="Digitale-doc"><a onclick="drillDown(\''+res1+'\',\''+DIGITALE_DOC+'\',\''+rows+'\');">'+FACET[19][LANGUAGE]+' ('+v20+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Digitale-doc"><a>'+FACET[19][LANGUAGE]+' (-)</a></li>');
}
if (v21 != "") {
	document.writeln('<li class="facet" id="Veelgestelde-vragen"><a onclick="drillDown(\''+res1+'\',\''+FAQ+'\',\''+rows+'\');">'+FACET[20][LANGUAGE]+' ('+v21+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="Veelgestelde-vragen"><a>'+FACET[20][LANGUAGE]+' (-)</a></li>');
}
	document.getElementById(clicked).className = 'facet_open';
}

function FragenFacetMenu(res1,rows,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30,v31,v32,v33,v34) {
	if (nw_search == '0' && sv1 != '') { //v uit sessie gebruiken ipv parameter
		v1=sv1;v2=sv2;v3=sv3;v4=sv4;v5=sv5;v6=sv6;v7=sv7;v8=sv8;v9=sv9;v10=sv10;v11=sv11;v12=sv12;v13=sv13;v14=sv14;v15=sv15;v16=sv16;
		v17=sv17;v18=sv18;v19=sv19;v20=sv20;v21=sv21;v22=sv22;v23=sv23;v24=sv24;v25=sv25;v26=sv26;v27=sv27;v28=sv28;v29=sv29;v30=sv30;v31=sv31;v32=sv32;
		v33=sv33;v34=sv34;
	}
	if (nw_search == '1') { // FacetinSession!
    var url = '../../zoek/facetinsession.jsp?v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9+'&v10='+v10+'&v11='+v11+'&v12='+v12+'&v13='+v13+'&v14='+v14+'&v15='+v15+'&v16='+v16+'&v17='+v17+'&v18='+v18+'&v19='+v19+'&v20='+v20+'&v21='+v21+'&v22='+v22
    +'&v23='+v23+'&v24='+v24+'&v25='+v25+'&v26='+v26+'&v27='+v27+'&v28='+v28+'&v29='+v29+'&v30='+v30+'&v31='+v31+'&v32='+v32+'&v33='+v33+'&v34='+v34;
    Send(url,'textPopup','false');
    clicked = 'totaal';
	}

	document.writeln('<li class="facet" id="totaal"><a onclick="FdrillDown(\':totaal\',\'totaal\',\''+rows+'\');">'+FACET[0][JSL]+' ('+v1+')</a></li>');
	document.writeln('<div class=menuBlue>Type</div>');
if (v2 != "") {
	document.writeln('<li class="facet" id="book"><a onclick="FdrillDown(\'AND class:Book\',\''+FRAGEN+'\',\''+rows+'\');">'+'Book'+' ('+v2+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="book"><a>'+'Book'+' (x)</a></li>');
}
if (v3 != "") {
	document.writeln('<li class="facet" id="article"><a onclick="FdrillDown(\'AND class:Article\',\''+FRAGEN+'\',\''+rows+'\');">'+'Article'+' ('+v3+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="article"><a>'+'Article'+' (x)</a></li>');
}
if (v4 != "") {
	document.writeln('<li class="facet" id="periodical"><a onclick="FdrillDown(\'AND class:Periodical\',\''+FRAGEN+'\',\''+rows+'\');">'+'Periodical'+' ('+v4+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="periodical"><a>'+'Periodical'+' (x)</a></li>');
}
if (v5 != "") {
	document.writeln('<li class="facet" id="other"><a onclick="FdrillDown(\'AND class:Other\',\''+FRAGEN+'\',\''+rows+'\');">'+'Other'+' ('+v5+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="other"><a>'+'Other'+' (x)</a></li>');
}
	document.writeln('<div class=menuBlue>Country</div>');
if (v7 != "") {
	document.writeln('<li class="facet" id="austria"><a onclick="FdrillDown(\'AND country:austria\',\''+FRAGEN+'\',\''+rows+'\');">'+'Austria'+' ('+v7+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="austria"><a>'+'Austria'+' (x)</a></li>');
}
if (v8 != "") {
	document.writeln('<li class="facet" id="belgium"><a onclick="FdrillDown(\'AND country:belgium\',\''+FRAGEN+'\',\''+rows+'\');">'+'Belgium'+' ('+v8+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="belgium"><a>'+'Belgium'+' (x)</a></li>');
}
if (v9 != "") {
	document.writeln('<li class="facet" id="bulgaria"><a onclick="FdrillDown(\'AND country:bulgaria\',\''+FRAGEN+'\',\''+rows+'\');">'+'Bulgaria'+' ('+v9+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="bulgaria"><a>'+'Bulgaria'+' (x)</a></li>');
}
if (v10 != "") {
	document.writeln('<li class="facet" id="croatia"><a onclick="FdrillDown(\'AND country:croatia\',\''+FRAGEN+'\',\''+rows+'\');">'+'Croatia'+' ('+v10+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="croatia"><a>'+'Croatia'+' (x)</a></li>');
}
if (v11 != "") {
	document.writeln('<li class="facet" id="cyprus"><a onclick="FdrillDown(\'AND country:cyprus\',\''+FRAGEN+'\',\''+rows+'\');">'+'Cyprus'+' ('+v11+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="cyprus"><a>'+'Cyprus'+' (x)</a></li>');
}
if (v6 != "") {
	document.writeln('<li class="facet" id="czech"><a onclick="FdrillDown(\'AND country:czech\',\''+FRAGEN+'\',\''+rows+'\');">'+'Czech Republic'+' ('+v6+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="czech"><a>'+'Czech Republic'+' (x)</a></li>');
}
if (v12 != "") {
	document.writeln('<li class="facet" id="denmark"><a onclick="FdrillDown(\'AND country:denmark\',\''+FRAGEN+'\',\''+rows+'\');">'+'Denmark'+' ('+v12+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="denmark"><a>'+'Denmark'+' (x)</a></li>');
}
if (v13 != "") {
	document.writeln('<li class="facet" id="estonia"><a onclick="FdrillDown(\'AND country:estonia\',\''+FRAGEN+'\',\''+rows+'\');">'+'Estonia'+' ('+v13+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="estonia"><a>'+'Estonia'+' (x)</a></li>');
}
if (v34 != "") {
	document.writeln('<li class="facet" id="finland"><a onclick="FdrillDown(\'AND country:finland\',\''+FRAGEN+'\',\''+rows+'\');">'+'Finland'+' ('+v34+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="finland"><a>'+'Finland'+' (x)</a></li>');
}
if (v14 != "") {
	document.writeln('<li class="facet" id="franc"><a onclick="FdrillDown(\'AND country:franc\',\''+FRAGEN+'\',\''+rows+'\');">'+'France'+' ('+v14+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="franc"><a>'+'France'+' (x)</a></li>');
}
if (v15 != "") {
	document.writeln('<li class="facet" id="germani"><a onclick="FdrillDown(\'AND country:germani\',\''+FRAGEN+'\',\''+rows+'\');">'+'Germany'+' ('+v15+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="germani"><a>'+'Germany'+' (x)</a></li>');
}
if (v16 != "") {
	document.writeln('<li class="facet" id="greec"><a onclick="FdrillDown(\'AND country:greec\',\''+FRAGEN+'\',\''+rows+'\');">'+'Greece'+' ('+v16+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="greec"><a>'+'Greece'+' (x)</a></li>');
}
if (v17 != "") {
	document.writeln('<li class="facet" id="hungari"><a onclick="FdrillDown(\'AND country:hungari\',\''+FRAGEN+'\',\''+rows+'\');">'+'Hungary'+' ('+v17+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="hungari"><a>'+'Hungary'+' (x)</a></li>');
}
if (v18 != "") {
	document.writeln('<li class="facet" id="ireland"><a onclick="FdrillDown(\'AND country:ireland\',\''+FRAGEN+'\',\''+rows+'\');">'+'Ireland'+' ('+v18+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="ireland"><a>'+'Ireland'+' (x)</a></li>');
}
if (v19 != "") {
	document.writeln('<li class="facet" id="itali"><a onclick="FdrillDown(\'AND country:itali\',\''+FRAGEN+'\',\''+rows+'\');">'+'Italy'+' ('+v19+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="itali"><a>'+'Italy'+' (x)</a></li>');
}
if (v21 != "") {
	document.writeln('<li class="facet" id="latvia"><a onclick="FdrillDown(\'AND country:latvia\',\''+FRAGEN+'\',\''+rows+'\');">'+'Latvia'+' ('+v21+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="latvia"><a>'+'Latvia'+' (x)</a></li>');
}
if (v22 != "") {
	document.writeln('<li class="facet" id="lithuania"><a onclick="FdrillDown(\'AND country:lithuania\',\''+FRAGEN+'\',\''+rows+'\');">'+'Lithuania'+' ('+v22+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="lithuania"><a>'+'Lithuania'+' (x)</a></li>');
}
if (v23 != "") {
	document.writeln('<li class="facet" id="luxembourg"><a onclick="FdrillDown(\'AND country:luxembourg\',\''+FRAGEN+'\',\''+rows+'\');">'+'Luxembourg'+' ('+v23+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="luxembourg"><a>'+'Luxembourg'+' (x)</a></li>');
}
if (v24 != "") {
	document.writeln('<li class="facet" id="malta"><a onclick="FdrillDown(\'AND country:malta\',\''+FRAGEN+'\',\''+rows+'\');">'+'Malta'+' ('+v24+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="malta"><a>'+'Malta'+' (x)</a></li>');
}
if (v25 != "") {
	document.writeln('<li class="facet" id="poland"><a onclick="FdrillDown(\'AND country:poland\',\''+FRAGEN+'\',\''+rows+'\');">'+'Poland'+' ('+v25+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="poland"><a>'+'Poland'+' (x)</a></li>');
}
if (v26 != "") {
	document.writeln('<li class="facet" id="portug"><a onclick="FdrillDown(\'AND country:portug\',\''+FRAGEN+'\',\''+rows+'\');">'+'Portugal'+' ('+v26+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="portug"><a>'+'Portugal'+' (x)</a></li>');
}
if (v27 != "") {
	document.writeln('<li class="facet" id="romania"><a onclick="FdrillDown(\'AND country:romania\',\''+FRAGEN+'\',\''+rows+'\');">'+'Romania'+' ('+v27+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="romania"><a>'+'Romania'+' (x)</a></li>');
}
if (v28 != "") {
	document.writeln('<li class="facet" id="slovakia"><a onclick="FdrillDown(\'AND country:slovakia\',\''+FRAGEN+'\',\''+rows+'\');">'+'Slovakia'+' ('+v28+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="slovakia"><a>'+'Slovakia'+' (x)</a></li>');
}
if (v29 != "") {
	document.writeln('<li class="facet" id="slovenia"><a onclick="FdrillDown(\'AND country:slovenia\',\''+FRAGEN+'\',\''+rows+'\');">'+'Slovenia'+' ('+v29+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="slovenia"><a>'+'Slovenia'+' (x)</a></li>');
}
if (v30 != "") {
	document.writeln('<li class="facet" id="spain"><a onclick="FdrillDown(\'AND country:spain\',\''+FRAGEN+'\',\''+rows+'\');">'+'Spain'+' ('+v30+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="spain"><a>'+'Spain'+' (x)</a></li>');
}
if (v33 != "") {
	document.writeln('<li class="facet" id="sweden"><a onclick="FdrillDown(\'AND country:sweden\',\''+FRAGEN+'\',\''+rows+'\');">'+'Sweden'+' ('+v33+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="sweden"><a>'+'Sweden'+' (x)</a></li>');
}
if (v32 != "") {
	document.writeln('<li class="facet" id="netherland"><a onclick="FdrillDown(\'AND country:netherland\',\''+FRAGEN+'\',\''+rows+'\');">'+'The Netherlands'+' ('+v32+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="netherland"><a>'+'The Netherlands'+' (x)</a></li>');
}
if (v31 != "") {
	document.writeln('<li class="facet" id="turkey"><a onclick="FdrillDown(\'AND country:turkey\',\''+FRAGEN+'\',\''+rows+'\');">'+'Turkey'+' ('+v31+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="turkey"><a>'+'Turkey'+' (x)</a></li>');
}
if (v20 != "") {
	document.writeln('<li class="facet" id="kingdom"><a onclick="FdrillDown(\'AND country:kingdom\',\''+FRAGEN+'\',\''+rows+'\');">'+'United Kingdom'+' ('+v20+')</a></li>');
}	
else {
	document.writeln('<li class="facet" id="kingdom"><a>'+'United Kingdom'+' (x)</a></li>');
}
	document.getElementById(clicked).className = 'facet_open';
}

function fotoFormulier(){
	var destination = '/aletta/bestelfoto_action.jsp';
	var form = document.getElementById('fotoForm');
	var input = form.getElementsByTagName('input');
	var error = document.getElementById('fotoError');
	var output = document.getElementById('outputdiv');
	var a = 0;
	var count = 0;
	var data = '';
	var radiovalue = '';
	var checkboxvalue = '';
	
	// als de form wel of niet mag submitten
	while(a < input.length){
		if(input[a].type == 'radio'){
			
			if(input[a].checked == true){
				count++;
			}
		 }
		 if(input[a].type == 'radio' && input[a].checked == true){
		 	radiovalue = input[a].value;
		 }
		 if(input[a].type == 'checkbox' && input[a].checked == true){
		 	checkboxvalue = input[a].value;
		 }
		a++;
	}
	
	if(count >= 1){
		
		error.innerHTML = '';
		data  = 'titel=' + document.getElementById('title').value;
		data += '&priref=' + document.getElementById('priref').value;
		data += '&gebruik=' + radiovalue;
		data += '&cdrom=' + checkboxvalue;
//		destination = destination + '?' + data;

		SendS(destination,data,'textPopup','');
		updatebestellingcount();
//		output.innerHTML = 'gelukt!';
	}else{
		error.innerHTML = '<b style="color: red;">Er moet minimaal een radio button aangevinkt zijn </b>';
	}
	
}	
var Validator = {

 	 form_name: function(frm){
 	 		this.form = document.forms[frm];
 	 },
        
	 validate: function(field){
			  if (this.form[field].value==""){

				    this.form[field].style.background = '#ffdbdb';
				    this.form[field].style.border = '1px solid #b60202';
				    this.form[field].style.color = '#b60202';
				return true;
			    
			  } else { 
				    this.form[field].style.background = '';
				    this.form[field].style.border = '';
				    this.form[field].style.color = '';	
			    return false;		    
			  }
 	},
 	
 	url: function(field){	
 		return this.form[field].name +'='+ this.form[field].value;
 	}
}

function sendReageren(){
	Validator.form_name('formReageren');
	var data = '';
	var error = false;
	
	if(Validator.validate('naam')){
		error = true;
	}
	if(Validator.validate('from')){
		error = true;
	}
	if(Validator.validate('subject')){
		error = true;
	}
	if(Validator.validate('body')){
		error = true;
	}	
	
	if(error == false){
		data += '' + Validator.url('naam');
		data += '&' + Validator.url('from');
		data += '&' + Validator.url('subject');
		data += '&' + Validator.url('body');
		// hidden fields
		data += '&' + Validator.url('titel');
		data += '&' + Validator.url('id');
		data += '&' + Validator.url('bron');	
		
		SendS('/aletta/mailer', data ,'textPopup','');
	}
}

function sendDoorsturen(){
	Validator.form_name('formDoorsturen');
	var data = '';
	var error = false;
	
	if(Validator.validate('naam')){
		error = true;
	}
	if(Validator.validate('bericht')){
		error = true;
	}
	if(Validator.validate('subject')){
		error = true;
	}
	if(Validator.validate('email')){
		error = true;
	}	
	
	if(error == false){
		data += '' + Validator.url('naam');
		data += '&' + Validator.url('bericht');
		data += '&' + Validator.url('subject');
		data += '&' + Validator.url('email');
		// hidden fields
		data += '&' + Validator.url('titel');
		data += '&' + Validator.url('id');
		data += '&' + Validator.url('bron');	
		data += '&' + Validator.url('from');
		data += '&' + Validator.url('body');
		
		SendS('/aletta/mailer', data ,'textPopup','');
	}
}

function facet_klik(klik) {
		var url = '../../FacetklikinSession?klik='+klik;
//	alert(klik);
		Send(url,'textPopup',false);
	
}
function KeywSearch(keyword,coll) {
//	var key = '"'+keyword+'"';
		var key = keyword;
//	alert('>'+key+'<');
//	document.keywform.res1.value = key;
//	document.keywform.res2.value = "all";
	var form = document.keywform;
	if (coll == 'thes') {
		form = document.headform;
	}
	PutinSession(key,"all","0","10","1",form);
//	document.keywform.submit();
}
function FKeywSearch(keyword,coll) {
//	var key = 'keyw:"'+keyword+'"';
	var key = 'keyword:'+keyword;
	var form = document.keywform;
	PutinSession(key,"all","0","10","1",form);
}
function FCountry(land,coll) {
	var key = 'country:'+'"'+land+'"';
//	alert('>'+key+'<');
	var form = document.keywform;
	PutinSession(key,coll,"0","10","1",form);
}
function show_survey(id){
	SendPopupF('../../zoek/survey.jsp?id='+id,'textPopup');
}
function AutSearch(auteur,shard) {
	var key = 'auteur_s:' + '"'+auteur+'"';
//		var key = auteur;
//		var key = 'auteur_vz:' + auteur;		
//	alert('>'+key+'<');
	if (shard){
	  var sh = shard;
	}
	else {
	  var sh = "all";
	}
	PutinSession(key,sh,"0","10","1",document.keywform);
//	document.keywform.submit();
}
function FAutSearch(auteur,shard) {
	var key = 'authors:' + '"'+auteur+'"';
	if (shard){
	  var sh = shard;
	}
	else {
	  var sh = "all";
	}
	PutinSession(key,sh,"0","10","1",document.keywform);
}
function TitleSearch(titel,shard,coll) {
	//var key = 'titel_s:' + '"'+titel+'"';
	//var key = '"'+titel+'"';
	var form = document.collectieForm;
	if (coll == 'boek') {
		var key = 'titel_s:' + '"'+titel+'"';
		form = document.keywform;
	}
	else if (coll == 'tijdschrift') {
		var key = 'titel_s:' + '"'+titel+'"';
		form = document.keywform;
	}
	else if (coll == 'art') {
		var key = 'titel_s:' + '"'+titel+'"';
		form = document.keywform;
	}
	else if (coll == 'faq') {
		var key = 'titel_s:' + '"'+titel+'"';
		form = document.keywform;
	}
	else if (coll == 'dossier') {
		var key = 'title:' + '"'+titel+'"';
		form = document.keywform;
	}
	else if (coll == 'fragen') {
		var key = 'english_titleSort:'+ '"' + titel+'"';
		form = document.keywform;
	}
	else {
		var key = '"'+titel+'"';
	}
	
	if (shard){
	  var sh = shard;
	}
	else {
	  var sh = "all";
	}
	PutinSession(key,sh,"0","10","1",form);
}
function NameSearch(titel,shard,coll) {
	//var key = 'titel_s:' + '"'+titel+'"';
	//var key = '"'+titel+'"';
	if (coll == 'archief') {
		var key = 'archiefnaam_s:' + '"'+titel+'"';
	}
	else if (coll == 'info') {
		var key = 'naam_s:' + '"'+titel+'"';
	}
	else if (coll == 'org') {
		var key = 'naam_s:' + '"'+titel+'"';
	}
	else if (coll == 'website') {
		var key = 'naam_s:' + '"'+titel+'"';
	}
	else if (coll == 'biografie') {
		var key = 'naam_s:' + '"'+titel+'"';
		form = document.keywform;
	}
	else {
		var key = '"'+titel+'"';
	}
	if (shard){
	  var sh = shard;
	}
	else {
	  var sh = "all";
	}
	PutinSession(key,sh,"0","10","1",document.keywform);
}
function ThesKeyw(titel,shard) {
	var key = 'keyword:' + '"'+titel+'"';
	//var key = '"'+titel+'"';
	if (shard){
	  var sh = shard;
	}
	else {
	  var sh = "all";
	}
	PutinSession(key,sh,"0","10","1",document.keywform);
}
function ThesRubr(rub) {
	//var key = 'titel_s:' + '"'+titel+'"';
	var key = '"'+rub+'"';
	PutinSession(key,"localhost:8080/solr/core1","0","10","1",document.rubrform);
}

function CatSearch(rub,shard) {
	var key = '"'+rub+'"';
	if (shard){
	  var sh = shard;
	}
	else {
	  var sh = "localhost:8080/solr/core1";
	}
	PutinSession(key,sh,"0","10","1",document.keywform);
}
function Setnumresult(res1,res2) {
	start='';
	rows='';
//	document.numresult.res1.value = res1;
//	document.numresult.res2.value = "all";
	var s = document.numresult.rows.selectedIndex;
	rows = document.numresult.rows[s].text;	
	PutinSession(res1,res2,start,rows,"0",document.numresult);
}
function popup_print(div,cnt) {
//	alert(div, cnt);
	var url = '../../zoek/print.jsp'+'?div='+div+'&cnt='+cnt;
//	alert(url);
	window.open(url,'Print','height=400,width=400,scrollbars=yes');
}
function popup_opslaan(q,s,n,langu) {
	var url = '../../zoek/popup_opslaan.jsp'+'?res1='+q+'&sh='+s+'&n='+n+'&langu='+langu;
	SendPopup(url,'textPopup');
//	window.open(url,'Opslaan','height=400,width=400,scrollbars=yes');
}
function popup_mail(div,id,bron,cnt) {
	var url = '../../zoek/popup_mail.jsp?div='+div+'&id='+id+'&bron='+bron+'&cnt='+cnt+'&titel=mail_friend';
	SendPopup(url,'textPopup');
}
function popup_maillist(res1,res2) {
	var url = '../../zoek/popup_mail.jsp?id='+res1+'&bron='+res2+'&titel=res_lijst';
	SendPopup(url,'textPopup');
}
function popup_reactie(titel,id,bron) {
	var url = '../../zoek/popup_reactie.jsp?titel='+titel+'&id='+id+'&bron='+bron;
	SendPopup(url,'textPopup');
}
function popup_pdf (url){
//	alert(url.replace(/file:/gi, "../.."));
	var url1 = url.replace(/file:/gi, "../..")+ '#search="' + antieSpatie(zoek)+ '"';

	window.open(url1);
}
function zoek_web(q) {
	var url = '../../zoek/zoek_web.jsp?q='+q;
	SendPopup(url,'textPopup');
}
function add_hist(qs,sh) {
//	var url1 = '../../Hist_bewaren?qs='+antieSpatie(qs)+'&sh='+sh;
	if (login == 'loggedin'){
	var url1 = encodeUrl('../../zoek/add_history.jsp?qs='+antieSpatie(qs))+'&sh='+sh;
	var url2 = encodeUrl(url1);
	SendO(url2,'hist1');
	}else{
		//alert('Zoekgeschiedenis opslaan werkt alleen als u bent ingelogd.');
		window.top.location.href = '../community/inloggen';
	}
	
}
function del_histitem(nr,z) {
	if (z == 'z') {
	var url = '../../zoek/del_history.jsp?sel=zoek&nr='+nr;
	}else {
	var url = '../../zoek/del_history.jsp?nr='+nr;
	Send(url,'textPopup');
	}
}
function del_selitem(nr,z) {
	if (z == 'z') {
	var url = '../../zoek/del_selectie.jsp?sel=zoek&nr='+nr;
	}else {
	var url = '../../zoek/del_selectie.jsp?nr='+nr;
	}
	SendPopup(url,'textPopup');
}
function show_histitem(q,s) {
//	alert(q);
	PutinSession(q,s,"0","10","1",'true');
	window.top.location.href = '../zoek/head';
}
function get_histnew(q,s,d) {
//	alert(q);
	var url='../../zoek/n_result.jsp?res1='+q+'&res2='+s;
	Send(url,d);
}
function invalidate_session(){
	Send('../../zoek/inv_session.jsp','textPopup');
}
function add_sel(titel,id,bron){ 
//	var url = '../../Selectie_bewaren?titel='+titel+'&id='+id+'&bron='+bron;
	if (login == 'loggedin'){
	var url = '../../zoek/selectie_bewaren.jsp?titel='+titel+'&id='+id+'&bron='+bron;
	SendO(url,'sel');
	}else{
		//alert('Selectie opslaan werkt alleen als u bent ingelogd.');
		window.top.location.href = '../community/inloggen';
	}
}
function show_selitem(q,s) {
	PutinSession(q,"all","0","10","1",'true');
//	window.top.location.href = '../zoek/head';
	window.top.location.href = '../../nl/zoek/head';
}
function updatebestellingcount(){
var c = 0;
	if (document.getElementById('basket')) {
	  c = parseInt(document.getElementById('basket').innerHTML);
	  document.getElementById('basket').innerHTML = c+1;
	}
	c++;
	if (document.getElementById('mijn_bestelling')) {
	  document.getElementById('mijn_bestelling').innerHTML = MY_ORDER[LANGUAGE] + ' ('+c+')';
	}
}
function leen_boek(titel,id,status) {

	var leen = new AjaxContainer();
		leen.destination = '/aletta/leen.jsp';
		leen.responsHolderID = 'textPopup';
		leen.addParam('titel',titel);
		leen.addParam('priref',id);
		leen.addParam('status',status);
		leen.executeONreadyState_1['popup'] = function(){
			popUpP('shadow','popupHolder','block');
			document.getElementById('textPopup').style.height='500px';
			};
		//leen.executeONerror['error'] = function(){};
		leen.executeONreadyState_4['popup'] = function(){
			updatebestellingcount();
			};
		leen.loader = '<img style="margin:250px 0px 0px 250px" src="/aletta/img/ajax-loader.gif"/>';
		leen.noRespons = false;
		leen.activate_detect_error = true;
		leen.regEx = /(toegevoegd)|(good)/i
		leen.createNewHttpObject();
	    leen.send();	    
}	
function fotocopie(titel,id,pag) {
	SendPopup('/aletta/fotocopie.jsp?titel='+titel+'&priref='+id+'&pag='+pag,'textPopup');
//	SendPopup('/aletta/fotocopie_temp.jsp?titel='+titel+'&priref='+id,'textPopup');
	updatebestellingcount();
}
function bestelfoto(titel,id,bron) {
	SendPopup('/aletta/bestelfoto.jsp?titel='+titel+'&priref='+id,'textPopup');
//	SendPopup('/aletta/bestelfoto_temp.jsp?titel='+titel+'&priref='+id,'textPopup');
//	updatebestellingcount();
}
function toon_dossier(id) {
	SendPopup('/aletta/zoek/dossier.jsp?id='+id,'textPopup');
}
function toon_faq(id) {
	SendPopup('../../zoek/faq.jsp?id='+id,'textPopup');
}
function toon_ead(id) {
//alert(id);
	SendPopup('../../zoek/ead_popup.jsp?id='+id,'textPopup');
}
var windowPopUp = {
	windowname : 'Aletta',
	width  : 900,
	height : 700,
	top : 50,
	left : 200,
	win : '',
	execute : function(id){
		url = '../../zoek/ead_popup.jsp?id='+id+'&lang='+LANGUAGE+'&zoek='+antieSpatie(zoek);
		this.win = window.open(url ,this.windowname ,'width='+this.width+',height='+this.height+',top='+this.top+',left='+this.left+',scrollbars=no,toolbar=no,location=no,menubar=no,status=no,resizable=yes');
		this.win.focus();
		//return this.win;
	}
}
function popup_EADpdf(id,par) {
	SendPopup('../../Eadpdf?id='+id);
}
