
var textSvg=new Array(); 
var txtRecherche="";
var onPage=0;
var trouve=0; 
var page_c=1;
var dixsurdix=1;
var p_tot_out="";  
var mx=0;
var testOn=0;

var vtypebien=20;
var countTxt='france';
var invertIndex=1; 
var intervalPromo=10000;
var cetInt=null;             
var ididixa=0;
var id_ixa_page=new Array();
var divGrAnnonce=new Array();
var messAnnonce=new Array();
var go=0;
var du=0;
var du2=0;
var sessIdReqFind=0;
var sessIdReqCount=0;
var alfarus=new Array('б','г','д','ж','з','и','л','п','ф','ц','ч','ш','щ','э','ю','я');
var gorod=new Array(); 
///////
function russ(m){
for(i=0;i<alfarus.length;i++){
  if(m.match(alfarus[i]))return true;
}
return false;
}
 
///////////////////////////////////////
function addEspaces(sttr){
var repl=new RegExp("[ ]","g");
if(sttr.value)var valstr=sttr.value; else return false;
valstr=valstr.replace(repl,'');
var val=valstr.length;   
if(val>3 && val<=6){
var ot=val-3;
sttr.value=valstr.substr(0,ot)+' '+valstr.substring(ot,val);  }
else if(val>6 && val<=9){
var ot=val-3; var ot2=val-6;
sttr.value=valstr.substr(0,ot2)+' '+valstr.substring(ot2,ot)+' '+valstr.substr(ot,val);  }
else if(val>9 && val<=12){
var ot=val-3; var ot2=val-6;var ot3=val-9;
sttr.value=valstr.substr(0,ot3)+' '+valstr.substring(ot3,ot2)+' '+valstr.substring(ot2,ot)+' '+valstr.substr(ot,val);  } 
if(val>12){val=12; valstr=valstr.substring(0,val);
var ot=val-3; var ot2=val-6;var ot3=val-9;
sttr.value=valstr.substr(0,ot3)+' '+valstr.substring(ot3,ot2)+' '+valstr.substring(ot2,ot)+' '+valstr.substr(ot,val);  }   
}

function getVhistory(){
if(!document.forms["search"])return false;  
   if(document.forms["search"].ta) document.forms["search"].ta.selectedIndex=getCookies('ta');
   if(document.forms["search"].typedebien && getCookies('typedebien')) document.forms["search"].typedebien.selectedIndex=getCookies('typedebien'); 
   if(document.forms["search"].nbpcmin && getCookies('nbpcmin'))document.forms["search"].nbpcmin.value=getCookies('nbpcmin'); 
   if(document.forms["search"].nbpcmax && getCookies('nbpcmax')) document.forms["search"].nbpcmax.value=getCookies('nbpcmax'); 
   if(document.forms["search"].nbchbmin && getCookies('nbchbmin')) document.forms["search"].nbchbmin.value=getCookies('nbchbmin'); 
   if(document.forms["search"].nbchbmax && getCookies('nbchbmax')) document.forms["search"].nbchbmax.value=getCookies('nbchbmax'); 
   if(document.forms["search"].surfacemin && getCookies('surfacemin')) document.forms["search"].surfacemin.value=getCookies('surfacemin'); 
   if(document.forms["search"].surfacemax && getCookies('surfacemax')) document.forms["search"].surfacemax.value=getCookies('surfacemax'); 
   if(document.forms["search"].prixmin && getCookies('prixmin')) document.forms["search"].prixmin.value=getCookies('prixmin'); 
   if(document.forms["search"].prixmax && getCookies('prixmax')) document.forms["search"].prixmax.value=getCookies('prixmax'); 
   if(document.forms["search"].devise && getCookies('devise')) document.forms["search"].devise.selectedIndex=getCookies('devise'); 
   if(document.forms["search"].country && getCookies('country'))document.forms["search"].country.selectedIndex=getCookies('country'); 
   if(document.forms["search"].endroit && getCookies('endroit')) document.forms["search"].endroit.value=getCookies('endroit');     
}

function setCookiesSF(xx){
var val= xx.selectedIndex; 
if(!val)val=0;
var namek=xx.name;    
setCookies(namek,val,180);  
} 
function setCookiesFF(xx){
var val=xx.value; 
if(!val)val=''; 
var namek=xx.name;
setCookies(namek,val,180);  
}       
///////////////////////////////////////
function getPays(){
if(!formData)return false;
var si=1;
if(formData.country.selectedIndex){si=formData.country.selectedIndex;
if(si==-1)si=1;
pays=encodeURIComponent(formData.country.options[si].value);
countTxt=formData.country.options[si].text; }else countTxt='France';
//
si=1;
if(formData.typedebien.selectedIndex){si=formData.typedebien.selectedIndex;  
if(si==-1)si=1;
vtypebien= encodeURIComponent(formData.typedebien.options[si].value); }else{vtypebien='villa';}      
}
function initf(){  
getVhistory(); 
getPays(); 
 //ajaxer('SE/fcountry.php','','fcountry');  
 countTot(); 
 if(startPageId!=0)showAnnonce(startPageId,0);else if(intro)promoannonce();   else altererPromo();   
}

 //
function sessOff(){
ajaxer('SE/ajax_resp.php','','sessOff');
} 
function countTot(){
//ajaxer('SE/ajax_resp.php','','qaa');
}
function clicSource(idsource){
ajaxer('SE/ajax_resp.php','&idsource='+idsource,'clicsource');
} 

function isMail(mail){
var rm=new RegExp("^[0-9a-z._-]+@{1}[0-9a-z._-]{2,}[.]{1}[a-z]{2,5}$");
return rm.test(mail);
}
 function ifInt(val){   
 var val2=parseInt(val);
 alert(val2);
 return true;
 }
//
function setCookies(name,val,ex,secur){
var sec=""; 
if(secur)sec="; secure"; 
if(!ex)ex=30;
var dt2=new Date();
dt2.setDate(dt2.getDate()+parseInt(ex));
dt2.setHours(dt2.getHours());
dt2.setMinutes(dt2.getMinutes());
var oex="; expires="+dt2.toUTCString();
var sup="; path=/";
var dom="; "+pHost;
if(name){document.cookie=name+"="+escape(val)+oex+sup+dom+sec; }
}

function getCookies(nam){
if(document.cookie.length==0)return 0;
var rc=new RegExp("(; )","g");  
var cookies=document.cookie.split(rc);      
for(var i=0;i<cookies.length;i++){    
    var ri=new RegExp("=","g");
    var infos=cookies[i].split(ri);  
    if(infos[0]==nam){
    var cookout=unescape(infos[1]);
    if(!cookout)cookout='';        
    return cookout;
    }
}
return 0;
}
//
 function sendfrendff(id){
var divA=document.getElementById("sendfrend_"+id);
var divB=document.getElementById("form_sdfrend_"+id);
if(divA)divA.style.display='none'; var intervalG=0; 
}
var intervalG=0;
function sendfrendON(id){
if(cetInt){clearTimeout(cetInt); cetInt=null; }  
intervalG=1;
var divA=document.getElementById("sendfrend_"+id);
var divB=document.getElementById("form_sdfrend_"+id);
var divC=document.getElementById("sendfrend_msg_"+id);
if(divB)divB.style.display='block'; 
if(divA)divA.innerHTML=messDemInfo;
if(divC)divC.style.display='none';
var ocoo=getCookies("mailClreq");  
if(ocoo)document.forms['sendfrend_mail_'+id].elements['mailfrend_from_'+id].value=ocoo; 
}
// 
function sendfrend(id,kod){
var divA=document.getElementById("sendfrend_"+id);
var divB=document.getElementById("form_sdfrend_"+id);
var divC=document.getElementById("sendfrend_msg_"+id);
if(divB)divB.style.display='block'; 
var mail=document.forms['sendfrend_mail_'+id].elements['mailfrend_from_'+id].value;
var mailto=document.forms['sendfrend_mail_'+id].elements['mailfrend_to_'+id].value;  
if(isMail(mail) && isMail(mailto)){
intervalG=0;
setCookies('mailClreq',mail,180);
if(divA)divA.style.display='block';
if(divA)divA.innerHTML=messDemInfoOk;  
var txtreqclient=document.forms['sendfrend_mail_'+id].elements['txtreqfrend_'+id].value;
setTimeout("sendfrendff('"+id+"')",7000); 
ajaxer('SE/ajax_resp.php','&ixa='+id+'&mona='+kod+'&mailfrom='+encodeURIComponent(mail)+'&mailto='+encodeURIComponent(mailto)+'&txt='+encodeURIComponent(txtreqclient),'mailfrends');
if(divB)divB.style.display='none';  
if(divB)divB.innerHTML=''; 
}else{
if(divA)divA.innerHTML=messDemInfoAlert;  
if(divA)divA.style.display='block';
} 
} 
//
function seekdemoff(id){
var divA=document.getElementById("sendclient_"+id);
var divB=document.getElementById("form_sdclnt_"+id);
if(divA)divA.style.display='none'; var intervalG=0; 
}
var intervalG=0;
function seekerdemON(id){
if(cetInt){clearTimeout(cetInt); cetInt=null;}   
intervalG=1;
var divA=document.getElementById("sendclient_"+id);
var divB=document.getElementById("form_sdclnt_"+id);
var divC=document.getElementById("sendclient_msg_"+id);
if(divB)divB.style.display='block'; 
if(divA)divA.innerHTML=messDemInfo;
if(divC)divC.style.display='none';
var ocoo=getCookies("mailClreq");  
if(ocoo)document.forms['sendclient_mail_'+id].elements['mailSeeker_'+id].value=ocoo; 
}
// 
function seekerdem(id,kod){
var divA=document.getElementById("sendclient_"+id);
var divB=document.getElementById("form_sdclnt_"+id);
var divC=document.getElementById("sendclient_msg_"+id);
if(divB)divB.style.display='block'; 
var mail=document.forms['sendclient_mail_'+id].elements['mailSeeker_'+id].value;  
if(isMail(mail)){
intervalG=0;
setCookies('mailClreq',mail,180);
if(divA)divA.style.display='block';
if(divA)divA.innerHTML=messDemInfoOk;  
var txtreqclient=document.forms['sendclient_mail_'+id].elements['txtreqclient_'+id].value;
setTimeout("seekdemoff('"+id+"')",7000); 
ajaxer('SE/ajax_resp.php','&ixa='+id+'&mona='+kod+'&mailclient='+mail+'&txt='+encodeURIComponent(txtreqclient),'seekerdem');
if(divB)divB.style.display='none';  
if(divB)divB.innerHTML=''; 
}else{
if(divA)divA.innerHTML=messDemInfoAlert;  
if(divA)divA.style.display='block';
} 
}                
/***********************************************/
function make_annonce(idixa,du){ if(cetInt){clearTimeout(cetInt); cetInt=null; }    
id_ixa_page[ididixa]=idixa;
ididixa++;
if(!frommona)var frommona=0;else frommona=1; 
ajaxer('SE/ajax_resp.php','&frommona='+frommona+'&id_ixa='+idixa+'&du='+du,'showannonce');  
}
//
function showAnnonce(ixa,du2){
if(document.getElementById('block_'+ixa)){
document.getElementById('block_'+ixa).className="blok_v"; markBlok[ixa]="blok_v";  
}
du=du2;  var h=0;                                         
if(cetInt){clearTimeout(cetInt); cetInt=null;}
if(ididixa){                
for(var i=0;i<id_ixa_page.length;i++){   
if(id_ixa_page[i]==ixa){ go=i; h=1;   
break; }   
}
} 
if(h)reMakeAnnonce(go); else make_annonce(ixa,du);
//tret=setTimeout("window.location.href='http://www.vikidom.com/?id="+ixa+"'",14000);
}
var tret;
 //
function goCount(){
if(!formData)return false;
var si=1; 
if(formData.typedebien.selectedIndex){si=formData.typedebien.selectedIndex;
if(si==-1)si=1;
vtypebien= encodeURIComponent(formData.typedebien.options[si].value);}else vtypebien='villa';
if(trigMap)markersOnMap();   
}
function goCount2(){ 
if(!formData)return false; 
if(formData.prixmin.value!='' || formData.prixmax.value!='')
if(trigMap)markersOnMap();   
}

function promoannonce(){ var tai;   
if(document.forms["search"]){
 if(document.forms["search"].ta){
 tai=document.forms["search"].ta.selectedIndex;
 if(tai==-1)tai=0;
 var f_ta=document.forms["search"].ta.options[tai].value;
 }
 if(document.forms["search"].typedebien){
 tai=document.forms["search"].typedebien.selectedIndex;   
  if(tai==-1)tai=1; 
  var f_tb=document.forms["search"].typedebien.options[tai].value;
 } 
 var f_country=220;  
if(document.forms["search"].country)f_country=document.forms["search"].country.options[document.forms["search"].country.selectedIndex].value;
                     
ajaxer('SE/ajax_resp.php','&tcy_x='+f_country+'&t_operation='+f_ta+'&tb='+f_tb,'promoannonce');
//ixaton();
}
}
function altererPromo(){ 
if(trouve<1){
if(cetInt){clearTimeout(cetInt);cetInt=null;}
makeDefPromo();
ifDomStyleOn('listannonces');
ifDomStyleOn('promoannonce',1);
} 
}
//
function makeDefPromo(){           
if(document.getElementById('promoannonce')){
if(defiler) {clearTimeout(cetInt);cetInt=null;}
if(!intervalG)cetInt=setTimeout("promoannonce()",intervalPromo);  //setInterval
}else {
if(document.getElementById("divMapG"))initializeMaps(1);
}
}
//       //        //
function RFD(){  
if(document.forms["search"]){
var repl=new RegExp("[ ]","g");

   if(document.forms["search"].ta) var f_ta=document.forms["search"].ta.options[document.forms["search"].ta.selectedIndex].value;
   if(document.forms["search"].typedebien) var f_tb=document.forms["search"].typedebien.options[document.forms["search"].typedebien.selectedIndex].value;
   if(document.forms["search"].nbpcmin){ var f_nbpcmin=document.forms["search"].nbpcmin.value;  f_nbpcmin=f_nbpcmin.replace(repl,''); }
   if(document.forms["search"].nbpcmax){ var f_nbpcmax=document.forms["search"].nbpcmax.value; f_nbpcmax=f_nbpcmax.replace(repl,'');         }
   if(document.forms["search"].nbchbmin){ var f_nbchbmin=document.forms["search"].nbchbmin.value; f_nbchbmin=f_nbchbmin.replace(repl,'');      }
   if(document.forms["search"].nbchbmax){ var f_nbchbmax=document.forms["search"].nbchbmax.value; f_nbchbmax=f_nbchbmax.replace(repl,'');      }
   if(document.forms["search"].surfacemin){ var f_surfacemin=document.forms["search"].surfacemin.value;  f_surfacemin=f_surfacemin.replace(repl,'');  }
   if(document.forms["search"].surfacemax){ var f_surfacemax=document.forms["search"].surfacemax.value;  f_surfacemax=f_surfacemax.replace(repl,'');}
   if(document.forms["search"].prixmin){ var f_prixmin=document.forms["search"].prixmin.value;  f_prixmin=f_prixmin.replace(repl,'');   }
   if(document.forms["search"].prixmax){ var f_prixmax=document.forms["search"].prixmax.value;   f_prixmax=f_prixmax.replace(repl,'');  }
   if(document.forms["search"].devise) var f_devise=document.forms["search"].devise.options[document.forms["search"].devise.selectedIndex].value;                  
   var qq='&dvs='+f_devise+'&t_operation='+f_ta+'&tb='+f_tb+'&smin='+f_surfacemin+'&smax='+f_surfacemax+'&chmin='+f_nbchbmin+'&chmax='+f_nbchbmax+'&pcmin='+f_nbpcmin+'&pcmax='+f_nbpcmax+'&prixmin='+f_prixmin+'&prixmax='+f_prixmax;  
}else var qq='';  
 return qq;
}

var markBlok=new Array();
//
function siteAgence(mona){ 
if(mona){
ajaxer('SE/ajax_resp.php','&mona'+mona,'siteAgence');
}}
function markAnnonce(idi,koda,dk){ 
if(idi){
if(document.getElementById('block_'+idi)){
document.getElementById('block_'+idi).className="blok_v_out";   markBlok[idi]="blok_v_out"; 
}   
ajaxer('SE/ajax_resp.php','&kod='+koda+'&id='+idi+'&du='+dk,'markAnnonce');
}}
function markList(koda){ 
if(koda){
ajaxer('SE/ajax_resp.php','&kod='+koda,'markList');
}}
//  
function actions(n,k,o){    ord='';   if(o)ord='&tord=1&ord='+o;else {trigord=0;addOrder();} 
for(var fa in intervalmap){ if(intervalmap[fa])clearTimeout(intervalmap[fa]); intervalmap[fa]=null;  }
if(cetInt){clearTimeout(cetInt);cetInt=null;}
var f_country=220;  
if(document.forms["search"].country)f_country=document.forms["search"].country.options[document.forms["search"].country.selectedIndex].value;
 switch (n){ 
 case 1:   du=0;
 var qq=RFD();
 if(document.forms["search"]){ 
  
  if(document.forms["search"].endroit) var f_endroit=encodeURIComponent(document.forms["search"].endroit.value);    
 gorod['found']=document.forms["search"].endroit.value;} 
 ajaxer('SE/ajax_resp.php','&t_country='+f_country+'&endroitl='+f_endroit+qq,'found'); 
 break;
 case 2:
 var qq=RFD();
 if(document.forms["search"]){
  if(document.forms["search"].endroit) var f_endroit=encodeURIComponent(document.forms["search"].endroit.value); 
 gorod['count']=document.forms["search"].endroit.value;} 
 ajaxer('SE/ajax_resp.php','&t_country='+f_country+'&endroitl='+f_endroit+qq,'count'); 
 break;
 case 3:du=1;         
 ajaxer('SE/ajax_resp.php','&idAgency='+k+'&du=1','foundListByA');
 break;
 case 4:if(document.forms["searchById"]){ 
if(document.forms["searchById"].id_ixar)var f_id_ixar=document.forms["searchById"].id_ixar.value;  
if(f_id_ixar)ajaxer('SE/ajax_resp.php','&id_ixa='+f_id_ixar,'found'); 
} 
break;
}
}
//
function showListRes(index){   
if(cetInt){clearTimeout(cetInt);cetInt=null;} 
//ajaxer('SE/ajax_resp.php','&villeMap=1&index='+index,'vMapRecherche'); 
ajaxer('SE/ajax_resp.php','&villeMap=1&index='+index,'found');     
}
//   
var ord=''; 
function goNext(i,d,o){   ord=''; if(o)ord='&tord=1&ord='+o;  
if(cetInt){clearTimeout(cetInt);cetInt=null;}
if(d==1)--dixsurdix;else if(d==2)++dixsurdix;
page_c=i;            
st=(dixsurdix-1)*10+start_search;
ajaxer('SE/ajax_resp.php','&dix='+i+'&start_search='+start_search+reqSvg['found']+'&du='+du,'gonext');          
}

//order               ord tord 1 down.gif up.gif
var trigord=0;
var orderD="<td width=20>&nbsp;</td><td class='ordDown' onclick='makeOrder()'>"+orderBy+"</td>"; 
//    //     //
function begunok(){
if(divBeg)divBeg.innerHTML='';
if(divBarre_bas)divBarre_bas.innerHTML='';
if(trouve>maxParPage){
var begun='<table cellpadding=0 cellspacing=0><tr>';
var x=0;
var max=Math.ceil(trouve/100);
var mm=Math.ceil(trouve/maxParPage);
var xmm=mm-st;
if(mm<maxDixParPage)x=mm;
else if(xmm<maxDixParPage)x=xmm+start_search;
else x=maxDixParPage; 
var px=st;         
//                   
for(var i=1;i<=x;i++){  
if(dixsurdix>1 && i==1){begun+='<td><a class="kub" href="#" onclick="goNext('+(px-1)+','+1+');">-</a></td>'; }
if(page_c==px)begun+='<td><div class="kub_i">'+px+'</div></td>';
else begun+='<td><a class="kub" href="#" onclick="goNext('+px+');">'+px+'</a></td>';
if(i==maxDixParPage && (max-dixsurdix)>0)
begun+='<td><a class="kub" href="#" onclick="goNext('+(px+1)+','+2+');">+</a></td>';  
px++; 
} 
//
begun=begun+orderD;
begun+='</tr></table>'; 

// affich
if(divBeg)divBeg.innerHTML=begun;
if(divBeg)divBeg.style.display='block';
if(divBarre_bas)divBarre_bas.innerHTML=begun; 
if(divBarre_bas)divBarre_bas.style.display='block';
}
}
 function addOrder(){
 if(trigord<=1)var classord='ordDown';else if(trigord==2) var classord='ordUp'; 
orderD="<td width=20>&nbsp;</td><td class='"+classord+"' onclick='makeOrder()'>"+orderBy+"</td>";
 }
function makeOrder(){  
if(trigord<=1)  trigord=2;else if(trigord==2)trigord=1;  addOrder();    
if(page_c==start_search)actions(1,0,trigord);else   goNext(page_c,0,trigord);   
}
// limitStrLen   //           //
function limitUrl(str){
var lim=500;
var d1 =8.2;
var d2 =8.2;
var d3 =4;
var lStr=str.length -1;
var L1=Math.round(lim / d1);
var L2=Math.round(lim / d2); 
        if (lStr > L1 && lStr > d3)
            {
            var strT=str.substr( 0, L2);
            var xc  =strT.indexOf(' ', (L2 - d3));

            if (xc && xc>0)
                {
                var str_1=str.substr(0, xc) + '...';
                }
            else
                {
                var str_1=str.substr(0, ((lim / d2) - d3)) + '...';
                }
            
            }else  str_1=str;
            return str_1;
}
//     ///
function sendcontactoff(){
var divA=document.getElementById("sendcontact_info");
if(divA)divA.style.visibility='hidden';
if(document.forms['sendcontact_mail'].elements['txtcontact'])document.forms['sendcontact_mail'].elements['txtcontact'].text='';
}
// 
function sendcontact(a){
var divA=document.getElementById("sendcontact_info");  
if(document.forms['sendcontact_mail'].elements['mailcontact'])var mail=document.forms['sendcontact_mail'].elements['mailcontact'].value;  
if(isMail(mail)){
if(divA)divA.innerHTML=messMerci; 
if(divA)divA.style.visibility='visible';

setCookies('mailClreq',mail,180);
if(document.forms['sendcontact_mail'].elements['txtcontact'])var txtreqclient=document.forms['sendcontact_mail'].elements['txtcontact'].value;
ajaxer('SE/ajax_resp.php','&a='+a+'&mailcontact='+mail+'&txt='+encodeURIComponent(txtreqclient),'contact');
 //setTimeout("sendcontactoff()",7000); 
}else{
if(divA)divA.innerHTML=messDemInfoAlert;  
if(divA)divA.style.visibility='visible';
} 
}   

