function getHeight()
{
  var h = 600;
  if (window.innerHeight)
  {
    h = window.innerHeight;
  } 
  else if (document.body.clientHeight) h = document.body.clientHeight;
  return h;
}
function check_height()
{
  var h = getHeight();
  if (h>550)
  {
    document.write('<style type="text/css">#main {top:'+Math.ceil((h-550)/2)+'px; position:absolute; }</style>');
  }
}
function openPreview(src, w, h)
{
  tmpWindow = window.open("", "_popup", "width="+w+",height="+h+",status=no,toolbar=no,menubar=no");
  tmpWindow.document.open();  
  tmpWindow.document.write('<html><head><title>I.W. 380 - Gallery</title></head><body style="background:#FFFFFF; margin:0px; padding:0px;"><img src=' + src + ' border="0" /></body></html>');
  tmpWindow.document.close();
}
function getPos(el)
{
  var r = { x: el.offsetLeft, y: el.offsetTop };
  if (el.offsetParent)
  {
    var tmp = getPos(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
}
var imgPos = null;
var last_info = null;
function fetch_info(id)
{
  div = document.getElementById('main_info');
  if (last_info) document.getElementById('info' + last_info).style.display = 'none';
  last_info = id;
  document.getElementById('info' + last_info).style.display = '';
  try {
  imgPos = getPos(document.getElementById('map'));
  div.style.left = (imgPos.x + 100) + 'px';
  div.style.top = (imgPos.y + 20) + 'px';
  }
  catch (e) {}
  div.style.display = '';

}
function close_info()
{
  div = document.getElementById('main_info');
  if (last_info) document.getElementById('info' + last_info).style.display = 'none';
  last_info = null;
  div.style.display = 'none';
}
function checkForm(frm, arr)
{
  el = null;
  err = '';
  for(i in arr)
  {
    switch(frm.elements[i].type)
    {
      case 'text':
      case 'password':
        if (frm.elements[i].value == '')
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + "\n";
        }
    	break;
      case 'select-one':
        if (frm.elements[i].selectedIndex == 0)
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + "\n";
        }
    	break;
    }
  }
  if (err == '') return true;
  else
  {
    el.focus();
    alert("Please fill in required fields:\n-----------------------------------\n" + err + "-----------------------------------");
    return false;
  }
}