top.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 ) { top.sdisplay = ""; }	//dirty hack for NS6 which makes me mad
top.sposition = ( navigator.appName.indexOf( "Netscape" ) >-1 ) ? "inherit" : "relative";
currcrc = "";
top.lastspan = ( typeof( top.lastspan ) == "undefined" ) ? "" : top.lastspan;
top.lastthes = ( typeof( top.lastthes ) == "undefined" ) ? "" : top.lastthes;
top.nomodsel = ( typeof( top.nomodsel ) == "undefined" ) ? true : top.nomodsel;
// MG091102 a small extension to the Array object to fix the impossibility to sort associative arrays
// MG091103 implementing this via prototype f*cks up the array in that you can't do a "for xx in yy" anymore, because
// the function becomes part of the array index, unlike the other built-in functions do. UN-BE-LIE-VA-BLE!
function asort( arrp ) {
	var temparr = new Array( );
	var hareturn = new Array( );
	for ( var i in arrp ) {
		temparr.push( [i, arrp[i]] );
	}
	temparr.sort( function () { return arguments[0][1] < arguments[1][1] } );
	for (	var i = temparr.length-1; i >= 0; i-- ) {
		hareturn[temparr[i][0]] = temparr[i][1];
	}
	return hareturn;
}
// rwh 090907 in case of a browser that does not support the XMLHttpRequest object, create appropriate ActiveXObject instead
if (typeof XMLHttpRequest  === "undefined") {
  XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
      catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
      catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); }
      catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(e) {}
    throw new Error("This browser does not support XMLHttpRequest.");
  };
}
// rwh 090907 
// for this function the following variables need to be declared in the calling template - with example values:
// top.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( top.cinactive ) == -1 ) ) {
		var modulebox = document.getElementById( 'modid' );
		var selectedmodule = new Array( );
		if ( modulebox ) {
			if ( top.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++; }
			}
			top.nomodsel = (nselcount>0)?false:true;
			if ( top.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.indexOf( top.cdeselected ) > -1 ) {
				uihandle.className = uihandle.className.replace( top.cdeselected, top.cselected );
				if ( document.getElementById('imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=top.mipath+modid+'h.gif';
				}
				if ( document.getElementById('imodule_'+modid) ) {	// switches an optional second "module image" image
					document.getElementById('imodule_'+modid).src=top.mipath+modid+'h2.gif';
				}
				if ( document.getElementById('cmodule'+modid) ) {	// switches an optional checkbox
					document.getElementById('cmodule'+modid).checked=true;
				}
				bsel = true;
			}
			else {
				uihandle.className = uihandle.className.replace( top.cselected, top.cdeselected );
				if ( document.getElementById( 'imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=top.mipath+modid+'l.gif';
				}
				if ( document.getElementById( 'imodule_'+modid) ) {	// switches an optional second "module image" image
					document.getElementById('imodule_'+modid).src=top.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 ( ! top.lastoperator ) {
			top.lastoperator = new Array( );
		}
		if ( ! top.lastoperator[field] ) {
			top.lastoperator[field] = 'operator_0_' + field;	// this is the default shown field when we first come in
		}
		if ( top.lastoperator[field] ) {
			hide( document.getElementById( top.lastoperator[field] ) );
		}
		top.lastoperator[field] = 'operator_' + fieldtype + '_' + field;
		show( document.getElementById( 'operator_' + fieldtype + '_' + field ) );
		toggleop( fieldtype, field );
		// activate the proper choice element
		if ( typeof( top.lastchoice ) == "undefined" ) {
			top.lastchoice = new Array( );
			top.lastchoice2 = new Array( );
		}
		if ( typeof( top.lastchoice[field] ) == "undefined" ) {
			top.lastchoice[field] = 'choice_0_' + field;	// this is the default shown field when we first come in
			top.lastchoice2[field] = false;	// this is the default shown 2nd field when we first come in - i.e. none
		}
		if ( top.lastchoice[field] ) {
			hide( document.getElementById( top.lastchoice[field] ) );
			if ( top.lastchoice2[field] ) {
				hide( document.getElementById( top.lastchoice2[field] ) );
			}
		}
		if ( document.getElementById( top.lastchoice[field] + "_c" ) ) {
			hide( document.getElementById( top.lastchoice[field] + "_c" ) );
		}
		if ( ( fieldtype == 7 ) || ( fieldtype == 10 ) ) {
			top.lastchoice[field] = 'choice_0_' + field;
			top.lastchoice2[field] = 'choice_' + lookup + '_' + field;
			if ( document.getElementById( top.lastchoice[field] ) ) {
				show( document.getElementById( top.lastchoice[field] ) );
			}
			if ( document.getElementById( top.lastchoice2[field] ) ) {
				var newclass = document.getElementById( top.lastchoice[field] ).className + " lookup";
				var newwidth = parseInt( parseInt( document.getElementById( top.lastchoice[field] ).style.width ) / 2 );
				document.getElementById( top.lastchoice[field] ).className = newclass;
				document.getElementById( top.lastchoice[field] ).style.width = newwidth + "px";
				show( document.getElementById( top.lastchoice2[field] ) );
				document.getElementById( top.lastchoice2[field] ).className = newclass;
				document.getElementById( top.lastchoice2[field] ).style.width = newwidth + "px";
			} else {
				var oldclass = document.getElementById( top.lastchoice[field] ).className;
				oldclass = oldclass.substr( 0, oldclass.length - " lookup".length );
				var oldwidth = parseInt( document.getElementById( top.lastchoice[field] ).style.width ) * 2;
				document.getElementById( top.lastchoice[field] ).className = oldclass;
				document.getElementById( top.lastchoice[field] ).style.width = oldwidth + "px";
				hide( document.getElementById( top.lastchoice2[field] ) );
				document.getElementById( top.lastchoice2[field] ).className = oldclass;
				document.getElementById( top.lastchoice2[field] ).style.width = oldwidth + "px";
			}
		} else if ( ( fieldtype == 8 ) || ( fieldtype == 9 ) ) {
			top.lastchoice[field] = 'choice_' + lookup + '_' + field;
			top.lastchoice2[field] = false;
			show( document.getElementById( top.lastchoice[field] ) );
			if ( document.getElementById( top.lastchoice[field] + "_c" ) ) {
				show( document.getElementById( top.lastchoice[field] + "_c" ) );
			}
			var oldclass = document.getElementById( top.lastchoice[field] ).className;
		} else {
			top.lastchoice[field] = 'choice_' + lookup + '_' + field;
			top.lastchoice2[field] = false;
			if ( document.getElementById( top.lastchoice[field] ) ) {
				show( document.getElementById( top.lastchoice[field] ) );
				var oldclass = document.getElementById( top.lastchoice[field] ).className;
				if ( oldclass.indexOf( " lookup" ) > -1 ) {
					oldclass = oldclass.substr( 0, oldclass.length - " lookup".length );
					var oldwidth = parseInt( document.getElementById( top.lastchoice[field] ).style.width ) * 2;
					document.getElementById( top.lastchoice[field] ).className = oldclass;
					document.getElementById( top.lastchoice[field] ).style.width = oldwidth + "px";
					if ( document.getElementById( top.lastchoice2[field] ) ) {
						document.getElementById( top.lastchoice2[field] ).className = oldclass;
						document.getElementById( top.lastchoice2[field] ).style.width = oldwidth + "px";
					}
				}
			}
			else {
				alert( 'no special input field available for field ' + top.lastchoice[field] );
				show( document.getElementById( 'choice_0_' + field ) );
			}
		}
		if ( dbfield == "*" ) {
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( top.lastchoice[field] ).style.filter = "alpha(opacity=30)";
			} else {
				document.getElementById( top.lastchoice[field] ).style.opacity = "0.3";
			}
		} else {
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( top.lastchoice[field] ).style.filter = "alpha(opacity=100)";
			} else {
				document.getElementById( top.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( top.lastchoice ) != "undefined" ) && ( typeof( top.lastchoice[field] ) != "undefined" ) ) {
			document.getElementById( top.lastchoice[field] ).disabled = true;
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( top.lastchoice[field] ).style.filter = "alpha(opacity=30)";
			} else {
				document.getElementById( top.lastchoice[field] ).style.opacity = "0.3";
			}
		}
	} else {
		if ( ( typeof( top.lastchoice ) != "undefined" ) && ( typeof( top.lastchoice[field] ) != "undefined" ) ) {
			document.getElementById( top.lastchoice[field] ).disabled = false;
			if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) || ( navigator.userAgent.indexOf( ".NET" ) > -1 ) ) {
				document.getElementById( top.lastchoice[field] ).style.filter = "alpha(opacity=100)";
			} else {
				document.getElementById( top.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==top.cinactive ) && ( matchcols[modid] == testcols.length ) ) {
				handle.className = top.cdeselected;
				if ( document.getElementById('imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=top.mipath+modid+'l.gif';
				}
				if ( document.getElementById('imodule_'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule_'+modid).src=top.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==top.cdeselected ) && ( matchcols[modid] < testcols.length ) ) {
				handle.className = top.cinactive;
				if ( document.getElementById('imodule'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule'+modid).src=top.mipath+modid+'d.gif';
				}
				if ( document.getElementById('imodule_'+modid) ) {	// switches the "module image" images
					document.getElementById('imodule_'+modid).src=top.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=' + ( parseInt( hgt ) + ((navigator.userAgent.toLowerCase().indexOf("firefox/3"))?parseInt(30):parseInt(0)) ); }
	if (lt>-1) { params+=',left='+lt; }
	if (tp>-1) { params+=',top='+tp; }
	top.window[name] = open(url,name,params);
	if ((wid>-1)&&(hgt>-1)) {
		if (top.window[name] && !top.window[name].closed) { 
			try {
				top.window[name].resizeTo( wid, hgt ); 
			}
			catch( err ) { }
		}
	}
	if (top.window[name] && !top.window[name].closed) { top.window[name].focus(); }
}
function winrefresh(name) {
	if (top.window[name] && !top.window[name].closed) { top.window[name].location.reload(); }
}
function winclose(name) {
	if (top.window[name] && !top.window[name].closed) { top.window[name].close(); }
	else {
		top.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 (top.window[name] && !top.window[name].closed) { top.window[name].close(); }
	}
}
function flipspan(spanname) {	// cant use the visibility/ position trick here as IE "forgets" to display all the images...
	if ((top.lastspan!='')&&document.getElementById(top.lastspan)) {
		document.getElementById(top.lastspan).style.display='none';
	}
	if (document.getElementById(spanname)) {
		document.getElementById(spanname).style.display=top.sdisplay;
		top.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('*');
	top.fterror='';
	if (satest1.length>3) {top.fterror='satest1.length>3';}
	var satest2=term.split('?');
	if ((satest2.length>1)&&(satest1.length>1)) {top.fterror+=((top.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);
						if ( document.getElementById( "_ftx_usequotes" ) && ( document.getElementById( "_ftx_usequotes" ).value == "use" ) ) {
							saand[saand.length-1] = '"' + saand[saand.length-1] + '"';
						}
					}
					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);
						if ( document.getElementById( "_ftx_usequotes" ) && ( document.getElementById( "_ftx_usequotes" ).value == "use" ) ) {
							sanot[sanot.length-1] = '"' + sanot[sanot.length-1] + '"';
						}
					}
					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);
						if ( document.getElementById( "_ftx_usequotes" ) && ( document.getElementById( "_ftx_usequotes" ).value == "use" ) ) {
							saor[saor.length-1] = '"' + saor[saor.length-1] + '"';
						}
					}
					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=''; /*top.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" );
				document.getElementById( "img" + key ).className = document.getElementById( "img" + key ).className.replace( /plus/, "minus" );
			}
			if ( document.getElementById( "entryimg" + key ) ) {
				document.getElementById( "entryimg" + key ).src = document.getElementById( "entryimg" + key ).src.replace( /closed/, "open" );
				document.getElementById( "entryimg" + key ).className = document.getElementById( "entryimg" + key ).className.replace( /closed/, "open" );
			}
			if ( typeof( top.open_keys ) != "undefined" ) {
				top.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" );
				document.getElementById( "img" + key ).className = document.getElementById( "img" + key ).className.replace( /minus/, "plus" );
			}
			if ( document.getElementById( "entryimg" + key ) ) {
				document.getElementById( "entryimg" + key ).src = document.getElementById( "entryimg" + key ).src.replace( /open/, "closed" );
				document.getElementById( "entryimg" + key ).className = document.getElementById( "entryimg" + key ).className.replace( /open/, "closed" );
			}
			if ( typeof( top.open_keys ) != "undefined" ) {
				delete top.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 = top.sdisplay;
	}
	if ( typeof( top.lastthes != "udefined" ) && ( top.lastthes != "" ) && ( top.lastthes != "thes" + thes ) && ( document.getElementById( top.lastthes ) ) ) {
		document.getElementById( top.lastthes ).style.display = "none";
	}
	top.lastthes = "thes" + thes;
}
function togglesearch(name,via_chapter) {
	handle = document.getElementById( name );
	if ( handle ) {
		if ( ( via_chapter==-1 ) && ( eval( 'top.s_toggle'+name ) ) ) {
			if ( eval('top.s_toggle'+name) == 'none' ) {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = 'none';
					document.getElementById('sshow').style.display = top.sdisplay;
				}
				handle.style.display = 'none';
			}
			else {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = top.sdisplay;
					document.getElementById('sshow').style.display = 'none';
				}
				handle.style.display = top.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 = top.sdisplay;
				}
				handle.style.display = 'none';
			}
			else {
				if ( document.getElementById('shide') && document.getElementById('shide') ) {
					document.getElementById('shide').style.display = top.sdisplay;
					document.getElementById('sshow').style.display = 'none';
				}
				handle.style.display = top.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;
top.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=top.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;
	top.mwin = null;
	top.mwin = open( url,'mail','width=10,height=10');
	if (top.mwin) {
		setTimeout( "top.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 setmltext( container, thetext ) {
	if ( container ) {
		var lcltext = thetext.split( /\n/g );
		for ( var i = 0; i < lcltext.length; i++ ) {
			container.appendChild( finddocument( container ).createTextNode( lcltext[i] ) );
			container.appendChild( finddocument( container ).createElement( "br" ) );
		}
	}
}
function readtext( container ) {
	var sreturn = "";
	if ( container ) {
		if ( ( container.firstChild ) && ( container.firstChild.nodeType == 3 ) ) {	// text node?
			sreturn = container.firstChild.nodeValue;
		}
	}
	return sreturn;
}
// MG100827 does the same as above but reads all text nodes inside a container node
function readanytext( container ) {
	var sreturn = "";
	if ( container ) {
		for ( var i = 0; i < container.childNodes.length; i++ ) {
			if ( container.childNodes[i].nodeType == 3 ) {
				sreturn += ( ( sreturn == "" ) ? "" : " " ) + container.childNodes[i].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 );
		}
	}
}

// rwh 080716 
// takes a string parameter and tries 
function formatNumber( sNumberP, cDSP, cGSP, nDecimalPlacesP ) {
	cDSP==null?cDS=",":cDS=cDSP; // set default decimal seperator to ","
	cGSP==null?cGS=".":cGS=cGSP; // set default group seperator to "."
	nDecimalPlacesP==null?nDecimalPlaces=false:nDecimalPlaces=nDecimalPlacesP; // set default decimal places to false
	sTemp = new String( sNumberP );
	aNumber = sTemp.split( /,|\./ )
	sResult = "";
	if ( aNumber.length > 2 ) { // if more than one separator characters found the value is most likely formated already -> return original value
		return( sNumberP );
	} else if ( sTemp.match( /[^0-9\.,]/ ) ) { // if any nonnumerical characters found -> return original value
		return( sNumberP );
	} else if ( aNumber.length > 2 ) { // if more than one separator characters found the value is most likely formated already -> return original value
		return( sNumberP );
	} else {
		// group first part
		aVKS = aNumber[0].split( "" );
		groupCounter = -1;
		for ( i = aVKS.length-1; i >= 0; i-- ) {
			if ( ( groupCounter % 3 ) == 0 ) {
				sResult = cGS + sResult;
			}
			sResult = aVKS[i] + sResult;
			groupCounter==-1?groupCounter=1:groupCounter++;
		}
		// add decimal digits
		if ( aNumber.length == 2 ) {
			if ( nDecimalPlaces ) {
				aNumber[1] = aNumber[1].substr( 0, nDecimalPlaces );
				while( aNumber[1].length < nDecimalPlaces ) {
					aNumber[1] += "0";
				}
			sResult += cDS + aNumber[1];
		}
		} else if ( nDecimalPlaces ) {
			aNumber[1] = "";
			while( aNumber[1].length < nDecimalPlaces ) {
				aNumber[1] += "0";
			}
			sResult += cDS + aNumber[1];
		}
		return( sResult );
	}
}
// rwh 080716 end
// enable some data checking patterns on input fields, if needed
function activateinputpatterns( ) {
	var allinputs = document.getElementsByTagName( "input" );
	for ( var i = 0; i < allinputs.length; i++ ) {
		if ( allinputs[i].getAttribute( "pattern" ) ) {
			// enable some pre-set patterns:
			if ( allinputs[i].getAttribute( "pattern" ) == "currency" ) {
				allinputs[i].setAttribute( "pattern", "\\d{1,7}(?:[,\\.]\\d{0,2}|)" );
			} else if ( allinputs[i].getAttribute( "pattern" ) == "numeric" ) {
				allinputs[i].setAttribute( "pattern", "\\d{1,10}(?:[,\\.]\\d{0,2}|)" );
			} else if ( allinputs[i].getAttribute( "pattern" ) == "number" ) {
				allinputs[i].setAttribute( "pattern", "\\d{1,10}" );
			} else if ( allinputs[i].getAttribute( "pattern" ).indexOf( "date" ) === 0 ) {
				allinputs[i].setAttribute( "pattern", "\\d{1,2}(?:[\\.\\s\\/\\-\\:]\\d{0,2}(?:[\\.\\s\\/\\-\\:]\\d{0,4}|)|)" );
			}
			allinputs[i].setAttribute( "lastvalue", "" );
			allinputs[i].onkeyup = new Function( "event", "var myev=(event)?event:window.event;if((this.value.match(new RegExp(this.getAttribute('pattern'),'gi'))!=this.value)&&(this.value!='')){this.value=this.getAttribute('lastvalue');}else{this.setAttribute('lastvalue',this.value);}" );
		}
	}
}
function checkRequiredFields( docp ) {
	var breturn = true;
	var elmnames = new Array( "input", "select", "textarea" );
	for ( var j = 0; j < elmnames.length; j++ ) {
		var allelms = docp.getElementsByTagName( elmnames[j] );
		for ( var i = 0; i < allelms.length; i++ ) {
			if ( allelms[i].getAttribute( "istate" ) && ( allelms[i].getAttribute( "istate" ) == "required" ) && ( allelms[i].value == "" ) ) {
				breturn = false;
			}
		}
	}
	return breturn;
}
// rwh 090609 
function validate_email( str ) {
	var at = "@";
	var dot = ".";
	var lat = str.indexOf( at );
	var lstr = str.length;
	var ldot = str.indexOf( dot );
	if ( str.indexOf( at ) == -1 ) {
		//alert( "Invalid E-mail ID" )
		return false;
	}
	if ( ( str.indexOf( at ) == -1 ) || ( str.indexOf( at ) == 0 ) || ( str.indexOf( at ) == lstr ) ) {
		//alert("Invalid E-mail ID")
		return false;
	}
	if ( ( str.indexOf( dot ) == -1 ) || ( str.indexOf( dot ) == 0 ) || ( str.indexOf( dot ) == lstr ) ) {
		 //alert("Invalid E-mail ID")
		 return false;
	}
	if ( str.indexOf( at, ( lat + 1 ) ) != -1 ){
	 //alert("Invalid E-mail ID")
	 return false;
	}
	if ( ( str.substring( lat - 1, lat ) == dot ) || ( str.substring( lat + 1, lat + 2 ) == dot ) ) {
	 //alert("Invalid E-mail ID")
	 return false;
	}
	if ( str.indexOf( dot, ( lat + 2 ) ) == -1 ) {
	 //alert("Invalid E-mail ID")
	 return false;
	}
	if ( str.indexOf( " " ) != -1 ) {
	 //alert("Invalid E-mail ID")
	 return false;
	}
	return true;
}
// rwh 090609 
// rwh 090617 
////////////////////////////////////////////////////////////////////////////////////////////////////
// this takes a complete url including querystring, splits it into scriptname and querystring,
// creates a form from the querystring and submits it via post
////////////////////////////////////////////////////////////////////////////////////////////////////
function postUrl( sURL ) {
	oForm = document.createElement( "form" );
	oForm.action = sURL.split( "?" )[0];
	oForm.method = "post";
	saAnchor = sURL.split( "#" );
	sURL = saAnchor[0];
	if ( saAnchor[1] ) {
		oForm.action += "#" + saAnchor[1];
	}
	saParams = sURL.split( "?" )[1].split( "&" );
	for( i = 0; i < saParams.length; i++ ) {
		saParam = saParams[i].split( "=" );
		oInput = document.createElement( "input" );
		oInput.type = "hidden";
		oInput.name = saParam[0];
		oInput.value = saParam[1];
		oForm.appendChild( oInput );
	}
	document.body.appendChild( oForm );
	oForm.submit();
}
// rwh 090617 
// rwh 091030
function pausecomp( millis ) {
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); }
	while( curDate-date < millis );
} 
// rwh 091030
// rwh 090910 
////////////////////////////////////////////////////////////////////////////////////////////////////
// this rips out all children of a DOM node
////////////////////////////////////////////////////////////////////////////////////////////////////
function ripOutChildren( anElement ) {
	if ( anElement && anElement != 'undefined' ) {
		while ( anElement.hasChildNodes() ) {
			anElement.removeChild( anElement.firstChild );
		}
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// this moves all children of a DOM node to another DOM node
// if bClearNewParentFirstP is set to true all children of the destination node are ripped out first
// if sWrapperTagP is set a node of that type is created, added to the destination node and serves as
// container for the children to move
////////////////////////////////////////////////////////////////////////////////////////////////////
function moveDOMTree( oOldParentP, oNewParentP, sWrapperTagP, bClearNewParentFirstP ) {
	var oaChildrenToMove = oOldParentP.childNodes;
	if ( bClearNewParentFirstP == true ) {
		ripOutChildren( oNewParentP );
	}
	if ( sWrapperTagP != "" ) {
		oWrapper = document.createElement( sWrapperTagP );
		oNewParentP.appendChild( oWrapper );
		oNewParent = oWrapper;
	} else {
		oNewParent = oNewParentP;
	}
// rwh 100907	for ( var i = 0; i < oaChildrenToMove.length; i++ ) {
//		oNewParent.appendChild( oaChildrenToMove[i] );
//	}
	while ( oaChildrenToMove.length > 0 ) {
		oNewParent.appendChild( oaChildrenToMove[0] );
	}
}
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (k = 0, l = arrObjClass.length; k < l; k++) {
      for (m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}
// rwh 090910 
// rwh 091021 
function getcomputedstyle( etargetp, propp ) {
	var thestyle = "";
	if ( etargetp.currentStyle ) {
		thestyle = etargetp.currentStyle[propp];
	} else {
		var hdoc = finddocument( etargetp );
		thestyle = hdoc.defaultView.getComputedStyle( etargetp, null ).getPropertyValue( propp );
//		alert( etargetp.id + " " + propp + ": " + hdoc.defaultView.getComputedStyle( etargetp, null ).getPropertyValue( "propp" ) );
	}
	return thestyle;
}
// rwh 091021 
// rwh 091030 
function getXMLHttpRequest( forceActiveXInIE ) {
	forceActiveXInIE == null ? forceActiveXInIE = false : forceActiveXInIE = true ;
	var xmlhttp = false;
//	alert( navigator.userAgent );
	if ( ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) ) { // some kind of ie
		if ( ! forceActiveXInIE ) {
			if ( ! xmlhttp ) try { xmlhttp = new XMLHttpRequest(); } catch( e ) { xmlhttp = false; }
//			if ( ! xmlhttp ) try { alert("ie, no force, try xmlhttprequest"); xmlhttp = new XMLHttpRequest(); } catch( e ) { xmlhttp = false; alert("failed"); }
		}
		if ( ! xmlhttp ) try { xmlhttp = new ActiveXObject( "MSXML2.XMLHTTP" ); } catch( e ) { xmlhttp = false; }
//		if ( ! xmlhttp ) try { alert("ie, force, try MSXML2.XMLHTTP"); xmlhttp = new ActiveXObject( "MSXML2.XMLHTTP" ); } catch( e ) { xmlhttp = false; alert("failed"); }
		if ( ! xmlhttp ) try { xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" ); } catch( e ) { xmlhttp = false; }
//		if ( ! xmlhttp ) try { alert("ie, force, try Microsoft.XMLHTTP"); xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" ); } catch( e ) { xmlhttp = false; alert("failed"); }
	} else {
	  if ( ! xmlhttp ) try{ xmlhttp = new XMLHttpRequest(); } catch( e ) { xmlhttp = false; }
//	  if ( ! xmlhttp ) try{ alert("no ie, try xmlhttprequest"); xmlhttp = new XMLHttpRequest(); } catch( e ) { xmlhttp = false; alert("failed"); }
	}
	return xmlhttp;
}
// rwh 091030 
// rwh 100113 
////////////////////////////////////////////////////////////////////////////////////////////////////
// this function fades images into each other
// params:
//	- sImage1IdP, sImage1IdP:	the ids of two image nodes to contain the images;
//										those should be the same size and have the same position
//										src properties set to ""
//	- sCommaSeparatedImagesP:	a comma separated string containing image names as to be set in src
// - nShowtimeSecondsP:			int; time in second each image is shown until fading begins
// - nFadeStepsP:					int; number of steps for fading; the more steps the smoother the fading
// - nFadestepsIntervalMillisecondsP:	int; milliseconds between two fading steps; 
//										caution: can be quite cpu consuming if set to a low value
// - bFadeInP:						bool; fade in the first image; defaults to false;
// - bFadeInFromFractionP:		fraction of nFadeStepsP the fading in of the first image starts with
//										e.g. if set to 2 the first image will start with approx. 50% opacity
//										defaults to 3 (approx. 33% opacity)
////////////////////////////////////////////////////////////////////////////////////////////////////
function imageFader( sImage1IdP, sImage2IdP, sCommaSeparatedImagesP, nShowtimeSecondsP, nFadeStepsP, nFadestepsIntervalMillisecondsP, bFadeInP, bFadeInFromFractionP, sCommaSeparatedURLsP, sAnchorIdP ) {
	if ( bFadeInP == null) { bFadeInP = false; }
	if ( bFadeInFromFractionP == null )	{ bFadeInFromFractionP = 3 };
	bHandleAnchor = true;
	bURLHandeled = false;
	if ( sCommaSeparatedURLsP == null ) { bHandleAnchor = false; }
	if ( sAnchorIdP == null ) { bHandleAnchor = false; }
	var aImages = ( sCommaSeparatedImagesP != "" ) ? sCommaSeparatedImagesP.split( "," ) : new Array(); // splitting an empty string results in an array containing an empty string, which spoils my intention!
	if ( bHandleAnchor ) {
		var eAnchor = document.getElementById( sAnchorIdP ); 
		if ( eAnchor ) {
			var aURLs = ( sCommaSeparatedURLsP != "" ) ? sCommaSeparatedURLsP.split( "," ) : new Array(); // splitting an empty string results in an array containing an empty string, which spoils my intention!
		} else {
			bHandleAnchor = false;
		}
	}
	var nImageIndex = 0;
	var nDurationIndex = 0;
	var nStepIndex = 0;
	var aImageToggler = Array( document.getElementById( sImage1IdP ), document.getElementById( sImage2IdP ) );
	aImageToggler[1].style.opacity = ".0";
	aImageToggler[1].style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
	var useCSSDefinition = false;

	aImageToggler[0].src = aImages[nImageIndex];
	aImageToggler[1].src = ( aImages.length > 1 ) ? aImages[++nImageIndex] : "undefined";
	if ( bFadeInP ) {
		aImageToggler[0].src = "undefined";
		aImageToggler[0].style.visibility = "hidden";
		aImageToggler[1].src = aImages[0];
		nImageIndex--;
		nDurationIndex = nShowtimeSecondsP;
		nStepIndex = parseInt( nFadeStepsP / bFadeInFromFractionP );
	} 
	if ( aImages.length > 0 ) {
		var oTimer = setInterval( fade, nFadestepsIntervalMillisecondsP );
	} else {
		aImageToggler[0].style.visibility = "hidden";
		aImageToggler[1].style.visibility = "hidden";
	}

		function fade() {
			if ( nDurationIndex < nShowtimeSecondsP ) { // show image whithout fading for nShowtimeSecondsP seconds
				nDurationIndex += nFadestepsIntervalMillisecondsP/1000; 
				if ( aImages.length == 1 )	{
					clearInterval( oTimer );
				}
				if ( bFadeInP ) {
					aImageToggler[1].style.visibility = "visible";
					bFadeInP = false;
				}
			} else {
				if ( nStepIndex < nFadeStepsP ) { // fading in process
					nStepIndex++;
					if ( useCSSDefinition ) {
						aImageToggler[0].className = "opaque" + ( nFadeStepsP - nStepIndex ) * 100/nFadeStepsP;
						aImageToggler[1].className = "opaque" + nStepIndex * 100/nFadeStepsP;
					} else {
						aImageToggler[0].style.opacity = ( nFadeStepsP - nStepIndex ) /nFadeStepsP; //".7";
						//aImageToggler[0].style.-ms-filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + ( nFadeStepsP - nStepIndex ) * 10; //70)";
						aImageToggler[0].style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + ( ( nFadeStepsP - nStepIndex ) * 100/nFadeStepsP ) + ")"; //70)";
						//aImageToggler[0].style.filter = "alpha(opacity=" + ( nFadeStepsP - nStepIndex ) * 10; //70)";
						aImageToggler[1].style.opacity = nStepIndex * 100/nFadeStepsP /100; //".7";
						//aImageToggler[1].style.-ms-filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + nStepIndex * 10; //70)";
						aImageToggler[1].style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + nStepIndex * 100/nFadeStepsP + ")"; //70)";
						//aImageToggler[1].style.filter = "alpha(opacity=" + nStepIndex * 10; //70)";
					}
					if ( bHandleAnchor && ! bURLHandeled ) {
						if ( nStepIndex > ( nFadeStepsP / 2 ) ) {
							bURLHandeled = true;
							nURLIndex = ( nImageIndex == -1 ) ? 0 : nImageIndex;
							if ( aURLs[nURLIndex] ) {
								eAnchor.href = aURLs[nURLIndex];
								eAnchor.style.display = "";
							} else {
								eAnchor.style.display = "none";
							}
						} else if ( nStepIndex > ( nFadeStepsP / 2 ) - 1 ) { // hide anchor for one single step to force change of window status
							eAnchor.style.display = "none";
						}
					}

				} else { // fading done, reset nDurationIndex, increment nImageIndex, reload next image into transparent container
					// rwh 100804 this would remove the white spray _after_ the image transition but leave it while, which is nearly as ugly
					// aImageToggler[1].style.removeAttribute("filter");
					// rwh 100804 end
					nDurationIndex = 0;
					nStepIndex = 0;
					nImageIndex = ++nImageIndex % aImages.length;
					aImageToggler[0].src = aImages[nImageIndex];
					aImageToggler.push( aImageToggler.shift() );
					bURLHandeled = false;
				}
			}
		}
}
// rwh 100113 
////////////////////////////////////////////////////////////////////////////////////////////////////
// MG100119 a couple of string helper fns: trim and pad
// rwh 100614 changed to be able to trim other chars than whitespace as well
////////////////////////////////////////////////////////////////////////////////////////////////////
String.prototype.trim = function( chars ) {
	return this.ltrim( chars ).rtrim( chars );
}
String.prototype.ltrim = function( chars ) {
	chars = chars || "\\s";
	return this.replace( new RegExp( "^[" + chars + "]+", "g" ), "" );
}
String.prototype.rtrim = function( chars ) {
	chars = chars || "\\s";
	return this.replace( new RegExp( "[" + chars + "]+$", "g" ), "" );
}
// rwh 100614 
String.prototype.lpad = function( padString, length ) {
	var str = this;
	while ( str.length < length ) {
		str = padString + str;
	}
	return str;
}
String.prototype.rpad = function( padString, length ) {
	var str = this;
	while ( str.length < length ) {
		str = str + padString;
	}
	return str;
}
String.prototype.bindec = function( ) {
	n = 0;
	for ( var i = 0; i < this.length; i++ ) {
		if ( this.substr( this.length - i - 1, 1 ) == "1" ) {
			n += Math.pow( 2, i );
		}
	}
	return n;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// MG100119 a couple of handy bool functions to help deal with bits above 32.
// mind that this only really works up to the 46th bit as afterwards PHP loses the
// accuracy for numbers due to the "E" notation.
// the _ prefixed functions are intended for internal use only, use bitand, bitor, bitxor and bnot.
////////////////////////////////////////////////////////////////////////////////////////////////////
function _bitstring( n ) {
	var l = parseInt( n & 2147483647 );
	var h = Math.floor( n / 2147483648 );
	return h.toString( 2 ).lpad( "0", 31 ) + l.toString( 2 ).lpad( "0", 31 );
}
function _bittonum( s ) {
	var h = s.substr( 17, 14 );
	var l = s.substr( 31, 31 );
	return h.bindec( ) * 2147483648 + l.bindec( );
}
function _bitop( n1, n2, op ) {
	var bits1 = _bitstring( parseInt( n1 ) );
	var bits2 = _bitstring( parseInt( n2 ) );
	var bits3 = new Array( );
	for( pos = 0; pos < bits1.length; pos++ ) {
		if ( op == "and" ) {
			bits3[pos] = parseInt( bits1.substr( pos, 1 ) ) & parseInt( bits2.substr( pos, 1 ) );
		} else if ( op == "or" ) {
			bits3[pos] = parseInt( bits1.substr( pos, 1 ) ) | parseInt( bits2.substr( pos, 1 ) );
		} else if ( op == "xor" ) {
			bits3[pos] = parseInt( bits1.substr( pos, 1 ) ) ^ parseInt( bits2.substr( pos, 1 ) );
		} else if ( op == "not" ) {
			bits3[pos] = ( parseInt( bits1.substr( pos, 1 ) ) ) ? "0" : "1";
		}
	}
	var bits3 = bits3.join( "" );
	return _bittonum( bits3 );
}
function bitand( n1, n2 ) {
	return _bitop( n1, n2, "and" );
}
function bitor( n1, n2 ) {
	return _bitop( n1, n2, "or" );
}
function bitxor( n1, n2 ) {
	return _bitop( n1, n2, "xor" );
}
function bitnot( n1 ) {
	return _bitop( n1, 0, "not" );
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// rwh 100225 checks whether a date given as d.m.y is valid or not
// expected date format is d.m.yyyy
////////////////////////////////////////////////////////////////////////////////////////////////////
function validateDate( sDateP ) {
	var result = false;
	if ( sDateP ) {
		var qDatum = /^(\d{1,2}\.)(\d{1,2}\.)(\d{4})$/gi;
		qDatum.compile(qDatum); 
		var match = qDatum.exec( sDateP );
		if ( match != null ) {
			nTempDay = parseInt( match[1], 10 );
			nTempMonth = parseInt( match[2], 10 );
			nTempYear = parseInt( match[3], 10 );
			var oDate = new Date( nTempYear, nTempMonth - 1, nTempDay );
			if ( ( oDate.getMonth() + 1 == nTempMonth ) && ( oDate.getDate() == nTempDay ) && ( oDate.getFullYear() == nTempYear ) ) {
				result = true;
			}
		}
	}
	return result;
}
// rwh 100225 
// rwh 100611 
function divisionFader( sCommaSeparatedDivisionIdsP, nShowtimeSecondsP, nFadeStepsP, nFadestepsIntervalMillisecondsP ) {
	var aDivs = ( sCommaSeparatedDivisionIdsP != "" ) ? sCommaSeparatedDivisionIdsP.split( "," ) : new Array(); // splitting an empty string results in an array containing an empty string, which spoils my intention!
	var nDivIndex = 0;
	var nNextDivIndex = 1;
	var nDurationIndex = 0;
	var nStepIndex = 0;
	var aImageToggler = Array();
	for ( var i = 0; i < aDivs.length; i++ ) {
		aImageToggler[i] = document.getElementById( aDivs[i] );
		if ( i > 0 ){
			aImageToggler[i].style.opacity = ".0";
			aImageToggler[i].style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
		}
	}
	var useCSSDefinition = false;

	if ( aDivs.length > 0 ) {
		var oTimer = setInterval( fade, nFadestepsIntervalMillisecondsP );
	}

		function fade() {
			if ( nDurationIndex < nShowtimeSecondsP ) { // show image whithout fading for nShowtimeSecondsP seconds
				nDurationIndex += nFadestepsIntervalMillisecondsP/1000; 
				if ( aDivs.length == 1 )	{
					clearInterval( oTimer );
				}
			} else {
				if ( nStepIndex < nFadeStepsP ) { // fading in process
					nStepIndex++;
					if ( useCSSDefinition ) {
						aImageToggler[nDivIndex].className = "opaque" + ( nFadeStepsP - nStepIndex ) * 100/nFadeStepsP;
						aImageToggler[nNextDivIndex].className = "opaque" + nStepIndex * 100/nFadeStepsP;
					} else {
						aImageToggler[nDivIndex].style.opacity = ( nFadeStepsP - nStepIndex ) /nFadeStepsP; //".7";
						aImageToggler[nDivIndex].style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + ( ( nFadeStepsP - nStepIndex ) * 100/nFadeStepsP ) + ")"; //70)";
						aImageToggler[nNextDivIndex].style.opacity = nStepIndex * 100/nFadeStepsP /100; //".7";
						aImageToggler[nNextDivIndex].style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + nStepIndex * 100/nFadeStepsP + ")"; //70)";
					}
					aImageToggler[nDivIndex].style.zIndex = ( nFadeStepsP - nStepIndex ) * 100/nFadeStepsP
					aImageToggler[nNextDivIndex].style.zIndex = nStepIndex * 100/nFadeStepsP; //".7";

				} else { // fading done, reset nDurationIndex, increment nDivIndex, reload next image into transparent container
					nDurationIndex = 0;
					nStepIndex = 0;
					nDivIndex = nNextDivIndex;
					nNextDivIndex = ++nNextDivIndex % aDivs.length;
				}
			}
		}
}
// rwh 100611 

// rwh 110111 
/* This script and many more are available free online at
   The JavaScript Source :: http://javascript.internet.com 
   Copyright Robert Nyman, http://www.robertnyman.com
   Free to use if this text is included */
function getElementsByAttribute( oElm, strTagName, strAttributeName, strAttributeValue ) {
	var arrElements = ( strTagName == "*" && document.all ) ? document.all : oElm.getElementsByTagName( strTagName );
	var arrReturnElements = new Array();
	var oAttributeValue = ( typeof strAttributeValue != "undefined" ) ? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for( var i = 0; i < arrElements.length; i++ ) {
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute( strAttributeName );
		if ( typeof oAttribute == "string" && oAttribute.length > 0 ) {
			if ( typeof strAttributeValue == "undefined" || ( oAttributeValue && oAttributeValue.test( oAttribute ) ) ) {
				arrReturnElements.push( oCurrent );
			}
		}
	}
	return arrReturnElements;
}
// rwh 110111 
