var etatCookie=navigator.cookieEnabled;
var cpuClass=navigator.cpuClass;
var navPlatf=navigator.platform;
var resolutXY=window.screen.availWidth+","+window.screen.availHeight;
var codeNav=0;
var tna=navigator.userAgent.toLowerCase();
if(tna.indexOf("msie")>=0)codeNav=4;
else if(tna.indexOf("netscape")>=0)codeNav=1; 
else if(tna.indexOf("firefox")>=0)codeNav=2;  
else if(tna.indexOf("opera")>=0)codeNav=3;

var WIN=(navigator.userAgent.indexOf("Win")!=-1);  //1
var MAC=(navigator.userAgent.indexOf("Mac")!=-1);  //2
var LIN=(navigator.userAgent.indexOf("X11")!=-1);  //3
var PLATF=(WIN) ? 1 : ((MAC) ?  2 : 3);

var pays=220;
var http_request = false;
var xhr = false;
var arrmots=new Array();
var reqSvg=new Array();
//var ajaxResponseText=new Array();
/***********************************************/

 /* q=>запрос;n=>ключ массива;   */ 

 
 function ajaxer(url,q,n){
//this.n=n; 
xhr = false;
  if (window.XMLHttpRequest) 
  { // Mozilla, Safari,...
    xhr = new XMLHttpRequest();
    if (xhr.overrideMimeType) { xhr.overrideMimeType('text/plain'); }
  } 
  else 
  if (window.ActiveXObject) 
  { // IE
    try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } 
    catch (e) 
    {
      try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } 
      catch (e) {alert('XMLHttp request error');}
    }
  }                                                                         
 //if(n!='siteAgence' && n!='markList' && n!='markAnnonce' && n!='ixaton' && n!='promoannonce' && n!='fcountry'  && n!='seekerdem' && n!='foto' && n!='count' && n!='qaa' && n!='mapsGoogle' && n!='showmap')z_hide(0,1); else chasy(1);//if(document.getElementById("divPat2"))document.getElementById("divPat2").style.display="block"; 
 chasy(1);  
xhr.open("POST",zH+url,true);   
xhr.onreadystatechange = function (){


  if (xhr.readyState == 4) 
  {     //alert('There the request. :'+n);   
         if (xhr.status == 200) 
    {        //if(n=='gonext')alert(xhr.responseText);       
         var text=getNewId(xhr.responseText); 
         
      switch(n){
      
          case 'qaa': showTot(text); break; 
          case 'count': countOn(text); break;
         // case 'vMapAdsCount': mapCountOn(text); break;
         case 'fcountry': if(document.getElementById("country"))document.getElementById("country").innerHTML=unescape(text[0]); break;
          case 'found':      
                        trouve=text[1]; if(trouve)initializeMaps(0);
                        dixsurdix=1;
                        p_tot_out="";  
                        mx=0;
                        page_c=1;
                        st=start_search;
                        if(reqSvg['found'].indexOf('endroit')>-1){
                       var currcntr=''; 
                       if(document.forms["search"].country)currcntr=document.forms["search"].country.options[document.forms["search"].country.selectedIndex].value;   
                       if(currcntr!=122){ 
                        if(trouve==0 && russ(gorod['found']))showErrRus(gorod['found']); 
                        } 
                        }   // 
                        foundOn(text,0);
                        break;
          case 'foundListByA':
                        retourList();  
                        trouve=text[1];if(trouve)initializeMaps(0); 
                        dixsurdix=1;
                        p_tot_out="";  
                        mx=0;
                        page_c=1;
                        st=start_search;
                        foundOn(text,0);
                        break;
                        
          case 'gonext':  //if(text[1]>1)   
           
          foundOn(text,1); break;    
          case 'showannonce': clearTimeout(tret);makeAnnonce(text[0]);    break;    
         
          case 'promoannonce':
          makeDefPromo();
          if(document.getElementById("promoannonce"))document.getElementById("promoannonce").innerHTML=text[0]; break;
          //case 'seekerdem':makeDefPromo();     break;
          case 'vMapMarkers':vMarkers(text);     break;
        
      }
     
      if(n!='fcountry' && n!='promoannonce' && n!='seekerdem' && n!='foto' && n!='count' && n!='qaa' && n!='mapsGoogle' && n!='showmap')z_hide(0,0);else if(document.getElementById("divPat2"))document.getElementById("divPat2").style.display="none";
    }
     z_hide(0,0); 
     chasy(); 
  }
}  
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.setRequestHeader("Content-length", q.length);
xhr.setRequestHeader("Connection", "close");
reqSvg[n]=q;  //alert(q);     
if(!ord)ord='';      
xhr.send('NC='+NC+'&SI='+SI+'&idSite='+encodeURIComponent(idSite)+'&p='+PLATF+'&b='+codeNav+'&pays='+pays+'&zpage='+n+reqSvg[n]+ord);                                              
        //  alert('NC='+NC+'&SI='+SI+'&idSite='+encodeURIComponent(idSite)+'&p='+PLATF+'&b='+codeNav+'&pays='+pays+'&zpage='+n+reqSvg[n]+ord);                                                
}

function getNewId(x){  //alert(x);
var b=x.split('<22>');
   if(b[2])NC=b[2];
    if(b[3])SI=b[3];   // alert(NC+'--'+SI);
     return b;
}
 
 
function ixaton(){ /*
var xhr2=null;
if(window.XMLHttpRequest){
xhr2=new XMLHttpRequest();
}else if(window.ActiveXObject){
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
xhr2.open("GET",zH+'ro/ixaton.php',true);  
xhr2.send(null);   xhr2=null;  return false; */
}
