﻿$(document).ready(function() {
      $("#topmenubar").setActiveTab();
    $('#itemsearchbutton').click(function() {
        itemSearch();
        return false;
    });
    document.lookupHash = new Hash();
    var lastValue;
    //$("#itemsearchinput").autocomplete("/ajaxpages/AjaxGet.aspx?classname=CwWPGenerator&methodname=execute&webpartid=ProductAutoSuggest.ax", { width: 300, scroll: false, scrollHeight: 350 });
    $("#itemsearchinput").keydown(function(e) {
        switch (e.keyCode) {
            case KEY.RETURN:
                //$('#itemsearchinput').val(lastValue);
                itemSearch();
                return false;
            default:
                lastValue = $('#itemsearchinput').val();
                return true;
        }
    });
    /*if($('#ProductListGrid').length){
        $('input.num[name=qty]',$('#ProductListGrid')).
    }*/
});
function itemSearch() {
    if(document.productViewWebPartId === undefined)
        document.productViewWebPartId = 'ProductView.ax';
        
    if ($('#itemsearchinput').val()) {
        window.location = '/?webpartid='+document.productViewWebPartId+
                            '&search=true' +
                            '&searchparam=itemsearchinput' +
                            '&itemsearchinput=' + encodeURIComponent($('#itemsearchinput').val());
    }
    return true;
}
function refreshMiniBasket(){
    var options = { loadinto: '.minibasketwrapper', webpartid: 'Jegs-MiniSalesBasket.ax' };
    serverConnector.loadHtml(options);
}

function refreshMenuVert(){
    var options = { loadinto: '.ctl00_prodnavdynamic', webpartid: 'ProductCatalog.ax' };
    serverConnector.loadHtml(options);

}
