


var timerID = null;
var timerRunning = false;
var timeLeft;
function showtime() {
	secPerDen = 86400;
	secPerHour = 3600;
	secPerMinute = 60;
	sTemp = timeLeft
	daysLeft = Math.floor(sTemp / secPerDen)
	sTemp = sTemp - (daysLeft*secPerDen)
	hrsLeft = Math.floor(sTemp / secPerHour)
	sTemp = sTemp - (hrsLeft*secPerHour)
	minsLeft = Math.floor(sTemp / secPerMinute)
	sTemp = sTemp - (minsLeft*secPerMinute)
	secLeft = sTemp
	
	if(Math.abs(daysLeft)==1){sTempDay = 'den'}else if(Math.abs(daysLeft)>1 && Math.abs(daysLeft)<5){sTempDay = 'dny'}else{sTempDay = 'dnù'}
	if(Math.abs(hrsLeft)==1){sTempHour = 'hodina'}else if(Math.abs(hrsLeft)>1 && Math.abs(hrsLeft)<5){sTempHour = 'hodiny'}else{sTempHour = 'hodin'}
	if(Math.abs(minsLeft)==1){sTempMinut = 'minuta'}else if(Math.abs(minsLeft)>1 && Math.abs(minsLeft)<5){sTempMinut = 'minuty'}else{sTempMinut = 'minut'}
	if(Math.abs(secLeft)==1){sTempSecond = 'sekunda'}else if(Math.abs(secLeft)>1 && Math.abs(secLeft)<5){sTempSecond = 'sekundy'}else{sTempSecond = 'sekund'}
	if(minsLeft<10){minsLeft = "0"+minsLeft}else{minsLeft = minsLeft}
	if(secLeft<10){secLeft = "0"+secLeft}else{secLeft = secLeft}
	Temp3=daysLeft+' '+sTempDay+', '+hrsLeft+' '+sTempHour+', '+minsLeft+' '+sTempMinut+', '+secLeft+' '+sTempSecond+'.'
	document.frm.left.value=Temp3;
	timeLeft = timeLeft-1;
	timerID = setTimeout("showtime()",1000);
	timerRunning = true;
}
function stopclock () {
	if(timerRunning)
	clearTimeout(timerID);
	timerRunning = false;
}
function stopClock() {
        stopclock();    
        return;
}
function startclock () {
	timeLeft = (document.getElementById("sTemp").value);
	stopclock();
	showtime();
}



function objGet(x) {
	   if (typeof x != 'string') return x;
	   else if (Boolean(document.getElementById))
	      return document.getElementById(x);
	   else if (Boolean(document.all))
	      return eval('document.all.'+x);
	   else if (Boolean(document.ids))
	      return eval('document.ids.'+x);
	   else
	      return null;
	}
  function openWindow(url,o,w,h){
    wasOpen  = false;
    win = window.open(url,o,'width='+w+',height='+h);
    return (typeof(win)=='object')?true:false;
  }
  function openWin(url){
    wasOpen  = false;
    win = window.open(url);    
    return (typeof(win)=='object')?true:false;
  }

/*************************PROGRAM*************************/
function findUl(){
	var detectionResults
	detectionResults = detectWMP();
	var main = document.getElementById('program');
	var collection = main.getElementsByTagName('a');
	var output1 = collection.length;
	for (x = 0; x < collection.length; x++){
  		if(document.getElementsByTagName('a')[x].className.substring(0,3)=='wmp'){
			if (window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1)
			{
			  // IE for Windows object instantiation -- use of ActiveXObject
			  document.getElementsByTagName('a')[x].className='wmp_off'
			}
			else if(window.GeckoActiveXObject)
			{
			  // Netsape 7.1 object instantiation --use of GeckoActiveXObject
			  document.getElementsByTagName('a')[x].className='wmp_off'
			}
			else if(navigator.mimeTypes)
			{
			  // Plugin architecture, such as in Netscape 4x - 7.02 and Opera browsers
			  document.getElementsByTagName('a')[x].className='wmp_off'
			}
		}
	}	
}
function showProgram(arg) {
//	alert(arg)
//	alert(oldOpen)
	if(document.getElementById(arg)!=null){
		if(oldOpen==arg){
			if(document.getElementById(arg).className=='open'){
				document.getElementById(arg).className='close'
			}else{
				document.getElementById(arg).className='open'
			}
		}else{
			document.getElementById(arg).className='open'
			if(objGet(oldOpen)!=null){
			document.getElementById(oldOpen).className='close'
			}
		}
		oldOpen = arg;
	}
}


/*****************DETECT WMP*********************/
function detectWMP()
{
	var wmpInfo = {
		installed: false,
		scriptable: false,
		type: null,
		versionInfo: null
	};
	var wmp64 = "MediaPlayer.MediaPlayer.1";
	var wmp7 = "WMPlayer.OCX.7";
	if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1) || window.GeckoActiveXObject){
		wmpInfo.type = "ActiveX";
		var player = createActiveXObject(wmp7);
		if(player){
			wmpInfo.installed = true;
			wmpInfo.scriptable = true;
			wmpInfo.versionInfo = player.versionInfo;
			return wmpInfo;
		}else{
			player = createActiveXObject(wmp64);
			if(player){
				wmpInfo.installed = true;
				wmpInfo.scriptable = true;
				wmpInfo.versionInfo = "6.4";
				return wmpInfo;
			}else{
				wmpInfo.versionInfo = "none";
				return wmpInfo;
			}
		}
	}else if(navigator.mimeTypes){
		wmpInfo.type = "NetscapePlugin";
		var player = navigator.mimeTypes['application/x-mplayer2'].enabledPlugin;
		if(player){	
			wmpInfo.installed = true;
			//wmpInfo.scriptable = false;
			wmpInfo.versionInfo = "PluginVersion";
			return wmpInfo;
		}
		return wmpInfo;
	}
}
function createActiveXObject(id){
  var error;
  var control = null;
  try{
    if (window.ActiveXObject){
      control = new ActiveXObject(id);
    }else if (window.GeckoActiveXObject){
      control = new GeckoActiveXObject(id);
    }
  }
  catch (error){;}
  return control;
}
	

function printResults(){
	var detectionResults = detectWMP();
	var sTemp = "<div>"
	sTemp=sTemp+"Browser architecture supports: " + detectionResults.type + "<br />";
	sTemp=sTemp+"Windows Media Player Installed: " + detectionResults.installed + "<br />";
	if(detectionResults.installed)
	{
		sTemp=sTemp+"Windows Media Scriptable: " + detectionResults.scriptable + "<br />";
		sTemp=sTemp+"Windows Media Version: " + detectionResults.versionInfo + "<br />";
	}
	sTemp=sTemp+"</div>"
	return sTemp
}


/******************************/
var WMPOnPage = false;
var bBuffering = false;
cKonec = 0;
function UnInit() {
	cKonec = 1;
}

var detectionResults


var detectionResults = detectWMP();
function init() {
	detectionResults = detectWMP();
	if(detectionResults.installed){
		document.getElementById("message").innerHTML = printResults();
		if(detectionResults.versionInfo){
			if(detectionResults.versionInfo.substring(0,1)==9 || detectionResults.versionInfo.substring(0,1)==1){
				if(Boolean(document.getElementById("VideoPlayer").uiMode)){WMPOnPage = true;}
				setup();
			}else{
				if(detectionResults.versionInfo.substring(0,1)==6){
					ShowUpgrade();
				}else{
					StopMe();
					ShowUpgrade();
				}
			}
		}
	}else{
		ShowUpgrade();
	}
}
function test(){
try{
	if(document.getElementById("VideoPlayer").controls.isAvailable("stop")){WMPOnPage = true;}
}catch(e){}
	if(WMPOnPage){
		clearTimeout(tt);	
	}
	setup()
}
function ShowPlay(){
	if(detectionResults.versionInfo.substring(0,1)==6){
		objGet("VideoPlayer6").style.visibility='visible';
	}else{
		objGet("VideoPlayer").style.visibility='visible';
	}
	objGet("VideoRychlost").style.visibility='hidden';
	objGet("VideoUpgrade").style.visibility='hidden';
}
function ShowStop(){
	if(detectionResults.versionInfo.substring(0,1)==6){
		objGet("VideoPlayer6").style.visibility='hidden';
	}else{
		objGet("VideoPlayer").style.visibility='hidden';
	}
	objGet("VideoRychlost").style.visibility='visible';
	objGet("VideoUpgrade").style.visibility='hidden';
}
function ShowUpgrade(){
	if(detectionResults.versionInfo.substring(0,1)==6){
		objGet("VideoPlayer6").style.visibility='hidden';
	}else{
		objGet("VideoPlayer").style.visibility='hidden';
	}
	objGet("VideoRychlost").style.visibility='hidden';
	objGet("VideoUpgrade").style.visibility='visible';
}


var tt
function setup(){
	if(WMPOnPage){
		document.getElementById("VideoPlayer").uiMode="none";
		document.getElementById("Panel").style.display="block";
		document.getElementById("Panel").style.visibility="visible";
		ShowText();
	}else{
		tt=setTimeout("test()",5000);
		document.getElementById("Panel").style.display="block";
		document.getElementById("Panel").style.visibility="hidden";
	}
}


function addZero(s) {
  var str
  str="0"+s;
  if (str.length==3) str=str.substring(1,3);
  return str;
}
function FormatTime(h) {
  var hodina;
  var minuta;
  var sekunda;
  hodina=parseInt(h/3600);
  h=Math.round(h-hodina*3600);
  minuta=parseInt(h/60);
  h=Math.round(h-minuta*60);
  sekunda=Math.round(h);
  return addZero(hodina)+":"+addZero(minuta)+":"+addZero(sekunda);
}


function ShowText() {
	/*FLASH*/
	player.SetVariable("volproc", VideoPlayer.settings.volume);
	/*DHTML*/
	//document.getElementById("volume").innerHTML = document.getElementById("VideoPlayer").settings.volume;
	
	Aktualni_pozice=document.getElementById("VideoPlayer").controls.currentPosition;
	Celkem=(document.getElementById("VideoPlayer").currentMedia.duration);
	pozice_cas=FormatTime(Aktualni_pozice);

	if (document.getElementById("VideoPlayer").controls.isAvailable('FastForward')) {
		//OFFLINE
		if(!bBuffering){
			/*FLASH*/
			player.SetVariable("streaminfo", pozice_cas+'/'+FormatTime(Celkem));
			/*DHTML*/
			//document.getElementById("cas").innerHTML = pozice_cas+'/'+FormatTime(Celkem);
			//Posun v procentech
			/*FLASH*/
			player.SetVariable("garf_perc",parseInt(100*Aktualni_pozice/Celkem));
		}
	}else{
		//ONLINE
		if(!bBuffering){
			/*FLASH*/
			player.SetVariable("streaminfo", pozice_cas);
			/*DHTML*/
			//document.getElementById("cas").innerHTML = pozice_cas
		}
	}
	if(document.getElementById("VideoPlayer").network.bandwidth != 0){
		/*FLASH*/
		player.SetVariable("rychlost", document.getElementById("VideoPlayer").network.bandWidth + " Kb/s");
		/*DHTML*/
		//document.getElementById("rychlost").innerHTML = document.getElementById("VideoPlayer").network.bandWidth + " Kb/s";
	}
	timerID=setTimeout("ShowText()",1000);
}


function StopMe () {
	if(detectionResults.versionInfo.substring(0,1)==6){
		objGet("VideoPlayer").stop();
	}else{
		objGet("VideoPlayer").controls.stop();
	}
}
function PlayVideo () {
	objGet("VideoPlayer").controls.play();
}


var bZoom;
bZoom=2;
/*
1 1:1
2 fit
3 fullScreen
*/

function fZoom(arg) {
	if (bZoom!=1 || arg>0) {
		bZoom=bZoom+(1*arg);
	}
	if (bZoom==1) {
		document.getElementById("VideoPlayer").stretchToFit = "false";
	}
	if (bZoom==2) {
		document.getElementById("VideoPlayer").stretchToFit = "true";
	}
	if (bZoom==3) {
		if (document.getElementById("VideoPlayer").playState==3) {
			alert('Press <ESC> to exit full screen mode!');
			document.getElementById("VideoPlayer").fullScreen = "true";
			bZoom=2;
		} else {
			bZoom=2;
		}
	}
}

function sVolume (arg) {
	if (document.getElementById("VideoPlayer").settings.volume+arg*10>=100) {
		document.getElementById("VideoPlayer").settings.volume=100;
	} else if (document.getElementById("VideoPlayer").settings.volume+arg*10<=0) {
		document.getElementById("VideoPlayer").settings.volume=0;
	}else{
		document.getElementById("VideoPlayer").settings.volume=document.getElementById("VideoPlayer").settings.volume+arg*10;
	}
}

var g_bPaused = false; // To track pause button state;

function PauseMe(){
	if( g_bPaused == true ) {
		document.getElementById("VideoPlayer").controls.play();
		g_bPaused = false;
	}else{  
		document.getElementById("VideoPlayer").controls.pause();
		g_bPaused = true;
	}
}

function GoTime (iPr) {
 if (VideoPlayer.controls.isAvailable('FastForward')) {
  //OFFLINE
  if (!isNaN(iPr) && (iPr != '')) {
   Celkem=(VideoPlayer.currentMedia.duration);
   VideoPlayer.controls.currentPosition = (iPr*Celkem)/100;
  }
 }
}
	  
function GoMarker (iPos) {
	var collection = document.getElementsByTagName('a');
	for (x = 0; x < collection.length; x++){
		if(document.getElementsByTagName('a')[x].className.indexOf('StreamActive')!=-1){
			_class = document.getElementsByTagName('a')[x].className;
			_class = _class.substring(0,document.getElementsByTagName('a')[x].className.indexOf('StreamActive'));
	  		document.getElementsByTagName('a')[x].className=_class;
		}
	}	

 if (parent.document.VideoPlayer.controls.isAvailable('FastForward')) {
  //OFFLINE
  if (!isNaN(iPos) && (iPos != ''))  {
   parent.document.VideoPlayer.controls.currentMarker = iPos;
  }
 }
}

function UpdateBP(){
	
	
	
	try{
	/*FLASH*/
	player.SetVariable("streaminfo", "buffering: " + VideoPlayer.network.bufferingProgress + "%");
	/*DHTML*/
	//document.getElementById("cas").innerHTML = "Buffering: " + document.getElementById("VideoPlayer").network.bufferingProgress + "%";
	}catch(e){}
}

