self.sdisplay = (navigator.appName.indexOf('Netscape')>-1)?'inherit':'inline';
// absolutely horrible check here...
stest = new String( window.open );
if ( stest.indexOf( "SymWinOpen" ) > -1 ) {
	window.open = SymRealWinOpen;
}
if ( navigator.userAgent.indexOf( "Netscape6" ) > -1 ) { self.sdisplay = ""; }	//dirty hack for NS6 which makes me mad
self.sposition = ( navigator.appName.indexOf( "Netscape" ) >-1 ) ? "inherit" : "relative";
currcrc = "";
self.lastspan = ( typeof( self.lastspan ) == "undefined" ) ? "" : self.lastspan;
self.lastthes = ( typeof( self.lastthes ) == "undefined" ) ? "" : self.lastthes;
self.nomodsel = ( typeof( self.nomodsel ) == "undefined" ) ? true : self.nomodsel;
// for this function the following variables need to be declared in the calling template - with example values:
// self.mipath = 'images/'
// imodule<modid> - an image for the module named e.g. 501h.gif, 501l.gif, 501d.gif
// imodule_<modid> - an optional second image for the module named e.g. 501h2.gif, 502l2.gif, 502d2.gif
// cmodule<modid>
// module<modid>
function selm( modid ) {
	var uihandle = document.getElementById('module'+modid);
	// if the module is disabled, do nothing here...
	if ( uihandle && ( uihandle.className.indexOf( self.cinactive ) == -1 ) ) {
		var modulebox = document.getElementById( 'modid' );
		var selectedmodule = new Array( );
		if ( modulebox ) {
			if ( self.nomodsel == true ) {
				for( var i=0; i<modulebox.options.length; i++ ) {
					modulebox.options[i].selected = false;	// reset all modules in case no module is selected at all
				}
			}
			var nselcount = 0;
			for( var i=0; i<modulebox.options.length; i++ ) {
				if ( modulebox.options[i].value == modid ) {
					modulebox.options[i].selected = (modulebox.options[i].selected)?false:true;
				}
				if ( modulebox.options[i].selected ) { nselcount++; }
			}
			self.nomodsel = (nselcount>0)?false:true;
			if ( self.nomodsel == true ) {
				for( var i=0; i<modulebox.options.length; i++ ) {
					if ( modulebox.options[i].value>0 ) {	// thanx opera.
						modulebox.options[i].selected = true;	// set all modules in case no module is selected
					}
				}
			}
			for( var i=0; i<modulebox.options.length; i++ ) {
				if ( modulebox.options[i].selected ) {
					selectedmodule[selectedmodule.length]=modulebox.options[i].value;
				}
			}
		}
		if ( uihandle ) {
			if ( uihandle.className==self.cdeselected ) {
				uihandle.className = self.cselected;
				if ( document.getElementById('imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=self.mipath+modid+'h.gif';
				}
				if ( document.getElementById('imodule_'+modid) ) {	// switches an optional second "module image" image
					document.getElementById('imodule_'+modid).src=self.mipath+modid+'h2.gif';
				}
				if ( document.getElementById('cmodule'+modid) ) {	// switches an optional checkbox
					document.getElementById('cmodule'+modid).checked=true;
				}
				bsel = true;
			}
			else {
				uihandle.className = self.cdeselected;
				if ( document.getElementById( 'imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=self.mipath+modid+'l.gif';
				}
				if ( document.getElementById( 'imodule_'+modid) ) {	// switches an optional second "module image" image
					document.getElementById('imodule_'+modid).src=self.mipath+modid+'l2.gif';
				}
				if ( document.getElementById( 'cmodule'+modid) ) {	// switches an optional checkbox
					document.getElementById('cmodule'+modid).checked=false;
				}
			}
		}
		// get a list of all search field drop downs on the display
		var searchfield = new Array( );
		var allcolumns = document.getElementsByTagName( 'select' );
		for( i=0; i<allcolumns.length; i++ ) {
			if ( allcolumns[i].id.substring( 0, 7 ) == 'column_' ) {
				searchfield[searchfield.length] = allcolumns[i];
			}
		}
		// get a list of all options' values
		var searchcolumns = new Array( );
		for ( var i=0; i<searchfield.length; i++ ) {
			searchcolumns[i] = new Array( );
			for ( var j=0; j<searchfield[i].options.length; j++ ) {	// has to be done like this, 'in' doesn't work. strange though....
				searchcolumns[i][searchcolumns[i].length] = searchfield[i].options[j].value;
			}
		}
		availablecolumn = new Array( );
		availablelabel = new Array( );
		for( i=0; i<selectedmodule.length; i++ ) {
			var columnpool = document.getElementById( 'columnpool_' + selectedmodule[i] );
			if ( columnpool ) {
				for( j = 0; j < columnpool.options.length; j++ ) {
					var hvalue = columnpool.options[j].value;
					availablecolumn[availablecolumn.length] = hvalue.substring( 0, hvalue.indexOf( ':' ) );
					availablelabel[availablecolumn[availablecolumn.length-1]] = columnpool.options[j].text;
				}
			}
		}
		var currfield = '~';	// this aint a possible field name
		availablecolumn.sort( );
		var fcount = 0;
		var colinallselectedmodules = new Array( );
		for( var colix in availablecolumn ) {
			if ( currfield != availablecolumn[colix] ) {
				if ( ( currfield != '~' ) && ( fcount == selectedmodule.length ) ) {	// if the field is there as often as modules are selected it's obviously in all modules
					colinallselectedmodules[colinallselectedmodules.length] = currfield;
					for( var k in searchcolumns ) {
						if ( in_array( currfield, searchcolumns[k] ) == false ) {
							searchfield[k][searchfield[k].length] = new Option( availablelabel[currfield], currfield );
						}
					}
				}
				fcount = 0;
				currfield = availablecolumn[colix];
			}
			fcount++;
		}
		if ( ( currfield != '~' ) && ( fcount == selectedmodule.length ) ) {	// the last one - if the field is there as often as modules are selected it's obviously in all modules
			colinallselectedmodules[colinallselectedmodules.length] = currfield;
			for( k in searchcolumns ) {
				if ( in_array( currfield, searchcolumns[k] ) == false ) {
					searchfield[k][searchfield[k].length] = new Option( availablelabel[currfield], currfield );
				}
			}
		}
		for ( var i=0; i<searchfield.length; i++ ) {
			for( j=searchfield[i].options.length-1; j>=0; j-- ) {
				stest = searchfield[i].options[j].value;
				if ( in_array( stest, colinallselectedmodules ) == false ) {
					searchfield[i].remove( j );
				}
			}
		}
		setactivestate();	// to be sure that all modules get updated properly
		for ( var i=0; i<searchfield.length; i++ ) {
			togglefield(searchfield[i].id.substr(searchfield[i].id.indexOf('_')+1));
		}
	}
}
function togglefield( field ) {
	var searchfield = document.getElementById( 'column_' + field );
	var modulebox = document.getElementById( 'modid' );
	if ( searchfield && modulebox ) {
		var dbfield = searchfield.value; //searchfield.options[searchfield.selectedIndex].value;
		var lookup = 0;
		var fieldtype = 0;
		if ( dbfield != 0 ) {
			var amodid = -1;
			for ( var i = 0; i < modulebox.options.length; i++ ) {
				if ( modulebox.options[i].selected ) {
					amodid = modulebox.options[i].value;	// which module we choose here isn't important, as we have our field list derived from the modules and so the field is in all active modules.
				}
			}
			if ( amodid > -1 ) {	// just to be sure!
				var pool = document.getElementById( 'columnpool_' + amodid );
				if ( pool ) {
					for( i = 0; i < pool.options.length; i++ ) {
						if ( pool.options[i].value.indexOf( dbfield+':' ) > -1 ) {
							lookup = pool.options[i].value;
							lookup = lookup.substring( lookup.indexOf( ':' ) + 1 );
							fieldtype = lookup.substring( lookup.indexOf( ':' ) + 1 );	// after the 2nd ':' we have the field type encoded
							lookup = lookup.substring( 0, lookup.indexOf( ':' ) );
						}
					}
				}
			}
		}
		if ( lookup == -1 ) { lookup = 0; }
		// activate the proper operator element
		if ( ! self.lastoperator ) {
			self.lastoperator = new Array( );
		}
		if ( ! self.lastoperator[field] ) {
			self.lastoperator[field] = 'operator_0_' + field;	// this is the default shown field when we first come in
		}
		if ( self.lastoperator[field] ) {
			hide( document.getElementById( self.lastoperator[field] ) );
		}
		self.lastoperator[field] = 'operator_' + fieldtype + '_' + field;
		show( document.getElementById( 'operator_' + fieldtype + '_' + field ) );
		toggleop( fieldtype, field );
		// activate the proper choice element
		if ( typeof( self.lastchoice ) == "undefined" ) {
			self.lastchoice = new Array( );
			self.lastchoice2 = new Array( );
		}
		if ( typeof( self.lastchoice[field] ) == "undefined" ) {
			self.lastchoice[field] = 'choice_0_' + field;	// this is the default shown field when we first come in
			self.lastchoice2[field] = false;	// this is the default shown 2nd field when we first come in - i.e. none
		}
		if ( self.lastchoice[field] ) {
			hide( document.getElementById( self.lastchoice[field] ) );
			if ( self.lastchoice2[field] ) {
				hide( document.getElementById( self.lastchoice2[field] ) );
			}
		}
		if ( document.getElementById( self.lastchoice[field] + "_c" ) ) {
			hide( document.getElementById( self.lastchoice[field] + "_c" ) );
		}
		if ( ( fieldtype == 7 ) || ( fieldtype == 10 ) ) {
			self.lastchoice[field] = 'choice_0_' + field;
			self.lastchoice2[field] = 'choice_' + lookup + '_' + field;
			if ( document.getElementById( self.lastchoice[field] ) ) {
				show( document.getElementById( self.lastchoice[field] ) );
			}
			if ( document.getElementById( self.lastchoice2[field] ) ) {
				var newclass = document.getElementById( self.lastchoice[field] ).className + " lookup";
				var newwidth = parseInt( parseInt( document.getElementById( self.lastchoice[field] ).style.width ) / 2 );
				document.getElementById( self.lastchoice[field] ).className = newclass;
				document.getElementById( self.lastchoice[field] ).style.width = newwidth + "px";
				show( document.getElementById( self.lastchoice2[field] ) );
				document.getElementById( self.lastchoice2[field] ).className = newclass;
				document.getElementById( self.lastchoice2[field] ).style.width = newwidth + "px";
			} else {
				var oldclass = document.getElementById( self.lastchoice[field] ).className;
				oldclass = oldclass.substr( 0, oldclass.length - " lookup".length );
				var oldwidth = parseInt( document.getElementById( self.lastchoice[field] ).style.width ) * 2;
				document.getElementById( self.lastchoice[field] ).className = oldclass;
				document.getElementById( self.lastchoice[field] ).style.width = oldwidth + "px";
				hide( document.getElementById( self.lastchoice2[field] ) );
				document.getElementById( self.lastchoice2[field] ).className = oldclass;
				document.getElementById( self.lastchoice2[field] ).style.width = oldwidth + "px";
			}
		} else if ( ( fieldtype == 8 ) || ( fieldtype == 9 ) ) {
			self.lastchoice[field] = 'choice_' + lookup + '_' + field;
			self.lastchoice2[field] = false;
			show( document.getElementById( self.lastchoice[field] ) );
			if ( document.getElementById( self.lastchoice[field] + "_c" ) ) {
				show( document.getElementById( self.lastchoice[field] + "_c" ) );
			}
			var oldclass = document.getElementById( self.lastchoice[field] ).className;
		} else {
			self.lastchoice[field] = 'choice_' + lookup + '_' + field;
			self.lastchoice2[field] = false;
			if ( document.getElementById( self.lastchoice[field] ) ) {
				show( document.getElementById( self.lastchoice[field] ) );
				var oldclass = document.getElementById( self.lastchoice[field] ).className;
				if ( oldclass.indexOf( " lookup" ) > -1 ) {
					oldclass = oldclass.substr( 0, oldclass.length - " lookup".length );
					var oldwidth = parseInt( document.getElementById( self.lastchoice[field] ).style.width ) * 2;
					document.getElementById( self.lastchoice[field] ).className = oldclass;
					document.getElementById( self.lastchoice[field] ).style.width = oldwidth + "px";
					if ( document.getElementById( self.lastchoice2[field] ) ) {
						document.getElementById( self.lastchoice2[field] ).className = oldclass;
						document.getElementById( self.lastchoice2[field] ).style.width = oldwidth + "px";
					}
				}
			}
			else {
				alert( 'no special input field available for field ' + self.lastchoice[field] );
				show( document.getElementById( 'choice_0_' + field ) );
			}
		}
		if ( dbfield == "*" ) {
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( self.lastchoice[field] ).style.filter = "alpha(opacity=30)";
			} else {
				document.getElementById( self.lastchoice[field] ).style.opacity = "0.3";
			}
		} else {
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( self.lastchoice[field] ).style.filter = "alpha(opacity=100)";
			} else {
				document.getElementById( self.lastchoice[field] ).style.opacity = "1.0";
			}
		}
		// allow for a custom display update fn in the respecting template - it must be called modifydisplay(field)
		if ( window.modifydisplay ) {
			modifydisplay(field);
		}
	}
}
function toggleop( vartype, field ) {
	if ( ( document.getElementById( "operator_" + vartype + "_" + field ).value == 5 ) || ( document.getElementById( "operator_" + vartype + "_" + field ).value == 6 ) ) {
		if ( ( typeof( self.lastchoice ) != "undefined" ) && ( typeof( self.lastchoice[field] ) != "undefined" ) ) {
			document.getElementById( self.lastchoice[field] ).disabled = true;
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( self.lastchoice[field] ).style.filter = "alpha(opacity=30)";
			} else {
				document.getElementById( self.lastchoice[field] ).style.opacity = "0.3";
			}
		}
	} else {
		if ( ( typeof( self.lastchoice ) != "undefined" ) && ( typeof( self.lastchoice[field] ) != "undefined" ) ) {
			document.getElementById( self.lastchoice[field] ).disabled = false;
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( self.lastchoice[field] ).style.filter = "alpha(opacity=100)";
			} else {
				document.getElementById( self.lastchoice[field] ).style.opacity = "1.0";
			}
		}
	}
}
function setactivestate( ) {
	var allselects = document.getElementsByTagName( 'select' );
	var testcols = new Array( );
	var matchcolix = new Array( );
	var matchcols = new Array( );	// here we will get a list of module IDs for which the column is available
	// first get all the selected columns
	for( var i = 0; i < allselects.length; i++ ) {
		if ( allselects[i].id.substring( 0, 7 ) == 'column_' ) {
			if ( ( allselects[i].value != '' ) && ( allselects[i].value != '0' ) ) {
				testcols[testcols.length] = allselects[i].value.toLowerCase();
			}
		}
	}
	// now check for each module if it has the very same field in its column pool
	for( var i = 0; i < allselects.length; i++ ) {
		if ( allselects[i].id.substring( 0, 11 ) == 'columnpool_' ) {
			var columnpool = allselects[i];
			var modid = columnpool.id.substring( columnpool.id.indexOf( '_' ) + 1 );
			matchcols[modid] = 0;
			for( var j = 0; j < columnpool.options.length; j++ ) {
				colinmodule = columnpool.options[j].value;
				colinmodule = colinmodule.substr( 0, colinmodule.indexOf( ':' ) );
				for ( var k in testcols ) {
					if ( colinmodule.toLowerCase() == testcols[k] ) {
						matchcols[modid]++;
					}
				}
			}
		}
	}
	for( modid in matchcols ) {
		var handle = document.getElementById('module'+modid);
		if ( handle ) {
			if ( ( handle.className==self.cinactive ) && ( matchcols[modid] == testcols.length ) ) {
				handle.className = self.cdeselected;
				if ( document.getElementById('imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=self.mipath+modid+'l.gif';
				}
				if ( document.getElementById('imodule_'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule_'+modid).src=self.mipath+modid+'l2.gif';
				}
				if ( document.getElementById('cmodule'+modid) ) {	// switches an optional checkbox
					document.getElementById('cmodule'+modid).checked=true;
					document.getElementById('cmodule'+modid).disabled=false;
				}
			}
			else if ( ( handle.className==self.cdeselected ) && ( matchcols[modid] < testcols.length ) ) {
				handle.className = self.cinactive;
				if ( document.getElementById('imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=self.mipath+modid+'d.gif';
				}
				if ( document.getElementById('imodule_'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule_'+modid).src=self.mipath+modid+'d2.gif';
				}
				if ( document.getElementById('cmodule'+modid) ) {	// switches an optional checkbox
					document.getElementById('cmodule'+modid).checked=false;
					document.getElementById('cmodule'+modid).disabled=true;
				}
			}
		}
	}
}
function show( elm ) {
	if ( elm ) {
		elm.style.position = "relative";
		elm.style.visibility = "visible";
	}
}
function hide( elm ) {
	if ( elm ) {
		elm.style.position = "absolute";
		elm.style.visibility = "hidden";
	}
}
function in_array(needle,haystack) {
	var breturn = false;
	for( var i in haystack ) {
		if ( needle == haystack[i] ) { breturn = true; }
	}
	return breturn;
}
function popit(name,url,params,wid,hgt,lt,tp) {
	// available params: resizable,scrollbars,location,menubar,status,toolbar,fullscreen
	if (!params) { params='resizable'; }
	if (wid>-1) { params+=',width='+wid; }
	if (hgt>-1) { params+=',height='+hgt; }
	if (lt>-1) { params+=',left='+lt; }
	if (tp>-1) { params+=',top='+tp; }
	self.window[name] = open(url,name,params);
	if ((wid>-1)&&(hgt>-1)) {
		if (self.window[name] && !self.window[name].closed) { self.window[name].resizeTo(wid,hgt); }
	}
	if (self.window[name] && !self.window[name].closed) { self.window[name].focus(); }
}
function winrefresh(name) {
	if (self.window[name] && !self.window[name].closed) { self.window[name].location.reload(); }
}
function winclose(name) {
	if (self.window[name] && !self.window[name].closed) { self.window[name].close(); }
	else {
		self.window[name] = open('index.html',name,'height=1,width=1,left=3000,top=3000');	// can't use about:blank here cos opera complains about security issues
		if (self.window[name] && !self.window[name].closed) { self.window[name].close(); }
	}
}
function flipspan(spanname) {	// cant use the visibility/ position trick here as IE "forgets" to display all the images...
	if ((self.lastspan!='')&&document.getElementById(self.lastspan)) {
		document.getElementById(self.lastspan).style.display='none';
	}
	if (document.getElementById(spanname)) {
		document.getElementById(spanname).style.display=self.sdisplay;
		self.lastspan = spanname;
	}
}
function foldercontent(folderid) {
	if (window.opener) {
		window.opener.location='webmill.php?s_id=10019&s_od=1&lin=folder&dstart=0&folderid='+folderid;
	}
	else {
		window.location='webmill.php?s_id=10019&s_od=1&lin=folder&dstart=0&folderid='+folderid;
	}
}
function bookmark(itemid,via_chapter,optname) {
	var dummy = new Image();
	dummy.src='webmill.php?id='+via_chapter+'&lid='+itemid+((optname)?'&lidname='+optname:'');	//10074 "executes stuff in the background"
	if(document.getElementById('book'+itemid)) {
		document.getElementById('book'+itemid).src='images/arbeitsmappe_x.gif'; // here no imgpath is used
	}
	if (window['wfolder']) {window['wfolder'].location.reload();}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// this parses entries into a search field for fulltext search
////////////////////////////////////////////////////////////////////////////////////////////////////
function parseftx(term) {
	var reCTest1 = /\sand\s/gi;
	var reCTest2 = /\sor\s/gi;
	var reCTest3 = /\snot\s/gi;
	// avoid crazed searches....
	if (term) {
		term=term.replace(reCTest1,' ').replace(reCTest2,' ').replace(reCTest3,' ');
	}
	var satest1=term.split('*');
	self.fterror='';
	if (satest1.length>3) {self.fterror='satest1.length>3';}
	var satest2=term.split('?');
	if ((satest2.length>1)&&(satest1.length>1)) {self.fterror+=((self.fterror.length>0)?'\n':'')+'satest2.length>1';}
	if ((satest1.length>3)||((satest1.length>1)&&(satest2.length>1))) {term='';}
	var sasplit=term.split(' ');
	var saand=new Array( );
	var saor=new Array( );
	var sanot=new Array( );
	var sreturn='';
	var i = 0;
	var stab = String.fromCharCode(20);
	while(i<sasplit.length) {
		if (sasplit[i]) {
			switch (sasplit[i].charCodeAt(0)) {
				case 32: {	//do nothing
					break;
				}
				case 43: {	//+
					sasplit[i] = sasplit[i].substr(1,sasplit[i].length-1); // cut off the +
					if (sasplit[i].charCodeAt(0)==34) {
						saand[saand.length]='';
						while ((i<sasplit.length)&&(sasplit[i].charCodeAt(sasplit[i].length-1)!= 34)) {
							saand[saand.length-1]+=stab+sasplit[i];
							i++;
						}
						if (sasplit[i]) { 
							if (sasplit[i].charCodeAt(sasplit[i].length-1)==34) {saand[saand.length-1]+=stab+sasplit[i].substr(0,sasplit[i].length-1);}
							else {saand[saand.length-1]+=stab+sasplit[i];}
						}
						saand[saand.length-1]=saand[saand.length-1].substr(2,saand[saand.length-1].length-2);
					}
					else {
						saand[saand.length]=sasplit[i];
						//saand[saand.length-1]=saand[saand.length-1].replace( re,'%');
						//saand[saand.length-1]=saand[saand.length-1].replace( re2,'_');
					}
					break;
				}
				case 45: {	//-
					sasplit[i]=sasplit[i].substr(1,sasplit[i].length-1); // cut off the -
					if (sasplit[i].charCodeAt(0)==34) {
						sanot[sanot.length]='';
						while ((i<sasplit.length)&&(sasplit[i].charCodeAt(sasplit[i].length-1)!= 34)) {
							sanot[sanot.length-1]+=stab+sasplit[i];
							i++;
						}
						if (sasplit[i]) { 
							if (sasplit[i].charCodeAt(sasplit[i].length-1)==34) {sanot[sanot.length-1]+=stab+sasplit[i].substr(0,sasplit[i].length-1)}
							else {sanot[sanot.length-1]+=stab+sasplit[i]}
						}
						sanot[sanot.length-1]=sanot[sanot.length-1].substr(2,sanot[sanot.length-1].length-2);
					}
					else {
						sanot[sanot.length]=sasplit[i];
						//sanot[sanot.length-1]=sanot[sanot.length-1].replace(re,'%');
						//sanot[sanot.length-1]=sanot[sanot.length-1].replace(re2,'_');
					}
					break;
				}
				default: {	// other char we'll search for
					if (sasplit[i].charCodeAt(0)==34) {	//"
						saor[saor.length]='';
						while ((i<sasplit.length)&&(sasplit[i].charCodeAt(sasplit[i].length-1)!=34)) {
							saor[saor.length-1]+=stab+sasplit[i];
							i++;
						}
						if (sasplit[i]) { 
							if (sasplit[i].charCodeAt(sasplit[i].length-1)==34) {saor[saor.length-1]+=stab+sasplit[i].substr(0,sasplit[i].length-1);}
							else {saor[saor.length-1]+=stab+sasplit[i];}
						}
						saor[saor.length-1]=saor[saor.length-1].substr(2,saor[saor.length-1].length-2);
					}
					else {
						saor[saor.length]=sasplit[i];
						//saor[saor.length-1]=saor[saor.length-1].replace(re,'%');
						//saor[saor.length-1]=saor[saor.length-1].replace(re2,'_');
					}
					break;
				}
			}
		}
		i++;
	}
	for (i=0;i<saand.length;i++) {
		(sreturn=='')?sreturn=saand[i]:sreturn+=String.fromCharCode(183)+saand[i];
	}
	for(i=0;i<saor.length;i++) {
		(sreturn=='')?sreturn=saor[i]:sreturn+=String.fromCharCode(247)+saor[i];
	}
	for(i=0;i<sanot.length;i++) {
		(sreturn=='')?sreturn='':sreturn+=String.fromCharCode(172)+sanot[i]; //if sreturn returns '', we have no valid FT search
	}
	if (saor.length>5) {sreturn=''; /*self.fterror = text_t;*/ }
	return sreturn;
}
function openkey(key) {
	var href=document.getElementById( "key_" + key + "_c" );
	if ( href ) {
		if ( href.style.display == "none" ) {
			href.style.display = "block";
			if ( document.getElementById( "img" + key ) ) {
				document.getElementById( "img" + key ).src = document.getElementById( "img" + key ).src.replace( /plus/, "minus" );
			}
			if ( document.getElementById( "entryimg" + key ) ) {
				document.getElementById( "entryimg" + key ).src = document.getElementById( "entryimg" + key ).src.replace( /closed/, "open" );
			}
			if ( typeof( self.open_keys ) != "undefined" ) {
				self.open_keys[key] = key;
			}
		}
		else {
			href.style.display = "none";
			if ( document.getElementById( "img" + key ) ) {
				document.getElementById( "img" + key ).src = document.getElementById( "img" + key ).src.replace( /minus/, "plus" );
			}
			if ( document.getElementById( "entryimg" + key ) ) {
				document.getElementById( "entryimg" + key ).src = document.getElementById( "entryimg" + key ).src.replace( /open/, "closed" );
			}
			if ( typeof( self.open_keys ) != "undefined" ) {
				delete self.open_keys[key];
			}
		}
	}
}
function addkey(key,keyname,children) {
	var keybox = document.getElementById('key');
	var keycbox = document.getElementById('keyc');
	var binbox = false;
	if (keybox) {
		for ( var i = 0; i < keybox.options.length; i++ ) {
			if ( keybox.options[i].value == key ) {
				binbox = true;
			}
		}
		if ( ! binbox ) {
			if ( keybox.options.length < 11 ) {
				keybox[keybox.length] = new Option( keyname, key );
				if ( keycbox ) {
					keycbox[keycbox.length] = new Option( (children)?'+':'o', key );
				}
			}
			else {
				alert( 'maximum number of search keys is 10' );
			}
		}
	}
}
function removekey(boxname) {
	if (boxname) {
		var keybox = document.getElementById(boxname);
		var keycbox = document.getElementById(boxname+'c');
	} else {
		var keybox = document.getElementById('key');
		var keycbox = document.getElementById('keyc');
	}
	if (keybox) {
		for ( var i = 0; i < keybox.options.length; i++ ) {
			if ( ( keybox.options[i].selected ) && ( keybox.options[i].value > 0 ) ) {
				keybox.remove( i );
				if (keycbox) { keycbox.remove( i ); }
			}
		}
	}
}
function showthes( thes ) {
	if ( document.getElementById( "thes" + thes ) ) {
		document.getElementById( "thes" + thes ).style.display = self.sdisplay;
	}
	if ( typeof( self.lastthes != "udefined" ) && ( self.lastthes != "" ) && ( self.lastthes != "thes" + thes ) && ( document.getElementById( self.lastthes ) ) ) {
		document.getElementById( self.lastthes ).style.display = "none";
	}
	self.lastthes = "thes" + thes;
}
function togglesearch(name,via_chapter) {
	handle = document.getElementById( name );
	if ( handle ) {
		if ( ( via_chapter==-1 ) && ( eval( 'self.s_toggle'+name ) ) ) {
			if ( eval('self.s_toggle'+name) == 'none' ) {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = 'none';
					document.getElementById('sshow').style.display = self.sdisplay;
				}
				handle.style.display = 'none';
			}
			else {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = self.sdisplay;
					document.getElementById('sshow').style.display = 'none';
				}
				handle.style.display = self.sdisplay;
			}
		}
		else {
			if ( handle.style.display.indexOf('none') == -1 ) {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = 'none';
					document.getElementById('sshow').style.display = self.sdisplay;
				}
				handle.style.display = 'none';
			}
			else {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = self.sdisplay;
					document.getElementById('sshow').style.display = 'none';
				}
				handle.style.display = self.sdisplay;
			}
			if (via_chapter>-1){
				// params of type s_toggle get set automatically as parameters in the output by the server - if available
				url='webmill.php?id='+via_chapter+'&s_toggle'+name+'='+handle.style.display;
				var dummy=new Image();
				dummy.src=url;
			}
		}
	}
}
function changecontent(elm,content) {
	if(document.getElementById(elm)){
		document.getElementById(elm).firstChild.nodeValue=content;
	}
}
// this removes options that are mutually exclusive
function toggleinput( fromlist ) {
	justselected=document.getElementById('xtrack'+fromlist).value;
	check=new Array();
	for (var i=0;i<avoid.length;i++) {
		if (avoid[i].indexOf(','+justselected+',')>-1) {
			check[check.length]=avoid[i];
		}
	}
	allselects=document.getElementsByTagName('select');
	trackid=fromlist.substr(0,fromlist.indexOf('_'));
	for (var i=0;i<allselects.length;i++) {
		if ((allselects[i].id.indexOf('xtrack'+trackid+'_')==0)) {
			if ( ( typeof( saveoptions ) != "undefined" ) && saveoptions[allselects[i].id] ) {
				saveoptions[allselects[i].id]=new Array();
				for (var j=0;j<allselects[i].options.length;j++) {
					saveoptions[allselects[i].id][j]=allselects[i].options[j].value+'||'+allselects[i].options[j].text;
				}
			}
			if (allselects[i].id!='xtrack'+fromlist) {
				prevsel=allselects[i].value;
				allselects[i].options.length=0;
				for (var j=0;j<saveoptions[allselects[i].id].length;j++) {
					saLcl=saveoptions[allselects[i].id][j].split('||');
					var append=true;
					for (var k=0;k<check.length;k++) {
						if (check[k].indexOf(','+saLcl[0]+',')>-1) { append=false; }
					}
					if (append==true) {
						allselects[i].options[allselects[i].options.length]=new Option( saLcl[1],saLcl[0] );
						if (saLcl[0]==prevsel) {	// reset what was set before - if possible
							allselects[i].options[allselects[i].options.length-1].selected=true;
						}
					}
				}
			}
		}
	}
}
function selectme( handle, newval ) {	// those browsers suck so bad...
	bhide = false;
	if ( handle ) {
		for ( var i = 0; i < handle.options.length; i++ ) {
			if ( handle.options[i].value == newval ) {
				if ( handle.style.visibility == "hidden" ) {
					bhide = true;
				}
				if ( bhide ) {
					handle.style.visibility = "visible";
				}
				if ( navigator.userAgent.toLowerCase( ).indexOf( "opera" ) > -1 ) {
					handle.options[i].selected = false;	// excuse me this is opera. otherwise it just won't work.
					handle.focus( );
					handle.blur( );
					handle.options[i].selected = true;
					handle.focus( );
					handle.blur( );
				} else {
					handle.options[i].selected = true;
				}
				if ( bhide ) {
					handle.style.visibility = "hidden";
				}
			}
		}
	}
}
function calcdate(which) {
	var mydate=document.getElementById('display_'+which).value;
	var test = new Number( mydate );
	document.getElementById(which).value='';
	if ( ( test == mydate ) && ( mydate.length < 5 ) ) {
		var year = mydate;
		bproceed = true; // suppose it's only a year
	}
	else {
		var re = /^(\d{1,2})[.-](\d{1,2})[.-](\d{4})$/g; // make all '.' or '-' s to '/'s
		var re2 = /(\w+)\s+\S*/gi; // truncate the bloody time!
		var re3 = /^(\d){2}\/{1}(\d){2}\/{1}(\d){4}$/g;
		var mydate2 = mydate.replace( re, "$2/$1/$3" ); // if data is "good", generates a valid JS date
		if ( mydate != mydate2 ) {
			var dtDate = new Date( mydate2 );
			test = dtDate.toLocaleString().replace( re2, "$1" );
			var test2 = test.replace( re3, "$2/$1/$3" );	//last check if the Date isn't NaN or so.....
			if ( test == test2 ) {
				bproceed = true;
				var datecomps = mydate2.split( '/' );
				var year = datecomps[2];
				var month = datecomps[0];
				var day = datecomps[1];
				this.sErrorStatus = '';
			}
			else {
				bproceed = false;
			}
		}
		else {
			bproceed = false;
		}
	}
	if ( bproceed ) {
		month = (month)?month:0;
		day = (day)?day:0;
		finaldate = ((new Number( year )*13)+new Number( month ) )*32+new Number(day);
		datestring = (((month>0)&&(day>0))?day+'. ':'') + ((month>0)?month+'. ':'') + year;
		if ( finaldate>0 ) {
			document.getElementById(which).value=finaldate;
		}
	} else {
		alert('Please enter a date in the format dd.mm.yyyy');
	}
}
function gtod(ndate,format,del1,del2) {
	sreturn = '';
	var nday = ndate % 32;
	var ntemp = (ndate-nday) / 32;
	var nmonth = ntemp % 13;
	var nyear = (ntemp-nmonth) / 13;
	if ( nyear ) {
		if ( format=='ymd' ) {
			sreturn = nyear+((nmonth>0)?del1+nmonth+((nday>0)?del2+nday:""):"");
		} else if ( format=='mdy' ) {
			sreturn = ((nmonth>0)?nmonth+del1+((nday>0)?nday+del2:""):"")+nyear;
		} else if ( format=='dmy' ) {
			sreturn = ((nday>0)?nday+del1+((nmonth>0)?nmonth+del2:""):"")+nyear;
		}
	}
	return sreturn;
}
function checkcookie() {
testValue=Math.floor(1000*Math.random());
SetCookie('AreCookiesEnabled',testValue);
if (testValue==ReadCookie('AreCookiesEnabled')) 
  return true;
else return false;
}
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
var xWin=null;
self.canpop=0;
var popwrite=false;
function poptest() {
	window.focus();
	popit('xWin','popuptest.html','resizable',1,1,5000,5000);
	setTimeout("test_xWin()",2000);
}
function checkpopups(){
// this is ---- again...
	var test = new String( navigator.appName );
	if (test.indexOf('xplorer')>0) {
		document.body.onload=poptest;
	} else {
		document.body.onload=poptest();
	}
}
function test_xWin(){
	xWindow = 2;
	if ((xWin==null)||(typeof(xWin)=="undefined")||(!popwrite)) {
		xWindow=1;
	}
	if (xWin) {
		xWin.close();
	}
	if ((xWindow<2)&&document.getElementById('nopops')) {
		document.getElementById('nopops').style.display=self.sdisplay;
	}
}
function selectall(which) {
	var listbox = document.getElementById(which);
	if ( listbox ) {
		for( var i = 0; i < listbox.options.length; i++ ) {
			listbox.options[i].selected = true;
		}
	}
}
function omail( addr, host ) {
	url = 'mailto:' + addr + '@' + host;
	self.mwin = null;
	self.mwin = open( url,'mail','width=10,height=10');
	if (self.mwin) {
		setTimeout( "self.mwin.close( )", 2000 );
	}
}
// rwh 070628 
function doAt() {
	document.write( "&#64;" );
}
// rwh 070628 
function cursor_wait() {
  document.body.style.cursor = 'wait';
}

function cursor_clear() {
  document.body.style.cursor = 'default';
}
function addelement( container, newelmtype, newelmid ) {
	if ( container ) {
		var newelement = document.createElement( newelmtype );
		container.appendChild( newelement );
		newelement.setAttribute( 'id', newelmid );
	}
}

function addtexttoelement( container, thetext ) {
	if ( container ) {
		container.appendChild( document.createTextNode( thetext ) );
	}
}

function finddocument( elm ) {
	while( ( elm.nodeType != 9 ) ) {
		elm = elm.parentNode;
	}
	var hreturn = elm;
	return hreturn;
}

function settext( container, thetext ) {
	if ( container ) {
		if ( ( container.firstChild ) && ( container.firstChild.nodeType == 3 ) ) {	// text node?
			container.firstChild.nodeValue = thetext;
		} else {
			container.appendChild( finddocument( container ).createTextNode( thetext ) );
		}
	}
}
function readtext( container ) {
	var sreturn = "";
	if ( container ) {
		if ( ( container.firstChild ) && ( container.firstChild.nodeType == 3 ) ) {	// text node?
			sreturn = container.firstChild.nodeValue;
		}
	}
	return sreturn;
}

function setAttribute( container, attrname, atrval ) {
	if ( container ) {
		container.setAttribute( attrname, attrval );
	}
}

function removeelement( container, delemid ) {
	if ( container ) {
		container.removeChild( document.getElementById( delelmid ) );
	}
}
function createpin() {
	var cmap = new Array( '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' );
	var pin = "";
	for ( var i = 0; i < 8; i++ ) {
		 pin += cmap[Math.round( 62 * Math.random( ) )];
	}
	return pin;
}
function getscrollxy() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

// sleep fn
Date.ONE_SECOND = 1000
Date.ONE_MINUTE = Date.ONE_SECOND * 60
Date.ONE_HOUR = Date.ONE_MINUTE * 60
Date.ONE_DAY = Date.ONE_HOUR * 24

function sleep ( m ) {
	var then = new Date( new Date( ).getTime( ) + m );
	while ( new Date( ) < then ) { }
}

// another new "feature", this time on the ff "front"
function removeffxx( handle ) {
	if ( navigator.userAgent.toLowerCase( ).indexOf( "firefox" ) > -1 ) {
		if ( handle.options.length == 0 ) {
			handle.options[0] = new Option( 1, 1 );
			handle.blur( );
			handle.focus( );
			handle.remove( 0 );
		}
	}
}

