﻿function RefreshChart() {
  document.getElementById('OnlineChart').src = document.getElementById('OnlineChart').src.split('?')[0] + '?' + (new Date()).getTime();
}

function SubmitSearch() {
  if (window.event.keyCode == 13) {
    Search();
    return false;
  }
  return true;
}

function Search() {
  window.location.href = '/Search/?k=' + encodeURIComponent(document.getElementById('ctl00_txtSearchKeyword').value) + '&amp;a=' + document.getElementById('ctl00_ddlSearchArea').value;
}

function SubmitKL() {
  if (window.event.keyCode == 13) {
    SkipKL();
    return false;
  }
  return true;
}

function SkipKL() {
  window.location.href = '?date=' + document.getElementById('ctl00_BCPP_jsdate').value;
}

function ShowAR() {
  document.getElementById('tbOtherAR').style.display='';
  document.getElementById('tbOther').style.display='none';
}

function ShowHK() {
  document.getElementById('divHistorieKotaci').style.display='';
  document.getElementById('divUzavreneObchody').style.display='none';
}

function ShowUO() {
  document.getElementById('divHistorieKotaci').style.display='none';
  document.getElementById('divUzavreneObchody').style.display='';
}

function ShowKLOL() {
  if (document.location.hash == "#KL") ShowKL();
  if (document.location.hash == "#OL") ShowOL();
}

function ShowKL() {
  document.getElementById('divKL').style.display='';
  document.getElementById('divOL').style.display='none';
  document.getElementById('liKL').className='active';
  document.getElementById('liOL').className='';
}

function ShowOL() {
  document.getElementById('divKL').style.display='none';
  document.getElementById('divOL').style.display='';
  document.getElementById('liKL').className='';
  document.getElementById('liOL').className='active';
}

var erCZK = 1

function enter(obj, string) {
  obj.expr.value += string
}

function checkNum(str) {
  for (var i = 0; i < str.length; i++) {
    var ch = str.substring(i, i+1)
    if (ch < "0" || ch > "9") {
      if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "." && ch != "(" && ch!= ")") {
        return false
      }
    }
  }
  return true
}

function compute(obj) {
  if (obj.expr.value == ''){obj.expr.value = '0'}
  obj.expr.value = obj.expr.value.replace(/,/g, '.').replace(/ /g, '');
  if (checkNum(obj.expr.value)){obj.expr.value = eval(obj.expr.value)} else {alert("Ve vzorci je chyba!")}
}

function recalculate(obj) {
  compute(obj)
  if (checkNum(obj.expr.value)) {
    if (obj.ZMeny.options[obj.ZMeny.selectedIndex].text != 'CZK'){
      obj.expr.value = eval('Math.round(100 * obj.expr.value * er' + obj.ZMeny.options[obj.ZMeny.selectedIndex].text + ')/100')
    } else {
      obj.expr.value = eval('Math.round(100 * obj.expr.value / er' + obj.DoMeny.options[obj.DoMeny.selectedIndex].text + ')/100')
    }
  }
}

function Go(strURI) {
  window.location.href = strURI;
  return false;
}

// Get the value of the cookie with the specified name.
function GetCookie(sName) {
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function SetCookie(sName, sValue) {
  date = new Date();
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 2099 23:59:59 GMT;";
}
