﻿function v(qid, m, v)	//the function that loads pages via AJAX
  {
      $.ajax({	//create an ajax request to load_page.php
          type: "POST",
          url: "/vote.aspx",
          data: 'id=' + qid + '&a=' + m + '&v=' + v, //with the page number as a parameter
          dataType: "html", //expect html to be returned
          success: function(msg) {

              $('#v' + qid).html(msg);


          } 
      })
  }

  function b(id)
  {
      $.ajax({
          type: "POST",
          url: "/basket.aspx",
          data: 'item=' + id,
          dataType: "html",
          success: function(msg) {

              $('#basket').html(msg);

              showCursorMessage('<div style="padding: 20px;"><nobr>Товар добавлен в корзину</nobr></div>');

          }
      })
  }


  function showCursorMessage(msg) {
      $.cursorMessage(msg);
  }


  $(document).ready(function () {

      $("input").keypress(function (e) { //change submit for input boxes. for input box create 'submit' atribute with value=class name of submit button
          if (((''+$(this).attr('submit')).length > 0) && ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))) {


              $("." + $(this).attr('submit')).click();
              return true;
          }
      });


      $("#searchFor").keypress(function (e) { //change submit for input boxes. for input box create 'submit' atribute with value=class name of submit button
          if (($(this).attr('submit').length > 0) && ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))) {

              window.location.replace('/find/' + ($('#searchFor').val().length > 0 ? $('#searchFor').val().replace(' ', '%20') : '%20')); return false;
          }
      });




  });




