var ns6=document.getElementById&&!document.all;
var timerID=0;
var showen=0;

//window.onload=function(){Ycx_initmenu('menu');};
window.onload=init_Page;

function init_Page(){
	Ycx_initmenu('menu');
}

function Ycx_fitmenusize(elem){
	menuelem=document.getElementById(elem);
	lis=menuelem.getElementsByTagName('li');
	
	liscount=0;
	liswidth=0;
	for(i=0;i<lis.length;i++){
		if (lis[i].parentNode==menuelem){
			liscount++;
			liswidth+=lis[i].offsetWidth;
		}
	}
	jednotka=Math.round((menuelem.offsetWidth - liswidth) / liscount);
	celkem=menuelem.offsetWidth - liswidth;
	for(i=0;i<lis.length;i++){
		if (lis[i].parentNode==menuelem){
			pricist=Math.min(celkem,jednotka)
			celkem-=pricist;
			lis[i].style.width=(lis[i].offsetWidth+pricist-1)+'px';
		}
	}
	//alert(lis.length+' ... '+liscount+' ... '+liswidth+' ... '+jednotka);
	//alert(menuelem.offsetWidth+'xxx');
}

function hideSidebar(){
	document.getElementById('leftcol').style.display='none';
	document.getElementById('container').style.marginLeft='-300px';
	document.getElementById('open').style.display='';
}
function showSidebar(){
	document.getElementById('leftcol').style.display='';
	document.getElementById('container').style.marginLeft='-223px';
	document.getElementById('open').style.display='none';
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function Ycx_menustop(){
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }	
}

function Ycx_menustart(elem){
	Ycx_menustop();
	showen=0;
	timerID = setTimeout("Ycx_hidesubmenu('"+elem+"')",1500);
}


function Ycx_initmenu(){
	for (i=0;i<Ycx_initmenu.arguments.length;i++){
		if (mn=document.getElementById(Ycx_initmenu.arguments[i])){

			if (ns6){
				mn.setAttribute("onMouseOut","Ycx_menustart('"+Ycx_initmenu.arguments[i]+"');");
			} else {
				eval("mn.attachEvent(\"onmouseout\",function(){Ycx_menustart('"+Ycx_initmenu.arguments[i]+"')});");
			}


			uls=mn.getElementsByTagName('ul');
			for (j=uls.length-1;j>=0;j--){
				uls[j].style.display='none';
			}
			
			lis=mn.getElementsByTagName('li');
			for (j=lis.length-1;j>=0;j--){
				if (ns6){
					lis[j].setAttribute("onMouseOver","Ycx_showsubmenu(this);");
				} else {
					lis[j].attachEvent("onmouseover",function(){Ycx_showsubmenu(this)});
				}
			}
		}
	}
}

function Ycx_showsubmenu(elem){
	if (!ns6){ elem=event.srcElement.parentNode; };
	
	lis=elem.parentNode.getElementsByTagName('li');
	pocet=0;
	showen=1;
	for (i=0;i<lis.length;i++){
		if (lis[i].parentNode==elem.parentNode){
			uls=lis[i].getElementsByTagName('ul');
			for (j=0;j<uls.length;j++){
				if (lis[i]==elem){
					if (j==0){
						uls[j].style.display='';
					} else {
						if (!ns6){
							uls[j].style.display='none';
						}
					}
				} else {
					uls[j].style.display='none';
				}
			}
		}
	}
}





function Ycx_hidesubmenu(menuid){
		elem=document.getElementById(menuid);
		if (!showen){
			
			uls=elem.getElementsByTagName('ul');
			for (i=uls.length-1;i>=0;i--){
				uls[i].style.display='none';
			}
		}
		Ycx_menustop();

}

	
	newsalpha = 0;
	newsrychlost = 70;
	newspauza = 4000;
	poradiaktuality=0;
	aktualityodecitani = false;
	
	function newsrotate(skipcheck){
		aktuality = document.getElementById('newscover3');
		if (aktuality){
			aktualita = aktuality.getElementsByTagName('li');
			for (i=0;i<aktualita.length;i++){
				if (i==poradiaktuality){
					aktualita[i].style.display='';
					if (ns6){
						aktualita[i].style.MozOpacity=newsalpha/10;
					} else {
						aktuality.style.top=-((10-newsalpha)*10)+'px';
					}
				} else {
					aktualita[i].style.display='none';
					aktualita[i].style.MozOpacity=0;
				}
			}
			fcepauza=newsrychlost;
			if (newsalpha==10){
				aktualityodecitani = true;
				fcepauza=newspauza;
			} else if (newsalpha==0) {
				aktualityodecitani = false;
				if (skipcheck){
					poradiaktuality = (poradiaktuality+1)%aktualita.length;
				}
			}
			if (aktualityodecitani){
				newsalpha--;
			} else {
				newsalpha++;
			}
			setTimeout("newsrotate(true)",fcepauza);
		}
	}
	
	smeraktualit=false;
	aktualityrunning=false;
	aktualitymin=207;
	aktualitymax=490;
	aktualitykrok = 10;
	aktualityrychlostvysuv=20;
	aktualityrychlostzasuv=10;
	
	pravevysunuto=aktualitymin;
	
	function vysunaktuality(skipcheck){
		hejble = document.getElementById('newscover2');
		if (pravevysunuto < aktualitymax && smeraktualit=='vysuv' && (!aktualityrunning || skipcheck)){
			aktualityrunning=true;
			pravevysunuto+=aktualitykrok;
			hejble.style.width=pravevysunuto+'px';
			if (pravevysunuto < aktualitymax){
				setTimeout("vysunaktuality(true)",aktualityrychlostvysuv);
			} else {
				aktualityrunning = false;
			}
		} else if (smeraktualit=='zasuv' && pravevysunuto > aktualitymin) {
			aktualityrunning=false;
			pravevysunuto-=aktualitykrok;
			hejble.style.width=pravevysunuto+'px';
			if (pravevysunuto > aktualitymin){
				setTimeout("vysunaktuality(true)",aktualityrychlostzasuv);
			}
		}
	}



	var x99=0;
	var y99=0;
	var sirka=705;
	var vyska=251;
	var xsmer='plus';
	var ysmer='plus';
	var rychlost=50;
	var op=0;
	
	var i99=0;
	var xxpocet=0;
	var aktpohyb=0;
	
	var pohyb=new Array();
	pohyb[0]="vert";
	pohyb[1]="hor";
	pohyb[2]="diag";
	
	function initgallery(){
		xxpocet=document.getElementById('foto').getElementsByTagName('img').length;
		startmove();
	}
	
	function startmove(){
		aktpohyb=Math.round(Math.random() * 2);
		//aktpohyb=1;
		domove();
	}
	
	function domove(){
		fotka=document.getElementById('foto').getElementsByTagName('img')[i99];
		fotka.style.filter='alpha(opacity='+(op*10)+')';
		fotka.style.MozOpacity=op/10;
		fotka.style.display='';
		fotka.style.left='-'+x99+'px';
		fotka.style.top='-'+y99+'px';
		switch(pohyb[aktpohyb]){
			case "vert":
				op=Math.min(10,x99,(fotka.width-sirka-x99));
				x99=Math.min(x99,fotka.width-sirka);
				y99=Math.round(fotka.height/2);
				if (xsmer=='plus'){
					if (x99+1>fotka.width-sirka){
						fotka.style.display='none';
						xsmer='minus';
						i99=(i99+1)%xxpocet;
						setTimeout("startmove()",rychlost);
					} else {
						x99++;
						fotka.style.left='-'+x99+'px';
						setTimeout("domove()",rychlost);
					}
				} else {
					if (x99-1<0){
						fotka.style.display='none';
						xsmer='plus';
						i99=(i99+1)%xxpocet;
						setTimeout("startmove()",rychlost);
					} else {
						x99--;
						fotka.style.left='-'+x99+'px';
						setTimeout("domove()",rychlost);
					}
				}
				break;
			case "hor":
				op=Math.min(10,y99,(fotka.height-vyska-y99));
				y99=Math.min(y99,fotka.height-vyska);
				//x99=Math.round(fotka.width/2);
				x99=200;
				if (ysmer=='plus'){
					if (y99+1>fotka.height-vyska){
						fotka.style.display='none';
						ysmer='minus';
						i99=(i99+1)%xxpocet;
						setTimeout("startmove()",rychlost);
					} else {
						y99++;
						fotka.style.top='-'+y99+'px';
						setTimeout("domove()",rychlost);
					}
				} else {
					if (y99-1<0){
						fotka.style.display='none';
						ysmer='plus';
						i99=(i99+1)%xxpocet;
						setTimeout("startmove()",rychlost);
					} else {
						y99--;
						fotka.style.top='-'+y99+'px';
						setTimeout("domove()",rychlost);
					}
				}
				break;
			case "diag":
				op=Math.min(10,y99,(fotka.height-vyska-y99),(fotka.width-sirka-x99));
				x99=Math.min(x99,fotka.width-sirka);
				y99=Math.min(y99,fotka.height-vyska);
				if (xsmer=='plus'){
					if (ysmer=='plus'){
						if (x99+1>fotka.width-sirka || y99+1>fotka.height-vyska){
							fotka.style.display='none';
							xsmer='minus';
							ysmer='minus';
							i99=(i99+1)%xxpocet;
							setTimeout("startmove()",rychlost);
						} else {
							x99++;
							y99++;
							fotka.style.left='-'+x99+'px';
							fotka.style.top='-'+y99+'px';
							setTimeout("domove()",rychlost);
						}
					} else {
						if (x99+1>fotka.width-sirka || y99-1<0){
							fotka.style.display='none';
							xsmer='minus';
							ysmer='plus';
							i99=(i99+1)%xxpocet;
							setTimeout("startmove()",rychlost);
						} else {
							x99++;
							y99--;
							fotka.style.left='-'+x99+'px';
							fotka.style.top='-'+y99+'px';
							setTimeout("domove()",rychlost);
						}
					}
				} else {
					if (ysmer=='plus'){
						if (x99-1<0 || y99+1>fotka.height-vyska){
							fotka.style.display='none';
							xsmer='plus';
							ysmer='minus';
							i99=(i99+1)%xxpocet;
							setTimeout("startmove()",rychlost);
						} else {
							x99--;
							y99++;
							fotka.style.left='-'+x99+'px';
							fotka.style.top='-'+y99+'px';
							setTimeout("domove()",rychlost);
						}
					} else {
						if (x99-1<0 || y99-1<0){
							fotka.style.display='none';
							xsmer='plus';
							ysmer='plus';
							i99=(i99+1)%xxpocet;
							setTimeout("startmove()",rychlost);
						} else {
							x99--;
							y99--;
							fotka.style.left='-'+x99+'px';
							fotka.style.top='-'+y99+'px';
							setTimeout("domove()",rychlost);
						}
					}
				}
				break;
		}
	}
	
	//window.onload=initgallery;
	//setTimeout("initgallery()",2000);
	//initgallery();

