
Zoekformulier = {};

$(document).ready(function() {       

    // auto aanvul op trefwoord
    sUrl = Website.Config.sBaseUrl +'zoekmachine/zoeken-autocomplete/zoek';        
    $("#q").autocomplete(sUrl, { 
                                delay:400,
                                selectFirst:1,
                                multiple:0,
                                onItemSelect:Zoekformulier.selectItem,
                                autoFill:false
                               }
                        );    
   
    
    // thema en type default niet tonen
    $("div#typeDocumentContainer").css('display', 'none');
    $("div#themaContainer").css('display', 'none');
    
    // type documenten/themas in en uitklappen
    $('select#soort').change(Zoekformulier.soortController);
    Zoekformulier.soortController();        
    
    
    // standaard zoek info + link 'uitgebreid zoeken' niet tonen 
    $('#uitklapUitgebreidZoekenForm').css('display', 'none');
    $('.gezochtOp').css('display', 'none');
    
    // na klik op link zoekformulier tonen
    $('#uitklapUitgebreidZoekenForm').click(Zoekformulier.uitklapFormulier);
    Zoekformulier.uitklapFormulier;    
}); 



Zoekformulier.findValue = function(li) {
    if( li == null ) return alert("Geen resultaat!");

    // if coming from an AJAX call, let's use the CityId as the value
    if( !!li.extra ) var sValue = li.extra[0];

    // otherwise, let's just display the value in the text box
    else var sValue = li.selectValue;
}

Zoekformulier.selectItem = function(li) {
    Zoekformulier.findValue(li);
}




Zoekformulier.uitklapFormulier = function() {      
    $('#uitgebreidZoekenForm').css('display', '');
    $('#uitklapUitgebreidZoekenForm').css('display', 'none');
    $('div.themaTagZoekTerm').css('display', 'none');
};

Zoekformulier.toonZoekInfo = function() {                     
    $('#uitgebreidZoekenForm').css('display', 'none');
    $('.gezochtOp').css('display', '');
    $('#uitklapUitgebreidZoekenForm').css('display', '');    
}


Zoekformulier.soortController = function() {            
             
    // Documenten - toon type document en thema velden
    if( $("select#soort option:selected").val() == 'documenten' ) {
        $("div#typeDocumentContainer").css('display', '');
        $("div#themaContainer").css('display', '');                
    }    
    // Thema - toon thema veld
    else if( $("select#soort option:selected").val() == 'nieuws' || $("select#soort option:selected").val() == 'agenda') {
        $("div#typeDocumentContainer").css('display', 'none');
        $("div#themaContainer").css('display', '');                
    }    
    else {
        $("div#typeDocumentContainer").css('display', 'none');
        $("div#themaContainer").css('display', 'none');                        
    }         
};



