// ------------------------------------------ funkce pro otevirani novych oken
function okno(soubor) {
  window.open(soubor,'','toolbar=no,scrollbars=yes,location=no,status=no,resizable=1')
}


// ------------------------------------------ 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 emailu pro odeslani clanku
function validate_odeslat(formular)  {
 	if((formular.email.value.indexOf("@") < 1 || formular.email.value.indexOf("@") != formular.email.value.lastIndexOf("@") || formular.email.value.lastIndexOf(".") < formular.email.value.lastIndexOf("@")+2  || formular.email.value.lastIndexOf(".") > (formular.email.value.length-3) || formular.email.value.lastIndexOf(".") < (formular.email.value.length-4))) { 
		alert ("CHYBA: vyplňte prosím správně svůj email!");
		return false;
  }
}

// ------------------------------------------ funkce pro kontrolu vyberu v ankete
function validate_anketa(formular)  {
	if ((!formular.anketa[0].checked) && (!formular.anketa[1].checked) && (!formular.anketa[2].checked) && (!formular.anketa[3].checked) && (!formular.anketa[4].checked)) {
		alert ("CHYBA: vyberte prosím alespoň jednu možnost!");
		return false;
  }
}

// ------------------------------------------ funkce pro emailu pro odeslani clanku
function validate_soutez(formular)  {
 	if((formular.email.value.indexOf("@") < 1 || formular.email.value.indexOf("@") != formular.email.value.lastIndexOf("@") || formular.email.value.lastIndexOf(".") < formular.email.value.lastIndexOf("@")+2  || formular.email.value.lastIndexOf(".") > (formular.email.value.length-3) || formular.email.value.lastIndexOf(".") < (formular.email.value.length-4))) { 
		alert ("CHYBA: vyplňte prosím správně svůj email!");
		return false;
   }
   
   if((formular.nazev.value=="") || (formular.jmeno.value=="") || (formular.adresa.value=="") || (formular.telefon.value=="") || (formular.vek.value=="") || (formular.navstevuje.value=="")) { 
		alert ("CHYBA: vyplňte prosím správně svůj všechna políčka formuláře!");
		return false;
   }
}



// ------------------------------------------ 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')
}

var PocetMenu = 10;
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="";
  }
}

	//nacteni obrazku do cache
	img = new Array();
	img[1] = new Image();
	img[2] = new Image();
	img[3] = new Image();
	img[4] = new Image();
	img[5] = new Image();
	img[6] = new Image();
	img[7] = new Image();
	img[8] = new Image();
	img[1].src = "img/mladez_1.gif";
	img[2].src = "img/mladez_2.gif";
	img[3].src = "img/mladez_3.gif";
	img[4].src = "img/mladez_1_hover.gif";
	img[5].src = "img/mladez_2_hover.gif";
	img[6].src = "img/mladez_3_hover.gif";
	img[7].src = "img/mladez_2_1.gif";
	img[8].src = "img/mladez_3_2.gif";
	
function change_tab(tab,idcko,pocet_menu){
	
	//nastaveni vsech tabu na stejny vzhled
	for(i=1; i<=pocet_menu; i++) {
      box = document.getElementById('tab'+tab+'_'+i);	
      box.style.display="none";
	  document.getElementById('tab'+tab+'_'+i+'_show').src=img[i].src;
	  
	}
	//prepnout na odkliknuty tab
	 box=document.getElementById('tab'+tab+'_'+idcko);
	 box.style.display="";
	 if (idcko==1){
		 document.getElementById('tab'+tab+'_'+idcko+'_show').src=img[4].src;
		 document.getElementById('tab'+tab+'_'+2+'_show').src=img[7].src;
	 }
	 if (idcko==2){
		 document.getElementById('tab'+tab+'_'+idcko+'_show').src=img[5].src;
		 document.getElementById('tab'+tab+'_'+3+'_show').src=img[8].src;
	 }
	 if (idcko==3){
		 document.getElementById('tab'+tab+'_'+idcko+'_show').src=img[6].src;
	 }
  
}

function soutez(x)
{window.open('soutez_tip/info.html','','toolbar=no,scrollbars=no,location=no,status=no,width=700,height=400,resizable=no')}

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);
         }
		 
  	var top_count=10;
	var top_class="top_story_left_box";
	
	function show_top(id_top){
		 
	 if (document.getElementById("top"+id_top).className!=top_class+" show"){
		 
		 for(i=1; i<=top_count; i++) {
		 	document.getElementById("top"+i).className=top_class;
			if (i%2==0)	document.getElementById("thumb"+i).className=""; else document.getElementById("thumb"+i).className="highlight"; 
		 }
		 document.getElementById("top"+id_top).className=top_class+" show";
		 document.getElementById("thumb"+id_top).className="selected";
	 }
	}
	
function switch_top(id_top){
		show_top(id_top);
}
