function delka() {
  c=document.pridatanalyzu.text.value.length+1;
  var mistoZobrazeni = document.getElementById("delka");
  mistoZobrazeni.innerHTML = "<strong>"+c+"</strong>";
}
	
function startclock()
{
  var thetime=new Date();

  var nhours=thetime.getHours();
  var nmins=thetime.getMinutes();
  var nsecn=thetime.getSeconds();


  if (nsecn<10)
    nsecn="0"+nsecn;

  if (nmins<10)
    nmins="0"+nmins;

  document.getElementById("time").innerHTML=nhours+":"+nmins+":"+nsecn;

  setTimeout('startclock()',1000);

}

function analyza(id)
{
  var url = 'zjistikurz.php?idcko='+id+'&tip='+document.getElementById('analyza_tip').value;

    	
  if (window.ActiveXObject)
  {
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else
  {
    httpRequest = new XMLHttpRequest();
  }
  httpRequest.open("GET", url, true);
  httpRequest.onreadystatechange= function () {
    analyzaRequest();
  } ;
  httpRequest.send(null);
      

}

function analyzaRequest()
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
	
      var mistoZobrazeni = document.getElementById("ana_kurz");
      mistoZobrazeni.innerHTML = httpRequest.responseText;
    }
    else
    {
      alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
    }
  }
}


function testselect(){
  if  (document.getElementById("kam").value == 'doleva')  {
    document.getElementById("select2").disabled = false;
  }
  else {
    document.getElementById("select2").disabled = true;
    document.getElementById("pole").disabled = true;
  }
} 

function testselect1(){
  if  (document.getElementById("select2").value == 'jine')  {
    document.getElementById("pole").disabled = false;
  }
  else {
    document.getElementById("pole").disabled = true;
  }
} 

function vyhra(mena) {
  if (document.tiket.vklad.value == "") {
    Vyhra = "";
    document.tiket.ev_vyhra.value = Vyhra;
  } else {
    if (mena == 'CZK') {
      Vyhra = eval(Math.round((document.tiket.kurz.value)*100)/100) * eval(MyRoundKoruny(MyReplaceNaBodku(document.tiket.vklad.value)));
      document.tiket.ev_vyhra.value = MyReplaceNaCiarku(MyRoundKorunyUp(Vyhra));
    } else {
      Vyhra = eval(Math.round((document.tiket.kurz.value)*100)/100) * eval(MyReplaceNaBodku(document.tiket.vklad.value));
      document.tiket.ev_vyhra.value = MyReplaceNaCiarku(Math.round(Vyhra*100)/100);
    }
  }
}
function MyReplaceNaCiarku(valore) {
  decimale=","
  svalore=new String (valore)
  pos=svalore.indexOf(".")
  if (pos==-1) {
    parteintera=svalore
    partedecimale="x"
  } else {
    parteintera=svalore.substring(0,pos)
    partedecimale=svalore.substring(pos+1,svalore.length)
  }
  if (partedecimale=="x"){
    return parteintera + ",00"
  } else {
    return parteintera + decimale + partedecimale
  }
}
function MyRoundKoruny(valore) {
  nvalore = valore
  svalore=new String (nvalore)
  pos=svalore.indexOf(".")
  if (pos==-1) {
    parteintera=svalore
  } else {
    parteintera=svalore.substring(0,pos)
  }
  return parteintera + ".00"
}

function MyReplaceNaBodku(valore) {
  decimale="."
  svalore=new String (valore)
  pos=svalore.indexOf(",")
  if (pos==-1) {
    parteintera=svalore
    partedecimale="x"
  } else {
    parteintera=svalore.substring(0,pos)
    partedecimale=svalore.substring(pos+1,svalore.length)
  }
  if (partedecimale=="x"){
    return parteintera + ".00"
  } else {
    return parteintera + decimale + partedecimale
  }
}

function MyRoundKorunyUp(valore) {
  nvalore = valore
  svalore = new String (nvalore)
  pos = svalore.indexOf(".")
  if (pos==-1) {
    parteintera=svalore
  }
  else
  {
    if (svalore.substring(pos+1,pos+3) == "00"){
      parteintera=svalore.substring(0,pos)
    }else{
      nvalore++
      ssvalore=new String (nvalore)
      pos=ssvalore.indexOf(".")
      parteintera=ssvalore.substring(0,pos)
    }
  }
  return parteintera + ".00"
}
function hokej(mul, wht) 
{ 
  var x = (document.getElementById(wht).value / mul);
  if (!isNaN(x))
  {
    if (wht!='input1')document.getElementById('input1').value = Math.round(2.25 *x * 100)/100;
    if (wht!='input2')document.getElementById('input2').value = Math.round(4.0 *x * 100)/100;
    if (wht!='input3')document.getElementById('input3').value = Math.round(2.25 *x * 100)/100;
    if (wht!='input4')document.getElementById('input4').value = Math.round(1.5 *x * 100)/100;
    if (wht!='input5')document.getElementById('input5').value = Math.round(1.5 *x * 100)/100;
    if (wht!='input6')document.getElementById('input6').value = Math.round(1.25 *x * 100)/100;

  }
} 
function fotbal(mul, wht) 
{ 
  var x = (document.getElementById(wht).value / mul);
  if (!isNaN(x))
  {
    if (wht!='input1')document.getElementById('input1').value = Math.round(2.6 *x * 100)/100;
    if (wht!='input2')document.getElementById('input2').value = Math.round(3.0 *x * 100)/100;
    if (wht!='input3')document.getElementById('input3').value = Math.round(2.6 *x * 100)/100;
    if (wht!='input4')document.getElementById('input4').value = Math.round(1.38 *x * 100)/100;
    if (wht!='input5')document.getElementById('input5').value = Math.round(1.38 *x * 100)/100;
    if (wht!='input6')document.getElementById('input6').value = Math.round(1.3 *x * 100)/100;

  }
} 
function basket(mul, wht) 
{ 
  var x = (document.getElementById(wht).value / mul);
  if (!isNaN(x))
  {
    if (wht!='input1')document.getElementById('input1').value = Math.round(1.85 *x * 100)/100;
    if (wht!='input2')document.getElementById('input2').value = Math.round(12.0 *x * 100)/100;
    if (wht!='input3')document.getElementById('input3').value = Math.round(1.85 *x * 100)/100;
    if (wht!='input4')document.getElementById('input4').value = Math.round(1.68 *x * 100)/100;
    if (wht!='input5')document.getElementById('input5').value = Math.round(1.68 *x * 100)/100;
  }
} 
function stahniData(url, method, request) {	
       
  var http_request = false;
  if (window.XMLHttpRequest) {
    http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (eror) {
      http_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
        
  http_request.onreadystatechange = function() {
    httpdata(http_request);
  };
  http_request.open(method, url, true);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(request);
}

function httpdata(http_request) {
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      var hlavicka = document.getElementsByTagName('head')[0];
      var dataLoader = document.getElementById('scriptLoader');
      if(dataLoader) hlavicka.removeChild(dataLoader);

      script = document.createElement('script');
      script.id = 'scriptLoader';
      script.type = 'text/javascript';
      script.innerHTML = http_request.responseText;

      x = document.getElementsByTagName('head')[0];
      x.appendChild(script);
    } else {
      alert('Chyba');
    }
  }
}
	
function insertAtCursor(myField, myValue, smile) {
  	
  var Value = "";
  	
  // Zvirazneni
  if(myValue == "smile") {
    Value = '*'+smile+'*';
  }
  else if (myValue == "html") {
    Value = '['+smile+'] [/'+smile+']';
  }
  else if (myValue == 'url') {
    Value = '[url=] [/url]';
  }
  else if (myValue == 'img') {
    Value = '[img=]';
  }
  else if (myValue == 'img2') {
    Value = '[img= alt= w= h=]';
  }
  // Barvy
  else if (myValue == 'black') {
    Value = '[color=#000000] [/color]';
  }
  else if (myValue == 'red') {
    Value = '[color=#ff0000] [/color]';
  }
  else if (myValue == 'green') {
    Value = '[color=#00cc05] [/color]';
  }
  else if (myValue == 'blue') {
    Value = '[color=#0000cc] [/color]';
  }
  else if (myValue == 'gray') {
    Value = 'color=#c0c0c0] [/color]';
  }
  else if (myValue == 'orange') {
    Value = '[color=#fe9901] [/color]';
  }
  else if (myValue == 'white') {
    Value = '[color=#ffffff] [/color]';
  }
  // Zarovani
  else if (myValue == 'left') {
    Value = '[left] [/left]';
  }
  else if (myValue == 'center') {
    Value = '[center] [/center]';
  }
  else if (myValue == 'right') {
    Value = '[right] [/right]';
  }
  else if (myValue == 'justify') {
    Value = '[justify] [/justify]';
  }
  // Odkaz


  	
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = Value;
  }
  else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
    + Value
    + myField.value.substring(endPos, myField.value.length);
  } else {
    myField.value += Value;
  }
}