/*
    © 2003 Verity, Inc. All rights reserved. Verity®, KeyView® are trademarks of
    Verity, Inc. in the USA and numerous other countries. All other marks or
    symbols are those of their respective owners. This software is licensed, not
    sold, and is subject to worldwide copyright laws and the terms of the Verity,
    Inc. software license agreement contained in this package.
 *
 * File: basicQuery.js
 *
 * Javascript for Verity K2 Enterprise Web Sample Templates - Basic Query
 *
 * Depends upon:
 *      none
 */

    //this function is to reset the query text to "" if user clicks Refine search button
    //and set back to last query text if New search button is clicked again
    
    var g_strQueryText = "";
    var g_blnLastChecked = false;


    
    function changeSType() 
    {
        var objCheckbox = document.getElementById("SearchWithinResults");

        if (document.getElementById("QueryText") && objCheckbox) {
            var strOldQueryText = document.getElementById("QueryText").value;
            document.getElementById("QueryText").value = g_strQueryText;
            g_blnLastChecked = objCheckbox.checked;
            g_strQueryText = strOldQueryText;

        }
    }
    

    //klbr 25.11.2004
    //diese Funktion steuert das AutoSubmit von Suchanfragen in anderen frames
    //zum Suchanfragefeld des basicQuery.asp über das onSubmit="AutoSubmit('0')
    //Achtung: der Suchtext wird per $_POST methode mit übertragen

    function AutoSubmit(cFlag, nFrame) 
    {
       
       //hidden input Feld dient als flag Variablen Speicher (value wird auf 1 gesetzt)
       
       if (cFlag == '1') {
           document.getElementById("flag").value = "1";
       } 
       
       //es verhindert ein ständiges submit (erst wenn ein neuer Suchtext eingegeben wird,
       //wird die hidden input value wieder 1 und dann hier (nach einem kleinen delay) ein neues submit durchführen
       //nach jedem Submit wird der Wert im PreQueryText gelöscht
       
       if (cFlag == '0') {
           if (parent.frames[nFrame].document.getElementById("flag").value == "1") {
               
               //zuerst wird der Wert vom PreQueryText Feld geholt 
               document.getElementById("QueryText").value = parent.frames[nFrame].document.getElementById("PreQueryText").value;
               
               //Hidden Feld Flag zurücksetzen
               parent.frames[nFrame].document.getElementById("flag").value = "0";            
               
               //Pause und Submit
               setTimeout("document.forms[0].submit()", 100);
               
               //Wert im PreQueryText löschen
               parent.frames[nFrame].document.getElementById("PreQueryText").value = "";
           }
       }   
    }
     