
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */

/**
 * $Id: scripts.js 641 2009-03-01 20:34:50Z costra $
 *
 * JS funkce - balast
 *
 * @author     Pavel Novak <p@innuendo.cz>
 * @copyright  Medicomp, s.r.o.
 * @license    Proprietary
 */

function open_popup(url, target, width, height)
{
    left = (window.screen.width / 2) - (width / 2);
    topi = (window.screen.height / 2) - (height / 2);

    options = 'margin=0,scrollbars=1,toolbar=0,resizable=1,statusbar=1,location=1,top=' + topi + ',left=' + left + ',menubar=1,width=' + width + ',height=' + height;
    win = window.open(url, target, options);
    win.focus();
    return ('object' == typeof(win)) ? true : false;
}

function noFrames(a)
{
  top.frames['horde_main'].location.href = a;
  return true;
}

function potvrd_odkaz(odkaz, textik)
{
    var potvrzeno = confirm('Opravdu:\n' + textik);
    if (potvrzeno) {
        odkaz.href += '&potvrzeno=1';
    }
    return potvrzeno;
}

function win(theUrl, winName, features, qa)
{
    if (null == qa) {
        qa = [];
    }
    qs = qa.join('&amp;');
    theUrl += (-1 == qs.indexOf('?')) ? '?' : '&amp;';
    theUrl += qs;
    var secondWindow = window.open(theUrl, winName, features);
    if (secondWindow != null) {
        secondWindow.focus();
    }
}

function checkLength(obj, len)
{
    if (len <= obj.value.length) {
        window.alert('Pøekroèena maximální délka ' + len + ' znakù.\n' +
                     'Text byl zkrácen na max. povolenou délku.');
        obj.value = obj.value.substring(0, len - 1);
        return false;
    }
    return true;
}

function new_win(url) {
  win = window.open(url);
  return ('object' == typeof(win)) ? true : false;
}

function switchAll(newState) {
  var boxes = document.getElementById('checkbox-list').getElementsByTagName('input');
  for (var i = 0; i < boxes.length; i++) {
    boxes[i].checked = newState ? 'checked' : '';
  }
}

function open_win(url, target) {
  was_open = false;
  win = window.open(url, target);
  win.focus();
  return ('object' == typeof(win)) ? true : false;
}

function open_pic(url, target, width, height) {
  left = (window.screen.width / 2) - (width / 2);
  topi = (window.screen.height / 2) - (height / 2);

  options = 'margin=0,scrollbars=0,toolbar=0,resizable=yes,top=' + topi + ',left=' + left + ',menubar=0,width=' + width + ',height=' + height;
  win = window.open(url, target, options);
  win.focus();
  return ('object' == typeof(win)) ? true : false;
}

function showObj(objId) {
    document.getElementById(objId).style.display = 'block';
}

function hideObj(objId) {
    document.getElementById(objId).style.display = 'none';
}


function showHide(objId) {
  if ('block' == document.getElementById(objId).style.display) {
      hideObj(objId);
  } else {
      showObj(objId);
  }
}

Date.prototype.dayDiff = function(d2) {
    var d = this - d2;
    return Math.floor(d / (24 * 60 * 60 * 1000));
}

function checkedValue(radioObj) {
    if (!radioObj) {
        return "";
    }
    var radioLength = radioObj.length;
    if (radioLength == undefined) {
        return radioObj.checked ? radioObj.value : '';
    }
    for (var i = 0; i < radioLength; i++) {
        if (radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return '';
}


