
function strReplace(s, r, w){
     return s.split(r).join(w);
}
function check(input, x, y)
{
   checkName(input,'',x,y);
}
function checkName(input, response,x,y)
{    
  try
  {
      if (response != ''){ 
        // Response mode
        //message = document.getElementById('nameCheckFailed');            
        if (response != ''){                    
            document.getElementById('show').innerHTML = strReplace(response,'#!#','<br />');                       
            snap('show','img',x,y);
            return true;
        } 
      }else{          
        // Input mode
        url = 'tst.php?q='+input+'&x='+x+'&y='+y;
        loadXMLDoc(url);
      }
  }
  catch(ex)
  {
      alert(ex.message);
  }

}

function snap(elm1, elm2, x, y)
{    
    document.getElementById(elm1).style.top = parseInt(document.getElementById(elm2).offsetTop)+parseInt(y);
    document.getElementById(elm1).style.left = parseInt(document.getElementById(elm2).offsetLeft)+parseInt(x);
    document.getElementById(elm1).style.display='block';
}
var lastId = 0;
function changeImage(elm2,src,width,id)
{
    document.getElementById('picture_div').style.top = parseInt(elm2.offsetTop)-22;
    document.getElementById('picture_div').style.left = parseInt(elm2.offsetLeft)+3+elm2.width-width;
    document.getElementById('picture_div').style.width = parseInt(width+4)+'px';
    document.getElementById('picture_img').src=src;
    document.getElementById('picture_div').style.display='block';
    lastId = id;
}
function doRedir() 
{
    window.location='spot.php?id='+lastId;
}
function doRedir2() 
{
    window.location='building.php?id='+lastId;
}


