// ------------------------------------------ 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+" ";
	document.getElementById("cely_text").value.focus();
}

// ------------------------------------------ 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;
  }
}

function fotka(soubor,w,h) { window.open(soubor,"","toolbar=no,scrollbars=no,location=no,status=no,width="+w+",height="+h+",resizable=1")}

// ------------------------------------------ funkce pro kontrolu vyberu v ankete
function validate_search(formular)  {
	if (formular.search_input.value=="") {
		alert ("CHYBA: zadejte prosím text, který chcete vyhledat!");
		formular.search_input.focus();
		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="";
  }
}

// ------------------------------------------ fce na rotaci TOPstory
var top;
top=1;
function prepni_top(id,end){
		 var i,id2,id3,id4,id5;
		 
		 if (end!=0) {	stop_top(); }else{
		 	document.getElementById("top_navigace_2_on").className="hidden";
			document.getElementById("top_navigace_2_off").className="button";
		 }
		 
		 if (end==2) {
			 id=top;
			 if (top<5){ id=id+1; }
			 top=id;
		 }	
		 
		 if (end==3) {
			 id=top;
			 if (top>1){ id=id-1; }
			 top=id;
		 }	
		 
		 for(i=1; i<=5; i++) {
		 	 id2="top"+i;
			 id3="top_navigace_"+(i+3)+"_on";
			 id4="top_navigace_"+(i+3)+"_off";
		     document.getElementById(id2).className="hidden";
			 document.getElementById(id3).className="hidden";
			 document.getElementById(id4).className="";
		 }
		id2="top"+id;
		//alert(id2);
		id3="top_navigace_"+(id+3)+"_on";
		id4="top_navigace_"+(id+3)+"_off";
		//alert(id)
	 	document.getElementById(id2).className="top_story_box";
		document.getElementById(id3).className="";
		document.getElementById(id4).className="hidden";
	}
	
	function stop_top(){
		clearTimeout(casovac);
		document.getElementById("top_navigace_2_on").className="button";
		document.getElementById("top_navigace_2_off").className="hidden";
	}
	
	function opakovana(id_top,control){
		id_top=id_top+1;
		if (id_top==6) {
			id_top=1;
		}
		
		if (control!=0) {
			casovac=window.setTimeout("opakovana("+id_top+","+control+")", 4000); // volá sebe samu odloženou o sekundu
			prepni_top(id_top,0);
		}
}

// ------------------------------------------ funkce pro posun photo boxu
var position = 0;
var a = 0;
var interval = 25;
var int2 = interval;

function scrollToRight() {

	if (position>-(3050)) position-=interval;
	moveElement(position);
	if (a<6)
	{
		if (a==5) interval=5;
		setTimeout("scrollToRight()", 20);
		a++;
	} else {
		a = 0;
		interval=int2;
	}
}

function scrollToLeft() {
	if (position<0) position+=interval;
	moveElement(position);
	if (a<6)
	{
		if (a==5) interval=5;
		setTimeout("scrollToLeft()", 20);
		a++;
	} else {
		a = 0;
		interval=int2;
	}
}

function moveElement() {
    trailery = document.getElementById('hidden_box').style;
	trailery.marginLeft = position + 'px';
}
function resetPosition() {position=0;}

// ------------------------------------------ funkce pro kontrolu vyberu v ankete
function validate_hlasovani(formular,type)  {
	if (type==1){
		pocet=document.getElementById("intPocetType").value;
		bollCheck=false;
		for(i=0; i<pocet; i++) {
			if (document.getElementById("hrac_"+i).checked) {
				bollCheck=true;
			}
		}
		if (bollCheck==false){
			alert ("CHYBA: vyberte prosím alespoň jednu možnost!");
			return false;
		}
	}
	if (type==2){
		pocet=document.getElementById("intPocetType").value;
		bollCheck=true;
		bollCheck2=true;
		for(i=1; i<=pocet; i++) {
			if (document.getElementById("hrac_"+i).value==0) {
				bollCheck=false;
			}
		}
		if (document.getElementById("hrac_1").value==document.getElementById("hrac_2").value || document.getElementById("hrac_1").value==document.getElementById("hrac_3").value || document.getElementById("hrac_2").value==document.getElementById("hrac_3").value){
			bollCheck2=false;
		}
		
		
		if (bollCheck==false){
			alert ("CHYBA: vyberte prosím z každé roletky jednoho hráče!");
			return false;
		}
		
		if (bollCheck2==false){
			alert ("CHYBA: nesmíte mít jednoho hráče vybraného vícekrát!");
			return false;
		}
	}
	
}

