// JavaScript Document
var IndexNews=1;
var IndexPortfolio=2;
var IndexProjects=3;
var IndexBiography=4;
var IndexExhibitions=5;
var IndexAwards=6;
var IndexPress=7;
var IndexContact=8;
var index=1;
var timer=0;
var pexst=0;
var pexon=1;
var news=0;			//pomucka pro zobrazeni 'pexeso' (news bylo prohlednuto)
var por=0;			//pomucka pro zobrazeni 'pexeso' (portfolio bylo prohlednuto)
var pro=0;			//pomucka pro zobrazeni 'pexeso' (projects bylo prohlednuto)
var bio=0;			//pomucka pro zobrazeni 'pexeso' (bigraphy bylo prohlednuto)
var exh=0;			//pomucka pro zobrazeni 'pexeso' (exhibitions bylo prohlednuto)
var awa=0;			//pomucka pro zobrazeni 'pexeso' (awards bylo prohlednuto)
var pre=0;			//pomucka pro zobrazeni 'pexeso' (press bylo prohlednuto)
var con=0;			//pomucka pro zobrazeni 'pexeso' (contact bylo prohlednuto)
var menu=0;			//polozka menu
var loading=1;
var moving=0;
var ldSupport=4;	//pomocne obrazky: pixel, loading, name, copyright
var ldMenuItems=2+2+2+2+2+2+2+2;	//polozky menu: 7*(aktivni+neaktivni+animace_aktivni+animace_neaktivni)
var ldTexts=1+0+1+1+1+1+1+0+1;
var ldNews=18+5+0+0+15+0+6;	//59=uvod+news1+news2+news3+news4+news5+news6+news7
var ldPortfolio=50;	//jen nahledy
var ldProjects=0;
var ldBiography=0;
var ldExhibitions=0;
var ldAwards=0;
var ldPress=10;
var ldContact=0;
var loaded=0;
//var allLoaded=3+3+6+6+6+6+10+10+10+2+1+10+4+4;	//pocet predem nacitanych obrazku
var allLoaded=ldSupport+ldMenuItems+ldTexts+ldNews+ldPortfolio+ldProjects+ldBiography+ldExhibitions+ldAwards+ldPress+ldContact;	//pocet predem nacitanych obrazku
//var allLoaded=19;
var sObj;			//object scrollbar
var aIndex = 0;			//index obrazku
var sPos;				//pozice scrollbaru
var sPosMax;
//sirky nahledu - pouziva se v lightboxu!!!
var nW = 7;				//mezera mezi nahledy
var wP = new Array(0,69+nW,64+nW,85+nW,62+nW,85+nW,85+nW,85+nW,85+nW,85+nW,89+nW,109+nW,85+nW,112+nW,103+nW,115+nW,109+nW,85+nW,109+nW,85+nW,60+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,64+nW,64+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW,85+nW); 
 
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { 
    v=args[i+2];
    if (obj.style) { 
	  obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
	}
    obj.visibility=v;
	if (v=='hidden') {
	  obj.position='absolute';
	  obj.left='-4000px';
	  obj.top='-4000px';
	} else {
	  obj.position='relative';
	  obj.left='0px';
	  obj.top='0px';
	}
  }
}

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 hidePexeso() {
  if (pexon==1) {
    document.pexeso.src="menu/pixel.gif";
	document.pexeso.width=0;
	document.pexeso.height=0;
	pexon=0;
  }
  clearTimeout( timer);
  timer=setTimeout( "showPexeso()", 10000);
}

function showPexeso() {
  if ((news==1) && (por==1) && (pro==1) && (bio==1) && (exh==1) && (awa==1) && (pre==1) && (con==1) && (menu==IndexPortfolio)) {
	document.pexeso.width=52;
	document.pexeso.height=14;
    document.pexeso.src="menu/pexeso.gif";
  }
  pexon=1;
  clearTimeout( timer);
  timer=setTimeout( "hidePexeso()", 600);
}

function centerVertically() {
  var arrayPageSize = getPageSize(); //pageWidth,pageHeight,windowWidth,windowHeight
  h=arrayPageSize[3]; //arrayPageSize[3] je windowHeight
  h=Math.round(h/5);
  if (h<0) {
    h=0;
  }
  document.spaceTop.height=h; //vyska obrazku spaceTop v prvnim radku tabulky
  document.spaceTop.src="menu/pixel.gif";
  if (pexst==0) {
	pexst=1;  
    timer=setTimeout( "showPexeso()", 10000);
  }
}

function initializeSite() {
	MM_preloadImages('menu/loading.gif','menu/pixel.gif','menu/name.gif','menu/copyrigh.gif');
	loaded=ldSupport;
	MM_preloadImages('menu/n_news.gif','menu/a_news.gif');
	MM_preloadImages('menu/a_portfo.gif','menu/n_portfo.gif');
	MM_preloadImages('menu/n_projec.gif','menu/a_projec.gif');
	MM_preloadImages('menu/n_biogra.gif','menu/a_biogra.gif');
	MM_preloadImages('menu/n_exhibi.gif','menu/a_exhibi.gif');
	MM_preloadImages('menu/n_awards.gif','menu/a_awards.gif');
	MM_preloadImages('menu/n_press.gif','menu/a_press.gif');
	MM_preloadImages('menu/n_contac.gif','menu/a_contac.gif');
	loaded=loaded+ldMenuItems;
	MM_preloadImages('txt/news.jpg','txt/projects.gif','txt/biograph.jpg','txt/exhibiti.gif','txt/awards.gif','txt/contact.gif');
	loaded=loaded+ldTexts;
	MM_preloadImages('portp/_01.jpg','portp/_02.jpg');
	MM_preloadImages('portp/01.jpg','portp/02.jpg','portp/03.jpg','portp/04.jpg','portp/05.jpg','portp/06.jpg','portp/07.jpg','portp/08.jpg','portp/09.jpg','portp/10.jpg');
	MM_preloadImages('portp/11.jpg','portp/12.jpg','portp/13.jpg','portp/14.jpg','portp/15.jpg','portp/16.jpg','portp/17.jpg','portp/18.jpg','portp/19.jpg','portp/20.jpg');
	MM_preloadImages('portp/21.jpg','portp/22.jpg','portp/23.jpg','portp/24.jpg','portp/25.jpg','portp/26.jpg','portp/27.jpg','portp/28.jpg','portp/29.jpg','portp/30.jpg');
	MM_preloadImages('portp/31.jpg','portp/32.jpg','portp/33.jpg','portp/34.jpg','portp/35.jpg','portp/36.jpg','portp/37.jpg','portp/38.jpg','portp/39.jpg','portp/40.jpg');
	MM_preloadImages('portp/41.jpg','portp/42.jpg','portp/43.jpg','portp/44.jpg','portp/45.jpg','portp/46.jpg','portp/47.jpg','portp/48.jpg');
	loaded=loaded+ldPortfolio;
	MM_preloadImages('news1/01.jpg','news1/02.jpg','news1/03.jpg','news1/04.jpg','news1/05.jpg','news1/06.jpg','news1/07.jpg','news1/08.jpg','news1/09.jpg','news1/10.jpg');
	MM_preloadImages('news1/11.jpg','news1/12.jpg','news1/13.jpg','news1/14.jpg','news1/15.jpg','news1/16.jpg','news1/17.jpg','news1/18.jpg');
	MM_preloadImages('news2/02.jpg','news2/03.jpg','news2/04.jpg','news2/05.jpg','news2/06.jpg');
	MM_preloadImages('news5/01.jpg','news5/02.jpg','news5/03.jpg','news5/04.jpg','news5/05.jpg','news5/06.jpg','news5/07.jpg','news5/08.jpg','news5/09.jpg','news5/10.jpg');
	MM_preloadImages('news5/11.jpg','news5/12.jpg','news5/13.jpg','news5/14.jpg','news5/15.jpg');
	MM_preloadImages('news7/1.jpg','news7/2.jpg','news7/3.jpg','news7/4.jpg','news7/5.jpg','news7/6.jpg');
	loaded=loaded+ldNews;
	MM_preloadImages('press/01.jpg','press/02.jpg','press/03.jpg','press/04.jpg','press/05.jpg','press/06.jpg','press/07.jpg','press/08.jpg','press/09.jpg','press/10.jpg');
	loaded=loaded+ldPress;
	//alert(loaded);
	//alert(allLoaded);
	centerVertically();
	showPortfolio();
	hidePexeso();
}

function resetMenu() {
  //document.news.src="menu/news_a.gif";	
  document.news.src="menu/n_news.gif";	
  document.portfolio.src="menu/n_portfo.gif";
  document.projects.src="menu/n_projec.gif";
  document.biography.src="menu/n_biogra.gif";
  document.exhibitions.src="menu/n_exhibi.gif";
  document.awards.src="menu/n_awards.gif";
  document.press.src="menu/n_press.gif";
  document.contact.src="menu/n_contac.gif";
  hidePexeso();
  sObj=0;
}

function animateNews(img) {
	if (menu!=IndexNews) {
		document.news.src=img;
	}
}

function showNews() {
  if (loaded>=allLoaded) {
	  if (menu!=IndexNews) {
		resetMenu();
		document.news.src="menu/a_news.gif";
		MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="menu/pixel.gif";
	    document.platno.width=0;
	    document.platno.height=0;
		document.novinky.width=357;
	    document.novinky.height=211;
		document.novinky.src="txt/news.gif";
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
	  }
	  news=1;
	  menu=IndexNews;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  } else {
	//alert(loaded);  
  }
}

function animatePortfolio(img) {
	if (menu!=IndexPortfolio) {
		document.portfolio.src=img;
	}
}

function showPortfolio() {
  if (loaded>=allLoaded) {	
	  if (menu!=IndexPortfolio) {
		resetMenu();
		document.portfolio.src="menu/a_portfo.gif";
	    document.platno.src="obr/pixel.gif";
		document.novinky.src="obr/pixel.gif";
		document.novinky.width=0;
	    document.novinky.height=16;
	    document.platno.width=0;
	    document.platno.height=16;
		document.copyr.width=150;
		document.copyr.src="menu/copyrigh.gif";
  	    MM_showHideLayers('portfolio_set','','show');
	  }
	  por=1;
	  menu=IndexPortfolio;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  }
}

function animateProjects(img) {
	if (menu!=IndexProjects) {
		document.projects.src=img;
	}
}

function showProjects() {
  if (loaded>=allLoaded) {	
	  if (menu!=IndexProjects) {
		resetMenu();
		document.projects.src="menu/a_projec.gif";
  	    MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="obr/pixel.gif";
		document.novinky.width=0;
	    document.novinky.height=0;
	    document.platno.width=83;
	    document.platno.height=13;
		document.platno.align="right";
		document.platno.src="txt/projects.gif"; //zobrazi
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
	  }
	  pro=1;
	  menu=IndexProjects;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  }
}

function animateBiography(img) {
	if (menu!=IndexBiography) {
		document.biography.src=img;
	}
}

function showBiography() {
  if (loaded>=allLoaded) {	
	  if (menu!=IndexBiography) {
		resetMenu();
		document.biography.src="menu/a_biogra.gif";
		MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="menu/pixel.gif"; //smaze
		document.novinky.width=0;
	    document.novinky.height=0;
	    document.platno.width=612; //nastavi rozmery
	    document.platno.height=361;
		document.platno.align="left";
		document.platno.src="txt/biograph.jpg"; //zobrazi
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
		window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
	  }
	  bio=1;
	  menu=IndexBiography;
  }
}

function animateExhibitions(img) {
	if (menu!=IndexExhibitions) {
		document.exhibitions.src=img;
	}
}

function showExhibitions() {
  if (loaded>=allLoaded) {
	  if (menu!=IndexExhibitions) {
		resetMenu();
		document.exhibitions.src="menu/a_exhibi.gif";
		MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="menu/pixel.gif";
		document.novinky.width=0;
	    document.novinky.height=0;
	    document.platno.width=462;
	    document.platno.height=396;
		document.platno.align="right";
		document.platno.src="txt/exhibiti.gif";
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
		//document.platno.usemap="";
	  }
	  exh=1;
	  menu=IndexExhibitions;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  }
}

function animateAwards(img) {
	if (menu!=IndexAwards) {
		document.awards.src=img;
	}
}

function showAwards() {
  if (loaded>=allLoaded) {
	  if (menu!=IndexAwards) {
		resetMenu();
	    document.awards.src="menu/a_awards.gif";
		MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="menu/pixel.gif";
		document.novinky.width=0;
	    document.novinky.height=0;
	    document.platno.width=564;
	    document.platno.height=118;
		document.platno.align="right";
		document.platno.src="txt/awards.gif";
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
	  }
	  awa=1;
	  menu=IndexAwards;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  }
}

function animatePress(img) {
	if (menu!=IndexPress) {
		document.press.src=img;
	}
}

function showPress() {
  if (loaded>=allLoaded) {	
	  if (menu!=IndexPress) {
		resetMenu();
		document.press.src="menu/a_press.gif";
  	    MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="obr/pixel.gif";
		document.novinky.width=0;
	    document.novinky.height=0;
	    document.platno.width=1;
	    document.platno.height=16;
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
	  }
	  pre=1;
	  menu=IndexPress;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  }
}

function animateContact(img) {
	if (menu!=IndexContact) {
		document.contact.src=img;
	}
}

function showContact() {
  if (loaded>=allLoaded) {	
	  if (menu!=IndexContact) {
		resetMenu();  
	    document.contact.src="menu/a_contac.gif";
		MM_showHideLayers('portfolio_set','','hide');
	    document.platno.src="menu/pixel.gif";
		document.novinky.width=0;
	    document.novinky.height=0;
	    document.platno.width=119;
	    document.platno.height=66;
		document.platno.align="right";
		document.platno.src="txt/contact.gif";
		document.copyr.width=0;
		document.copyr.src="menu/pixel.gif";
	  }
	  con=1;
	  menu=IndexContact;
	  window.focus(); //aby zmizel teckovany ramecek okolo obrazku menu v IE
  }
}

function LoadingIncrement() {
  if (loaded<allLoaded)	{
	showLoading(1);  
    clearTimeout( timer);
    timer=setTimeout( "LoadingWait(1)", 30);
  }	
}

function LoadingWait() {
  if (loaded<allLoaded)	{
    clearTimeout( timer);
    timer=setTimeout( "LoadingIncrement(1)", 30);
  }
}

function MM_preloadImages() { //v3.0
  centerVertically();
  var d=document;
  if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  //LoadingIncrement();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){	
	var xScroll, yScroll;	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}		
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//ulozi object
function storeObject(divObj) {
	if(divObj.id=='portfolio_set'){
		sObj=divObj;
		//alert(obj.scrollLeft);
		sPos=sObj.scrollLeft;
		sPosMax=sObj.scrollWidth;
		//alert(sPos);
	}
}

//obsluha udalosti onscroll
function shiftHorizontal(divObj) {
//var divObj,pos;
	if(sObj.id=='portfolio_set'){
		//sPos=sPos+wP[aIndex];
		sObj.scrollLeft=sPos;
		//alert(sPos);
	}
	//if(obj.id=='archive_set'){
		//pos=aA[aIndex];
		//sObj.scrollLeft=sPos;
	//}
	//alert(divObj.id+': '+pos);
//pos=parseInt(divObj.scrollLeft)/(parseInt(divObj.scrollWidth)-parseInt(divObj.style.width));
//alert(divObj.id);
//alert(aIndex + '/' + divObj.scrollLeft + '/' + divObj.scrollWidth);
//divObj.scrollLeft=aP[aIndex-1];
//divObj.scrollLeft=100;
//return pos;
//return parseInt(divObj.scrollLeft)/
//      (parseInt(divObj.scrollWidth)-parseInt(divObj.style.width));
}