function setActiveStyleSheet(style_title) {

    var i, link_tag;

    for(i = 0; (link_tag = document.getElementsByTagName("link")[i]); i++) {
        if((link_tag.getAttribute("rel").indexOf("style") != -1) && link_tag.getAttribute("title")) {

            link_tag.disabled = true;

            if(link_tag.getAttribute("title") == style_title) {
                link_tag.disabled = false;
            }
        }
    }
}

function getMouseX(e) {
   return e.pageX
                  || ( e.clientX + ( document.documentElement.scrollLeft
                  || document.body.scrollLeft ) );
}

function getMouseY(e) {
    return e.pageY
                  || ( e.clientY + ( document.documentElement.scrollTop
                  || document.body.scrollTop ) );
}

function hideinfo() {
    var b;
    b = document.getElementById('popupblock');
    b.style.display = "none";
}

function showme() {
    var b;
    b = document.getElementById('popupblock');
    b.style.display = "block";
}

function showinfo(ob, event) {

    var ob, b, mouse, element;
    mouse = new Object();
    element = new Object();
    
    mouse.left = getMouseX(event);
    mouse.top = getMouseY(event);

    b = document.getElementById('popupblock');
    b.innerHTML = '<a id="popupblockheader" href="'+ ob.href + '">' + ob.alt + '</a>' + '<div class="warning">Please, wait...</div>';

    getFlats(ob.alt);
    
    b.style.left = mouse.left + 'px';
    b.style.top = mouse.top + 'px';
    b.style.display = "block";
}

var xmlhttp = null;
function showResults() {
    var b, h;
    if (xmlhttp != null && xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            b = document.getElementById('popupblock');
            h = document.getElementById('popupblockheader');
            b.innerHTML = '<a id="popupblockheader" href="'+ h.href + '">' + h.innerHTML + '</a>' + xmlhttp.responseText;
	}
   }
}

function getFlats(station) {
  xmlhttp = createRequestObject();
  xmlhttp.open('GET', 'searchmap4ajax.html?station=' + encodeURIComponent(station), true);
  xmlhttp.onreadystatechange = showResults;
  xmlhttp.send(null);
}

function createRequestObject()
{
    if (window.XMLHttpRequest) {
        try {
            return new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            return new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
          try {
              return new ActiveXObject('Microsoft.XMLHTTP');
          } catch (e){}
        }
    }
    return null;
}
