function gethttp(url)
    {
    var p=null;
    if (window.ActiveXObject)
        {
        try {
            p=new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e){}
        if (!p)
           {
           p=new ActiveXObject("Msxml2.XMLHTTP");
           }
        } else {
               p=new XMLHttpRequest();
               }
    p.open("GET",url, false);
    p.setRequestHeader("Pragma", "no-cache");
    p.setRequestHeader("Cache-Control","no-cache, must-revalidate");
    p.setRequestHeader("If-Modified-Since","Mon, 1 Oct 1917 06:00:00 GMT");
    p.send(null);
    r = p.responseText;
    p = null;
    return r;
    }
function posthttp(url,dat)
  {
  var p=null;
  if (window.ActiveXObject)
    {
    try {p=new ActiveXObject('Microsoft.XMLHTTP');} catch(e){}
    if(!p) {p=new ActiveXObject('Msxml2.XMLHTTP');}
    } else {p=new XMLHttpRequest();}
  p.open('POST',url,false);
  p.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  p.send(dat);
  return p.responseText;
  }

function comments_insert(r,i)
    {
    if (document.getElementById('comments_nick').value!='' && document.getElementById('comments_email').value!='' &&
        document.getElementById('comments_msg').value!='' && document.getElementById('captcha').value!='' )
       {
       rc=posthttp( '/','captcha_code='+document.getElementById('captcha').value+
                   '&r='+r+
                   '&i='+i+
                   '&comments_msg='+encodeURIComponent(document.getElementById('comments_msg').value)+
                   '&comments_nick='+encodeURIComponent(document.getElementById('comments_nick').value)+
                   '&comments_email='+encodeURIComponent(document.getElementById('comments_email').value) );
       if(rc!="0") {
                   document.getElementById('comments_list').innerHTML=rc+document.getElementById('comments_list').innerHTML;
                   document.getElementById('comments_msg').value='';
                   } else alert('Неверно указано число с картинки');
       document.getElementById('captcha').value='';
       var d=new Date;
       document.getElementById('captcha_img').src='/?captcha='+parseInt(d.getTime());
       } else alert('Заполнены не все поля');
    }

function comments_form(r,i)
    {
    document.getElementById('comments_form').innerHTML=gethttp( '/?comments_button=1&r='+r+'&i='+i );
    document.getElementById('comments_nick').focus();
    }
function comments_page(r,i,page)
    {
    document.getElementById('comments_box').innerHTML=gethttp( '/?comments_page='+page+'&r='+r+'&i='+i );
    }
