nadpisy=new Array("home","CV","překlady","učebnice","filmy","knihy","ilustrace","anotace","ohlasy","archiv","básně","odkazy","kontakt")
odkazy=new Array("index.html","cv.html","preklady.html","ucebnice.html","filmy.html","knihy.html","ilustrace.html","anotace.html","ohlasy.html","archiv.html","basne.html","odkazy.html","kontakt.html")

loadImg=new Image()
loadImg.src="obrazky/loading.gif"

var bodyWidth;
var bodyHeight;

function writeMenu(){

//cont.innerHTML+=''
bodyWidth=document.body.clientWidth;
bodyHeight=document.body.clientHeight;

nabidka=document.getElementById("menu")
for(i=0;i<nadpisy.length;i++){
nabidka.innerHTML+='<br><a href="'+odkazy[i]+'">'+nadpisy[i]+'</a><br>'
}

cont=document.getElementById("content")
if(document.body.scrollHeight<document.body.clientHeight){cont.style.height=document.body.clientHeight}
else{cont.style.height=document.body.scrollHeight}

prepareGalleries()
}

function thumb(pictures){
if(pictures.indexOf(",")>-1){
picture=pictures.split(",")
output=""
for(i=0;i<picture.length;i++){output+='<a href="obrazky/'+picture[i]+'"><img src="nahledy/'+picture[i]+'"></a>'}
}
else{
picture=pictures
output='<a href="obrazky/'+picture+'"><img src="nahledy/'+picture+'"></a>'
}
document.write(output)
}

galleries=0
galPictures=new Array
galPicturesLarge=new Array

function gallery(pictures,gwidth){
prevButton='<img src="obrazky/prev.png" align=absmiddle border=0>'
nextButton='<img src="obrazky/next.png" align=absmiddle border=0>'
galleries++
galID=galleries
//galPictures[galID]=pictures.split(",")
galPictures[galID]=new Array
galPicturesLarge[galID]=new Array
gpic=pictures.split(",")
for(i=0;i<gpic.length;i++){
galPictures[galID][i]=new Image
galPictures[galID][i].src="nahledy/"+gpic[i]
galPicturesLarge[galID][i]="obrazky/"+gpic[i]
}
output='<span id="gal'+galID+'"><table style="width:'+(gwidth+10)+'px"><tr><td align=center><a href="'+galPicturesLarge[galID][0]+'"><img src="'+galPictures[galID][0].src+'"></a></td></tr><tr align=center><td><a class="arrow">'+prevButton+'</a> <span style="color:FF9900">'+1+' / '+galPictures[galID].length+'</span> <a class="arrow" href="javascript:nextPic('+galID+',0)">'+nextButton+'</a></td></tr></table></span>'
document.write(output)
}

function nextPic(galID,current){
if(document.getElementById("gal"+galID).firstChild.outerHTML!=undefined){
gwidth=document.getElementById("gal"+galID).firstChild.outerHTML.split('"')[1]
}
else{
gwidth=document.getElementById("gal"+galID).firstChild.getAttribute("style")
}

if(current+1==galPictures[galID].length-1){
output='<table style="'+gwidth+'"><tr><td align=center><a href="'+galPicturesLarge[galID][current+1]+'"><img src="'+galPictures[galID][current+1].src+'"></a></td></tr><tr align=center><td><a class="arrow" href="javascript:prevPic('+galID+','+(current+1)+')">'+prevButton+'</a> <span style="color:FF9900">'+(current+2)+' / '+galPictures[galID].length+'</span> <a class="arrow">'+nextButton+'</a></td></tr></table>'
}
else{
output='<table style="'+gwidth+'"><tr><td align=center><a href="'+galPicturesLarge[galID][current+1]+'"><img src="'+galPictures[galID][current+1].src+'"></a></td></tr><tr align=center><td><a class="arrow" href="javascript:prevPic('+galID+','+(current+1)+')">'+prevButton+'</a> <span style="color:FF9900">'+(current+2)+' / '+galPictures[galID].length+'</span> <a class="arrow" href="javascript:nextPic('+galID+','+(current+1)+')">'+nextButton+'</a></td></tr></table>'
}
document.getElementById("gal"+galID).innerHTML=output
prepareGalleries()
}

function prevPic(galID,current){
if(document.getElementById("gal"+galID).firstChild.outerHTML!=undefined){
gwidth=document.getElementById("gal"+galID).firstChild.outerHTML.split('"')[1]
}
else{
gwidth=document.getElementById("gal"+galID).firstChild.getAttribute("style")
}

if(current-1==0){
output='<table style="'+gwidth+'"><tr><td align=center><a href="'+galPicturesLarge[galID][0]+'"><img src="'+galPictures[galID][0].src+'"></a></td></tr><tr align=center><td><a class="arrow">'+prevButton+'</a> <span style="color:FF9900">'+(current)+' / '+galPictures[galID].length+'</span> <a class="arrow" href="javascript:nextPic('+galID+',0)">'+nextButton+'</a></td></tr></table>'
}
else{
output='<table style="'+gwidth+'"><tr><td align=center><a href="'+galPicturesLarge[galID][current-1]+'"><img src="'+galPictures[galID][current-1].src+'"></a></td></tr><tr align=center><td><a class="arrow" href="javascript:prevPic('+galID+','+(current-1)+')">'+prevButton+'</a> <span style="color:FF9900">'+(current)+' / '+galPictures[galID].length+'</span> <a class="arrow" href="javascript:nextPic('+galID+','+(current-1)+')">'+nextButton+'</a></td></tr></table>'
}
document.getElementById("gal"+galID).innerHTML=output
prepareGalleries()
}





function hide(obj){
obj.style.display="none"
i=document.getElementById("origImg");
i.width=40;
i.height=40;

s=document.getElementById("scrollSpace");
s.style.width="";
s.style.height="";
maximized=false;
emb=document.getElementsByTagName("embed");
if(emb!=null) for(i=0;i<emb.length;i++) emb[i].style.visibility="visible"
}

function prepareGalleries(){	
	if(navigator.appName.indexOf("Internet Explorer")==-1){
		pic=document.getElementsByTagName("a");			
		for(i=0;i<pic.length;i++){
			hr=pic[i].getAttribute("href");
			if(hr!=null)
				if(hr.toLowerCase().indexOf("javascript:")==-1 && hr.toLowerCase().indexOf(".jpg")>-1 || hr.indexOf(".png")>-1){				
					pic[i].setAttribute('href','javascript:showImage("'+hr+'")');
				}		
		}
	}
}

function showImage(file){
	
	myImg=new Image();
	myImg.src=file;
	
	resized=false
	
	if(document.getElementById("fotoFrame")==null)
			document.body.innerHTML+='<div id="fotoBackground"><div id="fotoFrame"><div id="fotoBar" align=right><a href="javascript:hide(document.getElementById(\'fotoBackground\'))" style="text-decoration:none;font-size:10pt;color:#FFFFFF;font-family:Tahoma;font-weight:bold;font-style:normal">X</a></div><div id="scrollSpace"><img id="origImg" src=""></div></div></div>';
	
	l=document.getElementById("origImg");
	l.src=loadImg.src;
	f=document.getElementById("fotoFrame");
	posLeft=(bodyWidth-f.offsetWidth)/2
	posTop=(bodyHeight-f.offsetHeight)/2
	f.style.left=posLeft;
	f.style.top=posTop;
		
	document.getElementById("fotoBackground").style.display="block";
	
	myImg.onload=function(){
		picWidth=myImg.width;
		picHeight=myImg.height;
		
		bodyWidth=document.body.clientWidth;
		bodyHeight=document.body.clientHeight;
		
		if(picWidth>bodyWidth || picHeight>bodyHeight){
			resized=true
			aspectRatio=picWidth/picHeight;
			if(aspectRatio>bodyWidth/bodyHeight){		
				picWidth=bodyWidth-2;
				picHeight=Math.ceil(picWidth/aspectRatio);
			}
			else{
				picHeight=bodyHeight-18;
				picWidth=Math.ceil(picHeight*aspectRatio);
			}
		}
		
		posLeft=(bodyWidth-picWidth-2)/2
		posTop=(bodyHeight-picHeight-18)/2
					
		emb=document.getElementsByTagName("embed");
		if(emb!=null) for(i=0;i<emb.length;i++) emb[i].style.visibility="hidden"
		
		i=document.getElementById("origImg");
		i.src=myImg.src;
		i.width=picWidth;
		i.height=picHeight;
		i.style.cursor="auto";
		i.onclick="void()";
		if(resized){
			i.style.cursor="url('obrazky/magnify.cur'), move";
			maximized=false;
			i.onclick=function(){
				bodyWidth=document.body.clientWidth;
				bodyHeight=document.body.clientHeight;
				if(!maximized){
					s=document.getElementById("scrollSpace");
					
					frameWidth=myImg.width>bodyWidth-2 ? bodyWidth-2 : myImg.width+17;
					frameHeight=myImg.height>bodyHeight-18 ? bodyHeight-18 : myImg.height+17;
					
					frameWidth=frameWidth>bodyWidth-2 ? bodyWidth-2 : frameWidth;
					frameHeight=frameHeight>bodyHeight-18 ? bodyHeight-18: frameHeight;
					
					i=document.getElementById("origImg");
					i.width=myImg.width;
					i.height=myImg.height;
					i.style.cursor="url('obrazky/minimize.cur'), move";
					
					s.style.width=frameWidth;
					s.style.height=frameHeight;
					s.style.overflow="auto";
					
					f=document.getElementById("fotoFrame");
					posLeft=(bodyWidth-f.offsetWidth)/2
					posTop=(bodyHeight-f.offsetHeight)/2
					f.style.left=posLeft;
					f.style.top=posTop;
					
					
					maximized=true;
				}
				else{
					i=document.getElementById("origImg");
					i.width=picWidth;
					i.height=picHeight;
					i.style.cursor="url('obrazky/magnify.cur'), move";
					f=document.getElementById("fotoFrame");
					posLeft=(bodyWidth-picWidth-2)/2
					posTop=(bodyHeight-picHeight-18)/2
					f.style.left=posLeft;
					f.style.top=posTop;
					
					s=document.getElementById("scrollSpace");
					s.style.width="";
					s.style.height="";
					maximized=false;
				}
			}
		}		
		
		f=document.getElementById("fotoFrame");
		f.style.left=posLeft;
		f.style.top=posTop;		
	}
}

