﻿// fce odznačí vsechny zaskrutnete checkboxy ve formulari
function uncheckAll(oCheckbox) {
  var el, i = 0, bWhich = oCheckbox.checked, oForm = oCheckbox.form;
  while (el = oForm[i++]) if (el.type == 'checkbox') el.checked = bWhich;
}

// fce zobrazi zadany typ dat pro editaci obsahu tutorialu
function showData(type){
  hideall();
  document.getElementById(type).style.display='block';
  
  function hideall()
  {  
    document.getElementById('data-images').style.display='none';
    document.getElementById('data-download').style.display='none';
    document.getElementById('data-source').style.display='none';
    document.getElementById('data-flash').style.display='none';
   }	
}

// fce zviditelni dalsi pole pro upload souboru na server
var a = 1, b = 1, c = 1, d = 1;
function addFile(type)
{
 if(type=='zdroje' && a <= 9)
 {
   document.getElementById(type + a).style.display='block';
   a++;
 }  
 
 if(type=='download' && b <= 9)
 {
   document.getElementById(type + b).style.display='block';
   b++;
 }  
 
 if(type=='obrazky' && c <= 9)
 {
   document.getElementById(type + c).style.display='block';
   c++;
 }
 
  if(type=='flash' && d <= 9)
 {
   document.getElementById(type + d).style.display='block';
   d++;
 }
}

// funkce odpocitavadla casu testu
function runClock()
{
  if (seconds > 0)
  {
    seconds-- ;
    if (seconds < 10)
    {
      seconds = "0"+ seconds;
    }
  }
  else
  {
    if (minutes > 0)
    {
      seconds = "59" ;
      minutes-- ;
      if (minutes < 10)
        {minutes = "0"+ minutes;}
    }
    else
    {
      if (hours > 0 )
      {
        seconds = "59" ;
        minutes = "59" ;
        hours-- ;
        if (hours < 10)
         {hours = "0"+ hours;}
      }
      else
      {
        seconds = "00" ;
        minutes = "00" ;
        hours = "00" ;
        document.getElementById("test-form").submit();
      }
    }
  }
   
  timeValue  = hours +":"+ minutes +":"+ seconds ;
  document.getElementById("hodiny").innerHTML = timeValue; // zobrazení času
  timerID = window.setTimeout ("runClock() " ,1000);
}


// fce pro oznaceni textu odkazu do bloku kvuli pretahovani do textarea v ie
/*function selectLink() {
    var range;

    var x = window.event.clientX;
    var y = window.event.clientY;
    if (window.event.srcElement.parentTextEdit)
    {
        range = window.event.srcElement.parentTextEdit.createTextRange();
        range.collapse();
        el = document.this;
        range.moveToPoint(el.x,el.y);
        range.expand('sentence');
        range.select();
    }
}*/
