var isWorking = false;

function swapMainPhoto(property_id, photo_id) {
  if(!isWorking) {
    http.open("GET", "inc/gallery.php?photo_id="+photo_id+"&js=yes", true);
    http.onreadystatechange = getSwapMainPhotoResponse;    
    isWorking = true;
    http.send(null);
  }
  return false;
}
function getSwapMainPhotoResponse() {
  if (http.readyState == 4) {
    results = http.responseText;
    document.getElementById('mainPhoto').innerHTML = results;
    isWorking = false;
  }
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
