/**
 * podown()
 *
 * pokusi se otevrit v miste openera pozadovanou stranku a zavre sam sebe
 * bez parametru pouze zavre okno
 *
 * @params string $okno identifikacni retezec
 * @params string $dont_close zda nezavrit okno na konci
 * @return true
 *
 */
function popdown(url,dont_close)
{
  if (window.opener) {
    window.opener.location.href  = url;
  }
  else {
    window.open(url);
  }
 	if (!dont_close) self.close();
  return true;
}

/**
 * popup()
 *
 * zobrazi popup dle parametru a toho, zda jeste nebyl zobrazen
 * doba trvani - session
 *
 * @params string $okno identifikacni retezec
 * @return void
 *
 */
function popup(url,width,height)
{
  winName = url;
  features = 'width='+width+',height='+height;
  cookie_name = 'popup['+url+']';
  cookie_exp = null;
  cookie_path = '/';

  if (!getCookie(cookie_name)) {
    setCookie(cookie_name, true, cookie_exp, cookie_path);
    window.open(url, "banner_chb", features);
   }
}

function setCookie(name, value, expires, path, domain, secure)
{
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name)
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

