//****************************************************************************************
//
//	Überprüfen der Bildschirmauflösung und anschließende Positionierung des div-Elements
//****************************************************************************************
document.write(' ');
var nosubmit = false;
var defaultButton = "";
var my_version = '0.1.0';
var dump =  'Performing browser test. Please wait.';
var prop = '';
var i;
var focus = '';
//  Abfrage des focus in Suchfeldern
var focuscheck = "false";
//  gesplitteter Inhalt der Suchfelder
var tempNew = "";			
//  original Inhalte der Suchfelder	
var txtand = "";
var txtany = "";
var txtnot = "";
//  original Inhalte der Suchfelder
var txtOrig = "";
//  Inhalte der Suchfelder
var txtNew = "";
//  Properties aus Thesaurus
var newinputPropThes = "";
//  Inhalt aus Thesaurus in Klammern mit Unterstrich zum Vergleichen
var newinputPropThesTemp = "";
//  extra Variable fuer LoopProp, true, wenn Property schon vorhanden
var txtsearchfoundProp = "false";
//  anfangende Klammer gefunden
var txtStartBrace = "false";
//  Variable, der jeweils neuer Eintrag in Suchfeldern zugewiesen wird 
var txtNewSystem = "";
//  Hochzaehlen des compound systems anhand der ID
//  faengt bei "Pure compound" an
var systemID = 1;
//  Abgleichen des Compoundsystems mit Anzahl ID
var boolSystemCheck = "true";
var substanceNew = "";
var substanceNewThes = "";
//  Stelle, an der system gefunden wurde
var tempPos = -1;
//  Check, ob "compound" oder "system" im Suchfeld vorhanden oder aus Thesaurus uebernommen werden soll
var tempCompoundCheckFeld = "";	
var tempCompoundCheckThes = "";	
var tempSystemCheckFeld = "";	
var tempSystemCheckThes = "";

// Java VM version number
var version = null;
var required_version = '1.3';



//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader


 var vbs = false;
// alert('vbs' + vbs + nosubmit);

setvb(vbs);

var agt = navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
// ellen, 26.11. auskommentiert
//var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win") != -1) || (agt.indexOf("32bit") != -1));
var mac = (agt.indexOf("mac") != -1);
var pluginlist = "";

if (ie && win) {
	// ellen, 26.11. auskommentiert
    /*pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") +
        detectIE("Adobe.SVGCtl.1","Adobe SVG Viewer 1") +
        detectIE("Adobe.SVGCtl.2","Adobe SVG Viewer 2") +
        detectIE("Adobe.SVGCtl.3","Adobe SVG Viewer 3") +
        detectIE("Adobe.SVGCtl.4","Adobe SVG Viewer 4") + */
        
    pluginlist = detectIE("SWCtl.SWCtl.1","Shockwave Director") +
        detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") +
        detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") +
        detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") +
        detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") +
        detectIE("PDF.PdfCtrl.5","Acrobat Reader");
}

// ellen, 26.11. auskommentiert
/*if (ns || !win) {
    nse = "";
    for (var i=0; i < navigator.mimeTypes.length; i++) {
        nse += navigator.mimeTypes[i].type.toLowerCase();
    }
    pluginlist = detectNS("image/svg-xml","SVG Viewer") +
        detectNS("application/x-director","Shockwave Director") +
        detectNS("application/x-shockwave-flash","Shockwave Flash") +
        detectNS("audio/x-pn-realaudio-plugin","RealPlayer") +
        detectNS("video/quicktime","QuickTime") +
        detectNS("application/x-mplayer2","Windows Media Player") +
        detectNS("application/pdf","Acrobat Reader");
}*/

// ellen, 26.11. auskommentiert
/*function detectVersion() {
    alert("Try to detect SVG Version");
    document.write('<SCRIPT LANGUAGE=VBScript>\n' +
                   ' Set svgObj = CreateObject("Adobe.SVGCtl") \n' +
                   ' version = svgObj.getSVGViewerVersion \n' +
                   '</SCRIPT>\n');
    alert("Version: [" + version + "]");
}*/


function detectIE(ClassID,name) {
    result = false;
    document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n');
    if (result) {
        return name+',';
    } else {
        return '';
    }
}

// ellen, 26.11. auskommentiert
/*function detectNS(ClassID,name) {
    n = "";
    if (nse.indexOf(ClassID) != -1) {
        if (navigator.mimeTypes[ClassID].enabledPlugin != null) {
            n = name+",";
        }
    }
    return n;
}*/

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

    function canDetectPlugins() {
        if( vbs || (navigator.plugins && navigator.plugins.length > 0) ) {
            return true;
        } else {
            return false;
        }
    }

//Flash
    flash = (pluginlist.indexOf("Flash") != -1) ? true : false;
//Windows Media Player
    wmp = (pluginlist.indexOf("Windows Media Player") != -1) ? true : false;
//Java
    java = (pluginlist.indexOf("Java") != -1) ? true : false;
//Shockwave
    shockwave = (pluginlist.indexOf("Shockwave") != -1) ? true : false;
//RealPlayer
    realplayer = (pluginlist.indexOf("RealPlayer") != -1) ? true : false;
//QuickTime
    quicktime = (pluginlist.indexOf("QuickTime") != -1) ? true : false;
//Acrobat Reader
    acrobat = (pluginlist.indexOf("Acrobat Reader") != -1) ? true : false;
    
//SVG Viewer
// ellen, 26.11. auskommentiert
    /*svg  = (pluginlist.indexOf("Adobe SVG Viewer") != -1) ? true : false;
    svg1 = (pluginlist.indexOf("Adobe SVG Viewer 1") != -1) ? true : false;
    svg2 = (pluginlist.indexOf("Adobe SVG Viewer 2") != -1) ? true : false;
    svg3 = (pluginlist.indexOf("Adobe SVG Viewer 3") != -1) ? true : false;
    svg4 = (pluginlist.indexOf("Adobe SVG Viewer 4") != -1) ? true : false; */


function setvb(vbs) {
    document.write('<SCRIPT LANGUAGE=VBScript>\n If ScriptEngineMajorVersion >= 2 then \n vbs = true \n End If </SCRIPT>\n');
        return vbs;
    }

function detectIE(ClassID,name) {
    result = false;
    document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n');
    if (result) {
        return name+',';
    } else {
        return '';
    }
}

// ellen, 26.11. auskommentiert
/*function detectNS(ClassID,name) {
    n = "";
    if (nse.indexOf(ClassID) != -1) {
        if (navigator.mimeTypes[ClassID].enabledPlugin != null) {
            n = name+",";
        }
    }
    return n;
}*/


//****************************************************************************************
// Aufruf in StandardSearch

function Init() {

	var browser = BrowserTest();
		
	document.Standard.submitSimpleSearch.onfocus = startsubmit;
	document.Standard.txtAndSearch.onkeypress = CheckEnter;
	document.Standard.txtAnySearch.onkeypress = CheckEnter;
	document.Standard.txtNotSearch.onkeypress = CheckEnter;		
	document.Standard.txtAndSearch.focus();
	
	//document.Standard.txtAndSearch.value = '';
	//document.Standard.txtAnySearch.value = '';
	//document.Standard.txtNotSearch.value = '';
    // Änderung Mars testweise, 02.09.08
    
    // wenn "no hits" Thesaurus sofort einblenden 
    /*if (document.getElementById("nohits").style.display == "block"){
 		 getFlexApp();
    }*/
    
    // Thesaurus jetzt immer einblenden
    getFlexApp();
    
    // nach Laden der Seite searchLabelAnd immer fett
	// zur Uebernahme des Thesaurusinhaltes
	document.getElementById( 'searchLabelAnd').style.fontWeight = "bold";
	
	// ellen, 21.04. txtAnySearch und txtNotSearch inaktiv setzen, wenn felder leer sind
	if(document.getElementById( 'txtAnySearch').value == 0){
	 	document.getElementById( 'txtAnySearch').style.backgroundColor = "#dedede";
	}
	else{
	 	document.getElementById( 'txtAnySearch').style.backgroundColor = "white";
	}
		
	if(document.getElementById( 'txtNotSearch').value == 0 ){
		document.getElementById( 'txtNotSearch').style.backgroundColor = "#dedede";
	}	
	else{
		document.getElementById( 'txtNotSearch').style.backgroundColor = "white";
	}
    

   	if (navigator.cookieEnabled ) {
 		 document.getElementById("errorline1").style.display = "none";
    }
    else {
 		 document.getElementById("errorline1").style.display = "inline";
    }   

    if (window.Event) {
        window.captureEvents(Event.KEYDOWN);
        window.onkeydown = NetscapeEventHandler_KeyDown;
    	} else {
        document.onkeydown = MicrosoftEventHandler_KeyDown;
    }
}    



//****************************************************************************************
// ThesarusFlexJS.swf laden

function getFlexApp(appName) {

		// ellen, 02.03.2009, servlet "standardSearch" wird an "ThesaurusFlexJS.mxml" uebergeben
		// dort wird "type" abgefragt --> es wird der OpenThesaurusBtn eingeblendet
		//var type = "";
		//var flashvars = [];
		//var flashvars = {type: "standardSearch"};
		
		// wenn "no hits" ThesaurusTree einblenden, servlet "advancedSearch" wird an "ThesaurusFlexJS.mxml" uebergeben
    	//if (document.getElementById("nohits").style.display == "block"){
    	//		var flashvars = {type: "advancedSearch"};
	    //} else{
  		// ansonsten wird OpenThesaurusBtn eingeblendet, servlet "standardSearch"
	    //		var flashvars = {type: "standardSearch"};
	    //}
		//alert("flashvars: " + flashvars["type"]);
		
	    // 03.04.2009, Thesaurus soll auf beiden Seiten sofort geöffnet sein	
		//swfobject.embedSWF("../swf/ThesaurusFlexJS.swf", "ThesaurusLoaderIndex", "280", "550", "7", "", flashvars);
		
		swfobject.embedSWF("../swf/thesaurusFlex.swf", "ThesaurusLoaderIndex", "280", "550", "7");
		
		if (navigator.appName.indexOf ("Microsoft") !=-1) {
			return window[appName];
						
		} else {
			return document[appName];
		}
		
}

//****************************************************************************************
// Thesaurus auf- und zuklappen

/*   function toggleThesaurus(control){
		var elem = document.getElementById(control);
						
		if(document.getElementById('tabnav2_btn').value == "Open thesaurus"){
			if(elem.style.display == "none"){
				elem.style.display = "block";
				document.getElementById('tabnav2_btn').value = "Close thesaurus";
				getFlexApp();
			}
		}		
		else{
			if(document.getElementById('tabnav2_btn').value == "Close thesaurus"){
				elem.style.display = "none";
				document.getElementById('tabnav2_btn').value = "Open thesaurus";
			}
		}	
	}	
*/
//****************************************************************************************
// Steuerung Focus in Textfeld
// Auswahl aus Thesaurus in Textfeld und mach Label fett
		function setFocusAnd(){
			focus="and";
			document.getElementById('searchLabelAnd').style.fontWeight = "bold";							
			document.getElementById('searchLabelAny').style.fontWeight = "normal";
			document.getElementById('searchLabelNot').style.fontWeight = "normal";
			document.getElementById( 'txtAndSearch').style.backgroundColor = "white";				
			document.getElementById( 'txtAnySearch').style.backgroundColor = "#dedede";
			document.getElementById( 'txtNotSearch').style.backgroundColor = "#dedede";
			return;	
		}			
				
		function setFocusAny(){
			focus="any";
			document.getElementById('searchLabelAny').style.fontWeight = "bold";								
			document.getElementById('searchLabelAnd').style.fontWeight = "normal";
			document.getElementById('searchLabelNot').style.fontWeight = "normal";
			document.getElementById( 'txtAnySearch').style.backgroundColor = "white";				
			document.getElementById( 'txtAndSearch').style.backgroundColor = "#dedede";
			document.getElementById( 'txtNotSearch').style.backgroundColor = "#dedede";
			return;														
		}			
				
		function setFocusNot(){
			focus="not";
			document.getElementById('searchLabelNot').style.fontWeight = "bold";
			document.getElementById('searchLabelAnd').style.fontWeight = "normal";
			document.getElementById('searchLabelAny').style.fontWeight = "normal";	
			document.getElementById( 'txtNotSearch').style.backgroundColor = "white";				
			document.getElementById( 'txtAndSearch').style.backgroundColor = "#dedede";
			document.getElementById( 'txtAnySearch').style.backgroundColor = "#dedede";								
			return;
		}
		
		
//****************************************************************************************		
// Aufruf über clearbtn, lösche Suchfelder  

   function clearQuery(){
		document.getElementById('searchLabelAny').style.fontWeight = "normal";								 
		document.getElementById('searchLabelNot').style.fontWeight = "normal";
		document.getElementById('txtAndSearch').value = "";
		document.getElementById('txtAnySearch').value = "";								 
		document.getElementById('txtNotSearch').value = "";
		document.Standard.txtAndSearch.focus();
	}	
																																																						
//****************************************************************************************
// Uebergabe aus ThesaurusFlexJS.mxml heraus
// bei Klick auf Thesaurus uebernehme Substanzen je nach Focus in txtSearch Felder
// wird aus ThesaurusFlexJS.mxml aufgerufen
//****************************************************************************************

function displaySubstance(substance){
// alert("displaySubstance");

		boolSystemCheck = "true";
		//alert("boolSystemCheck: " + boolSystemCheck);
		systemID = 0;
		//alert("systemID: " + systemID);
	 	txtNewSystem = "";
	 
		// knoten jetzt als item eintrag, wegen probleme mit doppelklick
		// items fangen mit "all" an --> "all" bei uebernahme in queryfeld wieder wegschmeissen
		var strsearch = "";
		var strall = "";
		var substancenew = "";
		var firstchar = "";
		var firstup = "";				
		var substancefirstdel = "";
		//var substancefirstup = "";				
		
		document.getElementById('txtAndSearch').text = substance;
		
		//alert(document.getElementById('txtAndSearch').text);				       				    
		strsearch = document.getElementById('txtAndSearch').text;

	   	// aus Thesaurus
		// suche alle strings nach "All" als einzelnes wort (Alloys aussparen)
		strall = strsearch.search(/\bAll\b/);
		//alert("strall: " + strall); 

    	if (strall != -1){
			//alert("All gefunden");
			// "all" abschneiden	    	
    		substancenew = substance.substring(4);
    		// 1. buchstaben ausgeben
    		firstchar = substancenew.charAt(0);
   		    //alert("firstchar: " + firstchar);
   		    // 1. buchstaben gross schreiben
    		firstup = firstchar.toUpperCase(); 
   		    //alert("firstup: " + firstup);
   		    // 1. buchstaben loeschen
   		    substancefirstdel = substance.substring(5);
   		    // 1. buchstaben mit grossgeschriebenen ersetzen
   		    substanceNew = firstup + substancefirstdel;
   		    //alert("substancenew: " + substancefirstup);
        }
        else{
        	substanceNew = substance;
        }

		substanceNewThes = " [" + substanceNew + "] ";
		//alert("substanceNewThes: " + substanceNewThes);


		if (focus == "and" && document.getElementById("txtAndSearch").value.length > 0){
			focuscheck = "true";
		}
		if(focus == "any" && document.getElementById("txtAnySearch").value.length > 0){
			focuscheck = "true";
		}
		if(focus == "not" && document.getElementById("txtNotSearch").value.length > 0){
			focuscheck = "true";
		}			 	

		if(focuscheck == "true"){
			//alert("focuscheck: " + focuscheck);
				
			// Eingaben auf doppelte Eintraege in Suchfelder pruefen  	
			CheckDoubleSubstance();

	        // keinen doppelten Eintrag gefunden
		    if(txtsearchfoundProp == "false"){ 
		    	//alert("txtsearchfound: " + txtsearchfoundProp);      

				
					// txtSearchFelder
					for (var i=0;i<txtNew.length;i++){
					//alert("i= " + i + "buchstabe " + txtNewTemp.charAt(i));

						// Klammer am Anfang: search(/^\[/)
						// charAt(), sonst erkennt es der IE nicht!								
						if(txtNew.charAt(i) == '[' ){
							txtStartBrace = "true";
						}   	

						// Klammer am Ende: search(/\]$/)
						if(txtNew.charAt(i) == ']' ){
							txtStartBrace = "false";
						}   	
						    	
						// Klammer auf und zu gefunden und Eingabe enthaelt Leerzeichen
						// mit Unterstrich auffuellen um zu vergleichen     	
					   	if(txtStartBrace == "true" && txtNew.charAt(i) == ' '){
					   	//if(txtandStartBrace == "true" && txtandNewInputIdCheck == "true" && txtandNewDBIdCheck == "true"){					   		
							//alert("txtandNew[]: '" + txtandNew[i] + "'");
							//alert("txtandNew[]: '" + txtandNew + "'");
							txtNew = txtNew.substr(0,i) + '_' + txtNew.substr(i + 1, txtNew.length-1)
							//alert("txtNew displaySubstance: " + txtNew);							
						}
					}
						
   		            //tempNew = txtNew.split(' ');
   		            tempNew = tempNew;
   		            //alert("tempNew: " + tempNew);
   		            

					for (var i=0;i<tempNew.length;i++){
						//alert(i + " tempNew[i]: " + tempNew[i])

						// "compound" in Suchfeld 
						tempCompoundCheckFeld = tempNew[i].search(/compound/);	

						// "compound" in Thesaurus 
						tempCompoundCheckThes = newinputPropThesTemp.search(/compound/);	

						// "system" in Suchfeld 
						tempSystemCheckFeld = tempNew[i].search(/system/);	

						// "system" in Thesauruseintrag 
						tempSystemCheckThes = newinputPropThesTemp.search(/system/);
							
						// wenn in Suchfeld "compound" und "system" soll per Thesaurus uebernommen werden --> ersetze "compound" mit "system"
						if(tempCompoundCheckFeld != -1 && tempSystemCheckThes != -1){								
							//alert("Compound gefunden");							
							//alert("tempSystem: " + tempSystemCheck);
							tempPos = i;
							boolSystemCheck = "false";
						}

						// wenn in Suchfeld "system" und "compound" soll per Thesaurus uebernommen werden --> ersetze "system" mit "compound"
						if(tempSystemCheckFeld != -1 && tempCompoundCheckThes != -1){								
							//alert("System gefunden");							
							//alert("tempSystem: " + tempSystemCheck);
							tempPos = i;
							boolSystemCheck = "false";
						}

						// wenn in Suchfeld "..system" und "..system" soll per Thesaurus uebernommen werden --> ersetze "..system"	
						if(tempSystemCheckFeld != -1 && tempSystemCheckThes != -1){
							//alert("System gefunden");							
							//alert("tempSystem: " + tempSystemCheck);
							tempPos = i;
							boolSystemCheck = "false";
						}
					}
					

					if (focus == "and"){
						// kein "compound/system" gefunden --> neues anfuegen					
						// txtSearchFeld mit ausgewaehltem System 
						if (boolSystemCheck == "true"){
							//alert("boolSystemCheck: " + boolSystemCheck);							
							for (var i=0;i<tempNew.length;i++){
								if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){									
								//if(tempPos != i){									
									//alert("tempNew[i]: " + tempNew[i])												
									//txtNewSystem += tempNew[i].replace(/\_/g,' ') + " ";
									txtNewSystem = txtand;
									//txtNewSystem += substanceNewThes;									
									//alert("txtNewSystem: " + txtNewSystem);
								}
							}
						}
	
						// "compound/system" gefunden --> loeschen und neues anfuegen
						else if (boolSystemCheck == "false"){
							//alert("boolSystemCheck: " + boolSystemCheck);

							for (var i=0;i<tempNew.length;i++){
								//alert("tempNew: " + tempNew[i]);									
								if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){
								//if(tempPos != i){									
									txtNewSystem += tempNew[i].replace(/\_/g,' ') + " ";
									//txtNewSystem += tempNew[i] + " ";									
									//txtNewSystem += substanceNewThes;									
									//alert("txtNewSystem: " + txtNewSystem);
								}
							}
						}

						document.getElementById('txtAndSearch').focus();
						document.getElementById('txtAndSearch').value = txtNewSystem;
						document.getElementById('txtAndSearch').value += substanceNewThes; 	
					}

				
					// Eintrag txtSearchFeld						
					else if (focus == "any"){
						// kein "compound/system" gefunden --> neues anfuegen					
						// txtSearchFeld mit ausgewaehltem System 
						if (boolSystemCheck == "true"){
							for (var i=0;i<tempNew.length;i++){
								if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){									
								//if(tempPos != i){									
									//alert("tempNew[i]: " + tempNew[i])												
									//txtNewSystem += tempNew[i].replace(/\_/g,' ') + " ";
									txtNewSystem = txtany;
									//txtNewSystem += substanceNewThes;									
									//alert("txtNewSystem: " + txtNewSystem);
								}
							}
						}
	
						// "compound/system" gefunden --> loeschen und neues anfuegen
						else if (boolSystemCheck == "false"){
							txtNewSystem = "";
							for (var i=0;i<tempNew.length;i++){
								//alert("tempNew: " + tempNew[i]);									
								if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){
								//if(tempPos != i){									
									txtNewSystem += tempNew[i].replace(/\_/g,' ') + " ";
									//txtNewSystem += tempNew[i] + " ";									
									//txtNewSystem += substanceNewThes;									
									//alert("txtNewSystem: " + txtNewSystem);
								}
							}
						}

						document.getElementById('txtAnySearch').focus();
						document.getElementById('txtAnySearch').value = txtNewSystem;
						document.getElementById('txtAnySearch').value += substanceNewThes;							
					}

						// Eintrag txtSearchFeld
						else if (focus == "not"){
							// kein "compound/system" gefunden --> neues anfuegen					
							// txtSearchFeld mit ausgewaehltem System 
							if (boolSystemCheck == "true"){
								for (var i=0;i<tempNew.length;i++){
									if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){									
									//if(tempPos != i){										
										//alert("tempNew[i]: " + tempNew[i])												
										//txtNewSystem += tempNew[i].replace(/\_/g,' ') + " ";
										txtNewSystem = txtnot;
										//txtNewSystem += substanceNewThes;									
										//alert("txtNewSystem: " + txtNewSystem);
									}	
								}
							}
	
							// "compound/system" gefunden --> loeschen und neues anfuegen
							else if (boolSystemCheck == "false"){
								txtNewSystem = "";
								for (var i=0;i<tempNew.length;i++){
									//alert("tempNew: " + tempNew[i]);									
									//if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){
									if(tempPos != i && tempNew[i] != ' ' && tempNew[i] != ''){									
									//if(tempPos != i){										
										txtNewSystem += tempNew[i].replace(/\_/g,' ') + " ";
										//txtNewSystem += tempNew[i] + " ";									
										//txtNewSystem += substanceNewThes;									
										//alert("txtNewSystem: " + txtNewSystem);
									}
								}
							}

							document.getElementById('txtNotSearch').focus();
							document.getElementById('txtNotSearch').value = txtNewSystem;
							document.getElementById('txtNotSearch').value += substanceNewThes;								
						}

		    	 
/*				if (focus == "and"){
					document.getElementById('txtAndSearch').focus();
					document.getElementById('txtAndSearch').value += " " + "[" + substance + "]" + " ";
					document.getElementById('txtAndSearch').value += substanceNew + " ";
				}
				else{	
					if (focus == "any"){
						document.getElementById('txtAnySearch').focus();
						document.getElementById('txtAnySearch').value += " " + "[" + substance + "]" + " ";
						document.getElementById('txtAnySearch').value += substanceNew + " ";			
					}
				    else{					
						if (focus == "not"){
							document.getElementById('txtNotSearch').focus();
							document.getElementById('txtNotSearch').value += " " + "[" + substance + "]" + " ";
							document.getElementById('txtNotSearch').value += substanceNew + " ";								
						}
					}
				}
*/
		    }
		}// focuscheck
		
		// wenn neuer Eintrag und Suchfelder leer
		else{
			if (focus == "and" && document.getElementById("txtAndSearch").value.length == 0){
				focuscheck = "true";
			}
			
			if (focus == "any" && document.getElementById("txtAnySearch").value.length == 0){
				focuscheck = "true";
			}
			
			if (focus == "not" && document.getElementById("txtNotSearch").value.length == 0){
				focuscheck = "true";
			}			 	
		
		
			if(focuscheck == "true"){	
			//alert("focuscheck2: " + focuscheck);


					if (focus == "and"){
						//alert(focus);
						document.getElementById('txtAndSearch').focus();
						//document.getElementById('txtAndSearch').value += " " + "[" + substance + "]" + " ";
						document.getElementById('txtAndSearch').value += substanceNewThes;
					}
					else{	
						if (focus == "any"){
							//alert(focus);					
							document.getElementById('txtAnySearch').focus();
							//document.getElementById('txtAnySearch').value += " " + "[" + substance + "]" + " ";
							document.getElementById('txtAnySearch').value += substanceNewThes;			
						}
					    else{					
							if (focus == "not"){
								//alert(focus);						
								document.getElementById('txtNotSearch').focus();
								//document.getElementById('txtNotSearch').value += " " + "[" + substance + "]" + " ";
								document.getElementById('txtNotSearch').value += substanceNewThes;								
							}
							else{
								focus = "and";
								document.getElementById('txtAndSearch').focus();
								document.getElementById('txtAndSearch').value += substanceNewThes;
							}	
						}
					}		
			} //focuscheck
	}   		    	
    
      
}	
	
//****************************************************************************************	
	
function CheckDoubleSubstance() {
//    	alert("checkdoubleSubstance");

    	newinputPropThes = substanceNew;
		//alert("newinputPropThes: " + newinputPropThes);
		
    	newinputPropThesTemp = "[" + newinputPropThes + "]";
		//alert("newinputPropThesTemp: " + newinputPropThesTemp);
	 		  	    

  	    // Klammer am Anfang und Ende der Suchfeld Eingabe suchen
  	    //var inputMollistStart = newinputMollist.search(/^\[/);
  	    //var inputMollistEnd = newinputMollist.search(/\]$/);

  	    var inputBraceStart = newinputPropThesTemp.search(/^\[/);
  	    var inputBraceEnd = newinputPropThesTemp.search(/\]$/);


		// wenn Klammer gefunden, ersetze Leerzeichen innerhalb Klammer mit Unterstrich
		// danach wird jeder Eintrag in Suchfeld ab Leerzeichen gesplittet	
    	if (inputBraceStart != -1 && inputBraceEnd != -1){		
			newinputPropThesTemp = newinputPropThesTemp.replace(/\s/g, "_");
			// Eintrag aus Thesaurus mit Unterstrich
			//alert("newinputPropThesTemp: " + newinputPropThesTemp);
    	}

		if (focus == "and"){
			//alert("focus auf AND");
			// Eingabe aus AND	 		  	    
            txtand = document.getElementById("txtAndSearch").value;
   			txtNew = txtand;
			txtOrig = txtNew;        
//			alert("txtNew: " + txtNew);			    	
  					
			LoopProp();
		}
			   

		if (focus == "any"){
			//alert("focus auf ANY");
			// Eingabe aus ANY	 		  	    
   	        txtany = document.getElementById("txtAnySearch").value;
   			txtNew = txtany; 
   			txtOrig = txtNew;   	
  								    					
			LoopProp();
		}
				
	   	if (focus == "not"){
			//alert("focus auf NOT");
			// Eingabe aus NOT	 		  	    
		    txtnot = document.getElementById("txtNotSearch").value;
        	txtNew = txtnot;
        	txtOrig = txtNew;
  					      			    	
			LoopProp();				    					
		}
					
}

function LoopProp(){
// alert("LoopProp");

					txtsearchfoundProp = "false";
//					alert("txtsearchfoundProp: " + txtsearchfoundProp);

					// Eintraege Suchfeld
					for (var i=0;i<txtNew.length;i++){
					//alert("txtNewfor : " + txtNew);						
//						alert("i= " + i + "buchstabe " + txtNew[i]);

						// Klammer am Anfang: search(/^\[/)								
						//if(txtNew[i] == '[' ){
						// charAt(), sonst erkennt es der IE nicht!								
						if(txtNew.charAt(i) == '[' ){
							txtStartBrace = "true";
						}   	

						// Klammer am Ende: search(/\]$/)
						//if(txtNew[i] == ']' ){
						if(txtNew.charAt(i) == ']' ){						
							txtStartBrace = "false";
						}   	
						    	
						// Klammer auf und zu gefunden und Eingabe enthaelt Leerzeichen     	
					   	//if(txtStartBrace == "true" && txtNew[i] == ' '){
					   	if(txtStartBrace == "true" && txtNew.charAt(i) == ' '){					   	
//					   		alert("Klammer gefunden");
							//alert("txtandNew[]: '" + txtandNew[i] + "'");
							// kein setCharAt in JSP	
							//txtandNew = setCharAt(txtandNew, i, '_');
							// ersetze Leerzeichen mit Unterstrich
							// Leerzeichen wird als Trenner fuer funktion split() verwendet
							txtNew = txtNew.substr(0,i) + '_' + txtNew.substr(i + 1, txtNew.length-1)
							// Eintrag in Suchfeld mit Unterstrich
							//alert("txtNew: " + txtNew);
						}
					}

	           	    // Eingabe splitten, um einzeln gegen neue Eingaben abzupruefen
   	                tempNew = txtNew.split(" ");
   	                // Eintrag in Suchfeld mit Unterstrich
   			        //alert("tempNewSplit: " + tempNew);   	                

					// neuer Eintrag wird auf Unterstrich durchsucht
		    		//var posTemp2 = newinputPropThesTemp.search(/_/); 
				    //alert("posTemp2: " + posTemp2);
					
					
				   // gesplittetes AND Array wird auf einzelne Eintraege geprueft	
		           //for(var i=1;i<=tempNew.length;i++) {
		           for(var i=0;i<tempNew.length;i++) {
				    	//alert("tempNew[i]: " + tempNew[i] + " ,newinpuMollist: " + newinputMollistTemp);
				    	// Eintrag in Suchfeld und aus Thesaurus mit Unterstrich
				    	//alert("tempNew[i]: " + tempNew[i] + " ,newinputPropThesTemp" + newinputPropThesTemp);

						// Eintrag in Suchfeld wird auf Unterstrich durchsucht
			    		//var posTemp1 = tempNew[i].search(/_/);
				    	//alert("posTemp1: " + posTemp1);			    			
			    		
			    		// Unterstrich in Mollist und Suchfeld gefunden	
//			    		if (posTemp1 != -1 && posTemp2 != -1){	
				    		//alert("posTemp1: " + posTemp1);			    			
				    		
				    		// neuer Eintrag bis Unterstrich
//				    		var tempNewSplit1 = tempNew[i].substr(0,posTemp1);
				    		//alert("tempNewSplit1: " + tempNewSplit1);
				    		// Eintrag in Suchfeld bis Unterstrich
//				    		var tempNewSplit2 = newinputPropThesTemp.substr(0,posTemp2);
				    		//alert("tempNewSplit2: " + tempNewSplit2);

			        			           	
							//if(tempNew[i] == newinputMollistTemp){
				    		// doppelten Eintrag gefunden							
//							if(tempNewSplit1 == tempNewSplit2){
							if(tempNew[i] == newinputPropThesTemp){															
							//if(tempNew[i] == newinputMollistTempSplit[i]){							
							    alert("Inputstring already in query!")
							    //alert("tempNew: " + tempNew);
				    			//alert("tempNew[i]: " + tempNew[i] +  " ,newinputPropThesTemp" + newinputPropThesTemp);				    	
							    txtsearchfoundProp = "true";
							    //alert("txtsearchfound: " + txtsearchfoundProp)
							    break;
							    //alert("txtsearchfound: " + txtsearchfound);
							    //return txtsearchfound;				    
							}
						
			    	}
    				

    				
				    //alert("txtsearchfound: " + txtsearchfoundProp)    				
    				// keinen doppelten Eintrag gefunden
    				if (txtsearchfoundProp == "false"){
					    //alert("txtsearchfound: " + txtsearchfoundProp)    					
						//txtNewSystem = newinputMollist;
						//alert("txtNewSystem Loop: " + txtNewSystem);
						// Eintrag in Klammern, Unterstrich wird mit Leerzeichen ueberschrieben
						// und an Suchfeld uebergeben
						//alert("newinputMollist: " + newinputMollistTemp);	
						newinputPropThes = newinputPropThesTemp.replace(/\_/g,' '); 
						// Eintrag aus Thesaurus in Klammern
						//alert("newinputPropThes Loop: " + newinputPropThes);
						substanceNew = newinputPropThes;		
						//alert("substanceNew: " + substanceNew);	
	
	
    				}	 
}    				

																								
//****************************************************************************************								

function startsubmit()
{
	nosubmit = false;

}

function CheckEnter(e) {	
	var browser = BrowserTest();
	
	if(!e) {var e = window.event;
        // Ereignis wird nur einmal verarbeitet, nicht mehrmals von verschiedenen Elementen	
		e.cancelBubble = true;
		// stopt den Ereignis-Fluss
		if(e.stopPropagation) e.stopPropagation();
	}
	var key = e.which ? e.which : e.keyCode;

/* alert('[' + typeof(key) + ']' + '[' + (key) + ']'); */

    // wenn Enter
	if (key == 13) {
	    // wird Wert von AndSearch abgefragt
    	/*if (document.Standard.txtAndSearch.value == ''){
			nosubmit = true;			
			document.Standard.txtAndSearch.focus();
		}
		else {*/
	    // search Btn erhaelt focus
			document.Standard.submitSimpleSearch.focus();
			nosubmit = true;			
            if(browser == "ie") nosubmit = false;
		//}
	}
}


function CheckEnterClear(event, wert) {
	value = wert;
	var browser = BrowserTest();
	var defaultButton = wert;
	
	if (browser == "ie" || browser == "ie-mac"){
	value = wert;
	
		CheckEnterClearIe(value);
	}
	else{
		nosubmit = true;
		switch(defaultButton) {
		
			case "clear":
				CheckEnterClearNs(event, value);
		}
	}				
}

function CheckEnterClearIe(wert) { 
	value = wert;
	var defaultButton = value;
	nosubmit = true;

   	switch(defaultButton) {
   		
	case"clear":		
	nosubmit = true;
		if (document.Standard.txtAndSearch.value != '' || document.Standard.txtAnySearch.value != '' || document.Standard.txtNotSearch.value != ''){
   			if(typeof event != 'undefined'){
				if (window.event.keyCode == 13) {
					nosubmit = true;
					// sonst bekommt txtAndSearch den focus nicht mehr?...
					//clearQuery();
				}
   			}
		}		
	break;
   	}
	defaultButton = "";
}   	


function CheckEnterClearNs(event, value) { 
	value = value;
	var defaultButton = value;	
	nosubmit = true;

   	switch(defaultButton) {
   		
		case"clear":		
   		nosubmit = true;
		if (document.Standard.txtAndSearch.value != '' || document.Standard.txtAnySearch.value != '' || document.Standard.txtNotSearch.value != ''){
   			if(typeof event != 'undefined'){
				if (event.which == 13) {
					nosubmit = true;
					clearQuery();
				}		
			}	
   		}
	break;
   	}
	defaultButton = "";
}   	


function checkSubmit() {
	if(nosubmit){
		nosubmit = false;
		return false;
	}
	else {
		return true;
	}
}


//****************************************************************************************
//
//	Überprüfen von Browser (Internet Explorer oder Netscape?)
//
//****************************************************************************************
function BrowserTest() {

	var browser = new String(navigator.userAgent);
	
	if (document.all) {
		if (browser.match("Mac_PowerPC"))
			return "ie-mac";
		else
			return "ie";
	}
	else
		return "ns";
}

//****************************************************************************************
//
//
//****************************************************************************************
function javaVersion() {
  props = new Array();
  i = 0;

  var now = new Date();
  now = now.toGMTString();
  dump += now + '\n\n';

  /*
    this indicates if the browser supports direct java method access
    shortcuts like:
      version = new java.lang.System.getProperty('java.version');
    result a javascript error
  */

  try {
    var obj = document["vmVersion"];
    if (typeof(obj) == 'object') {
      version = obj.vmVersion();
    } else {
      dump += '\nTestapplet not available.\nCheck the HTML code.\n\n';
    }
  } catch(e) {
    dump += 'number:\t\t' + e.number + '\n';
  }

  // important step that converts the version object into a string
  version = String(version);
  var available = ((version != null) ? ((parseFloat(version) >= parseFloat(required_version)) ? true : false) : false);

  return available;
}



function NetscapeEventHandler_KeyDown(e) {
    if (e.which == 13) {
        if (e.target.type == 'text') {
            document.getElementById('submitSimpleSearch').click();
        }
	    return e.target.type = 'submit';
    } else {
        return true;
    }
}

// IE bringt 'type' Fehler
/*function MicrosoftEventHandler_KeyDown() {
    if (event.keyCode == 13) {
        if (event.srcElement.type == 'text') {
            document.getElementById('submitSimpleSearch').click();
        }
        return event.srcElement.type = 'submit';
    } else {
        return true;
    }
}*/

function MicrosoftEventHandler_KeyDown() {
    if (event.keyCode == 13) {
        if (event.srcElement.type == 'text') {
        	if(document.getElementById('submitSimpleSearch').click()){
		        return event.srcElement.type = 'submit';
        	}
        }

    } else {
        return true;
    }
}

 
//****************************************************************************************
// ellen, 21.04. wenn nichts gefunden wurde, alertBox mit Info
// 11.05. jetzt von popup1.html uebernommen
//****************************************************************************************
function alertNoHits(){
	window.alert(unescape("No hits found%3F%0A" + 
						  "- Note%3A All database records are in English.%0A" + 
						  "- Check the thesaurus on the left side for valid search terms.%0A" + 
						  "- Use word fragments to find more hits %28e.g. %22rown%22 finds %22Brown%22 and %22crown-ether%22%29"));
}

//****************************************************************************************
function Operators(){
	/*fenster = window.open("/infothermTml/iHtml/alert1.html","popUp1", "width=500,height=170,left=400,top=400,resizable=no,statusbar=no");
	fenster.focus();
 	return false;*/
			    
	/*window.alert(unescape("AND, OR, NOT are no operators.%0A" + 
						  "- Make your search without operators."));
	*/ 

    if (document.getElementById('txtAndSearch').value != 0){
    	setFocusAnd();
    }
     						  
    if (document.getElementById('txtAnySearch').value != 0){
   		setFocusAny();
   	}
   	
   	if (document.getElementById('txtNotSearch').value != 0){
   		setFocusNot();
   	} 						  
   	 						  
}