    $(document).ready(function () {

            window.name = hwnd()

        	$("#search").autocomplete('/ajax.php?a=search', {
        		width: 266,
        		multiple: false,
        		matchContains: true
        	})

            $.ajax({
                url: 'ajax.php',
                data: 'a=checked',
                cache: false,
                success: function (data, textStatus) {
                    keys = data.split(',')
                    for(var i in keys) $(".check"+keys[i]).addClass('checked')
                }
            })


    })

    function wopen(w,h,path,id,resizable, scrolling){
        t = (screen.height-h-30)/2;
        l = (screen.width-w-30)/2;
        hwnd = window.open(path, 'window'+id, "top="+t+",left="+l+",width="+w+",height="+h+",resizable="+resizable+",scrollbars="+scrolling);
        hwnd.focus()
    }

    function basket(id) {
       $.ajax({
           url: '/ajax.php',
           cache: false,
           async: false,            // для корректной работы кук
           data: {a:'tobask',id:id},
           dataType : "json",
           success: function (data, textStatus) {
            if (data.empty) {
               $("._basket").css({'display':'none'})
               $("._basket_empty").css({'display':'inline'})
            } else {
               $("._basket").css({'display':'inline'})
               $("._basket_empty").css({'display':'none'})
               $("._basket_value").html(data.value)
               $("._basket_price").html(data.price)
            }
          }
       })
    }

    function _to_bask(id) {
        $(".check"+id).addClass('checked')
        basket(id)
	}

//Генерация идентификатора окна
   function hwnd() {
     var date = new Date()
     return date.getTime()
   }
