var PropTimer;
var xmlhttp;

function StartTimer() {
  PropTimer=setTimeout("ReLoadFeature()",15000);
}

function ReLoadFeature() {
  if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (xmlhttp!=null) {
    xmlhttp.onreadystatechange=state_Change;
    xmlhttp.open("GET","/Properties/ListingBar.asp",true);
    xmlhttp.send(null);
  }
  else {
    //alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change() {
  if (xmlhttp.readyState==4) {
    if (xmlhttp.status==200) {
      document.getElementById("FeatureProperty").innerHTML = xmlhttp.responseText;
    }
    StartTimer();
  }
}

function ViewProperty(InternalID) {
  var GetURL = "/Properties/ViewInfo.asp?IntID=" + InternalID;

  xmlhttp = null
  if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (xmlhttp!=null) {
    xmlhttp.onreadystatechange=propdisp_Change;
    xmlhttp.open("GET",GetURL,true);
    xmlhttp.send(null);
  }
  else {
    alert("Your browser does not support this function.");
  }
}

function ShowProperty(InternalID) {
  document.getElementById("ShowBox").src="/Properties/ViewInfo.asp?IntID=" + InternalID;
  CoverOver.style.visibility="visible";
}

function propdisp_Change() {
  if (xmlhttp.readyState==4) {
    if (xmlhttp.status==200) {
      scroll(0,0);
      document.getElementById("OptionDisplay").innerHTML = xmlhttp.responseText;
      document.getElementById("CoverOver").style.height = document.getElementById("NormalArea").offsetHeight + 30;
      document.getElementById("CoverOver").style.width = document.getElementById("NormalArea").offsetWidth + 20;
      document.getElementById("CoverOver").style.visibility = "visible";
      document.getElementById("OptionDisplay").style.left = String((parseInt(document.getElementById("CoverOver").style.width)-700)/2) + "px";
      CoverIframe(document.getElementById("OptionDisplay"));
    }
  }
}

function PhotoNavVis(doShow) {
  if (document.getElementById("PhotoNav")) {
    if (doShow) {
      document.getElementById("PhotoNav").style.visibility = "visible";
    }
    else {
      document.getElementById("PhotoNav").style.visibility = "hidden";
    }
  }
}

function PhotoNavMove(InternalID, moveDir, maxPhotos) {
  var PhotoSrc = "/Properties/ViewPhoto.asp?IntID=" + InternalID + "&PhotoID=";
  var CurrentPhotoID = parseInt(document.getElementById("MainPhoto").src.split("PhotoID=")[1]);
  if (moveDir == "Next") {
    CurrentPhotoID++;
  }
  else {
    CurrentPhotoID--;
  }
  if (CurrentPhotoID == 0) { CurrentPhotoID = maxPhotos; }
  if (CurrentPhotoID > maxPhotos) { CurrentPhotoID = 1; }
  PhotoSrc = PhotoSrc + CurrentPhotoID;
  document.getElementById("LoadingDiv").style.visibility = "visible";
  document.getElementById("MainPhoto").src = PhotoSrc;
}

function PhotoNavHeight() {
  document.getElementById("PhotoDiv").style.height = document.getElementById("MainPhoto").offsetHeight;
  if (document.getElementById("PhotoNav")) {
    document.getElementById("PhotoNav").style.height = document.getElementById("MainPhoto").offsetHeight;
    document.getElementById("PhotoNav").style.top = findPos(document.getElementById("MainPhoto"))[1] - 30;
    document.getElementById("PhotoNav").firstChild.style.paddingTop = (document.getElementById("MainPhoto").offsetHeight - 20) / 2;
    document.getElementById("PhotoNav").lastChild.style.paddingTop = (document.getElementById("MainPhoto").offsetHeight - 20) / 2;
    document.getElementById("LoadingDiv").style.visibility = "hidden";
    document.getElementById("LoadingDiv").style.top = (document.getElementById("MainPhoto").offsetHeight - 30) / 2;;
  }
}

function PhotoNavOpac(ButtonObj, MousePos) {
  
}

function ShowPrintWin(InternalID, WithPhotos) {
  window.open("/Properties/PrintInfo.asp?IntID=" + InternalID + "&WithPhotos=" + WithPhotos, "PropPrint", "directories=no,fullscreen=no,height=800,width=750,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no", true);
}
