/*
*Creates a new XMLHttpRequest Object to handle dynamic loading of data
*/
function createXML()
{ 
  var xmlHttp;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
  // Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX.  For the best user experience please consider"
            + "upgrading to a newer browser.");
        return false;
      }
    }
  }
  return xmlHttp;
  
}

function mapDisplay(communityId)
{
  var xml = createXML();
  if(xml)
  {
    result = true;
  }
  else
  {
    result = false;
  }
  document.getElementById("mapDisplay").style.display = "block";
  if((result) && (communityId != ""))
  {
    xml.onreadystatechange=function()
    {
     if(xml.readyState==4)
      {
        data = xml.responseXML.documentElement.getElementsByTagName("community");
        
        name = data[0].getAttribute("name");
        cId = data[0].getAttribute("cId");
        city = data[0].getAttribute("city");
        pricetext = data[0].getAttribute("price");
        hometext = data[0].getAttribute("home");
        flag = data[0].getAttribute("flag");
        image = data[0].getAttribute("image");
        html = "";
        if(flag == 0)
        {
          html = "<img src=\"" + image + "\" alt=\"" + name + "\" />";
        }
         html += "<h3>" + name + "</h3>"
              + "<h4>" + city + "</h4>"
              + "<h4>" + pricetext + "</h4>"
              + "<h4>" + hometext + "</h4>"
              + "<h4><a class=\"inlineLink\" href=\"communities.php?cid=" + cId + "\" title=\"More Information About " + name 
              + "\">More Information</a></h4>"
              + "<h4><a class=\"inlineLink\" href=\"communities.php#nogo\" title=\"Close\" onclick=\"return closeMapDisplay();\">Close</a></h4>";
        

        document.getElementById("mapDisplay").innerHTML = html;
      }
    }
    xml.open("GET","load-map-detail.php?communityId=" + communityId, true);
    xml.send(null);
  }
             
  return false;
}
function closeMapDisplay()
{
  
  document.getElementById("mapDisplay").style.display = "none";
  
  html = "<img style=\"margin-top: 196px;\" src=\"images/load.gif\" alt=\"Meadows at Olde Carpenter\"/>"
       + "<h4><a class=\"inlineLink\" href=\"communities.php#nogo\" title=\"Close\" onclick=\"return closeMapDisplay();\">Close</a></h4>";
       
  document.getElementById("mapDisplay").innerHTML = html;
  
}