function $(elid){
return document.getElementById(elid);
}
function display_element(elid)
{
     if(document.getElementById(elid).style.display=='none')
          document.getElementById(elid).style.display='';
     else
          document.getElementById(elid).style.display='none';
}

function AjaxLoadPage(url,elid){
     dest=elid;
     if(elid != ''){
          loadXML_ANSI(url);
     }
}

function loadXML_ANSI(url) 
{
     document.getElementById(dest).innerHTML="<img src='/images/progress.gif'>";
     text_res="";
     chatReq = (window.XMLHttpRequest) ? new XMLHttpRequest() : (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null;
     if (chatReq) 
     {
          chatReq.onreadystatechange = _chatLoadData;
          chatReq.open("GET", url+'&timeempvalue='+escape(Date()), true);
		  chatReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
//          chatReq.open("GET", url, true);
          chatReq.send(null);
     } 
     else 
     {
          alert('Ваш браузер неподдерживает XMLHttprequest');
     }
}

function _chatLoadData(){
     try {
          if (chatReq.readyState == 4) {
               if(chatReq.status==200){
                    document.getElementById(dest).innerHTML = chatReq.responseText;
                    chatReq.responseText = null;
               } // if
               chatReq=null;
          } // if
     } // try
     catch (e) {
          //
     } // catch
}
       function ajax_popup(url,elementid,parentelement){
               if($(elementid)){
               }
               else
               {
                    destinfo = elementid;
                     infoDiv = document.createElement('DIV');
                     parentelement.appendChild(infoDiv);
                     infoDiv.setAttribute('id',elementid);
                     infoDiv.style.position = 'absolute';
                     infoDiv.style.background = '#ffffff';
                     infoDiv.style.border = '1px solid black';
                     infoDiv.style.position = 'absolute';
                    infoDiv.innerHTML="<img src='/images/progress.gif'>";
                   text_res="";
                   
                    chatReq = (window.XMLHttpRequest) ? new XMLHttpRequest() : (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null;
                    if (chatReq) 
                    {
                         chatReq.onreadystatechange = InfoLoadData;
                         chatReq.open("GET", url+'&timeempvalue='+escape(Date()), true);
                           chatReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
                         l_eventx = event.x;
                         l_eventy = event.y;
                              var x = l_eventx;
                              var y = l_eventy;
                              if (document.body.clientWidth < x + 10) x -= 10;
                              if (document.body.clientHeight < y + infoDiv.clientHeight) y -= infoDiv.clientHeight - 20;
                           	infoDiv.style.top = y + document.body.scrollTop;
                              infoDiv.style.left = x + document.body.scrollLeft;
                              infoDiv.style.display = '';
                         chatReq.send(null);
                    } 
                    else 
                    {
                         alert('Ваш браузер неподдерживает XMLHttprequest');
                    }
               }
          }
          function InfoLoadData(){
          if (chatReq.readyState == 4) {
               if(chatReq.status==200){
                    infoDiv = document.getElementById(destinfo);
                infoDiv.innerHTML = "<TABLE><TR class='forum_tbl_title'><TD align='right' style='cursor:hand;' onclick='javascript:$(\""+destinfo+"\").parentNode.removeChild($(\""+destinfo+"\"));'>X<TR><TD>"+chatReq.responseText+"</TABLE>";
                         var x = l_eventx;
                         var y = l_eventy;
                         if (document.body.clientWidth < x + infoDiv.clientWidth) x -= infoDiv.clientWidth;
                         if (document.body.clientHeight < y + infoDiv.clientHeight) y -= infoDiv.clientHeight - 20;
                         infoDiv.style.top = y + document.body.scrollTop;
                         infoDiv.style.left = x + document.body.scrollLeft;
                         if(infoDiv.style.top.substr(0,1)=='-')infoDiv.style.top=0;
                         infoDiv.style.display = '';
               } // if
               chatReq=null;
          } // if
          }
          
      function ajax_popup_body(url,elementid){
               if($(elementid)){
                    $(elementid).parentNode.removeChild($(elementid));
               }
               else
               {
                    destinfo = elementid;
                     infoDiv = document.createElement('DIV');
                     document.body.appendChild(infoDiv);
                     infoDiv.setAttribute('id',elementid);
                     infoDiv.style.position = 'absolute';
                     infoDiv.style.background = '#ffffff';
                     infoDiv.style.border = '1px solid black';
                     infoDiv.style.position = 'absolute';
                    infoDiv.innerHTML="<img src='/images/progress.gif'>";
                   text_res="";
                   
                    chatReq = (window.XMLHttpRequest) ? new XMLHttpRequest() : (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null;
                    if (chatReq) 
                    {
                         chatReq.onreadystatechange = InfoLoadData;
                         chatReq.open("GET", url+'&timeempvalue='+escape(Date()), true);
                           chatReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
                         l_eventx = event.x;
                         l_eventy = event.y;
                              var x = l_eventx;
                              var y = l_eventy;
                              if (document.body.clientWidth < x + 10) x -= 10;
                              if (document.body.clientHeight < y + infoDiv.clientHeight) y -= infoDiv.clientHeight - 20;
                           	infoDiv.style.top = y + document.body.scrollTop;
                              infoDiv.style.left = x + document.body.scrollLeft;
                              infoDiv.style.display = '';
                         chatReq.send(null);
                    } 
                    else 
                    {
                         alert('Aao a?aoca? iaiiaaa??eaaao XMLHttprequest');
                    }
               }
          }