// ------------------------------------------ funkce pro otevirani novych oken
function okno(soubor) {
  window.open(soubor,'','toolbar=yes,scrollbars=yes,location=yes,status=yes,resizable=1,menubar=yes')
}

// ------------------------------------------ funkce pro zaskrtnuti vsech polozek
function CheckAll(f,el) {
	for (var i=0;i<f.elements.length;i++)
	{
		var e=f.elements[i];
		if (e.id==el) e.checked=f.check_all.checked;
	}
}

// ------------------------------------------ funkce pro presun z formularoveho prvku SELECT
function jdi_na() {
	location=document.skoc.go.options[document.skoc.go.selectedIndex].value
}

// ------------------------------------------ funkce pro pridani mezi oblibene
function addBookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

// ------------------------------------------ funkce pro pridani smajliku do fora
function insert_smile(type) {
	document.getElementById("cely_text").value=document.getElementById("cely_text").value+" "+type+" ";
}


// ------------------------------------------ zmeni tridu (class) objektu s danym ID
function ZmenTridu(trida,id)  {
  document.getElementById(id).className = trida;
}


function online(id)   {
  window.open('http://www.onlajny.cz/match/index/id/'+id+'','','toolbar=no,scrollbars=yes,location=no,status=yes,width=790,height=530,resizable=1')
}

function online_zap(id) {
  window.open('http://www.onlajny.cz/match/index/id/'+id+'','','toolbar=no,scrollbars=yes,location=no,status=no,width=790,height=590,resizable=1')
}

// ------------------------------------------ fce pro vysouvaci menu
var PocetMenu = 9;
function Show(CisMenu)    {
  var menu = document.getElementById('submenu'+CisMenu);	
  var menu2 = document.getElementById('menu'+CisMenu);	
  menu.style.visibility="visible";
  menu2.className="show";
}

function Hide() {
  var menu,menu2, i;
  for(i=1; i<=PocetMenu; i++) {
      menu = document.getElementById('submenu'+i);	
      menu.style.visibility="hidden";
	  menu2 = document.getElementById('menu'+i);	
      menu2.className="";
  }
}

// ------------------------------------------ fce zmenu TOP story
var top_count=3;
var class_image="top_image"; class_text="box_articles";
	
function switch_top(id_top){
 if (document.getElementById("text"+id_top).className!=class_image+" show"){
	 for(i=1; i<=top_count; i++) {
		document.getElementById("text"+i).className="hidden";
		document.getElementById("thumb"+i).className="";
	 }
	 document.getElementById("text"+id_top).className=class_text+" show";
	 document.getElementById("thumb"+id_top).className="selected";
 }
}

// ------------------------------------------ fce zmenu tabs na indexu
function switch_tab(id_tab,id_group){
	var tab_count=2;
	var tab;
	 for(i=1; i<=tab_count; i++) {
	 	document.getElementById("tab_box"+id_group+"_"+i).className="hidden";
	 }
	document.getElementById("tab_box"+id_group+"_"+id_tab).className="box";
	tab=document.getElementById("tab_"+id_group).className;
	if (id_tab==1){ 
		document.getElementById("tab_"+id_group).className="tabs on";
	}	
	else 
		{document.getElementById("tab_"+id_group).className="tabs off";}
}
	
//automaticke zmenseni img pro stare clanky
function changeSizeAllImg() {
	var imgGroup = document.getElementById("text").getElementsByTagName("img");
	for (var i=0; i<imgGroup.length; i++) {
		if (imgGroup[i].width>570){
			imgGroup[i].width=570;
		}
	}
}	

function countdown(year, month, day, hour, minute, format)
         {
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth();                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
         Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.getElementById("countdown").innerHTML = Time_Left + ' vteřin';
                    break;
               case 1:
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = ' dní'; hps = ' hodin'; mps = ' minut'; sps = ' vteřin';
                    //ps is short for plural suffix.
                    if(days == 1) dps =' den';
                    if(hours == 1) hps =' hodina';
                    if(minutes == 1) mps =' minuta';
                    if(seconds == 1) sps =' vteřina';
					
					if(days > 1 && days<5 ) dps =' dny';
                    if(hours > 1 && hours<5 ) hps =' hodiny';
                    if(minutes > 1 && minutes<5 ) mps =' minuty';
                    if(seconds > 1 && seconds<5 ) sps =' vteřiny';
                    if(seconds == 0 && minutes==0&& hours==0&& days==0){
						 //document.getElementById("countdown").innerHTML = 'utkání již bylo odehráno';
					}
					else{
						
						document.getElementById("countdown").innerHTML = 'zbývá ';
	                    document.getElementById("countdown").innerHTML += days +  dps + ' ';
    	                document.getElementById("countdown").innerHTML += hours +  hps + ' ';
        	            document.getElementById("countdown").innerHTML += minutes +  mps + ' ';
            	        document.getElementById("countdown").innerHTML += seconds + ' s' ;
					}
                    break;
               default: 
                    document.getElementById("countdown").innerHTML = Time_Left + ' vteřin';
               }
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
         }
		 

function show_calendar_event(id){
  
  for(i=1; i<=31; i++) {
    if (document.getElementById('cal_event_'+i)){ 
      document.getElementById('cal_event_'+i).style.display="none";
    }
  }
  document.getElementById('cal_event_'+id).style.display="block";
  
  
}

function show_calendar_event_hide(){
  for(i=1; i<=31; i++) {
    if (document.getElementById('cal_event_'+i)){ 
      document.getElementById('cal_event_'+i).style.display="none";
    }
  }
}

function show_video_list(){
	document.getElementById("video_list").className="on";
}

function hide_video_list(){
	document.getElementById("video_list").className="off";
}


