function send_http_request(args) {
 args = args || {};

 var is_timed_out = false;
 var timer = null;

 if (args.timeout) {
  timer = setTimeout(function () {
   is_timed_out = true;
   if (args.ontimeout) {
    args.ontimeout();
   }
   if (args.onfail) {
    args.onfail();
   }
   if (args.onfinish) {
    args.onfinish();
   }
  }, args.timeout);
 }

 var xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");

 xmlhttp.onreadystatechange = function () {
  if ((!is_timed_out) && (xmlhttp.readyState == 4)) {
   clearTimeout(timer);
   timer = null;
   if (xmlhttp.status == 200) {
    if (args.ontextready) {
     args.ontextready(xmlhttp.responseText);
    }
    if (args.ondataready) {
     var data = eval('res=' + xmlhttp.responseText + ';res');
     args.ondataready(data);
    }
    if (args.onfinish) {
     args.onfinish();
    }
   } else {
    if (args.onerror) {
     args.onerror(xmlhttp.status, xmlhttp.responseText);
    }
    if (args.onfail) {
     args.onfail();
    }
    if (args.onfinish) {
     args.onfinish();
    }
   }
  }
 };

 xmlhttp.open(args.method||'GET', args.url, args.async||true, args.user, args.passwd);
 xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
 xmlhttp.send(args.data||null);
}

function add_item(key) {
send_http_request({
 url: '/catalog/add/'+key+'?ajax=1',
 timeout: 20000,
 method: 'GET',
 async: false,
 ontextready: function(response_text) {
    alert("Товар добавлен");
    update_goods_info();
 }
 
});



return false;

}

function update_goods_info() {
send_http_request({
 url: '/catalog/count/',
 timeout: 20000,
 method: 'GET',
 async: false,
 ontextready: function(response_text) {
        obj = document.getElementById('good_count');
        if (obj) {
            obj.innerHTML = response_text;
}
 }
 
});

send_http_request({
 url: '/catalog/fullprice/',
 timeout: 20000,
 method: 'GET',
 async: false,
 ontextready: function(response_text) {
        obj = document.getElementById('full_price');
        if (obj) {
            obj.innerHTML = response_text;
}
 }
 
});

return false
}
