/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}


function respondMemberListing(){
      openDiv('scroll3'); 
      document.getElementById('popup').innerHTML = "<div class='loadingLogo' style='width: 100%; text-align: center; padding-top: 160px;'><img class='loadingLogo' src='images/global/loadingLogo.jpg' alt='Loading...'></div>";
   if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    if (response.length > 0){
      openDiv('scroll3'); 
      document.getElementById('popup').innerHTML = response;
      
    }
  }
}

function listFunction(communityId,nid){
   if (communityId==0) {
      var url="?mvcTask=displayTopLevelNeighborhoodInfo&id="+nid;
   } else {
      var url="?mvcTask=displayCommunityInfo&id="+communityId;
   }
   
  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = respondMemberListing;

  // Send the request
  xmlHttp.send(null);
  
}

function searchModels(){
    d=document.srchModels;

    sqft=d.sqft.value;
    city=d.city.value;
    pmin=d.minPrice.value;
    pmax=d.maxPrice.value;
    beds=d.Bedrooms.value;
    baths=d.Bath.value;

    var url="?mvcTask=ModelSearch&sqft=" + sqft + "&city=" + city + "&pmin=" + pmin + "&pmax=" + pmax + "&beds=" + beds + "&baths=" + baths;

    // Open a connection to the server

    xmlHttp.open("GET", url, true);

    // Setup a function for the server to run when it's done
    xmlHttp.onreadystatechange = respondModelSearch;

    // Send the request
    xmlHttp.send(null);
  
}

function respondModelSearch(){
      openDiv('searchResultsDiv');
      document.getElementById('searchArea').innerHTML = "<div class='loadingLogo' style='width: 100%; text-align: center; padding-top: 160px;'><img class='loadingLogo' src='images/global/loadingLogo.jpg' alt='Loading...'></div>";
   if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    if (response.length > 0){ 
      document.getElementById('searchArea').innerHTML = response;
    }
  }
}
var prevTipName = 0;
var prevTipTop = '0';
function closeDiv(name)
{
   try {document.getElementById(name).style.display = 'none';} catch(e){};
   /*alert(typeof(document.getElementById(name).style.oldTop));
   if(typeof(document.getElementById(name).style.oldTop) )
   {
	  // alert(document.getElementById(name).style.oldTop);
   }*/
   if( name == prevTipName )
   {
     //alert(prevTipName+': '+prevTipTop);
     document.getElementById(name).style.top = prevTipTop;
   }
}

function TimeOutDiv(name) {
  window.setTimeout("closeDiv('" + name.toString() + "');",10000);
}

function openDiv(name)
{
    try {
		for (i=0; i<mapIconCount; ++i) {
			closeDiv('info' + i);
		}
div = document.getElementById(name);
//alert( 'x: '+div.style.left+' y: '+div.style.top+' topper: '+topper );
if(parseInt(div.style.top) < 153 - topper)
{
	prevTipTop = div.style.top;
	prevTipName = name;
	div.style.top = (153 - topper)+'px';
}
if(parseInt(div.style.left) > 400)
{
	div.style.left = '400px';

}
  document.getElementById(name).style.display = '';
  
  } catch(e){}
}

