function ZobrazDetail(ev, id)
{

var detail=document.getElementById('detail');
detail.style.display='block';

if(ev!=0){

    if(document.getElementById)
      {

       if (document.all && !window.opera) {
          x = event.clientX + document.body.scrollLeft;
	if (document.documentElement && !document.documentElement.scrollTop)
		{scr=0;}
	else if (document.documentElement && document.documentElement.scrollTop)
		{scr=document.documentElement.scrollTop;}
	else if (document.body && document.body.scrollTop)
		{scr=document.body.scrollTop;}

          y = Math.round(event.clientY + scr);  
        }  
        else {
          x = ev.pageX;
          y = ev.pageY;
         }


	if(x>document.body.offsetWidth-200){
	x=x-200;
	}
	
	if(y<200){
	y=200;
	}


        if (document.all && !window.opera) {
          detail.style.pixelLeft = x;
          detail.style.pixelTop = y;
         }
         else {
          detail.style.left = x + 'px';
          detail.style.top = y + 'px';
         }
        

      }


det('detail',"/detail.php?id=" + id);



}


}

function Schovat(div){
	document.getElementById(div).style.display='none';
}

function det(element,url){


var httpRequest;

        if (typeof window.ActiveXObject != 'undefined')

        {

          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

        }

        else

        {

          httpRequest = new XMLHttpRequest();

        }

        httpRequest.open("GET", url, true);

        httpRequest.onreadystatechange= function () {data(httpRequest,element); } ;

        httpRequest.send(null);




}


function data(httpRequest,element)
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {

        if("ko"==httpRequest.responseText){
        document.getElementById(element).innerHTML="<strong>Bohužel se nepodařilo načíst data. Zkuste to prosím az chvíli. <a href='#' onlick='Schovat(\"detail\");return false'>Zavřít</a>.</strong>";
        }
        else{
        document.getElementById(element).innerHTML=httpRequest.responseText;

        }
    }
    else
    {
        document.getElementById(element).innerHTML="<strong>Bohužel se nepodařilo načíst data. Zkuste to prosím az chvíli. <a href='#' onlick='Schovat(\"detail\");return false'>Zavřít</a>.</strong>";
    }
  }
}


function zobraz(element) {

var stanice="";
  for (var i = 0; i < document.getElementById('vyberden').elements.length; i++) {
    if(document.getElementById('vyberden').elements[i].type == 'hidden'){
      stanice+='&stanice[]='+document.getElementById('vyberden').elements[i].value;
    }
  }

    self.location = "/?time=" + document.getElementById(element)[document.getElementById(element).selectedIndex].value + stanice;
}


function CheckAllINBOX() {
  for (var i = 0; i < document.getElementById('stanice').elements.length; i++) {
    if(document.getElementById('stanice').elements[i].type == 'checkbox'){
      document.getElementById('stanice').elements[i].checked = 'checked';
    }
  }
}
function UnCheckAllINBOX() {
  for (var i = 0; i < document.getElementById('stanice').elements.length; i++) {
    if(document.getElementById('stanice').elements[i].type == 'checkbox'){
      document.getElementById('stanice').elements[i].checked = '';
    }
  }
}


function NatahniProgram(stanice){

PosliDotaz('stanice='+stanice);

}

function PosliDotaz(url){


var httpRequest;

        if (typeof window.ActiveXObject != 'undefined')

        {

          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

        }

        else

        {

          httpRequest = new XMLHttpRequest();

        }


        httpRequest.onreadystatechange= function () {


  if (httpRequest.readyState == 4)
  {

    if(httpRequest.status == 200)
    {
	 document.getElementById('tvprogram').innerHTML=httpRequest.responseText;

	}

    }
    else
    {
	//
    }

} ;
        httpRequest.open("POST", '/', true);
        httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        httpRequest.setRequestHeader("Content-length", url.length);
        httpRequest.setRequestHeader("Connection", "close");
        httpRequest.send(url);

}
