function change_display(id){
  if(document.getElementById(id).style.display=='none'){
    document.getElementById(id).style.display='block';
  }else{
    document.getElementById(id).style.display='none';  
  }
}

function vypis_cas(){
  sekundy--; if(sekundy==-1){ sekundy=59; minuty--; }
  if(minuty<0){ document.location=document.location+''; minuty=0; }

  vypis=''; 
  if(minuty<10) vypis+='0';
  vypis+=minuty+':';
  if(sekundy<10) vypis+='0'; 
  vypis+=sekundy;

  document.getElementById('casomiera').innerHTML=vypis;
}

function getHeight(){
  var viewportheight;
  
  if (typeof window.innerHeight != 'undefined'){
    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight   
    viewportheight = window.innerHeight
  }else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0){
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)  
    viewportheight = document.documentElement.clientHeight
  }else{
    // older versions of IE
    viewportheight = document.getElementsByTagName('body')[0].clientHeight
  }

  return viewportheight;
}

function show_hint(id, obj){
  pos=findPos(obj);
  my_page=findPos( document.getElementById('page') );
  document.getElementById(id).style.left=(pos[0]-my_page[0])+'px';
  document.getElementById(id).style.top=(pos[1])+'px';
  document.getElementById(id).style.display='block';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
  	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
  return [curleft,curtop];
}

function clickodpoved(number, image){
  var odpoved=document.getElementById("my_answer").value;
  
  if(odpoved==number){
    image.style.border="1px dotted gray";
    image.style.margin="1px";
    document.getElementById("my_answer").value="";
  }else{
    if(odpoved!=""){
      document.getElementById("answer"+odpoved).style.border="1px dotted gray";
      document.getElementById("answer"+odpoved).style.margin="1px";
    }
    image.style.border="2px solid blue";
    image.style.margin="0px";
    document.getElementById("my_answer").value=number;  
  }
}

function koniec_testu(message, end_url){
  var ukoncit=window.confirm(message);
  
  if(ukoncit==false) return false;
  
  document.getElementById("my_form").action=end_url;
  document.getElementById("endflag").value='yes';
  return true;
}

function zmena_otazky(){
  if(document.getElementById('old_answer').value!=document.getElementById('my_answer').value){
    return confirm('Vaše odpověď není uložena. Opravdu chcete změnit otázku bez uložení Vaší odpovědi? \n(Pro uložení odpovědi použijte tlačítko "Předchozí" nebo "Další")');
  }
  return true;
}
