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
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

//function sndReq(vote,id_num,ip_num,units) {
function sndReq(vote,id_num,opt) {
	var theUL = document.getElementById('unit_ul'+id_num); // the UL
	
	// switch UL with a loading div
	theUL.innerHTML = '<div class="loading"></div>';
        setasread(id_num);
//alert(opt);
//alert('/rpc.php?j='+vote+'&q='+id_num+'&opt='+opt);

    xmlhttp.open('get', '/rpc.php?j='+vote+'&q='+id_num+'&opt='+opt);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);	
}

function handleResponse() {

  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1], update[2], update[3], update[4], update[5], update[6]);
        }
		}
    }
}

function changeText( div2show, text, rating, div2show_static, text_static, rating2, bid) {

//alert(div2show + text + rating + div2show_static + text_static + rating2 + bid);

    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"
    if (DOM) {
        var viewer = document.getElementById(div2show);
        viewer.innerHTML = text;
        if (document.getElementById(div2show_static)){
          var viewer_static = document.getElementById(div2show_static);
          viewer_static.innerHTML = text_static;
          var viewer2_static = document.getElementById('rating'+div2show_static);
          viewer2_static.innerHTML = rating2;
        }
        if (document.getElementById('rating'+div2show)){
          var viewer2 = document.getElementById('rating'+div2show);
          viewer2.innerHTML = rating;
        }
        var viewer3 = document.getElementById('thankyou'+div2show);
        viewer3.style.display = 'block';
        viewer3.innerHTML = '<div class="voted"><a href="/clearbookrating.phtml?id='+bid+'&action=removevote">исправить оценку</a></div>';
    }  else if(IE) {
        var viewer = document.getElementById(div2show);
        viewer.innerHTML = text;
        if (document.getElementById(div2show_static)){
          var viewer_static = document.getElementById(div2show_static);
          viewer_static.innerHTML = text_static;
          var viewer2_static = document.getElementById('rating'+div2show_static);
          viewer2_static.innerHTML = rating2;
        }
        if (document.getElementById('rating'+div2show)){
          var viewer2 = document.getElementById('rating'+div2show);
          viewer2.innerHTML = rating;
        }
        var viewer3 = document.getElementById('thankyou'+div2show);
        viewer3.style.display = 'block';
        viewer3.innerHTML = '<div class="voted"><a href="/clearbookrating.phtml?id='+bid+'&action=removevote">исправить оценку</a></div>';
    }
    setasread(bid);
}

/* =============================================================== */
