// Egyszeres kiválasztó.
function getSelected(fn) {
    // Get selected radio input value.
    var i;
    if (fn.length) {
      for (i=0; i < fn.length; i++) {
        if (fn[i].checked || fn[i].selected) {
          return fn[i].value;
        }
      }
    }
    else {
      if (fn.value) {
        return fn.value;
      }
    }
    return '';
}


function setFocus(field)
{
  var div;
  if (field)
  {
    document.getElementById('focusItem').value = field;
    div = document.getElementById(field);
    if (div)
      div.focus();
  }
  else
  {
    var f = document.getElementById('focusItem').value;
    div = document.getElementById(f);
    if (div)
    {
      div.focus();
      return false;
    }
  }
  
  //return true;
  return false;
}

function unsetFocus()
{
  document.getElementById('focusItem').value = '';
  return true;
}

function setSelected(id, value) {
  var select = document.getElementById(id);
  if (! select)
  {
    return;
  }

    for (var i = 0; i < select.options.length; i++) {
        if (select.options[i].value == value) {
            select.selectedIndex = i
            break
        }    
    }
    return
}

// Felbukkano ablak. (popup)
function popup(url, windowName)
{
  if (!url)
    url = '';
  if (!windowName)
    windowName = 'formTarget' + (new Date().getTime());
  window.open (url, windowName);
  
  return windowName;
}

function printpopup(form, print_val, windowname)
{
  var wn = popup(windowname);
  var oldtarget = form.target;
  
  // Set target.
  if (! print_val)
    print_val = 1;
  document.getElementById('print').value = print_val;
  form.target = wn;
  
  form.submit();
  
  // Re-set target.
  document.getElementById('print').value = '';
  form.target = oldtarget;
}


function getObj(id)
{
  return document.getElementById(id);
}

function getVal(id)
{
  var div = getObj(id);
  if (div.value)
    return div.value;
}

