function get_http(){
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new
                ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    @else
        xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

/** Ajax **/
function ajax(data, value) {
	this.http = get_http();
	this.working = false;
	var url = 'inc/ann.php';
	if (!this.working && this.http) {
	   	var http = this.http;
	    url = url + '?';
	    var arr_data = data.split('::');
	    var arr_value = value.split('::');
	    for(i=0; i<arr_data.length; i=i+1) {
        	url = url + arr_data[i] + '=';
        	if(arr_value[i]) url = url + encodeURIComponent(arr_value[i]);
        	url = url + '&';
    	}
		this.http.open("GET", url, true);
	    this.http.onreadystatechange = function() {
			if (http.readyState == 4) {
        	   	fill(http.responseText);
                this.working = false;
	        }
    	}
        this.working = true;
	    this.http.send(null);
	}
	if(!this.http) {
    	alert('Ошибка при создании XMLHTTP объекта!')
	}
}
function fill (data) {
	var insert = document.getElementById('sps_ann');
	insert.innerHTML = data;
}

function update_count (id, kol) {
	var count = document.trash.tovar_count;
	var price = document.trash.tovar_price;
	var sum = 0;
	if (count.length > 1) {
		for(var i=0; i<count.length; i++) {
			sum += price[i].value*count[i].value;
		}
	}
	else sum = count.value*price.value;
	document.getElementById('summ').innerHTML = sum;
	document.getElementById(id).value = kol;
}
