function createRequestObject() 
{
	var xmlhttp;
	
	try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(f) {
             xmlhttp = false;
        }
    }
    
    if(!xmlhttp && typeof XMLHttpRequest != "undefined")
    {
		try {
            xmlhttp = new XMLHttpRequest();
        } 
        catch (e) {
	    	xmlhttp = false;
        }    	
    }
    
	return  xmlhttp;
}

var http = createRequestObject();
var reload_flag = '';
var alert_flag = true;
var oText = null;
var old_text = null;


function recount_basket (form_obj, query)
{
	//obj = document.getElementById();
	//
	
	alert (document.list_basket.elements);
	
	//for (index = 0; index <= document.list_basket; index ++)
	//{
		
	//}
	
}


function sndReq (obj_id, query) 
{
	oText = document.getElementById(obj_id);
	
	//сказать пользователю, чтобы он немного подождал
	if (oText != null) 
	{
		if (navigator.appName == 'Netscape')
		{
			old_text = oText.textContent;
			oText.textContent = 'Подождите пока товар добавляется в корзину.';
		}
		else {
			old_text = oText.innerText;
			oText.innerText = 'Подождите пока товар добавляется в корзину.';
		}
	}
	
	try
	{
	    http.open('get', query);
    	http.onreadystatechange = handleResponse;
    	http.send(null);
	}
	catch(e){
		alert ('Не смог отправить запрос. Запрашиваемая процедура не будет завершена.');
	}
	finally{}
}


function handleResponse() 
{
	try
	{
    	if((http.readyState == 4) && (http.status == 200))
    	{
        	var response = http.responseText;
        	
        	if ( (response == 'Товар добавлен в корзину.') || (response == 'Такой товар уже есть в корзине.\r\nКоличество данного товар увеличено на 1.') )
        	{
				//увеличить счётчик проголосовавших на 1
				oCountGoods = document.getElementById('count_goods');
				if (oCountGoods != null)
				{
					if (navigator.appName == 'Netscape')
					{
						int_val = parseInt(oCountGoods.textContent) + 1;
						oCountGoods.textContent = int_val;
					}
					else
					   {
							int_val = parseInt(oCountGoods.innerText) + 1;
							oCountGoods.innerText = int_val;
					   }
				}
        	}
        	
        	if (alert_flag)
        	{
        		alert (response); 
        		
				//вернуть старый текст на место
				if (oText != null) 
				{
					if (navigator.appName == 'Netscape') oText.textContent = old_text;
					 else oText.innerText = old_text;
				}
        	}
        	else alert_flag = true;
		}
    }
	catch(e){}
	finally{}
}

function сhange_сursor(obj_id)
{
	var obj = document.getElementById(obj_id);
	obj.style.cursor = 'hand';
} 
