
var httpReq = false;
if (window.XMLHttpRequest) { // Mozilla/Safari 
  httpReq = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
  httpReq = new ActiveXObject("Microsoft.XMLHTTP");
}

var httpReq2 = false;
if (window.XMLHttpRequest) { // Mozilla/Safari 
  httpReq2 = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
  httpReq2 = new ActiveXObject("Microsoft.XMLHTTP");
}

var httpReq3 = false;
if (window.XMLHttpRequest) { // Mozilla/Safari 
  httpReq3 = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
  httpReq3 = new ActiveXObject("Microsoft.XMLHTTP");
}

function setRFavorites(idObj, idRe) {
  httpReq.open('POST', "setRFavorites.php?idre=" + idRe, true);
  httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  httpReq.onreadystatechange = function() {
    if (httpReq.readyState == 4) {
      document.getElementById(idObj).innerHTML = httpReq.responseText;
      document.getElementById('idFavSide').innerHTML = httpReq.responseText;
    }
  }
  httpReq.send(null);
}


function realtyDetails(idRe) {
  httpReq.open('POST', "ajax.php?file=realtyDetails&idre=" + idRe, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById('dhtmltooltip').innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}

function realtyGoogleMap(idRe) {
  if(document.getElementById('id_google_map').innerHTML == '') {
    
    httpReq.open('POST', "ajax.php?file=realtyGoogleMap&idre=" + idRe, true);
    try {
      httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      httpReq.onreadystatechange = function() {
        if (httpReq.readyState == 4) {
          document.getElementById('id_google_map').innerHTML = httpReq.responseText;
        }
      }
      httpReq.send(null);
    } catch (e) {
       // alert("ho-ho-hooo");
    }
  } else {
    document.getElementById('id_google_map').innerHTML = '';
  }
}

function setFavoritesFromList(idobj, xtype, iduser, iddiv) {
  httpReq.open('POST', "ajax.php?file=setFavoritesFromList&idobj=" + idobj + "&xtype=" + xtype + "&iduser=" + iduser + "&iddiv=" + iddiv, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById(iddiv).innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
  countFavorites(iduser);
}

function setFavoritesFromMoje(idobj, xtype, iduser, iddiv) {
  hideddrivetip();
  httpReq.open('POST', "ajax.php?file=setFavoritesFromMoje&idobj=" + idobj + "&xtype=" + xtype + "&iduser=" + iduser + "&iddiv=" + iddiv, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById(iddiv).innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
  countFavorites(iduser);
  countFavoritesListTitle(iduser);
}

function setFavoritesFromDetails(idobj, xtype, iduser, iddiv) {
  httpReq.open('POST', "ajax.php?file=setFavoritesFromDetails&idobj=" + idobj + "&xtype=" + xtype + "&iduser=" + iduser + "&iddiv=" + iddiv, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById(iddiv).innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
  countFavorites(iduser);
}

function countFavorites(iduser) {
  httpReq2.open('POST', "ajax.php?file=countFavorites&iduser=" + iduser, true);
  try {
    httpReq2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq2.onreadystatechange = function() {
      if (httpReq2.readyState == 4) {
        document.getElementById('idFavSide').innerHTML = httpReq2.responseText;
      }
    }
    httpReq2.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}

function countFavoritesListTitle(iduser) {
  httpReq3.open('POST', "ajax.php?file=countFavorites&iduser=" + iduser, true);
  try {
    httpReq3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq3.onreadystatechange = function() {
      if (httpReq3.readyState == 4) {
        document.getElementById('idFavTitle').innerHTML = httpReq3.responseText;
      }
    }
    httpReq3.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}

function changeSlideshowPhoto(skey) {
  httpReq.open('POST', "ajax.php?file=changeSlideshowPhoto&skey=" + skey, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById('idslideshow').innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
    httpReq2.open('POST', "ajax.php?file=changeSlideshowPhoto&skey=" + skey, true);
    httpReq2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq2.onreadystatechange = function() {
      if (httpReq2.readyState == 4) {
        document.getElementById('idslideshow').innerHTML = httpReq2.responseText;
      }
    }
    httpReq2.send(null);
//    alert("ho-ho-hooo");
  }  
}

function changeRealtyLangContent(idRe, lang) {
  httpReq.open('POST', "ajax.php?file=changeRealtyLangContent&idre=" + idRe + "&lang=" + lang, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById('idRealtyLangContent').innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}

function changeSharesLangContent(iddiv, idSh, lang) {
  httpReq.open('POST', "ajax.php?file=changeSharesLangContent&idsh=" + idSh + "&lang=" + lang + "&iddiv=" + iddiv, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById(iddiv).innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}

function setSharesFromMoje(idobj, iddiv, iduser, del) {
  hideddrivetip();
  if(del == 1 && !confirm('Naozaj chcete vymazať Váš inzerát?')) {
    return false;
  }
  httpReq.open('POST', "ajax.php?file=setSharesFromMoje&idobj=" + idobj + "&iddiv=" + iddiv + "&iduser=" + iduser, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById(iddiv).innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
  countMyAdds(iduser);
  countMyAddsListTitle(iduser);
}

function setAddsFromMoje(idobj, iddiv, iduser, del) {
  hideddrivetip();
  if(del == 1 && !confirm('Naozaj chcete vymazať Váš inzerát?')) {
    return false;
  }
  httpReq.open('POST', "ajax.php?file=setAddsFromMoje&idobj=" + idobj + "&iddiv=" + iddiv + "&iduser=" + iduser, true);
  try {
    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq.onreadystatechange = function() {
      if (httpReq.readyState == 4) {
        document.getElementById(iddiv).innerHTML = httpReq.responseText;
      }
    }
    httpReq.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
  countMyAdds(iduser);
  countMyAddsListTitle(iduser);
}

function countMyAdds(iduser) {
  httpReq2.open('POST', "ajax.php?file=countMyAdds&iduser=" + iduser, true);
  try {
    httpReq2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq2.onreadystatechange = function() {
      if (httpReq2.readyState == 4) {
        document.getElementById('idAddsSide').innerHTML = httpReq2.responseText;
      }
    }
    httpReq2.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}

function countMyAddsListTitle(iduser) {
  httpReq3.open('POST', "ajax.php?file=countMyAdds&iduser=" + iduser, true);
  try {
    httpReq3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpReq3.onreadystatechange = function() {
      if (httpReq3.readyState == 4) {
        document.getElementById('idAddsTitle').innerHTML = httpReq3.responseText;
      }
    }
    httpReq3.send(null);
  } catch (e) {
     // alert("ho-ho-hooo");
  }  
}



