var fadeTime = 250;
$(document).ready(function(){
    var opts = $("#s_type_opts");
    var a = $("#s_type_a");
    var hi = $("input[name=s_type]");
    var f = $("#top_search");
    var t = $("#searchBoxInput");
    a.click(function(){
        if(opts.css("display")=="none") {
            opts.fadeIn(fadeTime);
        } else {
            opts.fadeOut(fadeTime);
        }
        return false;
    });
    
    $("#s_type_opts li a").click(function(){
        if(opts.css("display")!="none") {
            a.html($(this).html());
            hi.val($(this).html());
            opts.fadeOut(fadeTime);
        }
        return false;
    });

    $("body").click(function(){
        if(opts.css("display")!="none") {
            opts.fadeOut(fadeTime);
        }
    });

    f.submit(function(){
        var v = hi.val();
        if(t.val() != "cauta") {
            switch(v.toLowerCase()) {
                case "articole":
                    location.href = "/articole/cauta/?s="+t.val();
                    break;
                case "unitati medicale":
                    location.href = "/unitati-medicale/cauta/?s="+t.val();
                    break;
                case "medici":
                    location.href = "/medici/cauta/?s="+t.val();
                    break;
            }
        } else {
            
        }

        return false;
    });
});

