var xmlHttp

function showcity(str)
{

var element = document.getElementById('searchCity');
var bounds = getBounds(element);
//alert('Координаты: ' +      '(' + bounds.left + ',' + bounds.top + ') x ' +      '(' + bounds.width + ',' + bounds.height + ')');
x=bounds.left;
y=bounds.top + bounds.height - 1;
//alert(y);
document.getElementById('spisok').style.left=x;
document.getElementById('spisok').style.width=bounds.width;
document.getElementById('spisok').style.top=y;


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Браузер не поддерживает запросы HTTP")
return
}
var url="show_city.php"
url=url+"?req="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("spisok").innerHTML=xmlHttp.responseText
if (xmlHttp.responseText != "") {document.getElementById('spisok').style.display='inline';}
else {document.getElementById('spisok').style.display='none';}
}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function getBounds(element)
{
  var left = element.offsetLeft;
  var top = element.offsetTop;
  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
  {
    left += parent.offsetLeft - parent.scrollLeft;
    top += parent.offsetTop - parent.scrollTop
  }
  return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}


