    //search adds value from query
    function doSearch(e,link,useSearchbar){
        var evt=window.event || e
        var finalLink=link+encodeURIComponent($('.query').val().replace("%","&#37;"));
        if(($("#showSearchBar:checked").length>0||useSearchbar)&&(evt.keyCode==0||evt.keyCode==13||null==evt.keyCode)){
            $.cookie('hideSearchBar', "false",{ expires: 700, path: '/' });
            if(evt.altKey || (!$.browser.msie && evt.button == 1) || ($.browser.msie && e.button == 4) ){
                window.open(finalLink);
            }else{
                self.parent.location.href=finalLink;
            }
        }else if(evt.keyCode==0||evt.keyCode==13||null==evt.keyCode){
            $.cookie('hideSearchBar', "true",{expires: 700, path: '/' });
             finalLink+="&hideSearchBar=true";
            if(evt.altKey){
                window.open(finalLink);
            }else{
                self.parent.location.href=finalLink;
            }
        }
    }

    //do first searchLink on enter
    function enterSearch(event){
        if(event.keyCode==13){
          $("#button1").click();
          return false;
        }
    }
    
//search.gsp

    function scaleSearchResult(){
        $("#searchResult").css("height",$(window).height()-50+"px");
    }

 $(document).ready(function () {
    //remove noJavascriptLayer
    //$("#noJavascript").remove();

    //Set dofair searchbar to cookie value
    if($.cookie('hideSearchBar') == "true"){
        $("#showSearchBar").removeAttr("checked");
    }else if($.cookie('hideSearchBar') == "false"){
        $("#showSearchBar").removeAttr("checked");
        $("#showSearchBar").attr("checked","checked");
    }
    //fade menuItems in and out
    var naviHoverConfig = {
        timeout: 100,
        over: function(){$(this).find(".subNavigation").fadeIn(130);},
        out: function(){$(this).find(".subNavigation").fadeOut(130);}
    };
    if($(".navigationItem").length>0){
        $(".navigationItem").hoverIntent(naviHoverConfig);
    }

    //fade contentboxes
     var contentBoxHoverConfig = {
        timeout: 300,
        over: function(){$(this).find(".contentBoxes").fadeIn(130);$(this).find(".arrow").toggleClass("arrowUp");},
        out: function(){$(this).find(".contentBoxes").fadeOut(130);$(this).find(".arrow").toggleClass("arrowUp");}
    };

    if($("#contentBoxesWrapper").length>0){
        $("#contentBoxesWrapper").hoverIntent(contentBoxHoverConfig);
    }

    //fade lang switch
     var langHoverConfig = {
        timeout: 300,
        over: function(){$(this).find(".langSelect").fadeIn(130);$(this).find(".arrow").toggleClass("arrowOpen");},
        out: function(){$(this).find(".langSelect").fadeOut(130);$(this).find(".arrow").toggleClass("arrowOpen");}
    };

    if($("#langSwitch").length>0){
        $("#langSwitch").hoverIntent(langHoverConfig);
    }

    //make parent of active submenu active too
    if($(".subNavigation .itemActive")>0){
        $(".subNavigation .itemActive").parent().parent().addClass("itemActive");
    }


    //make .head toggable
    $(".head").click(function() {
        $(this).parent().toggleClass("expanded");
        $(this).find(".arrow").toggleClass("arrowOpen");
        if($(this).parent().parent().hasClass("searchEnginesCategory")||$(this).parent().parent().hasClass("category")){
            $(this).toggleClass("notExpanded");
        }
        $(this).next().slideToggle('normal');
        return false;
    });

    //set focus to queryfield
    // DANGER AJAX URL delete /cmsm/ for deploy
    $("#query").focus().autoComplete({ajax: "/search/getSearchSuggest/",
        postVar: "query",
        multiple:true,
        delay:115,
        minChars:4,
        maxRequests:7,
        ajaxCache:true,
        preventEnterSubmit:true,
        striped:"suggest_alt",
        width:"498px"});

     if($("#querySmall").length>0){
        $("#querySmall").autoComplete({ajax: "/search/getSearchSuggest/",
        postVar: "query",
        multiple:true,
        delay:115,
        minChars:4,
        maxRequests:5,
        ajaxCache:true,
        preventEnterSubmit:true,
        striped:"suggest_alt",
        width:"330px"});
     }

    $("#magnifySubmit").click(function(){
        $("#button1").click();
    }
    );

 });