function initXR() {	//инициализация XML запроса
	var req;

	if(window.XMLHttpRequest)
		req = new XMLHttpRequest();
	else
		if(window.ActiveXObject) {
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e) {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}

		return req;
}

function my_rank(id) {	//загорание звёзд при наведении
	var d = document.getElementById(id);
	num = id.substring(id.indexOf('-') + 1, 6);
	prod = id.substring(id.indexOf('_') + 1, id.length);
	
	for(i = 1; i <= 5; i++)
	{
		if(num>=i)document.getElementById('star-' + i + '_' + prod).className = "rating_star_red";
		else document.getElementById('star-' + i + '_' + prod).className = "rating_star_black";
	}
}

function cur_rank(norm, prod) {	//текущее кол-во звёзд
	for(i = 1; i <= 5; i++)
	{
		if(norm>=i)document.getElementById("star-" + i + '_' + prod).className = "rating_star_red";
		else document.getElementById("star-" + i + '_' + prod).className = "rating_star_black";
	}
}

function set_rank(rank, product_id) {	//отправить запрос
	var req = initXR();
	if(req) {
		try {
			var temp = "";
			document.getElementById('product_rating_' + product_id).innerHTML = 'Загрузка...';

			req.open('GET', '_product.php?productID=' + product_id + '&vote=' + rank + '&');
			req.onreadystatechange = function() {
				if(req.readyState == 4)
					if(req.responseText)
						document.getElementById('product_rating_' + product_id).innerHTML = req.responseText;
			}

			req.send(null);
		}
		catch(e) {
			alert("Произошла ошибка: " + e);
		}
	}
}