function catOption(val)
    {      
        f  = window.document.recipeSrch;             
        f.stchwrtID.value = val.value;
        f.stchwrt2ID.value = 'notNull';
        
        f.adv.value = document.getElementById("advanced").style.display; //to keep advanced menu in previouse state
        
        f.forspecial.value = document.getElementById("eye").checked;
    //   alert(f.forspecial.value);
        isadv = is_adv();        
        
        f.submit();
        
    }
    
	function focusSchlagwort()
	{
		var doc = window.document.recipeSrch;
		if(doc){
			window.document.recipeSrch.schlagwort.focus();	
		}
	}
	
    function subcatOption(val)
    {
        //alert(val.value);
        document.recipeSrch.stchwrt2ID.value = val.value;
       // alert(document.recipeSrch.stchwrt2ID.value);
    }
    
    function goForth(id)
    {
        document.fromDetails.rcp.value = id;
        document.fromDetails.submit();
        
    }
    
    function goForthVariant(id, variant)
    {
        document.toVariant.rcp.value = id;
        document.toVariant.varNum.value = variant;
        document.toVariant.submit();
    }  
    
    function goBack()
    {
    	 	//   alert("TUT" + f.adv.value + "\n" + f.schlagwort.value);
        document.fromDetails.submit();
    } 
    
    function schlgwrtSch()
    {
        f=window.document.recipeSrch;
        //f2=window.document.fromDetails;
        strKeyword = f.schlagwort.value;        
        //if( (trim(strKeyword) == '') || (strKeyword.length < 2) ){ alert("Das Schlagwort muss zumindest teilweise eingegeben werden (mindestens 2 Zeichen)!"); document.recipeSrch.schlagwort.focus(); }else{
        //alert("keyWrd: "+trim(strKeyword)+"\n"+"Cat: "+f.category.value+"\n"+"subCat: "+f.subcategory.value);
        
        f.adv.value = document.getElementById("advanced").style.display;
        isadv = is_adv();
        //alert("isadv: " +isadv+"\n"+ f.adv.value);
        //alert(document.getElementById("eye").checked);
        
        f.forspecial.value = document.getElementById("eye").checked;
      
        if((f.category.value=='0' && f.subcategory.value == 'notNull' && trim(strKeyword) == '') && (isadv == 0) && !document.getElementById("eye").checked){
            alert("Wenn Sie nach allem suchen möchten, geben Sie im Feld Schlagwort bitte mindestens einen Suchbegriff ein.");
            f.schlagwort.focus();
        }else{
	        f.search.value = '1';	        
	        f.submit();
        }
        
        
    }
    
    function trim(str)
    {
        var newstr = str.replace(/^\s*(.+?)\s*$/, "$1");
        if (newstr == " ") {
            return "";
        }
        return newstr;
    }
    
    function advancedform()
    {
	    	var f = window.document.recipeSrch;
	      
	      if (document.getElementById("advanced").style.display == "none"){
		         document.getElementById("advanced").style.display = "block"; 
		         document.getElementById("advanced_off").style.display = "block";
		         document.getElementById("advanced_on").style.display = "none";
	      }else{                    
		         document.getElementById("advanced").style.display = "none";
		         document.getElementById("advanced_off").style.display = "none";
		         document.getElementById("advanced_on").style.display = "block"; 
		         
		         /* close advanced options and clean all advanced fields */
							    var inputs = document.getElementsByTagName("input");
                  for (var i =0; i<inputs.length; i++){
                      if(inputs[i].name.substring(0,2) == "w_" || inputs[i].name.substring(0,2) == "h_"){	
                       inputs[i].value =  "";                       
							    	}							
		         /*                    end           */
	      		}    
    		}
  }
    
    function is_adv()
    {
    	if (document.getElementById("advanced").style.display == "block"){
	    	f = document.recipeSrch;
				el = document.getElementById("schlagwort");
	
				allw = f.elements["w_all"].value;
				exact = f.elements["w_exact"].value;
				any = f.elements["w_any"].value;
				without = f.elements["w_without"].value;
	
				allw = trim(allw);
				exact = trim(exact);
				any = trim(any);
				without = trim(without);
				
				if( allw=="" && exact=="" && any=="" && without==""){
					f.withadv.value = 0;
					return 0;
				}else{ 
					f.withadv.value = 1;
	        		      	
	        f.h_allw.value = trim(f.w_all.value);	        	
	        	
	        f.h_exact.value = trim(f.w_exact.value);
	        		        	
	        f.h_any.value = trim(f.w_any.value);
	        	
	        f.h_without.value =trim(f.w_without.value);
	        	
					return 1; 
				}
			}else{
				f.withadv.value = 0;
				return 0;
			}
    }
    
    function take_advanced()
    {
    	f = document.recipeSrch;
			el = document.getElementById("schlagwort");

			allw = f.elements["w_all"].value;
			exact = f.elements["w_exact"].value;
			any = f.elements["w_any"].value;
			without = f.elements["w_without"].value;

			allw = trim(allw);
			exact = trim(exact);
			any = trim(any);
			without = trim(without);
			
			if( allw=="" && exact=="" && any=="" && without==""){
				return;
			}
						
			if(el.value!=""){
				if (!confirm("Schlagwort gemäß der erweiterten Suchoptionen modifizieren?")){				
					return;
				}
			}
			
			
    }