﻿$(document).ready(function () {
    $("#barcode").autocomplete({
        minLength: 2,
        source: function (request, response) {
            $.ajax({
                url: "/Home/FindBarcode/",
                type: "POST",
                data: { "barcode": request.term, "maxResults": 10 },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.barcode, value: item.barcode, id: item.id };
                    }))
                }
            })
        },
        select: function (event, ui) {
            top.location = (ui.item) ?
					findProductBase + "/" + ui.item.value :
					searchSubmitTo + "/" + this.value;
        },
        autoFocus: true
    });
    $("#searchForm").submit(function () {
        submitSearch();
        return false;
    });
    $("#searchFormSubmit").click(function () {
        submitSearch();
        return false;
    });
    
    swfobject.embedSWF('/Client/top.swf', "topSwf", "678", "147", "9.0.0");

});
function submitSearch() {
    if ($("#mFree").val()) {
        top.location = searchSubmitTo + "/" + $("#mFree").val();
    } 
};
