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 img_id = 0;

function sndReq (obj_id, query) 
{
	var action = '';

	oText = document.getElementById(obj_id);
	action = './plugins/gal/gal_ajax.php?action=get_vote&img_id=' + query;
	img_id = query;
	
	try
	{
	    http.open('get', action);
    	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 == 'Ваш голос учтён.')
        	{
        		//стереть с лица страницы кнопку на голосование
				if (oText != null) 
				{
					if (navigator.appName == 'Netscape') oText.textContent = '';
					 else oText.innerText = '';
				}
				
				//увеличить счётчик проголосовавших на 1
				oCountVoice = document.getElementById('count_voice_'+img_id);
				if (oCountVoice != null)
				{
					if (navigator.appName == 'Netscape')
					{
						int_val = parseInt(oCountVoice.textContent) + 1;
						oCountVoice.textContent = int_val;
					}
					else
					   {
							int_val = parseInt(oCountVoice.innerText) + 1;
							oCountVoice.innerText = int_val;
					   }
				}
        	}
        	
        	if (alert_flag) alert (response); else alert_flag = true;
		}
    }
	catch(e){}
	finally{}
}

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