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="button1";
		 }
		 
		 if (end==2) {
			 id=top;
			 if (top<4){ id=id+1; }
			 top=id;
		 }	
		 
		 if (end==3) {
			 id=top;
			 if (top>1){ id=id-1; }
			 top=id;
		 }	
		 
		 for(i=1; i<=4; 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;
		id3="top_navigace_"+(id+3)+"_on";
		id4="top_navigace_"+(id+3)+"_off";
		//alert(id)
	 	document.getElementById(id2).className="top_story";
		document.getElementById(id3).className="";
		document.getElementById(id4).className="hidden";
	}
	
	function stop_top(){
		clearTimeout(casovac);
		document.getElementById("top_navigace_2_on").className="button1";
		document.getElementById("top_navigace_2_off").className="hidden";
	}
	
	function opakovana(id_top,control){
		id_top=id_top+1;
		if (id_top==5) {
			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);
		}
}
